Commit 956fa1dd authored by Chao Yu's avatar Chao Yu Committed by Jaegeuk Kim

f2fs: fix to check return value of f2fs_reserve_new_block()

Let's check return value of f2fs_reserve_new_block() in do_recover_data()
rather than letting it fails silently.

Also refactoring check condition on return value of f2fs_reserve_new_block()
as below:
- trigger f2fs_bug_on() only for ENOSPC case;
- use do-while statement to avoid redundant codes;
Signed-off-by: default avatarChao Yu <chao@kernel.org>
Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
parent 94589150
......@@ -712,7 +712,16 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
*/
if (dest == NEW_ADDR) {
f2fs_truncate_data_blocks_range(&dn, 1);
f2fs_reserve_new_block(&dn);
do {
err = f2fs_reserve_new_block(&dn);
if (err == -ENOSPC) {
f2fs_bug_on(sbi, 1);
break;
}
} while (err &&
IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION));
if (err)
goto err;
continue;
}
......@@ -720,12 +729,14 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
if (f2fs_is_valid_blkaddr(sbi, dest, META_POR)) {
if (src == NULL_ADDR) {
err = f2fs_reserve_new_block(&dn);
while (err &&
IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION))
do {
err = f2fs_reserve_new_block(&dn);
/* We should not get -ENOSPC */
f2fs_bug_on(sbi, err);
if (err == -ENOSPC) {
f2fs_bug_on(sbi, 1);
break;
}
} while (err &&
IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION));
if (err)
goto err;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment