linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pankaj Raghav <p.raghav@samsung.com>
To: Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@infradead.org>,
	<damien.lemoal@opensource.wdc.com>
Cc: <linux-block@vger.kernel.org>, <gost.dev@samsung.com>
Subject: Re: [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for zoned block devices
Date: Wed, 28 Sep 2022 13:57:13 +0200	[thread overview]
Message-ID: <43776c04-8a84-a0e7-b77f-a0aa30fdc47f@samsung.com> (raw)
In-Reply-To: <3c6002c7-cd69-e020-24b8-650aaf9ad893@kernel.dk>

On 2022-09-27 18:52, Jens Axboe wrote:
>> Well, the only opcodes we do zone locking for is REQ_OP_WRITE and
>> REQ_OP_WRITE_ZEROES.  So this should be:
>>
>> 	if (zoned && (op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES))
>> 		return NULL;
> 
> I'd rather just make it explicit and use that. Pankaj, do you want
> to spin a v2 with that?
> 

Based on all the suggestions:

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 <hch@infradead.org>
Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>

diff --git a/block/blk-mq.h b/block/blk-mq.h
index 8ca453ac243d..297289cdd521 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -312,7 +312,8 @@ static inline void blk_mq_clear_mq_map(struct blk_mq_queue_map *qmap)
 static inline struct blk_plug *blk_mq_plug( struct bio *bio)
 {
 	/* Zoned block device write operation case: do not plug the BIO */
-	if (bdev_is_zoned(bio->bi_bdev) && op_is_write(bio_op(bio)))
+	if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
+	    blk_op_is_zoned_write(bio->bi_bdev, bio_op(bio)))
 		return NULL;

 	/*
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index a264621d4905..fa926424edb6 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -63,13 +63,10 @@ bool blk_req_needs_zone_write_lock(struct request *rq)
 	if (!rq->q->disk->seq_zones_wlock)
 		return false;

-	switch (req_op(rq)) {
-	case REQ_OP_WRITE_ZEROES:
-	case REQ_OP_WRITE:
+	if (blk_op_is_zoned_write(rq->q->disk->part0, req_op(rq)))
 		return blk_rq_zone_is_seq(rq);
-	default:
-		return false;
-	}
+
+	return false;
 }
 EXPORT_SYMBOL_GPL(blk_req_needs_zone_write_lock);

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 8038c5fbde40..719025028fa4 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1300,6 +1300,15 @@ static inline bool bdev_is_zoned(struct block_device *bdev)
 	return false;
 }

+static inline bool blk_op_is_zoned_write(struct block_device *bdev,
+					 blk_opf_t op)
+{
+	if (!bdev_is_zoned(bdev))
+		return false;
+
+	return op == REQ_OP_WRITE || op == REQ_OP_WRITE_ZEROES;
+}
+
 static inline sector_t bdev_zone_sectors(struct block_device *bdev)
 {
 	struct request_queue *q = bdev_get_queue(bdev);


Does this look fine?

  parent reply	other threads:[~2022-09-28 11:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220925185349eucas1p1dc689bac64668ca038ba8646c44fd580@eucas1p1.samsung.com>
2022-09-25 18:53 ` [PATCH 0/2] enable plugging only for reads in zoned block devices Pankaj Raghav
     [not found]   ` <CGME20220925185350eucas1p1fc354429027a88de7e548a3a4529b4ef@eucas1p1.samsung.com>
2022-09-25 18:53     ` [PATCH 1/2] block: modify blk_mq_plug() to allow only reads for " Pankaj Raghav
2022-09-25 22:55       ` Damien Le Moal
2022-09-26 14:37       ` Christoph Hellwig
2022-09-26 14:40         ` Jens Axboe
2022-09-26 14:43           ` Christoph Hellwig
2022-09-26 16:32             ` Jens Axboe
2022-09-26 19:20               ` Pankaj Raghav
2022-09-26 19:25                 ` Jens Axboe
2022-09-27 15:20                   ` Pankaj Raghav
2022-09-27 16:04                     ` Jens Axboe
2022-09-27 16:51                       ` Christoph Hellwig
2022-09-27 16:52                         ` Jens Axboe
2022-09-27 23:07                           ` Damien Le Moal
2022-09-27 23:10                             ` Damien Le Moal
2022-09-27 23:13                               ` Jens Axboe
2022-09-27 23:12                             ` Jens Axboe
2022-09-27 23:35                               ` Damien Le Moal
2022-09-28 11:57                           ` Pankaj Raghav [this message]
2022-09-28 22:19                             ` Damien Le Moal
     [not found]   ` <CGME20220925185351eucas1p1e0c37396c09611509c0b18bdcdeddfe1@eucas1p1.samsung.com>
2022-09-25 18:53     ` [PATCH 2/2] block: use blk_mq_plug() in blk_execute_rq_nowait() Pankaj Raghav
2022-09-25 22:56       ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43776c04-8a84-a0e7-b77f-a0aa30fdc47f@samsung.com \
    --to=p.raghav@samsung.com \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@opensource.wdc.com \
    --cc=gost.dev@samsung.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).