Skip to content

Commit 99a9476

Browse files
damien-lemoalaxboe
authored andcommitted
block: Do not special-case plugging of zone write operations
With the block layer zone write plugging being automatically done for any write operation to a zone of a zoned block device, a regular request plugging handled through current->plug can only ever see at most a single write request per zone. In such case, any potential reordering of the plugged requests will be harmless. We can thus remove the special casing for write operations to zones and have these requests plugged as well. This allows removing the function blk_mq_plug and instead directly using current->plug where needed. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> 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-29-dlemoal@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 97abee5 commit 99a9476

5 files changed

Lines changed: 2 additions & 57 deletions

File tree

block/blk-core.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -907,12 +907,6 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
907907
!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
908908
return 0;
909909

910-
/*
911-
* As the requests that require a zone lock are not plugged in the
912-
* first place, directly accessing the plug instead of using
913-
* blk_mq_plug() should not have any consequences during flushing for
914-
* zoned devices.
915-
*/
916910
blk_flush_plug(current->plug, false);
917911

918912
/*

block/blk-merge.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,10 +1113,9 @@ static enum bio_merge_status blk_attempt_bio_merge(struct request_queue *q,
11131113
bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
11141114
unsigned int nr_segs)
11151115
{
1116-
struct blk_plug *plug;
1116+
struct blk_plug *plug = current->plug;
11171117
struct request *rq;
11181118

1119-
plug = blk_mq_plug(bio);
11201119
if (!plug || rq_list_empty(plug->mq_list))
11211120
return false;
11221121

block/blk-mq.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,11 +1330,6 @@ void blk_execute_rq_nowait(struct request *rq, bool at_head)
13301330

13311331
blk_account_io_start(rq);
13321332

1333-
/*
1334-
* As plugging can be enabled for passthrough requests on a zoned
1335-
* device, directly accessing the plug instead of using blk_mq_plug()
1336-
* should not have any consequences.
1337-
*/
13381333
if (current->plug && !at_head) {
13391334
blk_add_rq_to_plug(current->plug, rq);
13401335
return;
@@ -2932,7 +2927,7 @@ static void blk_mq_use_cached_rq(struct request *rq, struct blk_plug *plug,
29322927
void blk_mq_submit_bio(struct bio *bio)
29332928
{
29342929
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
2935-
struct blk_plug *plug = blk_mq_plug(bio);
2930+
struct blk_plug *plug = current->plug;
29362931
const int is_sync = op_is_sync(bio->bi_opf);
29372932
struct blk_mq_hw_ctx *hctx;
29382933
unsigned int nr_segs = 1;

block/blk-mq.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -365,37 +365,6 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
365365
qmap->mq_map[cpu] = 0;
366366
}
367367

368-
/*
369-
* blk_mq_plug() - Get caller context plug
370-
* @bio : the bio being submitted by the caller context
371-
*
372-
* Plugging, by design, may delay the insertion of BIOs into the elevator in
373-
* order to increase BIO merging opportunities. This however can cause BIO
374-
* insertion order to change from the order in which submit_bio() is being
375-
* executed in the case of multiple contexts concurrently issuing BIOs to a
376-
* device, even if these context are synchronized to tightly control BIO issuing
377-
* order. While this is not a problem with regular block devices, this ordering
378-
* change can cause write BIO failures with zoned block devices as these
379-
* require sequential write patterns to zones. Prevent this from happening by
380-
* ignoring the plug state of a BIO issuing context if it is for a zoned block
381-
* device and the BIO to plug is a write operation.
382-
*
383-
* Return current->plug if the bio can be plugged and NULL otherwise
384-
*/
385-
static inline struct blk_plug *blk_mq_plug( struct bio *bio)
386-
{
387-
/* Zoned block device write operation case: do not plug the BIO */
388-
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
389-
bdev_op_is_zoned_write(bio->bi_bdev, bio_op(bio)))
390-
return NULL;
391-
392-
/*
393-
* For regular block devices or read operations, use the context plug
394-
* which may be NULL if blk_start_plug() was not executed.
395-
*/
396-
return current->plug;
397-
}
398-
399368
/* Free all requests on the list */
400369
static inline void blk_mq_free_requests(struct list_head *list)
401370
{

include/linux/blkdev.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,18 +1299,6 @@ static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
12991299
return disk_zone_no(bdev->bd_disk, sec);
13001300
}
13011301

1302-
/* Whether write serialization is required for @op on zoned devices. */
1303-
static inline bool op_needs_zoned_write_locking(enum req_op op)
1304-
{
1305-
return op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES;
1306-
}
1307-
1308-
static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
1309-
enum req_op op)
1310-
{
1311-
return bdev_is_zoned(bdev) && op_needs_zoned_write_locking(op);
1312-
}
1313-
13141302
static inline sector_t bdev_zone_sectors(struct block_device *bdev)
13151303
{
13161304
struct request_queue *q = bdev_get_queue(bdev);

0 commit comments

Comments
 (0)