bcachefs: Avoid write lock on mark_lock
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 3 Dec 2020 19:17:33 +0000 (14:17 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:21 +0000 (17:08 -0400)
commitfca1223ccfac2a461d7d3e29fb09a1b2142bdd7f
tree532c8e13a14d3f2e39c6df1fe019544f7db51cf3
parent33eb63e5753ad6229d4027340153817b92840760
bcachefs: Avoid write lock on mark_lock

mark_lock is a frequently taken lock, and there's also potential for
deadlocks since currently bch2_clear_page_bits which is called from
memory reclaim has to take it to drop disk reservations.

The disk reservation get path takes it when it recalculates the number
of sectors known to be available, but it's not really needed for
consistency.  We just want to make sure we only have one thread updating
the sectors_available count, which we can do with a dedicated mutex.

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