bcachefs: Fix lock ordering with snapshot_create_lock
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 19 Oct 2023 19:23:56 +0000 (15:23 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 31 Oct 2023 16:18:11 +0000 (12:18 -0400)
We must not hold btree locks while taking snapshot_create_lock - this
fixes a lockdep splat.

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

index 4982468bfe1182910fa6a03e3b691bf7ce8be758..5a62d2e14cb4b2479e2ff6279ece7e542a52fadf 100644 (file)
@@ -1447,6 +1447,7 @@ int bch2_delete_dead_snapshots(struct bch_fs *c)
                }
        }
 
+       bch2_trans_unlock(trans);
        down_write(&c->snapshot_create_lock);
 
        for_each_btree_key(trans, iter, BTREE_ID_snapshots,