summaryrefslogtreecommitdiff
path: root/fs/bcachefs/bkey_methods.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-03 18:30:08 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-11-04 22:19:13 -0400
commitd3c7727bb9269c7f7a2f17ef76b9e5c9b8cc8863 (patch)
tree402a0d35410e968724409c01de6b112b332d73e4 /fs/bcachefs/bkey_methods.c
parent01ccee225a373d859eb6e5d42dbe0138a40a7e0a (diff)
bcachefs: rebalance_work btree is not a snapshots btree
rebalance_work entries may refer to entries in the extents btree, which is a snapshots btree, or they may also refer to entries in the reflink btree, which is not. Hence rebalance_work keys may use the snapshot field but it's not required to be nonzero - add a new btree flag to reflect this. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/bkey_methods.c')
-rw-r--r--fs/bcachefs/bkey_methods.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/fs/bcachefs/bkey_methods.c b/fs/bcachefs/bkey_methods.c
index 2f518d7e1a64..761f5e33b1e6 100644
--- a/fs/bcachefs/bkey_methods.c
+++ b/fs/bcachefs/bkey_methods.c
@@ -186,15 +186,20 @@ int __bch2_bkey_invalid(struct bch_fs *c, struct bkey_s_c k,
if (type != BKEY_TYPE_btree) {
enum btree_id btree = type - 1;
- bkey_fsck_err_on(!btree_type_has_snapshots(btree) &&
- k.k->p.snapshot, c, err,
- bkey_snapshot_nonzero,
- "nonzero snapshot");
-
- bkey_fsck_err_on(btree_type_has_snapshots(btree) &&
- !k.k->p.snapshot, c, err,
- bkey_snapshot_zero,
- "snapshot == 0");
+ if (btree_type_has_snapshots(btree)) {
+ bkey_fsck_err_on(!k.k->p.snapshot, c, err,
+ bkey_snapshot_zero,
+ "snapshot == 0");
+ } else if (!btree_type_has_snapshot_field(btree)) {
+ bkey_fsck_err_on(k.k->p.snapshot, c, err,
+ bkey_snapshot_nonzero,
+ "nonzero snapshot");
+ } else {
+ /*
+ * btree uses snapshot field but it's not required to be
+ * nonzero
+ */
+ }
bkey_fsck_err_on(bkey_eq(k.k->p, POS_MAX), c, err,
bkey_at_pos_max,