diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-09-01 22:05:16 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:40 -0400 |
commit | 6b81f194f345d15dd15601ee7b604a0640445895 (patch) | |
tree | 1b496804097ee8f9502ede363bffb24b3408a51c /fs/bcachefs/btree_locking.c | |
parent | d5024b011cb37b03aeeddd4b38857db427a04f11 (diff) | |
download | linux-stable-6b81f194f345d15dd15601ee7b604a0640445895.tar.gz linux-stable-6b81f194f345d15dd15601ee7b604a0640445895.tar.bz2 linux-stable-6b81f194f345d15dd15601ee7b604a0640445895.zip |
bcachefs: Fix six_lock_readers_add()
Have to be careful with bit fields - when subtracting, this was
overflowing into the write_locking bit.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_locking.c')
-rw-r--r-- | fs/bcachefs/btree_locking.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_locking.c b/fs/bcachefs/btree_locking.c index 24d0ea903380..158cb7ac64f2 100644 --- a/fs/bcachefs/btree_locking.c +++ b/fs/bcachefs/btree_locking.c @@ -10,10 +10,12 @@ struct lock_class_key bch2_btree_node_lock_key; static inline void six_lock_readers_add(struct six_lock *lock, int nr) { - if (!lock->readers) + if (lock->readers) + this_cpu_add(*lock->readers, nr); + else if (nr > 0) atomic64_add(__SIX_VAL(read_lock, nr), &lock->state.counter); else - this_cpu_add(*lock->readers, nr); + atomic64_sub(__SIX_VAL(read_lock, -nr), &lock->state.counter); } struct six_lock_count bch2_btree_node_lock_counts(struct btree_trans *trans, |