Commit 62491956 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Move alloc assertion to .key_invalid()

.key_invalid is a better place for this assertion.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 1d8a2689
...@@ -361,6 +361,14 @@ int bch2_alloc_v4_invalid(const struct bch_fs *c, struct bkey_s_c k, ...@@ -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"); pr_buf(err, "cached bucket with read_time == 0");
return -EINVAL; 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; return 0;
......
...@@ -44,7 +44,6 @@ static inline enum bucket_state bucket_state(struct bch_alloc_v4 a) ...@@ -44,7 +44,6 @@ static inline enum bucket_state bucket_state(struct bch_alloc_v4 a)
return BUCKET_dirty; return BUCKET_dirty;
if (a.cached_sectors) if (a.cached_sectors)
return BUCKET_cached; return BUCKET_cached;
BUG_ON(a.data_type);
if (BCH_ALLOC_V4_NEED_DISCARD(&a)) if (BCH_ALLOC_V4_NEED_DISCARD(&a))
return BUCKET_need_discard; return BUCKET_need_discard;
if (alloc_gc_gen(a) >= BUCKET_GC_GEN_MAX) if (alloc_gc_gen(a) >= BUCKET_GC_GEN_MAX)
......
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