diff options
author | Daeho Jeong <daehojeong@google.com> | 2022-10-31 20:24:15 +0100 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2022-11-11 18:48:24 +0100 |
commit | 4d8d45df2252980f800c1b2fde941a103a18a70e (patch) | |
tree | 124cbcae04bf19dc164cabf41f9df71e4f27285c /fs/f2fs/inode.c | |
parent | f2fs: add proc entry to show discard_plist info (diff) | |
download | linux-4d8d45df2252980f800c1b2fde941a103a18a70e.tar.xz linux-4d8d45df2252980f800c1b2fde941a103a18a70e.zip |
f2fs: correct i_size change for atomic writes
We need to make sure i_size doesn't change until atomic write commit is
successful and restore it when commit is failed.
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/inode.c')
-rw-r--r-- | fs/f2fs/inode.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 9f0d3864d9f1..577f109b4e1d 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -621,9 +621,12 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) ri->i_uid = cpu_to_le32(i_uid_read(inode)); ri->i_gid = cpu_to_le32(i_gid_read(inode)); ri->i_links = cpu_to_le32(inode->i_nlink); - ri->i_size = cpu_to_le64(i_size_read(inode)); ri->i_blocks = cpu_to_le64(SECTOR_TO_BLOCK(inode->i_blocks) + 1); + if (!f2fs_is_atomic_file(inode) || + is_inode_flag_set(inode, FI_ATOMIC_COMMITTED)) + ri->i_size = cpu_to_le64(i_size_read(inode)); + if (et) { read_lock(&et->lock); set_raw_extent(&et->largest, &ri->i_ext); |