Skip to content

Commit cdc419d

Browse files
alanskindKent Overstreet
authored andcommitted
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>
1 parent 9c13cc9 commit cdc419d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/bcachefs/six.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,12 @@ static int six_lock_slowpath(struct six_lock *lock, enum six_lock_type type,
491491
list_del(&wait->list);
492492
raw_spin_unlock(&lock->wait_lock);
493493

494-
if (unlikely(acquired))
494+
if (unlikely(acquired)) {
495495
do_six_unlock_type(lock, type);
496+
} else if (type == SIX_LOCK_write) {
497+
six_clear_bitmask(lock, SIX_LOCK_HELD_write);
498+
six_lock_wakeup(lock, atomic_read(&lock->state), SIX_LOCK_read);
499+
}
496500
break;
497501
}
498502

@@ -501,10 +505,6 @@ static int six_lock_slowpath(struct six_lock *lock, enum six_lock_type type,
501505

502506
__set_current_state(TASK_RUNNING);
503507
out:
504-
if (ret && type == SIX_LOCK_write) {
505-
six_clear_bitmask(lock, SIX_LOCK_HELD_write);
506-
six_lock_wakeup(lock, atomic_read(&lock->state), SIX_LOCK_read);
507-
}
508508
trace_contention_end(lock, 0);
509509

510510
return ret;

0 commit comments

Comments
 (0)