diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2026-01-12 00:38:20 +0300 |
|---|---|---|
| committer | Mikulas Patocka <mpatocka@redhat.com> | 2026-01-19 17:38:28 +0300 |
| commit | 1bf7ba4ca342ada012e7ef88274fb306e88917ad (patch) | |
| tree | b7530eca975c794525bd3042c495259dd19dd10e | |
| parent | f93bc869825fdba3632ff6ddece4906a6673e679 (diff) | |
| download | linux-1bf7ba4ca342ada012e7ef88274fb306e88917ad.tar.xz | |
dm-bufio: merge cache_put() into cache_put_and_wake()
Merge cache_put() into its only caller, cache_put_and_wake().
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
| -rw-r--r-- | drivers/md/dm-bufio.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index f41f649c01d4..8a3f42bcbdcc 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -369,8 +369,8 @@ struct dm_buffer { * - IO * - Eviction or cache sizing. * - * cache_get() and cache_put() are threadsafe, you do not need to - * protect these calls with a surrounding mutex. All the other + * cache_get() and cache_put_and_wake() are threadsafe, you do not need + * to protect these calls with a surrounding mutex. All the other * methods are not threadsafe; they do use locking primitives, but * only enough to ensure get/put are threadsafe. */ @@ -619,24 +619,6 @@ static struct dm_buffer *cache_get(struct dm_buffer_cache *bc, sector_t block) /*--------------*/ -/* - * Returns true if the hold count hits zero. - * threadsafe - */ -static bool cache_put(struct dm_buffer_cache *bc, struct dm_buffer *b) -{ - bool r; - - cache_read_lock(bc, b->block); - BUG_ON(!atomic_read(&b->hold_count)); - r = atomic_dec_and_test(&b->hold_count); - cache_read_unlock(bc, b->block); - - return r; -} - -/*--------------*/ - typedef enum evict_result (*b_predicate)(struct dm_buffer *, void *); /* @@ -1745,12 +1727,18 @@ static void __check_watermark(struct dm_bufio_client *c, static void cache_put_and_wake(struct dm_bufio_client *c, struct dm_buffer *b) { + bool wake; + + cache_read_lock(&c->cache, b->block); + BUG_ON(!atomic_read(&b->hold_count)); + wake = atomic_dec_and_test(&b->hold_count); + cache_read_unlock(&c->cache, b->block); + /* * Relying on waitqueue_active() is racey, but we sleep * with schedule_timeout anyway. */ - if (cache_put(&c->cache, b) && - unlikely(waitqueue_active(&c->free_buffer_wait))) + if (wake && unlikely(waitqueue_active(&c->free_buffer_wait))) wake_up(&c->free_buffer_wait); } |
