[PATCH v2 2/2] block: return BLK_STS_NOTSUPP if operation is not supported

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Signed-off-by: Ritika Srivastava <ritika.srivastava@xxxxxxxxxx>
---
 block/blk-core.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index d241ab8..a6ebfeb 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 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 storage does not support the operation,
+		 * the following SCSI error will be returned.
+		 * Illegal Request
+		 * Invalid command operation code
+		 *
+		 * In turn device will set the corresponding queue limit to 0.
+		 *
+		 * If limit is 0, do not return IO error,
+		 * instead return operation not supported.
+		 */
+		if (queue_max_sector == 0)
+			return BLK_STS_NOTSUPP;
 		return BLK_STS_IOERR;
 	}
 
@@ -1253,8 +1267,10 @@ 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 cloned_limit_check = blk_cloned_rq_check_limits(q, rq);
+
+	if (cloned_limit_check != BLK_STS_OK)
+		return cloned_limit_check;
 
 	if (rq->rq_disk &&
 	    should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
-- 
1.8.3.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux