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[] = {
6464struct 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 ;
@@ -411,7 +411,7 @@ static struct blk_zone_wplug *disk_get_zone_wplug(struct gendisk *disk,
411411
412412 hlist_for_each_entry_rcu (zwplug , & disk -> zone_wplugs_hash [idx ], node ) {
413413 if (zwplug -> zone_no == zno &&
414- atomic_inc_not_zero (& zwplug -> ref )) {
414+ refcount_inc_not_zero (& zwplug -> ref )) {
415415 rcu_read_unlock ();
416416 return zwplug ;
417417 }
@@ -432,7 +432,7 @@ static void disk_free_zone_wplug_rcu(struct rcu_head *rcu_head)
432432
433433static inline void disk_put_zone_wplug (struct blk_zone_wplug * zwplug )
434434{
435- if (atomic_dec_and_test (& zwplug -> ref )) {
435+ if (refcount_dec_and_test (& zwplug -> ref )) {
436436 WARN_ON_ONCE (!bio_list_empty (& zwplug -> bio_list ));
437437 WARN_ON_ONCE (!list_empty (& zwplug -> link ));
438438 WARN_ON_ONCE (!(zwplug -> flags & BLK_ZONE_WPLUG_UNHASHED ));
@@ -463,7 +463,7 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
463463 * taken when the plug was allocated and another reference taken by the
464464 * caller context).
465465 */
466- if (atomic_read (& zwplug -> ref ) > 2 )
466+ if (refcount_read (& zwplug -> ref ) > 2 )
467467 return false;
468468
469469 /* We can remove zone write plugs for zones that are empty or full. */
@@ -533,7 +533,7 @@ static struct blk_zone_wplug *disk_get_and_lock_zone_wplug(struct gendisk *disk,
533533
534534 INIT_HLIST_NODE (& zwplug -> node );
535535 INIT_LIST_HEAD (& zwplug -> link );
536- atomic_set (& zwplug -> ref , 2 );
536+ refcount_set (& zwplug -> ref , 2 );
537537 spin_lock_init (& zwplug -> lock );
538538 zwplug -> flags = 0 ;
539539 zwplug -> zone_no = zno ;
@@ -624,7 +624,7 @@ static inline void disk_zone_wplug_set_error(struct gendisk *disk,
624624 * finished.
625625 */
626626 zwplug -> flags |= BLK_ZONE_WPLUG_ERROR ;
627- atomic_inc (& zwplug -> ref );
627+ refcount_inc (& zwplug -> ref );
628628
629629 spin_lock_irqsave (& disk -> zone_wplugs_lock , flags );
630630 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,
10991099 * reference we take here.
11001100 */
11011101 WARN_ON_ONCE (!(zwplug -> flags & BLK_ZONE_WPLUG_PLUGGED ));
1102- atomic_inc (& zwplug -> ref );
1102+ refcount_inc (& zwplug -> ref );
11031103 queue_work (disk -> zone_wplugs_wq , & zwplug -> bio_work );
11041104}
11051105
@@ -1444,7 +1444,7 @@ static void disk_destroy_zone_wplugs_hash_table(struct gendisk *disk)
14441444 while (!hlist_empty (& disk -> zone_wplugs_hash [i ])) {
14451445 zwplug = hlist_entry (disk -> zone_wplugs_hash [i ].first ,
14461446 struct blk_zone_wplug , node );
1447- atomic_inc (& zwplug -> ref );
1447+ refcount_inc (& zwplug -> ref );
14481448 disk_remove_zone_wplug (disk , zwplug );
14491449 disk_put_zone_wplug (zwplug );
14501450 }
@@ -1845,7 +1845,7 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
18451845 spin_lock_irqsave (& zwplug -> lock , flags );
18461846 zwp_zone_no = zwplug -> zone_no ;
18471847 zwp_flags = zwplug -> flags ;
1848- zwp_ref = atomic_read (& zwplug -> ref );
1848+ zwp_ref = refcount_read (& zwplug -> ref );
18491849 zwp_wp_offset = zwplug -> wp_offset ;
18501850 zwp_bio_list_size = bio_list_size (& zwplug -> bio_list );
18511851 spin_unlock_irqrestore (& zwplug -> lock , flags );
0 commit comments