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@xxxxxxxxxx> Signed-off-by: Ritika Srivastava <ritika.srivastava@xxxxxxxxxx> --- 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