summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-10-26 16:20:08 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-11-01 21:11:07 -0400
commit5394fe9494011de19baff276ce02a2f00eef568a (patch)
treee72deadf1c3384b98d7e6062ff77d7296c5bd0f4
parente84843489c15bf9d39eec3a9a95870f98a71ac24 (diff)
downloadlinux-stable-5394fe9494011de19baff276ce02a2f00eef568a.tar.gz
linux-stable-5394fe9494011de19baff276ce02a2f00eef568a.tar.bz2
linux-stable-5394fe9494011de19baff276ce02a2f00eef568a.zip
bcachefs: Fix snapshot skiplists
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/snapshot.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/bcachefs/snapshot.c b/fs/bcachefs/snapshot.c
index 315e88cc3867..e70adfcbd953 100644
--- a/fs/bcachefs/snapshot.c
+++ b/fs/bcachefs/snapshot.c
@@ -255,8 +255,7 @@ int bch2_snapshot_invalid(const struct bch_fs *c, struct bkey_s_c k,
for (i = 0; i < ARRAY_SIZE(s.v->skip); i++) {
id = le32_to_cpu(s.v->skip[i]);
- if ((id && !s.v->parent) ||
- (id && id <= k.k->p.offset)) {
+ if (id && id < le32_to_cpu(s.v->parent)) {
prt_printf(err, "bad skiplist node %u", id);
return -BCH_ERR_invalid_bkey;
}
@@ -1348,12 +1347,12 @@ static int bch2_fix_child_of_deleted_snapshot(struct btree_trans *trans,
u32 id = le32_to_cpu(s->v.skip[j]);
if (snapshot_list_has_id(deleted, id)) {
- id = depth > 1
- ? bch2_snapshot_nth_parent_skip(c,
+ id = bch2_snapshot_nth_parent_skip(c,
parent,
- get_random_u32_below(depth - 1),
- deleted)
- : parent;
+ depth > 1
+ ? get_random_u32_below(depth - 1)
+ : 0,
+ deleted);
s->v.skip[j] = cpu_to_le32(id);
}
}