diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-15 18:29:16 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:53 -0400 |
commit | 0cc1bc84d69138531d8a5e163caa57dfacd58cf2 (patch) | |
tree | 888c1c70898ed360c5a7bd0daa6ad181b79a277a /fs/bcachefs/six.c | |
parent | 70f0b0fd7e9b85a14fdb8b3f229572b7439d8915 (diff) | |
download | linux-0cc1bc84d69138531d8a5e163caa57dfacd58cf2.tar.gz linux-0cc1bc84d69138531d8a5e163caa57dfacd58cf2.tar.bz2 linux-0cc1bc84d69138531d8a5e163caa57dfacd58cf2.zip |
six locks: Simplify six_lock_counts()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/six.c')
-rw-r--r-- | fs/bcachefs/six.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c index 5d003e41ae43..e1e9df0368b6 100644 --- a/fs/bcachefs/six.c +++ b/fs/bcachefs/six.c @@ -830,19 +830,12 @@ struct six_lock_count six_lock_counts(struct six_lock *lock) { struct six_lock_count ret; - ret.n[SIX_LOCK_read] = 0; + ret.n[SIX_LOCK_read] = !lock->readers + ? lock->state.read_lock + : pcpu_read_count(lock); ret.n[SIX_LOCK_intent] = lock->state.intent_lock + lock->intent_lock_recurse; ret.n[SIX_LOCK_write] = lock->state.seq & 1; - if (!lock->readers) - ret.n[SIX_LOCK_read] += lock->state.read_lock; - else { - int cpu; - - for_each_possible_cpu(cpu) - ret.n[SIX_LOCK_read] += *per_cpu_ptr(lock->readers, cpu); - } - return ret; } EXPORT_SYMBOL_GPL(six_lock_counts); |