History

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.

Hannes Reinecke committed 10 years ago

Commit bf4e6b41 parent d0a712c2 files · +7 −15Browse files

Unified · Split

2 files
  1. block/blk-core.c +7 −14
  2. include/linux/blkdev.h +0 −1
block/blk-core.c+7−14
@@ -2114,7 +2114,8 @@ blk_qc_t submit_bio(int rw, struct bio *bio) · 2113 unmodified lines
21142114 EXPORT_SYMBOL(submit_bio);
21152115
21162116 /**
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
21182119 * @q: the queue
21192120 * @rq: the request being checked
21202121 *
@@ -2125,20 +2126,13 @@ EXPORT_SYMBOL(submit_bio); · 4 unmodified lines
21252126 * after it is inserted to @q, it should be checked against @q before
21262127 * the insertion using this generic function.
21272128 *
2128− * This function should also be useful for request stacking drivers
2129− * in some cases below, so export this function.
21302129 * 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).
2132− * Such request stacking drivers should check those requests against
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.
2130+ * limits when retrying requests on other queues. Those requests need
2131+ * to be checked against the new queue limits again during dispatch.
21362132 */
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)
21382135 {
2139− if (!rq_mergeable(rq))
2140− return 0;
2141−
21422136 if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) {
21432137 printk(KERN_ERR "%s: over max size limit.\n", __func__);
21442138 return -EIO;
@@ -2158,7 +2152,6 @@ int blk_rq_check_limits(struct request_queue *q, struct request *rq) · 13 unmodified lines
21582152
21592153 return 0;
21602154 }
2161−EXPORT_SYMBOL_GPL(blk_rq_check_limits);
21622155
21632156 /**
21642157 * 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) · 5 unmodified lines
21702163 unsigned long flags;
21712164 int where = ELEVATOR_INSERT_BACK;
21722165
2173− if (blk_rq_check_limits(q, rq))
2166+ if (blk_cloned_rq_check_limits(q, rq))
21742167 return -EIO;
21752168
21762169 if (rq->rq_disk &&
include/linux/blkdev.h+0−1
@@ -773,7 +773,6 @@ extern void blk_rq_set_block_pc(struct request *); · 772 unmodified lines
773773 extern void blk_requeue_request(struct request_queue *, struct request *);
774774 extern void blk_add_request_payload(struct request *rq, struct page *page,
775775 unsigned int len);
776−extern int blk_rq_check_limits(struct request_queue *q, struct request *rq);
777776 extern int blk_lld_busy(struct request_queue *q);
778777 extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
779778 struct bio_set *bs, gfp_t gfp_mask,