summaryrefslogtreecommitdiff
path: root/libbcachefs/alloc_background.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-07 17:52:51 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2022-04-07 17:52:51 -0400
commite05755a9fc28c2e757a531c8865773fa63dfea9c (patch)
tree28d7951ca32a6900b16f93fe90508a333043f0be /libbcachefs/alloc_background.c
parent941075cb57b469525df76d15e61abdb42d9c7a1b (diff)
Update bcachefs sources to 98a1bff393 bcachefs: Topology repair fixes
Diffstat (limited to 'libbcachefs/alloc_background.c')
-rw-r--r--libbcachefs/alloc_background.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libbcachefs/alloc_background.c b/libbcachefs/alloc_background.c
index 6d6798ae..99892515 100644
--- a/libbcachefs/alloc_background.c
+++ b/libbcachefs/alloc_background.c
@@ -346,12 +346,31 @@ int bch2_alloc_v3_invalid(const struct bch_fs *c, struct bkey_s_c k,
int bch2_alloc_v4_invalid(const struct bch_fs *c, struct bkey_s_c k,
int rw, struct printbuf *err)
{
+ struct bkey_s_c_alloc_v4 a = bkey_s_c_to_alloc_v4(k);
+
if (bkey_val_bytes(k.k) != sizeof(struct bch_alloc_v4)) {
pr_buf(err, "bad val size (%zu != %zu)",
bkey_val_bytes(k.k), sizeof(struct bch_alloc_v4));
return -EINVAL;
}
+ if (rw == WRITE) {
+ if (a.v->cached_sectors &&
+ !a.v->dirty_sectors &&
+ !a.v->io_time[READ]) {
+ 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;
}