f2fs: set fsync mark only for the last dnode

In order to give atomic writes, we should consider power failure during
sync_node_pages in fsync.
So, this patch marks fsync flag only in the last dnode block.

Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim
2016-04-15 09:43:17 -07:00
parent c267ec1526
commit 608514deba
4 changed files with 116 additions and 23 deletions

View File

@@ -182,7 +182,8 @@ static void try_to_fix_pino(struct inode *inode)
}
}
int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
int datasync, bool atomic)
{
struct inode *inode = file->f_mapping->host;
struct f2fs_inode_info *fi = F2FS_I(inode);
@@ -256,7 +257,7 @@ go_write:
goto out;
}
sync_nodes:
ret = fsync_node_pages(sbi, ino, &wbc);
ret = fsync_node_pages(sbi, ino, &wbc, atomic);
if (ret)
goto out;
@@ -290,6 +291,11 @@ out:
return ret;
}
int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
{
return f2fs_do_sync_file(file, start, end, datasync, false);
}
static pgoff_t __get_first_dirty_index(struct address_space *mapping,
pgoff_t pgofs, int whence)
{
@@ -1407,7 +1413,7 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
}
}
ret = f2fs_sync_file(filp, 0, LLONG_MAX, 0);
ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
err_out:
mnt_drop_write_file(filp);
return ret;
@@ -1465,7 +1471,7 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp)
drop_inmem_pages(inode);
if (f2fs_is_volatile_file(inode)) {
clear_inode_flag(F2FS_I(inode), FI_VOLATILE_FILE);
ret = f2fs_sync_file(filp, 0, LLONG_MAX, 0);
ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
}
mnt_drop_write_file(filp);