Commit 32913f49 authored by Kent Overstreet's avatar Kent Overstreet

six locks: Seq now only incremented on unlock

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2804d0f1
......@@ -652,7 +652,6 @@ void bch2_btree_path_level_init(struct btree_trans *trans,
BUG_ON(path->cached);
EBUG_ON(!btree_path_pos_in_node(path, b));
EBUG_ON(six_lock_seq(&b->c.lock) & 1);
path->l[b->c.level].lock_seq = six_lock_seq(&b->c.lock);
path->l[b->c.level].b = b;
......
......@@ -42,14 +42,7 @@ static inline struct btree *btree_path_node(struct btree_path *path,
static inline bool btree_node_lock_seq_matches(const struct btree_path *path,
const struct btree *b, unsigned level)
{
/*
* We don't compare the low bits of the lock sequence numbers because
* @path might have taken a write lock on @b, and we don't want to skip
* the linked path if the sequence numbers were equal before taking that
* write lock. The lock sequence number is incremented by taking and
* releasing write locks and is even when unlocked:
*/
return path->l[level].lock_seq >> 1 == six_lock_seq(&b->c.lock) >> 1;
return path->l[level].lock_seq == six_lock_seq(&b->c.lock);
}
static inline struct btree *btree_node_parent(struct btree_path *path,
......
......@@ -175,13 +175,13 @@ bch2_btree_node_unlock_write_inlined(struct btree_trans *trans, struct btree_pat
struct btree_path *linked;
EBUG_ON(path->l[b->c.level].b != b);
EBUG_ON(path->l[b->c.level].lock_seq + 1 != six_lock_seq(&b->c.lock));
EBUG_ON(path->l[b->c.level].lock_seq != six_lock_seq(&b->c.lock));
EBUG_ON(btree_node_locked_type(path, b->c.level) != SIX_LOCK_write);
mark_btree_node_locked_noreset(path, b->c.level, SIX_LOCK_intent);
trans_for_each_path_with_node(trans, b, linked)
linked->l[b->c.level].lock_seq += 2;
linked->l[b->c.level].lock_seq++;
six_unlock_write(&b->c.lock);
}
......
......@@ -302,9 +302,6 @@ bool six_trylock_ip(struct six_lock *lock, enum six_lock_type type, unsigned lon
if (type != SIX_LOCK_write)
six_acquire(&lock->dep_map, 1, type == SIX_LOCK_read, ip);
else
lock->seq++;
return true;
}
EXPORT_SYMBOL_GPL(six_trylock_ip);
......@@ -596,8 +593,6 @@ int six_lock_ip_waiter(struct six_lock *lock, enum six_lock_type type,
ret = do_six_trylock(lock, type, true) ? 0
: six_lock_slowpath(lock, type, wait, should_sleep_fn, p, ip);
lock->seq += !ret && type == SIX_LOCK_write;
if (ret && type != SIX_LOCK_write)
six_release(&lock->dep_map, ip);
if (!ret)
......
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