]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Move alloc assertion to .key_invalid()
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 7 Apr 2022 21:32:57 +0000 (17:32 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:30 +0000 (17:09 -0400)
.key_invalid is a better place for this assertion.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.h

index f030030a8b5033474959d4f9e1c271e58e38cc1e..090fdee581573aed4bf051f5f16701efd88bb8a9 100644 (file)
@@ -361,6 +361,14 @@ int bch2_alloc_v4_invalid(const struct bch_fs *c, struct bkey_s_c k,
                        pr_buf(err, "cached bucket with read_time == 0");
                        return -EINVAL;
                }
+
+               if (!a.v->dirty_sectors &&
+                   !a.v->cached_sectors &&
+                   !a.v->stripe &&
+                   a.v->data_type) {
+                       pr_buf(err, "empty, but data_type nonzero");
+                       return -EINVAL;
+               }
        }
 
        return 0;
index 9c6a590fa0737ae62f8cb95a356bbeaf580a5d84..11e0bca3e7f296d4d51ee70cd2f0643ee54848a6 100644 (file)
@@ -44,7 +44,6 @@ static inline enum bucket_state bucket_state(struct bch_alloc_v4 a)
                return BUCKET_dirty;
        if (a.cached_sectors)
                return BUCKET_cached;
-       BUG_ON(a.data_type);
        if (BCH_ALLOC_V4_NEED_DISCARD(&a))
                return BUCKET_need_discard;
        if (alloc_gc_gen(a) >= BUCKET_GC_GEN_MAX)