summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/bkey_methods.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-03 23:30:08 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2023-11-05 03:19:13 +0100
commitd3c7727bb9269c7f7a2f17ef76b9e5c9b8cc8863 (patch)
tree402a0d35410e968724409c01de6b112b332d73e4 /fs/bcachefs/bkey_methods.c
parentbcachefs: Add missing printk newlines (diff)
downloadlinux-d3c7727bb9269c7f7a2f17ef76b9e5c9b8cc8863.tar.xz
linux-d3c7727bb9269c7f7a2f17ef76b9e5c9b8cc8863.zip
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,