summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Huang <mmpgouride@gmail.com>2024-09-26 00:45:00 +0800
committerKent Overstreet <kent.overstreet@linux.dev>2025-01-14 10:45:08 -0500
commitcdc419dbf286eeaabb361d5cf5cee2cb566b6f5f (patch)
treec8b8296001611d42d35297a9d11c845c1944e0bb
parent9c13cc9c7dd7852ab5080f735f896b4e2ac7e9d4 (diff)
bcachefs: Merge the condition to avoid additional invocation
If the lock has been acquired and unlocked, we don't have to do clear and wakeup again, though harmless since we hold the intent lock. Merge the condition might be clearer. Signed-off-by: Alan Huang <mmpgouride@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/six.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/bcachefs/six.c b/fs/bcachefs/six.c
index 537bf049618f..7e7c66a1e1a6 100644
--- a/fs/bcachefs/six.c
+++ b/fs/bcachefs/six.c
@@ -491,8 +491,12 @@ static int six_lock_slowpath(struct six_lock *lock, enum six_lock_type type,
list_del(&wait->list);
raw_spin_unlock(&lock->wait_lock);
- if (unlikely(acquired))
+ if (unlikely(acquired)) {
do_six_unlock_type(lock, type);
+ } else if (type == SIX_LOCK_write) {
+ six_clear_bitmask(lock, SIX_LOCK_HELD_write);
+ six_lock_wakeup(lock, atomic_read(&lock->state), SIX_LOCK_read);
+ }
break;
}
@@ -501,10 +505,6 @@ static int six_lock_slowpath(struct six_lock *lock, enum six_lock_type type,
__set_current_state(TASK_RUNNING);
out:
- if (ret && type == SIX_LOCK_write) {
- six_clear_bitmask(lock, SIX_LOCK_HELD_write);
- six_lock_wakeup(lock, atomic_read(&lock->state), SIX_LOCK_read);
- }
trace_contention_end(lock, 0);
return ret;