From: Mike Snitzer <[email-masked]>

Propagate REQ_DISCARD in cmd_flags when cloning a discard request.
Skip blk_rq_check_limits's existing checks for discard requests because
discard limits will have already been checked in blkdev_issue_discard.

Signed-off-by: Mike Snitzer <[email-masked]>
Cc: Jens Axboe <[email-masked]>
Cc: Christoph Hellwig <[email-masked]>
Cc: Kiyoshi Ueda <[email-masked]>
Reviewed-by: Christoph Hellwig <[email-masked]>

---
block/blk-core.c |    5 +++++
 block/blk-core.c |    5 +++++
 1 file changed, 5 insertions(+)

--
dm-devel mailing list
[email-masked]
https://www.redhat.com/mailman/listinfo/dm-devel

Index: linux/block/blk-core.c
===================================================================
--- linux.orig/block/blk-core.c
+++ linux/block/blk-core.c
@@ -1628,6 +1628,9 @@ EXPORT_SYMBOL(submit_bio);
  */
 int blk_rq_check_limits(struct request_queue *q, struct request *rq)
 {
+	if (rq->cmd_flags & REQ_DISCARD)
+		return 0;
+
 	if (blk_rq_sectors(rq) > queue_max_sectors(q) ||
 	    blk_rq_bytes(rq) > queue_max_hw_sectors(q) << 9) {
 		printk(KERN_ERR "%s: over max size limit.\n", __func__);
@@ -2450,6 +2453,8 @@ static void __blk_rq_prep_clone(struct r
 {
 	dst->cpu = src->cpu;
 	dst->cmd_flags = (rq_data_dir(src) | REQ_NOMERGE);
+	if (src->cmd_flags & REQ_DISCARD)
+		dst->cmd_flags |= REQ_DISCARD;
 	dst->cmd_type = src->cmd_type;
 	dst->__sector = blk_rq_pos(src);
 	dst->__data_len = blk_rq_bytes(src);