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

bcachefs: Improve bkey_cached_lock_for_evict()

We don't need a write lock to check if a key is dirty.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c82ed304
......@@ -56,13 +56,12 @@ static bool bkey_cached_lock_for_evict(struct bkey_cached *ck)
if (!six_trylock_intent(&ck->c.lock))
return false;
if (!six_trylock_write(&ck->c.lock)) {
if (test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {
six_unlock_intent(&ck->c.lock);
return false;
}
if (test_bit(BKEY_CACHED_DIRTY, &ck->flags)) {
six_unlock_write(&ck->c.lock);
if (!six_trylock_write(&ck->c.lock)) {
six_unlock_intent(&ck->c.lock);
return false;
}
......
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