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 ;
@@ -417,7 +417,7 @@ static struct blk_zone_wplug *disk_get_zone_wplug(struct gendisk *disk,
417
417
418
418
hlist_for_each_entry_rcu (zwplug , & disk -> zone_wplugs_hash [idx ], node ) {
419
419
if (zwplug -> zone_no == zno &&
420
- atomic_inc_not_zero (& zwplug -> ref )) {
420
+ refcount_inc_not_zero (& zwplug -> ref )) {
421
421
rcu_read_unlock ();
422
422
return zwplug ;
423
423
}
@@ -438,7 +438,7 @@ static void disk_free_zone_wplug_rcu(struct rcu_head *rcu_head)
438
438
439
439
static inline void disk_put_zone_wplug (struct blk_zone_wplug * zwplug )
440
440
{
441
- if (atomic_dec_and_test (& zwplug -> ref )) {
441
+ if (refcount_dec_and_test (& zwplug -> ref )) {
442
442
WARN_ON_ONCE (!bio_list_empty (& zwplug -> bio_list ));
443
443
WARN_ON_ONCE (!list_empty (& zwplug -> link ));
444
444
WARN_ON_ONCE (!(zwplug -> flags & BLK_ZONE_WPLUG_UNHASHED ));
@@ -469,7 +469,7 @@ static inline bool disk_should_remove_zone_wplug(struct gendisk *disk,
469
469
* taken when the plug was allocated and another reference taken by the
470
470
* caller context).
471
471
*/
472
- if (atomic_read (& zwplug -> ref ) > 2 )
472
+ if (refcount_read (& zwplug -> ref ) > 2 )
473
473
return false;
474
474
475
475
/* 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,
539
539
540
540
INIT_HLIST_NODE (& zwplug -> node );
541
541
INIT_LIST_HEAD (& zwplug -> link );
542
- atomic_set (& zwplug -> ref , 2 );
542
+ refcount_set (& zwplug -> ref , 2 );
543
543
spin_lock_init (& zwplug -> lock );
544
544
zwplug -> flags = 0 ;
545
545
zwplug -> zone_no = zno ;
@@ -630,7 +630,7 @@ static inline void disk_zone_wplug_set_error(struct gendisk *disk,
630
630
* finished.
631
631
*/
632
632
zwplug -> flags |= BLK_ZONE_WPLUG_ERROR ;
633
- atomic_inc (& zwplug -> ref );
633
+ refcount_inc (& zwplug -> ref );
634
634
635
635
spin_lock_irqsave (& disk -> zone_wplugs_lock , flags );
636
636
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,
1105
1105
* reference we take here.
1106
1106
*/
1107
1107
WARN_ON_ONCE (!(zwplug -> flags & BLK_ZONE_WPLUG_PLUGGED ));
1108
- atomic_inc (& zwplug -> ref );
1108
+ refcount_inc (& zwplug -> ref );
1109
1109
queue_work (disk -> zone_wplugs_wq , & zwplug -> bio_work );
1110
1110
}
1111
1111
@@ -1450,7 +1450,7 @@ static void disk_destroy_zone_wplugs_hash_table(struct gendisk *disk)
1450
1450
while (!hlist_empty (& disk -> zone_wplugs_hash [i ])) {
1451
1451
zwplug = hlist_entry (disk -> zone_wplugs_hash [i ].first ,
1452
1452
struct blk_zone_wplug , node );
1453
- atomic_inc (& zwplug -> ref );
1453
+ refcount_inc (& zwplug -> ref );
1454
1454
disk_remove_zone_wplug (disk , zwplug );
1455
1455
disk_put_zone_wplug (zwplug );
1456
1456
}
@@ -1876,7 +1876,7 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
1876
1876
spin_lock_irqsave (& zwplug -> lock , flags );
1877
1877
zwp_zone_no = zwplug -> zone_no ;
1878
1878
zwp_flags = zwplug -> flags ;
1879
- zwp_ref = atomic_read (& zwplug -> ref );
1879
+ zwp_ref = refcount_read (& zwplug -> ref );
1880
1880
zwp_wp_offset = zwplug -> wp_offset ;
1881
1881
zwp_bio_list_size = bio_list_size (& zwplug -> bio_list );
1882
1882
spin_unlock_irqrestore (& zwplug -> lock , flags );
0 commit comments