18
18
#include <linux/vmalloc.h>
19
19
#include <linux/sched/mm.h>
20
20
#include <linux/spinlock.h>
21
- #include <linux/atomic .h>
21
+ #include <linux/refcount .h>
22
22
#include <linux/mempool.h>
23
23
24
24
#include "blk.h"
@@ -64,7 +64,7 @@ static const char *const zone_cond_name[] = {
64
64
struct blk_zone_wplug {
65
65
struct hlist_node node ;
66
66
struct list_head link ;
67
- atomic_t ref ;
67
+ refcount_t ref ;
68
68
spinlock_t lock ;
69
69
unsigned int flags ;
70
70
unsigned int zone_no ;
@@ -411,7 +411,7 @@ static struct blk_zone_wplug *disk_get_zone_wplug(struct gendisk *disk,
411
411
412
412
hlist_for_each_entry_rcu (zwplug , & disk -> zone_wplugs_hash [idx ], node ) {
413
413
if (zwplug -> zone_no == zno &&
414
- atomic_inc_not_zero (& zwplug -> ref )) {
414
+ refcount_inc_not_zero (& zwplug -> ref )) {
415
415
rcu_read_unlock ();
416
416
return zwplug ;
417
417
}
@@ -432,7 +432,7 @@ static void disk_free_zone_wplug_rcu(struct rcu_head *rcu_head)
432
432
433
433
static inline void disk_put_zone_wplug (struct blk_zone_wplug * zwplug )
434
434
{
435
- if (atomic_dec_and_test (& zwplug -> ref )) {
435
+ if (refcount_dec_and_test (& zwplug -> ref )) {
436
436
WARN_ON_ONCE (!bio_list_empty (& zwplug -> bio_list ));
437
437
WARN_ON_ONCE (!list_empty (& zwplug -> link ));
438
438
WARN_ON_ONCE (!(zwplug -> flags & BLK_ZONE_WPLUG_UNHASHED ));
@@ -463,7 +463,7 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
463
463
* taken when the plug was allocated and another reference taken by the
464
464
* caller context).
465
465
*/
466
- if (atomic_read (& zwplug -> ref ) > 2 )
466
+ if (refcount_read (& zwplug -> ref ) > 2 )
467
467
return false;
468
468
469
469
/* 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,
533
533
534
534
INIT_HLIST_NODE (& zwplug -> node );
535
535
INIT_LIST_HEAD (& zwplug -> link );
536
- atomic_set (& zwplug -> ref , 2 );
536
+ refcount_set (& zwplug -> ref , 2 );
537
537
spin_lock_init (& zwplug -> lock );
538
538
zwplug -> flags = 0 ;
539
539
zwplug -> zone_no = zno ;
@@ -624,7 +624,7 @@ static inline void disk_zone_wplug_set_error(struct gendisk *disk,
624
624
* finished.
625
625
*/
626
626
zwplug -> flags |= BLK_ZONE_WPLUG_ERROR ;
627
- atomic_inc (& zwplug -> ref );
627
+ refcount_inc (& zwplug -> ref );
628
628
629
629
spin_lock_irqsave (& disk -> zone_wplugs_lock , flags );
630
630
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,
1099
1099
* reference we take here.
1100
1100
*/
1101
1101
WARN_ON_ONCE (!(zwplug -> flags & BLK_ZONE_WPLUG_PLUGGED ));
1102
- atomic_inc (& zwplug -> ref );
1102
+ refcount_inc (& zwplug -> ref );
1103
1103
queue_work (disk -> zone_wplugs_wq , & zwplug -> bio_work );
1104
1104
}
1105
1105
@@ -1444,7 +1444,7 @@ static void disk_destroy_zone_wplugs_hash_table(struct gendisk *disk)
1444
1444
while (!hlist_empty (& disk -> zone_wplugs_hash [i ])) {
1445
1445
zwplug = hlist_entry (disk -> zone_wplugs_hash [i ].first ,
1446
1446
struct blk_zone_wplug , node );
1447
- atomic_inc (& zwplug -> ref );
1447
+ refcount_inc (& zwplug -> ref );
1448
1448
disk_remove_zone_wplug (disk , zwplug );
1449
1449
disk_put_zone_wplug (zwplug );
1450
1450
}
@@ -1845,7 +1845,7 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
1845
1845
spin_lock_irqsave (& zwplug -> lock , flags );
1846
1846
zwp_zone_no = zwplug -> zone_no ;
1847
1847
zwp_flags = zwplug -> flags ;
1848
- zwp_ref = atomic_read (& zwplug -> ref );
1848
+ zwp_ref = refcount_read (& zwplug -> ref );
1849
1849
zwp_wp_offset = zwplug -> wp_offset ;
1850
1850
zwp_bio_list_size = bio_list_size (& zwplug -> bio_list );
1851
1851
spin_unlock_irqrestore (& zwplug -> lock , flags );
0 commit comments