Browse Source

f2fs: enable in-place-update for fdatasync

This patch enforces in-place-updates only when fdatasync is requested.
If we adopt this in-place-updates for the fdatasync, we can skip to write the
recovery information.

Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Jaegeuk Kim 11 years ago
parent
commit
ea1aa12ca2
3 changed files with 12 additions and 0 deletions
  1. 1 0
      fs/f2fs/f2fs.h
  2. 7 0
      fs/f2fs/file.c
  3. 4 0
      fs/f2fs/segment.h

+ 1 - 0
fs/f2fs/f2fs.h

@@ -998,6 +998,7 @@ enum {
 	FI_INLINE_DATA,		/* used for inline data*/
 	FI_INLINE_DATA,		/* used for inline data*/
 	FI_APPEND_WRITE,	/* inode has appended data */
 	FI_APPEND_WRITE,	/* inode has appended data */
 	FI_UPDATE_WRITE,	/* inode has in-place-update data */
 	FI_UPDATE_WRITE,	/* inode has in-place-update data */
+	FI_NEED_IPU,		/* used fo ipu for fdatasync */
 };
 };
 
 
 static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)
 static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag)

+ 7 - 0
fs/f2fs/file.c

@@ -127,7 +127,14 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
 		return 0;
 		return 0;
 
 
 	trace_f2fs_sync_file_enter(inode);
 	trace_f2fs_sync_file_enter(inode);
+
+	/* if fdatasync is triggered, let's do in-place-update */
+	if (datasync)
+		set_inode_flag(fi, FI_NEED_IPU);
+
 	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
 	ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
+	if (datasync)
+		clear_inode_flag(fi, FI_NEED_IPU);
 	if (ret) {
 	if (ret) {
 		trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
 		trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
 		return ret;
 		return ret;

+ 4 - 0
fs/f2fs/segment.h

@@ -486,6 +486,10 @@ static inline bool need_inplace_update(struct inode *inode)
 	if (S_ISDIR(inode->i_mode))
 	if (S_ISDIR(inode->i_mode))
 		return false;
 		return false;
 
 
+	/* this is only set during fdatasync */
+	if (is_inode_flag_set(F2FS_I(inode), FI_NEED_IPU))
+		return true;
+
 	switch (SM_I(sbi)->ipu_policy) {
 	switch (SM_I(sbi)->ipu_policy) {
 	case F2FS_IPU_FORCE:
 	case F2FS_IPU_FORCE:
 		return true;
 		return true;