Skip to content

Commit 02ccd7c

Browse files
damien-lemoalaxboe
authored andcommitted
block: Remove zone write locking
Zone write locking is now unused and replaced with zone write plugging. Remove all code that was implementing zone write locking, that is, the various helper functions controlling request zone write locking and the gendisk attached zone bitmaps. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Tested-by: Hans Holmberg <hans.holmberg@wdc.com> Tested-by: Dennis Maisenbacher <dennis.maisenbacher@wdc.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Link: https://lore.kernel.org/r/20240408014128.205141-27-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent a98b05b commit 02ccd7c

5 files changed

Lines changed: 7 additions & 179 deletions

File tree

block/blk-mq-debugfs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ static const char *const rqf_name[] = {
256256
RQF_NAME(HASHED),
257257
RQF_NAME(STATS),
258258
RQF_NAME(SPECIAL_PAYLOAD),
259-
RQF_NAME(ZONE_WRITE_LOCKED),
260259
RQF_NAME(TIMED_OUT),
261260
RQF_NAME(RESV),
262261
};

block/blk-zoned.c

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -115,52 +115,6 @@ const char *blk_zone_cond_str(enum blk_zone_cond zone_cond)
115115
}
116116
EXPORT_SYMBOL_GPL(blk_zone_cond_str);
117117

118-
/*
119-
* Return true if a request is a write requests that needs zone write locking.
120-
*/
121-
bool blk_req_needs_zone_write_lock(struct request *rq)
122-
{
123-
if (!rq->q->disk->seq_zones_wlock)
124-
return false;
125-
126-
return blk_rq_is_seq_zoned_write(rq);
127-
}
128-
EXPORT_SYMBOL_GPL(blk_req_needs_zone_write_lock);
129-
130-
bool blk_req_zone_write_trylock(struct request *rq)
131-
{
132-
unsigned int zno = blk_rq_zone_no(rq);
133-
134-
if (test_and_set_bit(zno, rq->q->disk->seq_zones_wlock))
135-
return false;
136-
137-
WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
138-
rq->rq_flags |= RQF_ZONE_WRITE_LOCKED;
139-
140-
return true;
141-
}
142-
EXPORT_SYMBOL_GPL(blk_req_zone_write_trylock);
143-
144-
void __blk_req_zone_write_lock(struct request *rq)
145-
{
146-
if (WARN_ON_ONCE(test_and_set_bit(blk_rq_zone_no(rq),
147-
rq->q->disk->seq_zones_wlock)))
148-
return;
149-
150-
WARN_ON_ONCE(rq->rq_flags & RQF_ZONE_WRITE_LOCKED);
151-
rq->rq_flags |= RQF_ZONE_WRITE_LOCKED;
152-
}
153-
EXPORT_SYMBOL_GPL(__blk_req_zone_write_lock);
154-
155-
void __blk_req_zone_write_unlock(struct request *rq)
156-
{
157-
rq->rq_flags &= ~RQF_ZONE_WRITE_LOCKED;
158-
if (rq->q->disk->seq_zones_wlock)
159-
WARN_ON_ONCE(!test_and_clear_bit(blk_rq_zone_no(rq),
160-
rq->q->disk->seq_zones_wlock));
161-
}
162-
EXPORT_SYMBOL_GPL(__blk_req_zone_write_unlock);
163-
164118
/**
165119
* bdev_nr_zones - Get number of zones
166120
* @bdev: Target device
@@ -1506,9 +1460,6 @@ void disk_free_zone_resources(struct gendisk *disk)
15061460

15071461
kfree(disk->conv_zones_bitmap);
15081462
disk->conv_zones_bitmap = NULL;
1509-
kfree(disk->seq_zones_wlock);
1510-
disk->seq_zones_wlock = NULL;
1511-
15121463
disk->zone_capacity = 0;
15131464
disk->nr_zones = 0;
15141465
}
@@ -1556,7 +1507,6 @@ static int disk_revalidate_zone_resources(struct gendisk *disk,
15561507
struct blk_revalidate_zone_args {
15571508
struct gendisk *disk;
15581509
unsigned long *conv_zones_bitmap;
1559-
unsigned long *seq_zones_wlock;
15601510
unsigned int nr_zones;
15611511
unsigned int zone_capacity;
15621512
sector_t sector;
@@ -1574,7 +1524,6 @@ static int disk_update_zone_resources(struct gendisk *disk,
15741524

15751525
disk->nr_zones = args->nr_zones;
15761526
disk->zone_capacity = args->zone_capacity;
1577-
swap(disk->seq_zones_wlock, args->seq_zones_wlock);
15781527
swap(disk->conv_zones_bitmap, args->conv_zones_bitmap);
15791528

15801529
/*
@@ -1664,13 +1613,6 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
16641613
set_bit(idx, args->conv_zones_bitmap);
16651614
break;
16661615
case BLK_ZONE_TYPE_SEQWRITE_REQ:
1667-
if (!args->seq_zones_wlock) {
1668-
args->seq_zones_wlock =
1669-
blk_alloc_zone_bitmap(q->node, args->nr_zones);
1670-
if (!args->seq_zones_wlock)
1671-
return -ENOMEM;
1672-
}
1673-
16741616
/*
16751617
* Remember the capacity of the first sequential zone and check
16761618
* if it is constant for all zones.
@@ -1712,7 +1654,7 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
17121654
}
17131655

17141656
/**
1715-
* blk_revalidate_disk_zones - (re)allocate and initialize zone bitmaps
1657+
* blk_revalidate_disk_zones - (re)allocate and initialize zone write plugs
17161658
* @disk: Target disk
17171659
*
17181660
* Helper function for low-level device drivers to check, (re) allocate and
@@ -1786,9 +1728,8 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
17861728
}
17871729

17881730
/*
1789-
* Install the new bitmaps and update nr_zones only once the queue is
1790-
* stopped and all I/Os are completed (i.e. a scheduler is not
1791-
* referencing the bitmaps).
1731+
* Set the new disk zone parameters only once the queue is frozen and
1732+
* all I/Os are completed.
17921733
*/
17931734
blk_mq_freeze_queue(q);
17941735
if (ret > 0)
@@ -1799,7 +1740,6 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
17991740
disk_free_zone_resources(disk);
18001741
blk_mq_unfreeze_queue(q);
18011742

