]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcachefs: Add lockdep support for btree node locks
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 21 Dec 2023 23:54:09 +0000 (18:54 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:16 +0000 (19:00 -0400)
commit375476c41405ff6fc379cdbf1ad1df35c737500c
tree12a16c18e72755f57e23f143b8275c9decb298f0
parent1a616c2fe96b357894b74b41787d4ea6987f6199
bcachefs: Add lockdep support for btree node locks

This adds lockdep tracking for held btree locks with a single dep_map in
btree_trans, i.e. tracking all held btree locks as one object.

This is more practical and more useful than having lockdep track held
btree locks individually, because
 - we can take more locks than lockdep can track (unbounded, now that we
   have dynamically resizable btree paths)
 - there's no lock ordering between btree locks for lockdep to track (we
   do cycle detection)
 - and this makes it easy to teach lockdep that btree locks are not safe
   to hold while invoking memory reclaim.

The last rule is one that lockdep would never learn, because we only do
trylock() from within shrinkers - but we very much do not want to be
invoking memory reclaim while holding btree node locks.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_locking.h
fs/bcachefs/btree_types.h