linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits()
@ 2020-09-01 20:17 Ritika Srivastava
  2020-09-01 20:17 ` [PATCH 1/2] block: Return blk_status_t instead of errno codes Ritika Srivastava
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ritika Srivastava @ 2020-09-01 20:17 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ritika.srivastava

Hi Jens,

I applied the following patches on 5.10 branch and there are only line number changes.

[PATCH 1/2] block: Return blk_status_t instead of errno codes
[PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits

I am resending the patches applied on top of 5.10 branch.

$ git log --oneline --decorate -n 5
5749f24 (HEAD, for-5.10/block) block: better deal with the delayed not supported case in blk_cloned_rq_check_limits
bb79f6e block: Return blk_status_t instead of errno codes
9493111 (origin/for-5.10/block) block: remove the unused q argument to part_in_flight and part_in_flight_rw
8eeee76 block: remove the disk argument to delete_partition
7f201bc block: cleanup __alloc_disk_node

Thanks,
Ritika

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

* [PATCH 1/2] block: Return blk_status_t instead of errno codes
  2020-09-01 20:17 Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits() Ritika Srivastava
@ 2020-09-01 20:17 ` Ritika Srivastava
  2020-09-01 20:17 ` [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits Ritika Srivastava
  2020-09-01 22:56 ` Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits() Jens Axboe
  2 siblings, 0 replies; 7+ messages in thread
From: Ritika Srivastava @ 2020-09-01 20:17 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ritika.srivastava

Replace returning legacy errno codes with blk_status_t in
blk_cloned_rq_check_limits().

Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 1028c34..4c1af34 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1144,14 +1144,14 @@ blk_qc_t submit_bio(struct bio *bio)
  *    limits when retrying requests on other queues. Those requests need
  *    to be checked against the new queue limits again during dispatch.
  */
-static int blk_cloned_rq_check_limits(struct request_queue *q,
+static blk_status_t blk_cloned_rq_check_limits(struct request_queue *q,
 				      struct request *rq)
 {
 	if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, req_op(rq))) {
 		printk(KERN_ERR "%s: over max size limit. (%u > %u)\n",
 			__func__, blk_rq_sectors(rq),
 			blk_queue_get_max_sectors(q, req_op(rq)));
-		return -EIO;
+		return BLK_STS_IOERR;
 	}
 
 	/*
@@ -1164,10 +1164,10 @@ static int blk_cloned_rq_check_limits(struct request_queue *q,
 	if (rq->nr_phys_segments > queue_max_segments(q)) {
 		printk(KERN_ERR "%s: over max segments limit. (%hu > %hu)\n",
 			__func__, rq->nr_phys_segments, queue_max_segments(q));
-		return -EIO;
+		return BLK_STS_IOERR;
 	}
 
-	return 0;
+	return BLK_STS_OK;
 }
 
 /**
-- 
1.8.3.1


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

* [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits
  2020-09-01 20:17 Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits() Ritika Srivastava
  2020-09-01 20:17 ` [PATCH 1/2] block: Return blk_status_t instead of errno codes Ritika Srivastava
@ 2020-09-01 20:17 ` Ritika Srivastava
  2020-09-01 22:56 ` Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits() Jens Axboe
  2 siblings, 0 replies; 7+ messages in thread
From: Ritika Srivastava @ 2020-09-01 20:17 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, ritika.srivastava

If WRITE_ZERO/WRITE_SAME operation is not supported by the storage,
blk_cloned_rq_check_limits() will return IO error which will cause
device-mapper to fail the paths.

Instead, if the queue limit is set to 0, return BLK_STS_NOTSUPP.
BLK_STS_NOTSUPP will be ignored by device-mapper and will not fail the
paths.

Suggested-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
Changelog:
v4: Explain the window of error in the comments.
    Add reviewed-by tag from Martin
v3: Formatting changes and subject updated from previous version
    -block: return BLK_STS_NOTSUPP if operation is not supported
v2: Document scenario and SCSI error encountered in a comment in
    blk_cloned_rq_check_limits().
---
 block/blk-core.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 4c1af34..d857344 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1147,10 +1147,24 @@ blk_qc_t submit_bio(struct bio *bio)
 static blk_status_t blk_cloned_rq_check_limits(struct request_queue *q,
 				      struct request *rq)
 {
-	if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, req_op(rq))) {
+	unsigned int max_sectors = blk_queue_get_max_sectors(q, req_op(rq));
+
+	if (blk_rq_sectors(rq) > max_sectors) {
+		/*
+		 * SCSI device does not have a good way to return if
+		 * Write Same/Zero is actually supported. If a device rejects
+		 * a non-read/write command (discard, write same,etc.) the
+		 * low-level device driver will set the relevant queue limit to
+		 * 0 to prevent blk-lib from issuing more of the offending
+		 * operations. Commands queued prior to the queue limit being
+		 * reset need to be completed with BLK_STS_NOTSUPP to avoid I/O
+		 * errors being propagated to upper layers.
+		 */
+		if (max_sectors == 0)
+			return BLK_STS_NOTSUPP;
+
 		printk(KERN_ERR "%s: over max size limit. (%u > %u)\n",
-			__func__, blk_rq_sectors(rq),
-			blk_queue_get_max_sectors(q, req_op(rq)));
+			__func__, blk_rq_sectors(rq), max_sectors);
 		return BLK_STS_IOERR;
 	}
 
