linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] plugging cleanup v2
       [not found] <CGME20220929062427eucas1p1df45ba277e296b9dd67ebdef8ff088d4@eucas1p1.samsung.com>
@ 2022-09-29  6:24 ` Pankaj Raghav
       [not found]   ` <CGME20220929062427eucas1p25a6efd73d6cdf8d481adb42f9d4006c3@eucas1p2.samsung.com>
       [not found]   ` <CGME20220929062429eucas1p24790a979fa780e8bff61d9fd5ec05f8e@eucas1p2.samsung.com>
  0 siblings, 2 replies; 7+ messages in thread
From: Pankaj Raghav @ 2022-09-29  6:24 UTC (permalink / raw)
  To: axboe, hch; +Cc: damien.lemoal, linux-block, gost.dev, Pankaj Raghav

Hi Jens,

1st patch modifies blk_mq_plug() function to disable plugging for
 write and write zeroes in zoned block devices.

2nd patch uses the blk_mq_plug function in the block layer consistently.

The patches are based on next-20220923.

Changes since v1:
- Explicltly check only for write and write zeroes as they require zone
  locking in blk_mq_plug
- create a new helper to check for ops that require zone locking for
  zoned devices and also reuse it in blk_req_needs_zone_write_lock

Pankaj Raghav (2):
  block: adapt blk_mq_plug() to not plug for writes that require a zone
    lock
  block: use blk_mq_plug() wrapper consistently in the block layer

 block/blk-core.c       | 2 +-
 block/blk-mq.c         | 6 ++++--
 block/blk-mq.h         | 3 ++-
 block/blk-zoned.c      | 9 +++------
 include/linux/blkdev.h | 9 +++++++++
 5 files changed, 19 insertions(+), 10 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] block: adapt blk_mq_plug() to not plug for writes that require a zone lock
       [not found]   ` <CGME20220929062427eucas1p25a6efd73d6cdf8d481adb42f9d4006c3@eucas1p2.samsung.com>
@ 2022-09-29  6:24     ` Pankaj Raghav
  2022-09-29  6:55       ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Pankaj Raghav @ 2022-09-29  6:24 UTC (permalink / raw)
  To: axboe, hch
  Cc: damien.lemoal, linux-block, gost.dev, Pankaj Raghav,
	Christoph Hellwig

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>
---
 block/blk-mq.h         | 3 ++-
 block/blk-zoned.c      | 9 +++------
 include/linux/blkdev.h | 9 +++++++++
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/block/blk-mq.h b/block/blk-mq.h
index 8ca453ac243d..0b2870839cdd 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) &&
+	    bdev_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..db829401d8d0 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 (bdev_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..74bc30c680d6 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 bdev_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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] block: use blk_mq_plug() wrapper consistently in the block layer
       [not found]   ` <CGME20220929062429eucas1p24790a979fa780e8bff61d9fd5ec05f8e@eucas1p2.samsung.com>
@ 2022-09-29  6:24     ` Pankaj Raghav
  2022-09-29  6:56       ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Pankaj Raghav @ 2022-09-29  6:24 UTC (permalink / raw)
  To: axboe, hch; +Cc: damien.lemoal, linux-block, gost.dev, Pankaj Raghav

Use blk_mq_plug() wrapper to get the plug instead of directly accessing
it in the block layer.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
---
 block/blk-core.c | 2 +-
 block/blk-mq.c   | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 203be672da52..d0e97de216db 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -850,7 +850,7 @@ int bio_poll(struct bio *bio, struct io_comp_batch *iob, unsigned int flags)
 	    !test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
 		return 0;
 
-	blk_flush_plug(current->plug, false);
+	blk_flush_plug(blk_mq_plug(bio), false);
 
 	if (bio_queue_enter(bio))
 		return 0;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index c11949d66163..5bf245c4bf0a 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1209,12 +1209,14 @@ static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq)
  */
 void blk_execute_rq_nowait(struct request *rq, bool at_head)
 {
+	struct blk_plug *plug = blk_mq_plug(rq->bio);
+
 	WARN_ON(irqs_disabled());
 	WARN_ON(!blk_rq_is_passthrough(rq));
 
 	blk_account_io_start(rq);
-	if (current->plug)
-		blk_add_rq_to_plug(current->plug, rq);
+	if (plug)
+		blk_add_rq_to_plug(plug, rq);
 	else
 		blk_mq_sched_insert_request(rq, at_head, true, false);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] block: adapt blk_mq_plug() to not plug for writes that require a zone lock
  2022-09-29  6:24     ` [PATCH v2 1/2] block: adapt blk_mq_plug() to not plug for writes that require a zone lock Pankaj Raghav
