]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
block: Do not special-case plugging of zone write operations
authorDamien Le Moal <dlemoal@kernel.org>
Mon, 8 Apr 2024 01:41:28 +0000 (10:41 +0900)
committerJens Axboe <axboe@kernel.dk>
Wed, 17 Apr 2024 14:44:03 +0000 (08:44 -0600)
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>
block/blk-core.c
block/blk-merge.c
block/blk-mq.c
block/blk-mq.h
include/linux/blkdev.h

index e1a5344c2257cb9210eacb63e370e9dbcdc9a19b..47400a4fe851301cf0b816aac6a1ff18e59bc68b 100644 (file)
@@ -907,12 +907,6 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
            !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
                return 0;
 
-       /*
-        * As the requests that require a zone lock are not plugged in the
-        * first place, directly accessing the plug instead of using
-        * blk_mq_plug() should not have any consequences during flushing for
-        * zoned devices.
-        */
        blk_flush_plug(current->plug, false);
 
        /*
index 7f8a808b74c1672b15c5cc065f5c6c02c093c937..f64115d72f3d4359713ebbb9d85170cdadab4890 100644 (file)
@@ -1113,10 +1113,9 @@ static enum bio_merge_status blk_attempt_bio_merge(struct request_queue *q,
 bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio,
                unsigned int nr_segs)
 {
-       struct blk_plug *plug;
+       struct blk_plug *plug = current->plug;
        struct request *rq;
 
-       plug = blk_mq_plug(bio);
        if (!plug || rq_list_empty(plug->mq_list))
                return false;
 
index 9f2d9970eeba0b2fbc4d660d9a893073c8390908..434d45219e2347c67379fa3aefa5c2f0058f6207 100644 (file)
@@ -1330,11 +1330,6 @@ void blk_execute_rq_nowait(struct request *rq, bool at_head)
 
        blk_account_io_start(rq);
 
-       /*
-        * As plugging can be enabled for passthrough requests on a zoned
-        * device, directly accessing the plug instead of using blk_mq_plug()
-        * should not have any consequences.
-        */
        if (current->plug && !at_head) {
                blk_add_rq_to_plug(current->plug, rq);
                return;
@@ -2932,7 +2927,7 @@ static void blk_mq_use_cached_rq(struct request *rq, struct blk_plug *plug,
 void blk_mq_submit_bio(struct bio *bio)
 {
        struct request_queue *q = bdev_get_queue(bio->bi_bdev);
-       struct blk_plug *plug = blk_mq_plug(bio);
+       struct blk_plug *plug = current->plug;
        const int is_sync = op_is_sync(bio->bi_opf);
        struct blk_mq_hw_ctx *hctx;
        unsigned int nr_segs = 1;
index f75a9ecfebde1bfd14a3a525d6198a118baf7d95..260beea8e332ce5037fd0171a384e5d8a44f01eb 100644 (file)
@@ -365,37 +365,6 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
                qmap->mq_map[cpu] = 0;
 }
 
-/*
- * blk_mq_plug() - Get caller context plug
- * @bio : the bio being submitted by the caller context
- *
- * Plugging, by design, may delay the insertion of BIOs into the elevator in
- * order to increase BIO merging opportunities. This however can cause BIO
- * insertion order to change from the order in which submit_bio() is being
- * executed in the case of multiple contexts concurrently issuing BIOs to a
- * device, even if these context are synchronized to tightly control BIO issuing
- * order. While this is not a problem with regular block devices, this ordering
- * change can cause write BIO failures with zoned block devices as these
- * require sequential write patterns to zones. Prevent this from happening by
- * ignoring the plug state of a BIO issuing context if it is for a zoned block
- * device and the BIO to plug is a write operation.
- *
- * Return current->plug if the bio can be plugged and NULL otherwise
- */
-static inline struct blk_plug *blk_mq_plug( struct bio *bio)
-{
-       /* Zoned block device write operation case: do not plug the BIO */
-       if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
-           bdev_op_is_zoned_write(bio->bi_bdev, bio_op(bio)))
-               return NULL;
-
-       /*
-        * For regular block devices or read operations, use the context plug
-        * which may be NULL if blk_start_plug() was not executed.
-        */
-       return current->plug;
-}
-
 /* Free all requests on the list */
 static inline void blk_mq_free_requests(struct list_head *list)
 {
index 7e8a6880532423690b4731d424c60e16a4da5a0c..1ce8ba08e318de1a8dc856ef138e0efb2c7184a2 100644 (file)
@@ -1299,18 +1299,6 @@ static inline unsigned int bdev_zone_no(struct block_device *bdev, sector_t sec)
        return disk_zone_no(bdev->bd_disk, sec);
 }
 
-/* Whether write serialization is required for @op on zoned devices. */
-static inline bool op_needs_zoned_write_locking(enum req_op op)
-{
-       return op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES;
-}
-
-static inline bool bdev_op_is_zoned_write(struct block_device *bdev,
-                                         enum req_op op)
-{
-       return bdev_is_zoned(bdev) && op_needs_zoned_write_locking(op);
-}
-
 static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 {
        struct request_queue *q = bdev_get_queue(bdev);