diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-11-23 20:22:39 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:51 +0300 |
commit | 19fe87e00b6a601b2ec8251d0231f4c9b3bb5002 (patch) | |
tree | 0361c52ec7e58c284d54204c41f9e077737f8a43 /fs/bcachefs/two_state_shared_lock.c | |
parent | a8b3a677e786fa869d220a6a78b5532a36dc2f4d (diff) | |
download | linux-19fe87e00b6a601b2ec8251d0231f4c9b3bb5002.tar.xz |
bcachefs: Inline bch2_two_state_(trylock|unlock)
Standard inlining of fast paths - these locks are now used by our new
nocow mode.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/two_state_shared_lock.c')
-rw-r--r-- | fs/bcachefs/two_state_shared_lock.c | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/fs/bcachefs/two_state_shared_lock.c b/fs/bcachefs/two_state_shared_lock.c index dc508d545de0..9764c2e6a910 100644 --- a/fs/bcachefs/two_state_shared_lock.c +++ b/fs/bcachefs/two_state_shared_lock.c @@ -2,32 +2,7 @@ #include "two_state_shared_lock.h" -void bch2_two_state_unlock(two_state_lock_t *lock, int s) +void __bch2_two_state_lock(two_state_lock_t *lock, int s) { - long i = s ? 1 : -1; - - BUG_ON(atomic_long_read(&lock->v) == 0); - - if (atomic_long_sub_return_release(i, &lock->v) == 0) - wake_up_all(&lock->wait); -} - -bool bch2_two_state_trylock(two_state_lock_t *lock, int s) -{ - long i = s ? 1 : -1; - long v = atomic_long_read(&lock->v), old; - - do { - old = v; - - if (i > 0 ? v < 0 : v > 0) - return false; - } while ((v = atomic_long_cmpxchg_acquire(&lock->v, - old, old + i)) != old); - return true; -} - -void bch2_two_state_lock(two_state_lock_t *lock, int s) -{ - wait_event(lock->wait, bch2_two_state_trylock(lock, s)); + __wait_event(lock->wait, bch2_two_state_trylock(lock, s)); } |