Commit 7b4c4ccf authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: fix race in bch2_btree_node_evict()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 2aeed876
...@@ -1148,6 +1148,8 @@ void bch2_btree_node_evict(struct btree_trans *trans, const struct bkey_i *k) ...@@ -1148,6 +1148,8 @@ void bch2_btree_node_evict(struct btree_trans *trans, const struct bkey_i *k)
btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_intent); btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_intent);
btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_write); btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_write);
if (unlikely(b->hash_val != btree_ptr_hash_val(k)))
goto out;
if (btree_node_dirty(b)) { if (btree_node_dirty(b)) {
__bch2_btree_node_write(c, b, BTREE_WRITE_cache_reclaim); __bch2_btree_node_write(c, b, BTREE_WRITE_cache_reclaim);
...@@ -1162,7 +1164,7 @@ void bch2_btree_node_evict(struct btree_trans *trans, const struct bkey_i *k) ...@@ -1162,7 +1164,7 @@ void bch2_btree_node_evict(struct btree_trans *trans, const struct bkey_i *k)
btree_node_data_free(c, b); btree_node_data_free(c, b);
bch2_btree_node_hash_remove(bc, b); bch2_btree_node_hash_remove(bc, b);
mutex_unlock(&bc->lock); mutex_unlock(&bc->lock);
out:
six_unlock_write(&b->c.lock); six_unlock_write(&b->c.lock);
six_unlock_intent(&b->c.lock); six_unlock_intent(&b->c.lock);
} }
......
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