bcachefs: Factor out two_state_shared_lock
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 4 Nov 2022 17:25:57 +0000 (13:25 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:45 +0000 (17:09 -0400)
commita7ecd30c8300624448c4e66cd7a7e7209b96ea61
treec282d706dbb238c2078f0d18f93f097d5f58f609
parenta1ee777bfcceeb916d837321144c782e12082588
bcachefs: Factor out two_state_shared_lock

We have a unique lock used for controlling adding to the pagecache: the
lock has two states, where both states are shared - the lock may be held
multiple times for either state - but not both states at the same time.

This is exactly what we need for nocow mode locking, so this patch pulls
it out of fs.c into its own file.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/Makefile
fs/bcachefs/fs-io.c
fs/bcachefs/fs.c
fs/bcachefs/fs.h
fs/bcachefs/two_state_shared_lock.c [new file with mode: 0644]
fs/bcachefs/two_state_shared_lock.h [new file with mode: 0644]