]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: add f2fs_bug_on() to detect potential bug
authorChao Yu <chao@kernel.org>
Mon, 12 May 2025 11:54:41 +0000 (19:54 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 27 May 2025 23:52:35 +0000 (23:52 +0000)
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>
fs/f2fs/checkpoint.c
fs/f2fs/node.c

index 39ee75321d14e4000e8cbd2318d9a50ece7a5483..164b7719f365bae95bc1391470c86538e4f622ab 100644 (file)
@@ -504,6 +504,7 @@ static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
 {
        struct inode_management *im = &sbi->im[type];
        struct ino_entry *e = NULL, *new = NULL;
+       int ret;
 
        if (type == FLUSH_INO) {
                rcu_read_lock();
@@ -516,7 +517,8 @@ retry:
                new = f2fs_kmem_cache_alloc(ino_entry_slab,
                                                GFP_NOFS, true, NULL);
 
-       radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+       ret = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+       f2fs_bug_on(sbi, ret);
 
        spin_lock(&im->ino_lock);
        e = radix_tree_lookup(&im->ino_root, ino);
index 3f6b8037d25f7a90881eaaf50d2565e57e2f2e2e..88d3032236cb4178913b44c0079266406e15fd22 100644 (file)
@@ -2309,7 +2309,7 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct free_nid *i, *e;
        struct nat_entry *ne;
-       int err = -EINVAL;
+       int err;
        bool ret = false;
 
        /* 0 nid should not be used */
@@ -2323,7 +2323,10 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
        i->nid = nid;
        i->state = FREE_NID;
 
-       radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+       err = radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
+       f2fs_bug_on(sbi, err);
+
+       err = -EINVAL;
 
        spin_lock(&nm_i->nid_list_lock);