diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-04-12 14:36:11 -0700 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-04-15 08:50:25 -0700 |
commit | c27753d675fccd3b15a78621a2a66616507693d4 (patch) | |
tree | 2205e04b3163f3caab4abfb486a66f56dce6c320 | |
parent | 63c52d7878903a014fa4c9075afd051b1e77597b (diff) | |
download | linux-stable-c27753d675fccd3b15a78621a2a66616507693d4.tar.gz linux-stable-c27753d675fccd3b15a78621a2a66616507693d4.tar.bz2 linux-stable-c27753d675fccd3b15a78621a2a66616507693d4.zip |
f2fs: flush dirty pages before starting atomic writes
If somebody wrote some data before atomic writes, we should flush them in order
to handle atomic data in a right period.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r-- | fs/f2fs/file.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index ed389f6a37b4..7de90e60abd1 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1369,7 +1369,16 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) set_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE); f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); - return 0; + if (!get_dirty_pages(inode)) + return 0; + + f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING, + "Unexpected flush for atomic writes: ino=%lu, npages=%u", + inode->i_ino, get_dirty_pages(inode)); + ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX); + if (ret) + clear_inode_flag(F2FS_I(inode), FI_ATOMIC_FILE); + return ret; } static int f2fs_ioc_commit_atomic_write(struct file *filp) |