bcachefs: Ensure srcu lock is not held too long
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 30 Oct 2023 16:30:52 +0000 (12:30 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 4 Nov 2023 18:17:11 +0000 (14:17 -0400)
commitc4accde498dd7db8352d574958d19a5f710aba69
tree7dc805652f5bcf02f1772dc8b44dfa210a92c0ee
parent6dfa10ab22a6a322269a3454d7ac720dc2f8bf11
bcachefs: Ensure srcu lock is not held too long

The SRCU read lock that btree_trans takes exists to make it safe for
bch2_trans_relock() to deref pointers to btree nodes/key cache items we
don't have locked, but as a side effect it blocks reclaim from freeing
those items.

Thus, it's important to not hold it for too long: we need to
differentiate between bch2_trans_unlock() calls that will be only for a
short duration, and ones that will be for an unbounded duration.

This introduces bch2_trans_unlock_long(), to be used mainly by the data
move paths.

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