linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] block: return BLK_STS_NOTSUPP if operation is not supported
@ 2020-07-24 16:33 Ritika Srivastava
  2020-07-26 15:10 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Ritika Srivastava @ 2020-07-24 16:33 UTC (permalink / raw)
  To: linux-block; +Cc: axboe, ritika.srivastava

If WRITE_ZERO/WRITE_SAME operation is not supported by the storage,
blk_cloned_rq_check_limits() will return -EIO 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>
---
 block/blk-core.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 9bfaee0..173bb04 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -1223,10 +1223,13 @@ blk_qc_t submit_bio(struct bio *bio)
 static int 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 queue_max_sector = blk_queue_get_max_sectors(q, req_op(rq));
+
+	if (blk_rq_sectors(rq) > queue_max_sector) {
 		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), queue_max_sector);
+		if (queue_max_sector == 0)
+			return -EOPNOTSUPP;
 		return -EIO;
 	}
 
@@ -1253,7 +1256,11 @@ static int 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))
+	int cloned_limit_check = blk_cloned_rq_check_limits(q, rq);
+
+	if (cloned_limit_check == -EOPNOTSUPP)
+		return BLK_STS_NOTSUPP;
+	else if (cloned_limit_check)
 		return BLK_STS_IOERR;
 
 	if (rq->rq_disk &&
-- 
1.8.3.1


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

end of thread, other threads:[~2020-07-28 17:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24 16:33 [PATCH 1/1] block: return BLK_STS_NOTSUPP if operation is not supported Ritika Srivastava
2020-07-26 15:10 ` Christoph Hellwig
2020-07-27 19:11   ` Ritika Srivastava
2020-07-28  7:28     ` Christoph Hellwig
2020-07-28 17:18       ` 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).