Skip to content

Commit 7b4c4cc

Browse files
author
Kent Overstreet
committed
bcachefs: fix race in bch2_btree_node_evict()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 2aeed87 commit 7b4c4cc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/bcachefs/btree_cache.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,8 @@ void bch2_btree_node_evict(struct btree_trans *trans, const struct bkey_i *k)
11481148

11491149
btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_intent);
11501150
btree_node_lock_nopath_nofail(trans, &b->c, SIX_LOCK_write);
1151+
if (unlikely(b->hash_val != btree_ptr_hash_val(k)))
1152+
goto out;
11511153

11521154
if (btree_node_dirty(b)) {
11531155
__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)
11621164
btree_node_data_free(c, b);
11631165
bch2_btree_node_hash_remove(bc, b);
11641166
mutex_unlock(&bc->lock);
1165-
1167+
out:
11661168
six_unlock_write(&b->c.lock);
11671169
six_unlock_intent(&b->c.lock);
11681170
}

0 commit comments

Comments
 (0)