From 9631e4cc1a030aa71dea588cc9a57533b657489f Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Thu, 20 Aug 2020 11:46:03 -0400 Subject: btrfs: introduce BTRFS_NESTING_COW for cow'ing blocks When we COW a block we are holding a lock on the original block, and then we lock the new COW block. Because our lockdep maps are based on root + level, this will make lockdep complain. We need a way to indicate a subclass for locking the COW'ed block, so plumb through our btrfs_lock_nesting from btrfs_cow_block down to the btrfs_init_buffer, and then introduce BTRFS_NESTING_COW to be used for cow'ing blocks. The reason I've added all this extra infrastructure is because there will be need of different nesting classes in follow up patches. Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/locking.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'fs/btrfs/locking.h') diff --git a/fs/btrfs/locking.h b/fs/btrfs/locking.h index 5fabda8f0a80..8b47ba34fb03 100644 --- a/fs/btrfs/locking.h +++ b/fs/btrfs/locking.h @@ -24,6 +24,14 @@ enum btrfs_lock_nesting { BTRFS_NESTING_NORMAL, + /* + * When we COW a block we are holding the lock on the original block, + * and since our lockdep maps are rootid+level, this confuses lockdep + * when we lock the newly allocated COW'd block. Handle this by having + * a subclass for COW'ed blocks so that lockdep doesn't complain. + */ + BTRFS_NESTING_COW, + /* * We are limited to MAX_LOCKDEP_SUBLCLASSES number of subclasses, so * add this in here and add a static_assert to keep us from going over -- cgit v1.2.3-73-gaa49b