Commit 3c5a9457 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Kamal Mostafa

block: Always check queue limits for cloned requests

commit bf4e6b4e upstream.

When a cloned request is retried on other queues it always needs
to be checked against the queue limits of that queue.
Otherwise the calculations for nr_phys_segments might be wrong,
leading to a crash in scsi_init_sgtable().

To clarify this the patch renames blk_rq_check_limits()
to blk_cloned_rq_check_limits() and removes the symbol
export, as the new function should only be used for
cloned requests and never exported.

Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Ewan Milne <emilne@redhat.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Fixes: e2a60da7 ("block: Clean up special command handling logic")
Acked-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 057b2f7d
...@@ -1888,7 +1888,8 @@ void submit_bio(int rw, struct bio *bio) ...@@ -1888,7 +1888,8 @@ void submit_bio(int rw, struct bio *bio)
EXPORT_SYMBOL(submit_bio); EXPORT_SYMBOL(submit_bio);
/** /**
* blk_rq_check_limits - Helper function to check a request for the queue limit * blk_cloned_rq_check_limits - Helper function to check a cloned request
* for new the queue limits
* @q: the queue * @q: the queue
* @rq: the request being checked * @rq: the request being checked
* *
...@@ -1899,20 +1900,13 @@ EXPORT_SYMBOL(submit_bio); ...@@ -1899,20 +1900,13 @@ EXPORT_SYMBOL(submit_bio);
* after it is inserted to @q, it should be checked against @q before * after it is inserted to @q, it should be checked against @q before
* the insertion using this generic function. * the insertion using this generic function.
* *
* This function should also be useful for request stacking drivers
* in some cases below, so export this function.
* Request stacking drivers like request-based dm may change the queue * Request stacking drivers like request-based dm may change the queue
* limits while requests are in the queue (e.g. dm's table swapping). * limits when retrying requests on other queues. Those requests need
* Such request stacking drivers should check those requests agaist * to be checked against the new queue limits again during dispatch.
* the new queue limits again when they dispatch those requests,
* although such checkings are also done against the old queue limits
* when submitting requests.
*/ */
int blk_rq_check_limits(struct request_queue *q, struct request *rq) static int blk_cloned_rq_check_limits(struct request_queue *q,
struct request *rq)
{ {
if (!rq_mergeable(rq))
return 0;
if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) { if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) {
printk(KERN_ERR "%s: over max size limit.\n", __func__); printk(KERN_ERR "%s: over max size limit.\n", __func__);
return -EIO; return -EIO;
...@@ -1932,7 +1926,6 @@ int blk_rq_check_limits(struct request_queue *q, struct request *rq) ...@@ -1932,7 +1926,6 @@ int blk_rq_check_limits(struct request_queue *q, struct request *rq)
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(blk_rq_check_limits);
/** /**
* blk_insert_cloned_request - Helper for stacking drivers to submit a request * blk_insert_cloned_request - Helper for stacking drivers to submit a request
...@@ -1944,7 +1937,7 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq) ...@@ -1944,7 +1937,7 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)
unsigned long flags; unsigned long flags;
int where = ELEVATOR_INSERT_BACK; int where = ELEVATOR_INSERT_BACK;
if (blk_rq_check_limits(q, rq)) if (blk_cloned_rq_check_limits(q, rq))
return -EIO; return -EIO;
if (rq->rq_disk && if (rq->rq_disk &&
......
...@@ -776,7 +776,6 @@ extern struct request *blk_make_request(struct request_queue *, struct bio *, ...@@ -776,7 +776,6 @@ extern struct request *blk_make_request(struct request_queue *, struct bio *,
extern void blk_requeue_request(struct request_queue *, struct request *); extern void blk_requeue_request(struct request_queue *, struct request *);
extern void blk_add_request_payload(struct request *rq, struct page *page, extern void blk_add_request_payload(struct request *rq, struct page *page,
unsigned int len); unsigned int len);
extern int blk_rq_check_limits(struct request_queue *q, struct request *rq);
extern int blk_lld_busy(struct request_queue *q); extern int blk_lld_busy(struct request_queue *q);
extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src, extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
struct bio_set *bs, gfp_t gfp_mask, struct bio_set *bs, gfp_t gfp_mask,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment