lkml.org 
[lkml]   [2018]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v2 40/83] Log operation: file write entry append.
Date
From: Andiry Xu <jix024@cs.ucsd.edu>

NOVA performs writes by appending file write entries to the log.
A file write entry is the metadata of a write operation, and
contains pointers to the data blocks. A single write operation
may append multiple file write entries to the log, if the
allocator cannot provide enough contiguous data blocks.

Signed-off-by: Andiry Xu <jix024@cs.ucsd.edu>
---
fs/nova/log.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
fs/nova/log.h | 3 +++
2 files changed, 54 insertions(+)

diff --git a/fs/nova/log.c b/fs/nova/log.c
index 13f9597..437db26 100644
--- a/fs/nova/log.c
+++ b/fs/nova/log.c
@@ -20,6 +20,18 @@
#include "inode.h"
#include "log.h"

+static int nova_update_write_entry(struct super_block *sb,
+ struct nova_file_write_entry *entry,
+ struct nova_log_entry_info *entry_info)
+{
+ entry->epoch_id = cpu_to_le64(entry_info->epoch_id);
+ entry->trans_id = cpu_to_le64(entry_info->trans_id);
+ entry->mtime = cpu_to_le32(entry_info->time);
+ entry->size = cpu_to_le64(entry_info->file_size);
+ nova_persist_entry(entry);
+ return 0;
+}
+
static int nova_update_old_dentry(struct super_block *sb,
struct inode *dir, struct nova_dentry *dentry,
struct nova_log_entry_info *entry_info)
@@ -91,6 +103,11 @@ static int nova_update_log_entry(struct super_block *sb, struct inode *inode,

switch (type) {
case FILE_WRITE:
+ if (entry_info->inplace)
+ nova_update_write_entry(sb, entry, entry_info);
+ else
+ memcpy_to_pmem_nocache(entry, entry_info->data,
+ sizeof(struct nova_file_write_entry));
break;
case DIR_LOG:
if (entry_info->inplace)
@@ -149,6 +166,40 @@ static int nova_append_log_entry(struct super_block *sb,
return 0;
}

+/*
+ * Append a nova_file_write_entry to the current nova_inode_log_page.
+ * blocknr and start_blk are pgoff.
+ * We cannot update pi->log_tail here because a transaction may contain
+ * multiple entries.
+ */
+int nova_append_file_write_entry(struct super_block *sb, struct nova_inode *pi,
+ struct inode *inode, struct nova_file_write_item *item,
+ struct nova_inode_update *update)
+{
+ struct nova_inode_info *si = NOVA_I(inode);
+ struct nova_inode_info_header *sih = &si->header;
+ struct nova_file_write_entry *data = &item->entry;
+ struct nova_log_entry_info entry_info;
+ timing_t append_time;
+ int ret;
+
+ NOVA_START_TIMING(append_file_entry_t, append_time);
+
+ entry_info.type = FILE_WRITE;
+ entry_info.update = update;
+ entry_info.data = data;
+ entry_info.epoch_id = data->epoch_id;
+ entry_info.trans_id = data->trans_id;
+ entry_info.inplace = 0;
+
+ ret = nova_append_log_entry(sb, pi, inode, sih, &entry_info);
+ if (ret)
+ nova_err(sb, "%s failed\n", __func__);
+
+ NOVA_END_TIMING(append_file_entry_t, append_time);
+ return ret;
+}
+
int nova_append_dentry(struct super_block *sb, struct nova_inode *pi,
struct inode *dir, struct dentry *dentry, u64 ino,
unsigned short de_len, struct nova_inode_update *update,
diff --git a/fs/nova/log.h b/fs/nova/log.h
index 305e69b..db7a72e 100644
--- a/fs/nova/log.h
+++ b/fs/nova/log.h
@@ -364,6 +364,9 @@ static inline int is_dir_init_entry(struct super_block *sb,
}


+int nova_append_file_write_entry(struct super_block *sb, struct nova_inode *pi,
+ struct inode *inode, struct nova_file_write_item *item,
+ struct nova_inode_update *update);
int nova_append_dentry(struct super_block *sb, struct nova_inode *pi,
struct inode *dir, struct dentry *dentry, u64 ino,
unsigned short de_len, struct nova_inode_update *update,
--
2.7.4
\
 
 \ /
  Last update: 2018-03-10 19:36    [W:1.689 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site