diff options
author | Hannes Reinecke <hare@suse.de> | 2015-11-26 02:46:57 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-11-29 16:37:27 -0500 |
commit | bf4e6b4e757488dee1b6a581f49c7ac34cd217f8 (patch) | |
tree | 95e32c168d7478d0f541b5d19d1edf0e3d1160f1 /block | |
parent | d0a712ceb83ebaea32d520825ee7b997f59b168f (diff) |
block: Always check queue limits for cloned requests
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: Hannes Reinecke <hare@suse.de>
Fixes: e2a60da74 ("block: Clean up special command handling logic")
Cc: stable@vger.kernel.org # 3.7+
Acked-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 5131993b23a1..a0af4043dda2 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -2114,7 +2114,8 @@ blk_qc_t submit_bio(int rw, struct bio *bio) | |||
2114 | EXPORT_SYMBOL(submit_bio); | 2114 | EXPORT_SYMBOL(submit_bio); |
2115 | 2115 | ||
2116 | /** | 2116 | /** |
2117 | * blk_rq_check_limits - Helper function to check a request for the queue limit | 2117 | * blk_cloned_rq_check_limits - Helper function to check a cloned request |
2118 | * for new the queue limits | ||
2118 | * @q: the queue | 2119 | * @q: the queue |
2119 | * @rq: the request being checked | 2120 | * @rq: the request being checked |
2120 | * | 2121 | * |
@@ -2125,20 +2126,13 @@ EXPORT_SYMBOL(submit_bio); | |||
2125 | * after it is inserted to @q, it should be checked against @q before | 2126 | * after it is inserted to @q, it should be checked against @q before |
2126 | * the insertion using this generic function. | 2127 | * the insertion using this generic function. |
2127 | * | 2128 | * |
2128 | * This function should also be useful for request stacking drivers | ||
2129 | * in some cases below, so export this function. | ||
2130 | * Request stacking drivers like request-based dm may change the queue | 2129 | * Request stacking drivers like request-based dm may change the queue |
2131 | * limits while requests are in the queue (e.g. dm's table swapping). | 2130 | * limits when retrying requests on other queues. Those requests need |
2132 | * Such request stacking drivers should check those requests against | 2131 | * to be checked against the new queue limits again during dispatch. |
2133 | * the new queue limits again when they dispatch those requests, | ||
2134 | * although such checkings are also done against the old queue limits | ||
2135 | * when submitting requests. | ||
2136 | */ | 2132 | */ |
2137 | int blk_rq_check_limits(struct request_queue *q, struct request *rq) | 2133 | static int blk_cloned_rq_check_limits(struct request_queue *q, |
2134 | struct request *rq) | ||
2138 | { | 2135 | { |
2139 | if (!rq_mergeable(rq)) | ||
2140 | return 0; | ||
2141 | |||
2142 | if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) { | 2136 | if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) { |
2143 | printk(KERN_ERR "%s: over max size limit.\n", __func__); | 2137 | printk(KERN_ERR "%s: over max size limit.\n", __func__); |
2144 | return -EIO; | 2138 | return -EIO; |
@@ -2158,7 +2152,6 @@ int blk_rq_check_limits(struct request_queue *q, struct request *rq) | |||
2158 | 2152 | ||
2159 | return 0; | 2153 | return 0; |
2160 | } | 2154 | } |
2161 | EXPORT_SYMBOL_GPL(blk_rq_check_limits); | ||
2162 | 2155 | ||
2163 | /** | 2156 | /** |
2164 | * blk_insert_cloned_request - Helper for stacking drivers to submit a request | 2157 | * blk_insert_cloned_request - Helper for stacking drivers to submit a request |
@@ -2170,7 +2163,7 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq) | |||
2170 | unsigned long flags; | 2163 | unsigned long flags; |
2171 | int where = ELEVATOR_INSERT_BACK; | 2164 | int where = ELEVATOR_INSERT_BACK; |
2172 | 2165 | ||
2173 | if (blk_rq_check_limits(q, rq)) | 2166 | if (blk_cloned_rq_check_limits(q, rq)) |
2174 | return -EIO; | 2167 | return -EIO; |
2175 | 2168 | ||
2176 | if (rq->rq_disk && | 2169 | if (rq->rq_disk && |