Commit 5394fe94 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Fix snapshot skiplists

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent e8484348
...@@ -255,8 +255,7 @@ int bch2_snapshot_invalid(const struct bch_fs *c, struct bkey_s_c k, ...@@ -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++) { for (i = 0; i < ARRAY_SIZE(s.v->skip); i++) {
id = le32_to_cpu(s.v->skip[i]); id = le32_to_cpu(s.v->skip[i]);
if ((id && !s.v->parent) || if (id && id < le32_to_cpu(s.v->parent)) {
(id && id <= k.k->p.offset)) {
prt_printf(err, "bad skiplist node %u", id); prt_printf(err, "bad skiplist node %u", id);
return -BCH_ERR_invalid_bkey; return -BCH_ERR_invalid_bkey;
} }
...@@ -1348,12 +1347,12 @@ static int bch2_fix_child_of_deleted_snapshot(struct btree_trans *trans, ...@@ -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]); u32 id = le32_to_cpu(s->v.skip[j]);
if (snapshot_list_has_id(deleted, id)) { if (snapshot_list_has_id(deleted, id)) {
id = depth > 1 id = bch2_snapshot_nth_parent_skip(c,
? bch2_snapshot_nth_parent_skip(c,
parent, parent,
get_random_u32_below(depth - 1), depth > 1
deleted) ? get_random_u32_below(depth - 1)
: parent; : 0,
deleted);
s->v.skip[j] = cpu_to_le32(id); s->v.skip[j] = cpu_to_le32(id);
} }
} }
......
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