Skip to content

Commit 935fc6f

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: fix to check return value of inc_valid_block_count()
In __replace_atomic_write_block(), we missed to check return value of inc_valid_block_count(), for extreme testcase that f2fs image is run out of space, it may cause inconsistent status in between SIT table and total valid block count. Cc: Daeho Jeong <daehojeong@google.com> Fixes: 3db1de0 ("f2fs: change the current atomic write way") Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent b851ee6 commit 935fc6f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

fs/f2fs/segment.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,16 @@ static int __replace_atomic_write_block(struct inode *inode, pgoff_t index,
246246
} else {
247247
blkcnt_t count = 1;
248248

249+
err = inc_valid_block_count(sbi, inode, &count);
250+
if (err) {
251+
f2fs_put_dnode(&dn);
252+
return err;
253+
}
254+
249255
*old_addr = dn.data_blkaddr;
250256
f2fs_truncate_data_blocks_range(&dn, 1);
251257
dec_valid_block_count(sbi, F2FS_I(inode)->cow_inode, count);
252-
inc_valid_block_count(sbi, inode, &count);
258+
253259
f2fs_replace_block(sbi, &dn, dn.data_blkaddr, new_addr,
254260
ni.version, true, false);
255261
}

0 commit comments

Comments
 (0)