f2fs: enable in-place-update for fdatasync
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 25 Jul 2014 02:11:43 +0000 (19:11 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 30 Jul 2014 21:13:23 +0000 (14:13 -0700)
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>
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/segment.h

index ab3602576fb2970ba3e9aad579be7c29d18ed775..8f8685e168633699479259ff2b15e81ab80f532f 100644 (file)
@@ -998,6 +998,7 @@ enum {
        FI_INLINE_DATA,         /* used for inline data*/
        FI_APPEND_WRITE,        /* inode has appended 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)
index 9b888fbf08b64335dbb6565ccae3174d76d0a72b..95501358932c6e49eeaad2bddb72b6853e52d00b 100644 (file)
@@ -127,7 +127,14 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
                return 0;
 
        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);
+       if (datasync)
+               clear_inode_flag(fi, FI_NEED_IPU);
        if (ret) {
                trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
                return ret;
index ee5c75e08d9cc24b917356f01e1933717400f232..55973f7b0330be844e17c0f02b7c02d661ca8c3e 100644 (file)
@@ -486,6 +486,10 @@ static inline bool need_inplace_update(struct inode *inode)
        if (S_ISDIR(inode->i_mode))
                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) {
        case F2FS_IPU_FORCE:
                return true;