mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
block: Switch to using refcount_t for zone write plugs
Replace the raw atomic_t reference counting of zone write plugs with a refcount_t. No functional changes. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202411050650.ilIZa8S7-lkp@intel.com/ Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20241107065438.236348-1-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
ab9bc81c1c
commit
4122fef16b
@ -18,7 +18,7 @@
|
|||||||
#include <linux/vmalloc.h>
|
#include <linux/vmalloc.h>
|
||||||
#include <linux/sched/mm.h>
|
#include <linux/sched/mm.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
#include <linux/atomic.h>
|
#include <linux/refcount.h>
|
||||||
#include <linux/mempool.h>
|
#include <linux/mempool.h>
|
||||||
|
|
||||||
#include "blk.h"
|
#include "blk.h"
|
||||||
@ -64,7 +64,7 @@ static const char *const zone_cond_name[] = {
|
|||||||
struct blk_zone_wplug {
|
struct blk_zone_wplug {
|
||||||
struct hlist_node node;
|
struct hlist_node node;
|
||||||
struct list_head link;
|
struct list_head link;
|
||||||
atomic_t ref;
|
refcount_t ref;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
unsigned int zone_no;
|
unsigned int zone_no;
|
||||||
@ -411,7 +411,7 @@ static struct blk_zone_wplug *disk_get_zone_wplug(struct gendisk *disk,
|
|||||||
|
|
||||||
hlist_for_each_entry_rcu(zwplug, &disk->zone_wplugs_hash[idx], node) {
|
hlist_for_each_entry_rcu(zwplug, &disk->zone_wplugs_hash[idx], node) {
|
||||||
if (zwplug->zone_no == zno &&
|
if (zwplug->zone_no == zno &&
|
||||||
atomic_inc_not_zero(&zwplug->ref)) {
|
refcount_inc_not_zero(&zwplug->ref)) {
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return zwplug;
|
return zwplug;
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ static void disk_free_zone_wplug_rcu(struct rcu_head *rcu_head)
|
|||||||
|
|
||||||
static inline void disk_put_zone_wplug(struct blk_zone_wplug *zwplug)
|
static inline void disk_put_zone_wplug(struct blk_zone_wplug *zwplug)
|
||||||
{
|
{
|
||||||
if (atomic_dec_and_test(&zwplug->ref)) {
|
if (refcount_dec_and_test(&zwplug->ref)) {
|
||||||
WARN_ON_ONCE(!bio_list_empty(&zwplug->bio_list));
|
WARN_ON_ONCE(!bio_list_empty(&zwplug->bio_list));
|
||||||
WARN_ON_ONCE(!list_empty(&zwplug->link));
|
WARN_ON_ONCE(!list_empty(&zwplug->link));
|
||||||
WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_UNHASHED));
|
WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_UNHASHED));
|
||||||
@ -463,7 +463,7 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
|
|||||||
* taken when the plug was allocated and another reference taken by the
|
* taken when the plug was allocated and another reference taken by the
|
||||||
* caller context).
|
* caller context).
|
||||||
*/
|
*/
|
||||||
if (atomic_read(&zwplug->ref) > 2)
|
if (refcount_read(&zwplug->ref) > 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* We can remove zone write plugs for zones that are empty or full. */
|
/* We can remove zone write plugs for zones that are empty or full. */
|
||||||
@ -533,7 +533,7 @@ again:
|
|||||||
|
|
||||||
INIT_HLIST_NODE(&zwplug->node);
|
INIT_HLIST_NODE(&zwplug->node);
|
||||||
INIT_LIST_HEAD(&zwplug->link);
|
INIT_LIST_HEAD(&zwplug->link);
|
||||||
atomic_set(&zwplug->ref, 2);
|
refcount_set(&zwplug->ref, 2);
|
||||||
spin_lock_init(&zwplug->lock);
|
spin_lock_init(&zwplug->lock);
|
||||||
zwplug->flags = 0;
|
zwplug->flags = 0;
|
||||||
zwplug->zone_no = zno;
|
zwplug->zone_no = zno;
|
||||||
@ -624,7 +624,7 @@ static inline void disk_zone_wplug_set_error(struct gendisk *disk,
|
|||||||
* finished.
|
* finished.
|
||||||
*/
|
*/
|
||||||
zwplug->flags |= BLK_ZONE_WPLUG_ERROR;
|
zwplug->flags |= BLK_ZONE_WPLUG_ERROR;
|
||||||
atomic_inc(&zwplug->ref);
|
refcount_inc(&zwplug->ref);
|
||||||
|
|
||||||
spin_lock_irqsave(&disk->zone_wplugs_lock, flags);
|
spin_lock_irqsave(&disk->zone_wplugs_lock, flags);
|
||||||
list_add_tail(&zwplug->link, &disk->zone_wplugs_err_list);
|
list_add_tail(&zwplug->link, &disk->zone_wplugs_err_list);
|
||||||
@ -1099,7 +1099,7 @@ static void disk_zone_wplug_schedule_bio_work(struct gendisk *disk,
|
|||||||
* reference we take here.
|
* reference we take here.
|
||||||
*/
|
*/
|
||||||
WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED));
|
WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED));
|
||||||
atomic_inc(&zwplug->ref);
|
refcount_inc(&zwplug->ref);
|
||||||
queue_work(disk->zone_wplugs_wq, &zwplug->bio_work);
|
queue_work(disk->zone_wplugs_wq, &zwplug->bio_work);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1444,7 +1444,7 @@ static void disk_destroy_zone_wplugs_hash_table(struct gendisk *disk)
|
|||||||
while (!hlist_empty(&disk->zone_wplugs_hash[i])) {
|
while (!hlist_empty(&disk->zone_wplugs_hash[i])) {
|
||||||
zwplug = hlist_entry(disk->zone_wplugs_hash[i].first,
|
zwplug = hlist_entry(disk->zone_wplugs_hash[i].first,
|
||||||
struct blk_zone_wplug, node);
|
struct blk_zone_wplug, node);
|
||||||
atomic_inc(&zwplug->ref);
|
refcount_inc(&zwplug->ref);
|
||||||
disk_remove_zone_wplug(disk, zwplug);
|
disk_remove_zone_wplug(disk, zwplug);
|
||||||
disk_put_zone_wplug(zwplug);
|
disk_put_zone_wplug(zwplug);
|
||||||
}
|
}
|
||||||
@ -1845,7 +1845,7 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
|
|||||||
spin_lock_irqsave(&zwplug->lock, flags);
|
spin_lock_irqsave(&zwplug->lock, flags);
|
||||||
zwp_zone_no = zwplug->zone_no;
|
zwp_zone_no = zwplug->zone_no;
|
||||||
zwp_flags = zwplug->flags;
|
zwp_flags = zwplug->flags;
|
||||||
zwp_ref = atomic_read(&zwplug->ref);
|
zwp_ref = refcount_read(&zwplug->ref);
|
||||||
zwp_wp_offset = zwplug->wp_offset;
|
zwp_wp_offset = zwplug->wp_offset;
|
||||||
zwp_bio_list_size = bio_list_size(&zwplug->bio_list);
|
zwp_bio_list_size = bio_list_size(&zwplug->bio_list);
|
||||||
spin_unlock_irqrestore(&zwplug->lock, flags);
|
spin_unlock_irqrestore(&zwplug->lock, flags);
|
||||||
|
Loading…
Reference in New Issue
Block a user