@@ -1177,8 +1191,11 @@ static blk_status_t blk_cloned_rq_check_limits(struct request_queue *q,
  */
 blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *rq)
 {
-	if (blk_cloned_rq_check_limits(q, rq))
-		return BLK_STS_IOERR;
+	blk_status_t ret;
+
+	ret = blk_cloned_rq_check_limits(q, rq);
+	if (ret != BLK_STS_OK)
+		return ret;
 
 	if (rq->rq_disk &&
 	    should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
-- 
1.8.3.1


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

* Re: Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits()
  2020-09-01 20:17 Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits() Ritika Srivastava
  2020-09-01 20:17 ` [PATCH 1/2] block: Return blk_status_t instead of errno codes Ritika Srivastava
  2020-09-01 20:17 ` [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits Ritika Srivastava
@ 2020-09-01 22:56 ` Jens Axboe
  2 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2020-09-01 22:56 UTC (permalink / raw)
  To: Ritika Srivastava; +Cc: linux-block

On 9/1/20 2:17 PM, Ritika Srivastava wrote:
> Hi Jens,
> 
> I applied the following patches on 5.10 branch and there are only line number changes.
> 
> [PATCH 1/2] block: Return blk_status_t instead of errno codes
> [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits
> 
> I am resending the patches applied on top of 5.10 branch.
> 
> $ git log --oneline --decorate -n 5
> 5749f24 (HEAD, for-5.10/block) block: better deal with the delayed not supported case in blk_cloned_rq_check_limits
> bb79f6e block: Return blk_status_t instead of errno codes
> 9493111 (origin/for-5.10/block) block: remove the unused q argument to part_in_flight and part_in_flight_rw
> 8eeee76 block: remove the disk argument to delete_partition
> 7f201bc block: cleanup __alloc_disk_node

It failed for me again, but upon looking closer, it's actually b4 that
isn't pulling in patch #1. Hence #2 obviously fails. I've applied them
by hand, thanks.

-- 
Jens Axboe


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

* Re: [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits
  2020-08-18 19:43 ` Christoph Hellwig
@ 2020-08-26 17:03   ` Ritika Srivastava
  0 siblings, 0 replies; 7+ messages in thread
From: Ritika Srivastava @ 2020-08-26 17:03 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, Christoph Hellwig

Hi Jens,

Can the following patches please be applied.

[PATCH 1/2] block: Return blk_status_t instead of errno codes
[PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits

Thanks,
Ritika

> On Aug 18, 2020, at 12:43 PM, Christoph Hellwig <hch@infradead.org> wrote:
> 
> On Tue, Aug 18, 2020 at 10:39:40AM -0700, Ritika Srivastava wrote:
>> If WRITE_ZERO/WRITE_SAME operation is not supported by the storage,
>> blk_cloned_rq_check_limits() will return IO error which will cause
>> device-mapper to fail the paths.
>> 
>> Instead, if the queue limit is set to 0, return BLK_STS_NOTSUPP.
>> BLK_STS_NOTSUPP will be ignored by device-mapper and will not fail the
>> paths.
>> 
>> Suggested-by: Martin K. Petersen <martin.petersen@oracle.com>
>> Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com>
>> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
> 
> Looks good,
> 
> Reviewed-by: Christoph Hellwig <hch@lst.de>


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

* Re: [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits
  2020-08-18 17:39 [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits Ritika Srivastava
@ 2020-08-18 19:43 ` Christoph Hellwig
  2020-08-26 17:03   ` Ritika Srivastava
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2020-08-18 19:43 UTC (permalink / raw)
  To: Ritika Srivastava; +Cc: linux-block, axboe, martin.petersen, hch

On Tue, Aug 18, 2020 at 10:39:40AM -0700, Ritika Srivastava wrote:
> If WRITE_ZERO/WRITE_SAME operation is not supported by the storage,
> blk_cloned_rq_check_limits() will return IO error which will cause
> device-mapper to fail the paths.
> 
> Instead, if the queue limit is set to 0, return BLK_STS_NOTSUPP.
> BLK_STS_NOTSUPP will be ignored by device-mapper and will not fail the
> paths.
> 
> Suggested-by: Martin K. Petersen <martin.petersen@oracle.com>
> Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com>
> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

Looks good,

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

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

* [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits
@ 2020-08-18 17:39 Ritika Srivastava
  2020-08-18 19:43 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Ritika Srivastava @ 2020-08-18 17:39 UTC (permalink / raw)
  To: linux-block, axboe; +Cc: martin.petersen, hch, ritika.srivastava

If WRITE_ZERO/WRITE_SAME operation is not supported by the storage,
blk_cloned_rq_check_limits() will return IO error which will cause
device-mapper to fail the paths.

Instead, if the queue limit is set to 0, return BLK_STS_NOTSUPP.
BLK_STS_NOTSUPP will be ignored by device-mapper and will not fail the
paths.

Suggested-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Ritika Srivastava <ritika.srivastava@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
---
Changelog:
v4: Explain the window of error in the comments.
    Add reviewed-by tag from Martin
v3: Formatting changes and subject updated from previous version
    -block: return BLK_STS_NOTSUPP if operation is not supported
v2: Document scenario and SCSI error encountered in a comment in
    blk_cloned_rq_check_limits().
---
 block/blk-core.c | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index d241ab8..43401d3 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1223,10 +1223,24 @@ blk_qc_t submit_bio(struct bio *bio)
 static blk_status_t blk_cloned_rq_check_limits(struct request_queue *q,
 				      struct request *rq)
 {
-	if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, req_op(rq))) {
+	unsigned int max_sectors = blk_queue_get_max_sectors(q, req_op(rq));
+
+	if (blk_rq_sectors(rq) > max_sectors) {
+		/*
+		 * SCSI device does not have a good way to return if
+		 * Write Same/Zero is actually supported. If a device rejects
+		 * a non-read/write command (discard, write same,etc.) the
+		 * low-level device driver will set the relevant queue limit to
+		 * 0 to prevent blk-lib from issuing more of the offending
+		 * operations. Commands queued prior to the queue limit being
+		 * reset need to be completed with BLK_STS_NOTSUPP to avoid I/O
+		 * errors being propagated to upper layers.
+		 */
+		if (max_sectors == 0)
+			return BLK_STS_NOTSUPP;
+
 		printk(KERN_ERR "%s: over max size limit. (%u > %u)\n",
-			__func__, blk_rq_sectors(rq),
-			blk_queue_get_max_sectors(q, req_op(rq)));
+			__func__, blk_rq_sectors(rq), max_sectors);
 		return BLK_STS_IOERR;
 	}
 
@@ -1253,8 +1267,11 @@ static blk_status_t blk_cloned_rq_check_limits(struct request_queue *q,
  */
 blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *rq)
 {
-	if (blk_cloned_rq_check_limits(q, rq))
-		return BLK_STS_IOERR;
+	blk_status_t ret;
+
+	ret = blk_cloned_rq_check_limits(q, rq);
+	if (ret != BLK_STS_OK)
+		return ret;
 
 	if (rq->rq_disk &&
 	    should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
-- 
1.8.3.1


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

end of thread, other threads:[~2020-09-01 22:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 20:17 Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits() Ritika Srivastava
2020-09-01 20:17 ` [PATCH 1/2] block: Return blk_status_t instead of errno codes Ritika Srivastava
2020-09-01 20:17 ` [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits Ritika Srivastava
2020-09-01 22:56 ` Return BLK_STS_NOTSUPP and blk_status_t from blk_cloned_rq_check_limits() Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2020-08-18 17:39 [PATCH v4 2/2] block: better deal with the delayed not supported case in blk_cloned_rq_check_limits Ritika Srivastava
2020-08-18 19:43 ` Christoph Hellwig
2020-08-26 17:03   ` Ritika Srivastava

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