summaryrefslogtreecommitdiff
path: root/fs/bcachefs/six.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-08-22 06:08:53 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:39 +0300
commite3738c6909d69e980d8b56d33df2e438a2c1c798 (patch)
treee2b2b42ed3b76430627259f6566f12d907d9cd90 /fs/bcachefs/six.c
parent2e27f6567b2662a2f7440a651e007ebc77cdcc7a (diff)
downloadlinux-e3738c6909d69e980d8b56d33df2e438a2c1c798.tar.xz
six locks: Improve six_lock_count
six_lock_count now counts up whether a write lock held, and this patch now also correctly counts six_lock->intent_lock_recurse. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/six.c')
-rw-r--r--fs/bcachefs/six.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c
index 9dd4b71e63ab..464b1313d358 100644
--- a/fs/bcachefs/six.c
+++ b/fs/bcachefs/six.c
@@ -764,15 +764,19 @@ EXPORT_SYMBOL_GPL(six_lock_pcpu_alloc);
*/
struct six_lock_count six_lock_counts(struct six_lock *lock)
{
- struct six_lock_count ret = { 0, lock->state.intent_lock };
+ struct six_lock_count ret;
+
+ ret.n[SIX_LOCK_read] = 0;
+ 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.read += lock->state.read_lock;
+ ret.n[SIX_LOCK_read] += lock->state.read_lock;
else {
int cpu;
for_each_possible_cpu(cpu)
- ret.read += *per_cpu_ptr(lock->readers, cpu);
+ ret.n[SIX_LOCK_read] += *per_cpu_ptr(lock->readers, cpu);
}
return ret;