bcachefs: Fix snapshot skiplists during snapshot deletion
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 29 Sep 2023 04:46:30 +0000 (00:46 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:10:16 +0000 (17:10 -0400)
In snapshot deleion, we have to pick new skiplist nodes for entries that
point to nodes being deleted.

The function that finds a new skiplist node, skipping over entries being
deleted, was incorrect: if n = 0, but the parent node is being deleted,
we also need to skip over that node.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/snapshot.c

index 3ecc17b8d6fcaea206cb166d5ed58a5cad889f9c..b8c32d1cbd76e8e7d597ab38cff304bdfcd0e065 100644 (file)
@@ -1288,6 +1288,9 @@ static inline u32 bch2_snapshot_nth_parent_skip(struct bch_fs *c, u32 id, u32 n,
                                                snapshot_id_list *skip)
 {
        rcu_read_lock();
+       while (snapshot_list_has_id(skip, id))
+               id = __bch2_snapshot_parent(c, id);
+
        while (n--) {
                do {
                        id = __bch2_snapshot_parent(c, id);