Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Eric Biggers and committed by
Mikulas Patocka
1bf7ba4c f93bc869

+10 -22
+10 -22
drivers/md/dm-bufio.c
··· 369 369 * - IO 370 370 * - Eviction or cache sizing. 371 371 * 372 - * cache_get() and cache_put() are threadsafe, you do not need to 373 - * protect these calls with a surrounding mutex. All the other 372 + * cache_get() and cache_put_and_wake() are threadsafe, you do not need 373 + * to protect these calls with a surrounding mutex. All the other 374 374 * methods are not threadsafe; they do use locking primitives, but 375 375 * only enough to ensure get/put are threadsafe. 376 376 */ ··· 615 615 cache_read_unlock(bc, block); 616 616 617 617 return b; 618 - } 619 - 620 - /*--------------*/ 621 - 622 - /* 623 - * Returns true if the hold count hits zero. 624 - * threadsafe 625 - */ 626 - static bool cache_put(struct dm_buffer_cache *bc, struct dm_buffer *b) 627 - { 628 - bool r; 629 - 630 - cache_read_lock(bc, b->block); 631 - BUG_ON(!atomic_read(&b->hold_count)); 632 - r = atomic_dec_and_test(&b->hold_count); 633 - cache_read_unlock(bc, b->block); 634 - 635 - return r; 636 618 } 637 619 638 620 /*--------------*/ ··· 1727 1745 1728 1746 static void cache_put_and_wake(struct dm_bufio_client *c, struct dm_buffer *b) 1729 1747 { 1748 + bool wake; 1749 + 1750 + cache_read_lock(&c->cache, b->block); 1751 + BUG_ON(!atomic_read(&b->hold_count)); 1752 + wake = atomic_dec_and_test(&b->hold_count); 1753 + cache_read_unlock(&c->cache, b->block); 1754 + 1730 1755 /* 1731 1756 * Relying on waitqueue_active() is racey, but we sleep 1732 1757 * with schedule_timeout anyway. 1733 1758 */ 1734 - if (cache_put(&c->cache, b) && 1735 - unlikely(waitqueue_active(&c->free_buffer_wait))) 1759 + if (wake && unlikely(waitqueue_active(&c->free_buffer_wait))) 1736 1760 wake_up(&c->free_buffer_wait); 1737 1761 } 1738 1762