diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-01-08 00:05:30 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-02-03 21:48:49 -0500 |
commit | 2ef8ff7430cb99dd2826db208ed65da03517ad6c (patch) | |
tree | b24840ea5d6033a0bb6d7d3200486cd7d4916b80 /fs/bcachefs/btree_key_cache.c | |
parent | a8281b71f9862a4475e266980a0b5aaf7f0d7548 (diff) |
bcachefs: Improve bkey_cached_lock_for_evict()
We don't need a write lock to check if a key is dirty.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_key_cache.c')
-rw-r--r-- | fs/bcachefs/btree_key_cache.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c index 7accb959600f..1a4e743a8ac1 100644 --- a/fs/bcachefs/btree_key_cache.c +++ b/fs/bcachefs/btree_key_cache.c @@ -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; } |