1802-
kfree(args.seq_zones_wlock);
18031743
kfree(args.conv_zones_bitmap);
18041744

18051745
return ret;

include/linux/blk-mq.h

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ typedef __u32 __bitwise req_flags_t;
5454
/* Look at ->special_vec for the actual data payload instead of the
5555
bio chain. */
5656
#define RQF_SPECIAL_PAYLOAD ((__force req_flags_t)(1 << 18))
57-
/* The per-zone write lock is held for this request */
58-
#define RQF_ZONE_WRITE_LOCKED ((__force req_flags_t)(1 << 19))
5957
/* The request completion needs to be signaled to zone write pluging. */
6058
#define RQF_ZONE_WRITE_PLUGGING ((__force req_flags_t)(1 << 20))
6159
/* ->timeout has been called, don't expire again */
@@ -1152,85 +1150,4 @@ static inline int blk_rq_map_sg(struct request_queue *q, struct request *rq,
11521150
}
11531151
void blk_dump_rq_flags(struct request *, char *);
11541152

1155-
#ifdef CONFIG_BLK_DEV_ZONED
1156-
static inline unsigned int blk_rq_zone_no(struct request *rq)
1157-
{
1158-
return disk_zone_no(rq->q->disk, blk_rq_pos(rq));
1159-
}
1160-
1161-
static inline unsigned int blk_rq_zone_is_seq(struct request *rq)
1162-
{
1163-
return disk_zone_is_seq(rq->q->disk, blk_rq_pos(rq));
1164-
}
1165-
1166-
/**
1167-
* blk_rq_is_seq_zoned_write() - Check if @rq requires write serialization.
1168-
* @rq: Request to examine.
1169-
*
1170-
* Note: REQ_OP_ZONE_APPEND requests do not require serialization.
1171-
*/
1172-
static inline bool blk_rq_is_seq_zoned_write(struct request *rq)
1173-
{
1174-
return op_needs_zoned_write_locking(req_op(rq)) &&
1175-
blk_rq_zone_is_seq(rq);
1176-
}
1177-
1178-
bool blk_req_needs_zone_write_lock(struct request *rq);
1179-
bool blk_req_zone_write_trylock(struct request *rq);
1180-
void __blk_req_zone_write_lock(struct request *rq);
1181-
void __blk_req_zone_write_unlock(struct request *rq);
1182-
1183-
static inline void blk_req_zone_write_lock(struct request *rq)
1184-
{
1185-
if (blk_req_needs_zone_write_lock(rq))
1186-
__blk_req_zone_write_lock(rq);
1187-
}
1188-
1189-
static inline void blk_req_zone_write_unlock(struct request *rq)
1190-
{
1191-
if (rq->rq_flags & RQF_ZONE_WRITE_LOCKED)
1192-
__blk_req_zone_write_unlock(rq);
1193-
}
1194-
1195-
static inline bool blk_req_zone_is_write_locked(struct request *rq)
1196-
{
1197-
return rq->q->disk->seq_zones_wlock &&
1198-
test_bit(blk_rq_zone_no(rq), rq->q->disk->seq_zones_wlock);
1199-
}
1200-
1201-
static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
1202-
{
1203-
if (!blk_req_needs_zone_write_lock(rq))
1204-
return true;
1205-
return !blk_req_zone_is_write_locked(rq);
1206-
}
1207-
#else /* CONFIG_BLK_DEV_ZONED */
1208-
static inline bool blk_rq_is_seq_zoned_write(struct request *rq)
1209-
{
1210-
return false;
1211-
}
1212-
1213-
static inline bool blk_req_needs_zone_write_lock(struct request *rq)
1214-
{
1215-
return false;
1216-
}
1217-
1218-
static inline void blk_req_zone_write_lock(struct request *rq)
1219-
{
1220-
}
1221-
1222-
static inline void blk_req_zone_write_unlock(struct request *rq)
1223-
{
1224-
}
1225-
static inline bool blk_req_zone_is_write_locked(struct request *rq)
1226-
{
1227-
return false;
1228-
}
1229-
1230-
static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
1231-
{
1232-
return true;
1233-
}
1234-
#endif /* CONFIG_BLK_DEV_ZONED */
1235-
12361153
#endif /* BLK_MQ_H */

