Skip to content

Commit 9b6fc98

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: add f2fs_bug_on() to detect potential bug
Add f2fs_bug_on() to check whether memory preallocation will fail or not after radix_tree_preload(GFP_NOFS | __GFP_NOFAIL). Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent d005af3 commit 9b6fc98

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

fs/f2fs/checkpoint.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
504504
{
505505
struct inode_management *im = &sbi->im[type];
506506
struct ino_entry *e = NULL, *new = NULL;
507+
int ret;
507508

508509
if (type == FLUSH_INO) {
509510
rcu_read_lock();
@@ -516,7 +517,8 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
516517
new = f2fs_kmem_cache_alloc(ino_entry_slab,
517518
GFP_NOFS, true, NULL);
518519

519-
radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
520+
ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
521+
f2fs_bug_on(sbi, ret);
520522

521523
spin_lock(&im->ino_lock);
522524
e = radix_tree_lookup(&im->ino_root, ino);

fs/f2fs/node.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
23092309
struct f2fs_nm_info *nm_i = NM_I(sbi);
23102310
struct free_nid *i, *e;
23112311
struct nat_entry *ne;
2312-
int err = -EINVAL;
2312+
int err;
23132313
bool ret = false;
23142314

23152315
/* 0 nid should not be used */
@@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
23232323
i->nid = nid;
23242324
i->state = FREE_NID;
23252325

2326-
radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
2326+
err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
2327+
f2fs_bug_on(sbi, err);
2328+
2329+
err = -EINVAL;
23272330

23282331
spin_lock(&nm_i->nid_list_lock);
23292332

0 commit comments

Comments
 (0)