Skip to content

Commit 3571c1a

Browse files
damien-lemoalSasha Levin
authored andcommitted
block: Switch to using refcount_t for zone write plugs
commit 4122fef upstream. Replace the raw atomic_t reference counting of zone write plugs with a refcount_t. No functional changes. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fc2cca9 commit 3571c1a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

block/blk-zoned.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <linux/vmalloc.h>
1919
#include <linux/sched/mm.h>
2020
#include <linux/spinlock.h>
21-
#include <linux/atomic.h>
21+
#include <linux/refcount.h>
2222
#include <linux/mempool.h>
2323

2424
#include "blk.h"
@@ -64,7 +64,7 @@ static const char *const zone_cond_name[] = {
6464
struct blk_zone_wplug {
6565
struct hlist_node node;
6666
struct list_head link;
67-
atomic_t ref;
67+
refcount_t ref;
6868
spinlock_t lock;
6969
unsigned int flags;
7070
unsigned int zone_no;
@@ -417,7 +417,7 @@ static struct blk_zone_wplug *disk_get_zone_wplug(struct gendisk *disk,
417417

418418
hlist_for_each_entry_rcu(zwplug, &disk->zone_wplugs_hash[idx], node) {
419419
if (zwplug->zone_no == zno &&
420-
atomic_inc_not_zero(&zwplug->ref)) {
420+
refcount_inc_not_zero(&zwplug->ref)) {
421421
rcu_read_unlock();
422422
return zwplug;
423423
}
@@ -438,7 +438,7 @@ static void disk_free_zone_wplug_rcu(struct rcu_head *rcu_head)
438438

439439
static inline void disk_put_zone_wplug(struct blk_zone_wplug *zwplug)
440440
{
441-
if (atomic_dec_and_test(&zwplug->ref)) {
441+
if (refcount_dec_and_test(&zwplug->ref)) {
442442
WARN_ON_ONCE(!bio_list_empty(&zwplug->bio_list));
443443
WARN_ON_ONCE(!list_empty(&zwplug->link));
444444
WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_UNHASHED));
@@ -469,7 +469,7 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
469469
* taken when the plug was allocated and another reference taken by the
470470
* caller context).
471471
*/
472-
if (atomic_read(&zwplug->ref) > 2)
472+
if (refcount_read(&zwplug->ref) > 2)
473473
return false;
474474

475475
/* We can remove zone write plugs for zones that are empty or full. */
@@ -539,7 +539,7 @@ static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk,
539539

540540
INIT_HLIST_NODE(&zwplug->node);
541541
INIT_LIST_HEAD(&zwplug->link);
542-
atomic_set(&zwplug->ref, 2);
542+
refcount_set(&zwplug->ref, 2);
543543
spin_lock_init(&zwplug->lock);
544544
zwplug->flags = 0;
545545
zwplug->zone_no = zno;
@@ -630,7 +630,7 @@ static inline void disk_zone_wplug_set_error(struct gendisk *disk,
630630
* finished.
631631
*/
632632
zwplug->flags |= BLK_ZONE_WPLUG_ERROR;
633-
atomic_inc(&zwplug->ref);
633+
refcount_inc(&zwplug->ref);
634634

635635
spin_lock_irqsave(&disk->zone_wplugs_lock, flags);
636636
list_add_tail(&zwplug->link, &disk->zone_wplugs_err_list);
@@ -1105,7 +1105,7 @@ static void disk_zone_wplug_schedule_bio_work(struct gendisk *disk,
11051105
* reference we take here.
11061106
*/
11071107
WARN_ON_ONCE(!(zwplug->flags & BLK_ZONE_WPLUG_PLUGGED));
1108-
atomic_inc(&zwplug->ref);
1108+
refcount_inc(&zwplug->ref);
11091109
queue_work(disk->zone_wplugs_wq, &zwplug->bio_work);
11101110
}
11111111

@@ -1450,7 +1450,7 @@ static void disk_destroy_zone_wplugs_hash_table(struct gendisk *disk)
14501450
while (!hlist_empty(&disk->zone_wplugs_hash[i])) {
14511451
zwplug = hlist_entry(disk->zone_wplugs_hash[i].first,
14521452
struct blk_zone_wplug, node);
1453-
atomic_inc(&zwplug->ref);
1453+
refcount_inc(&zwplug->ref);
14541454
disk_remove_zone_wplug(disk, zwplug);
14551455
disk_put_zone_wplug(zwplug);
14561456
}
@@ -1876,7 +1876,7 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
18761876
spin_lock_irqsave(&zwplug->lock, flags);
18771877
zwp_zone_no = zwplug->zone_no;
18781878
zwp_flags = zwplug->flags;
1879-
zwp_ref = atomic_read(&zwplug->ref);
1879+
zwp_ref = refcount_read(&zwplug->ref);
18801880
zwp_wp_offset = zwplug->wp_offset;
18811881
zwp_bio_list_size = bio_list_size(&zwplug->bio_list);
18821882
spin_unlock_irqrestore(&zwplug->lock, flags);

0 commit comments

Comments
 (0)