include/linux/blk_types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ enum {
297297
BIO_QOS_THROTTLED, /* bio went through rq_qos throttle path */
298298
BIO_QOS_MERGED, /* but went through rq_qos merge path */
299299
BIO_REMAPPED,
300-
BIO_ZONE_WRITE_LOCKED, /* Owns a zoned device zone write lock */
301300
BIO_ZONE_WRITE_PLUGGING, /* bio handled through zone write plugging */
302301
BIO_EMULATES_ZONE_APPEND, /* bio emulates a zone append operation */
303302
BIO_FLAG_LAST

include/linux/blkdev.h

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -177,23 +177,14 @@ struct gendisk {
177177

178178
#ifdef CONFIG_BLK_DEV_ZONED
179179
/*
180-
* Zoned block device information for request dispatch control.
181-
* nr_zones is the total number of zones of the device. This is always
182-
* 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
183-
* bits which indicates if a zone is conventional (bit set) or
184-
* sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
185-
* bits which indicates if a zone is write locked, that is, if a write
186-
* request targeting the zone was dispatched.
187-
*
188-
* Reads of this information must be protected with blk_queue_enter() /
189-
* blk_queue_exit(). Modifying this information is only allowed while
190-
* no requests are being processed. See also blk_mq_freeze_queue() and
191-
* blk_mq_unfreeze_queue().
180+
* Zoned block device information. Reads of this information must be
181+
* protected with blk_queue_enter() / blk_queue_exit(). Modifying this
182+
* information is only allowed while no requests are being processed.
183+
* See also blk_mq_freeze_queue() and blk_mq_unfreeze_queue().
192184
*/
193185
unsigned int nr_zones;
194186
unsigned int zone_capacity;
195187
unsigned long *conv_zones_bitmap;
196-
unsigned long *seq_zones_wlock;
197188
unsigned int zone_wplugs_hash_bits;
198189
spinlock_t zone_wplugs_lock;
199190
struct mempool_s *zone_wplugs_pool;
@@ -635,15 +626,6 @@ static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
635626
return sector >> ilog2(disk->queue->limits.chunk_sectors);
636627
}
637628

638-
static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
639-
{
640-
if (!blk_queue_is_zoned(disk->queue))
641-
return false;
642-
if (!disk->conv_zones_bitmap)
643-
return true;
644-
return !test_bit(disk_zone_no(disk, sector), disk->conv_zones_bitmap);
645-
}
646-
647629
static inline void disk_set_max_open_zones(struct gendisk *disk,
648630
unsigned int max_open_zones)
649631
{
@@ -677,10 +659,6 @@ static inline unsigned int disk_nr_zones(struct gendisk *disk)
677659
{
678660
return 0;
679661
}
680-
static inline bool disk_zone_is_seq(struct gendisk *disk, sector_t sector)
681-
{
682-
return false;
683-
}
684662
static inline unsigned int disk_zone_no(struct gendisk *disk, sector_t sector)
685663
{
686664
return 0;
@@ -869,11 +847,6 @@ static inline bool bio_straddles_zones(struct bio *bio)
869847
disk_zone_no(bio->bi_bdev->bd_disk, bio_end_sector(bio) - 1);
870848
}
871849

872-
static inline unsigned int bio_zone_is_seq(struct bio *bio)
873-
{
874-
return disk_zone_is_seq(bio->bi_bdev->bd_disk, bio->bi_iter.bi_sector);
875-
}
876-
877850
/*
878851
* Return how much of the chunk is left to be used for I/O at a given offset.
879852
*/

0 commit comments

Comments
 (0)