aboutsummaryrefslogtreecommitdiffstats
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index f9e085dfb1f0..7f9ea9271ebe 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -160,15 +160,17 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
160 if (need_to_sync_dir(sbi, inode)) 160 if (need_to_sync_dir(sbi, inode))
161 need_cp = true; 161 need_cp = true;
162 162
163 f2fs_write_inode(inode, NULL);
164
165 if (need_cp) { 163 if (need_cp) {
166 /* all the dirty node pages should be flushed for POR */ 164 /* all the dirty node pages should be flushed for POR */
167 ret = f2fs_sync_fs(inode->i_sb, 1); 165 ret = f2fs_sync_fs(inode->i_sb, 1);
168 clear_inode_flag(F2FS_I(inode), FI_NEED_CP); 166 clear_inode_flag(F2FS_I(inode), FI_NEED_CP);
169 } else { 167 } else {
170 while (sync_node_pages(sbi, inode->i_ino, &wbc) == 0) 168 /* if there is no written node page, write its inode page */
171 f2fs_write_inode(inode, NULL); 169 while (!sync_node_pages(sbi, inode->i_ino, &wbc)) {
170 ret = f2fs_write_inode(inode, NULL);
171 if (ret)
172 goto out;
173 }
172 filemap_fdatawait_range(sbi->node_inode->i_mapping, 174 filemap_fdatawait_range(sbi->node_inode->i_mapping,
173 0, LONG_MAX); 175 0, LONG_MAX);
174 } 176 }