Skip to content

Commit 8cafdb5

Browse files
Panky-codesaxboe
authored andcommitted
block: adapt blk_mq_plug() to not plug for writes that require a zone lock
The current implementation of blk_mq_plug() disables plugging for all operations that involves a transfer to the device as we just check if the last bit in op_is_write() function. Modify blk_mq_plug() to disable plugging only for REQ_OP_WRITE and REQ_OP_WRITE_ZEROS as they might require a zone lock. Suggested-by: Christoph Hellwig <[email protected]> Suggested-by: Damien Le Moal <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Pankaj Raghav <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent dfdcbf1 commit 8cafdb5

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

block/blk-mq.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,8 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
312312
static inline struct blk_plug *blk_mq_plug( struct bio *bio)
313313
{
314314
/* Zoned block device write operation case: do not plug the BIO */
315-
if (bdev_is_zoned(bio->bi_bdev) && op_is_write(bio_op(bio)))
315+
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
316+
bdev_op_is_zoned_write(bio->bi_bdev, bio_op(bio)))
316317
return NULL;
317318

318319
/*

block/blk-zoned.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,10 @@ bool blk_req_needs_zone_write_lock(struct request *rq)
6363
if (!rq->q->disk->seq_zones_wlock)
6464
return false;
6565

66-
switch (req_op(rq)) {
67-
case REQ_OP_WRITE_ZEROES:
68-
case REQ_OP_WRITE:
66+
if (bdev_op_is_zoned_write(rq->q->disk->part0, req_op(rq)))
6967
return blk_rq_zone_is_seq(rq);
70-
default:
71-
return false;
72-
}
68+
69+
return false;
7370
}
7471
EXPORT_SYMBOL_GPL(blk_req_needs_zone_write_lock);
7572

include/linux/blkdev.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,15 @@ static inline bool bdev_is_zoned(struct block_device *bdev)
13041304
return false;
13051305
}
13061306

1307+
static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
1308+
blk_opf_t op)
1309+
{
1310+
if (!bdev_is_zoned(bdev))
1311+
return false;
1312+
1313+
return op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES;
1314+
}
1315+
13071316
static inline sector_t bdev_zone_sectors(struct block_device *bdev)
13081317
{
13091318
struct request_queue *q = bdev_get_queue(bdev);

0 commit comments

Comments
 (0)