@ 2022-09-29  6:55       ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2022-09-29  6:55 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: axboe, hch, damien.lemoal, linux-block, gost.dev,
	Christoph Hellwig

On Thu, Sep 29, 2022 at 08:24:24AM +0200, Pankaj Raghav wrote:
> 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>

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] block: use blk_mq_plug() wrapper consistently in the block layer
  2022-09-29  6:24     ` [PATCH v2 2/2] block: use blk_mq_plug() wrapper consistently in the block layer Pankaj Raghav
@ 2022-09-29  6:56       ` Christoph Hellwig
  2022-09-29  7:15         ` Pankaj Raghav
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2022-09-29  6:56 UTC (permalink / raw)
  To: Pankaj Raghav; +Cc: axboe, hch, damien.lemoal, linux-block, gost.dev

On Thu, Sep 29, 2022 at 08:24:25AM +0200, Pankaj Raghav wrote:
> Use blk_mq_plug() wrapper to get the plug instead of directly accessing
> it in the block layer.

I think this should explain why that is useful (or maybe even a bug
fix?).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] block: use blk_mq_plug() wrapper consistently in the block layer
  2022-09-29  6:56       ` Christoph Hellwig
@ 2022-09-29  7:15         ` Pankaj Raghav
  2022-09-29  7:19           ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Pankaj Raghav @ 2022-09-29  7:15 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: axboe, damien.lemoal, linux-block, gost.dev

On 2022-09-29 08:56, Christoph Hellwig wrote:
> On Thu, Sep 29, 2022 at 08:24:25AM +0200, Pankaj Raghav wrote:
>> Use blk_mq_plug() wrapper to get the plug instead of directly accessing
>> it in the block layer.
> 
> I think this should explain why that is useful (or maybe even a bug
> fix?).

I mentioned it in the commit header: to use this wrapper consistently
across block layer because I am not sure if either of the changes would
have led to a bug in zoned devices.

1) blk_execute_rq_nowait:
No issues here because only passthrough request can use this function.

2) calling blk_flush_plug in bio_poll:
As we don't plug the request that do a write or write zeroes to zoned
devices in the first place, flushing should not have any impact.

This is just a cleanup patch to use this helper consistently. Maybe I
should mention it explicitly again in the commit log to make it clear?

--
Pankaj

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/2] block: use blk_mq_plug() wrapper consistently in the block layer
  2022-09-29  7:15         ` Pankaj Raghav
@ 2022-09-29  7:19           ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2022-09-29  7:19 UTC (permalink / raw)
  To: Pankaj Raghav
  Cc: Christoph Hellwig, axboe, damien.lemoal, linux-block, gost.dev

On Thu, Sep 29, 2022 at 09:15:12AM +0200, Pankaj Raghav wrote:
> I mentioned it in the commit header: to use this wrapper consistently
> across block layer because I am not sure if either of the changes would
> have led to a bug in zoned devices.

The only thing that goes into source control is the commit message,
so the rationale needs to go into that.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-29  7:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20220929062427eucas1p1df45ba277e296b9dd67ebdef8ff088d4@eucas1p1.samsung.com>
2022-09-29  6:24 ` [PATCH v2 0/2] plugging cleanup v2 Pankaj Raghav
     [not found]   ` <CGME20220929062427eucas1p25a6efd73d6cdf8d481adb42f9d4006c3@eucas1p2.samsung.com>
2022-09-29  6:24     ` [PATCH v2 1/2] block: adapt blk_mq_plug() to not plug for writes that require a zone lock Pankaj Raghav
2022-09-29  6:55       ` Christoph Hellwig
     [not found]   ` <CGME20220929062429eucas1p24790a979fa780e8bff61d9fd5ec05f8e@eucas1p2.samsung.com>
2022-09-29  6:24     ` [PATCH v2 2/2] block: use blk_mq_plug() wrapper consistently in the block layer Pankaj Raghav
2022-09-29  6:56       ` Christoph Hellwig
2022-09-29  7:15         ` Pankaj Raghav
2022-09-29  7:19           ` Christoph Hellwig

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).