summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-07 17:32:57 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-02-01 20:40:28 -0500
commit385ea7804b1dc691f4535d8e17f2018a3431532b (patch)
tree3bca2c051e07bc7065c60b65bedc7d59ca380871
parentf701948c04678cd73b7bc44407e4783d8f251e07 (diff)
bcachefs: Move alloc assertion to .key_invalid()
.key_invalid is a better place for this assertion. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/alloc_background.c8
-rw-r--r--fs/bcachefs/alloc_background.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 786ee92a333a..fd734006a59f 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -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;
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h
index 9c6a590fa073..11e0bca3e7f2 100644
--- a/fs/bcachefs/alloc_background.h
+++ b/fs/bcachefs/alloc_background.h
@@ -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)