Commit 6b81f194 authored by Kent Overstreet's avatar Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent d5024b01
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment