Commit ea1aa12ca237149227ef68af50c9a1acf027b625
1 parent
6d99ba41a7
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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>
Showing 3 changed files with 12 additions and 0 deletions Side-by-side Diff
fs/f2fs/f2fs.h
... | ... | @@ -998,6 +998,7 @@ |
998 | 998 | FI_INLINE_DATA, /* used for inline data*/ |
999 | 999 | FI_APPEND_WRITE, /* inode has appended data */ |
1000 | 1000 | FI_UPDATE_WRITE, /* inode has in-place-update data */ |
1001 | + FI_NEED_IPU, /* used fo ipu for fdatasync */ | |
1001 | 1002 | }; |
1002 | 1003 | |
1003 | 1004 | static inline void set_inode_flag(struct f2fs_inode_info *fi, int flag) |
fs/f2fs/file.c
... | ... | @@ -127,7 +127,14 @@ |
127 | 127 | return 0; |
128 | 128 | |
129 | 129 | trace_f2fs_sync_file_enter(inode); |
130 | + | |
131 | + /* if fdatasync is triggered, let's do in-place-update */ | |
132 | + if (datasync) | |
133 | + set_inode_flag(fi, FI_NEED_IPU); | |
134 | + | |
130 | 135 | ret = filemap_write_and_wait_range(inode->i_mapping, start, end); |
136 | + if (datasync) | |
137 | + clear_inode_flag(fi, FI_NEED_IPU); | |
131 | 138 | if (ret) { |
132 | 139 | trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret); |
133 | 140 | return ret; |
fs/f2fs/segment.h
... | ... | @@ -486,6 +486,10 @@ |
486 | 486 | if (S_ISDIR(inode->i_mode)) |
487 | 487 | return false; |
488 | 488 | |
489 | + /* this is only set during fdatasync */ | |
490 | + if (is_inode_flag_set(F2FS_I(inode), FI_NEED_IPU)) | |
491 | + return true; | |
492 | + | |
489 | 493 | switch (SM_I(sbi)->ipu_policy) { |
490 | 494 | case F2FS_IPU_FORCE: |
491 | 495 | return true; |