blk-mq: enforce op-specific segment limits in blk_insert_cloned_request
authorUday Shankar <ushankar@purestorage.com>
Wed, 1 Mar 2023 00:06:55 +0000 (17:06 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Mar 2023 04:00:20 +0000 (21:00 -0700)
commit49d24398327e32265eccdeec4baeb5a6a609c0bd
treeeac5516659021cb104b90d7b398f18843ff84d8a
parent326ac2c5133e5da7ccdd08d4f9c562f2323021aa
blk-mq: enforce op-specific segment limits in blk_insert_cloned_request

The block layer might merge together discard requests up until the
max_discard_segments limit is hit, but blk_insert_cloned_request checks
the segment count against max_segments regardless of the req op. This
can result in errors like the following when discards are issued through
a DM device and max_discard_segments exceeds max_segments for the queue
of the chosen underlying device.

blk_insert_cloned_request: over max segments limit. (256 > 129)

Fix this by looking at the req_op and enforcing the appropriate segment
limit - max_discard_segments for REQ_OP_DISCARDs and max_segments for
everything else.

Signed-off-by: Uday Shankar <ushankar@purestorage.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20230301000655.48112-1-ushankar@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-merge.c
block/blk-mq.c
block/blk.h