diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-12 16:29:56 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-15 01:04:30 -0400 |
commit | e0a51ccce8533a91c7cc0cd0adc5662697c9bcfa (patch) | |
tree | 91408761ffbd7da783886c94a354d3b642e10587 /linux/six.c | |
parent | 3165f53b28b87b3c46c95763bae5e40a29166e2e (diff) |
Update bcachefs sources to 3e93567c51 bcachefs: Switch to local_clock() for fastpath time source
Diffstat (limited to 'linux/six.c')
-rw-r--r-- | linux/six.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/linux/six.c b/linux/six.c index b11660af..39f7ea79 100644 --- a/linux/six.c +++ b/linux/six.c @@ -148,6 +148,14 @@ static int __do_six_trylock_type(struct six_lock *lock, atomic64_add(__SIX_VAL(write_locking, 1), &lock->state.counter); smp_mb__after_atomic(); + } else if (!(lock->state.waiters & (1 << SIX_LOCK_write))) { + atomic64_add(__SIX_VAL(waiters, 1 << SIX_LOCK_write), + &lock->state.counter); + /* + * pairs with barrier after unlock and before checking + * for readers in unlock path + */ + smp_mb__after_atomic(); } ret = !pcpu_read_count(lock); @@ -162,9 +170,6 @@ static int __do_six_trylock_type(struct six_lock *lock, if (ret || try) v -= __SIX_VAL(write_locking, 1); - if (!ret && !try && !(lock->state.waiters & (1 << SIX_LOCK_write))) - v += __SIX_VAL(waiters, 1 << SIX_LOCK_write); - if (try && !ret) { old.v = atomic64_add_return(v, &lock->state.counter); if (old.waiters & (1 << SIX_LOCK_read)) |