summaryrefslogtreecommitdiffstats
path: root/block/blk-merge.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-04-19 02:56:24 -0400
committerJens Axboe <axboe@kernel.dk>2019-04-22 11:48:12 -0400
commitf9f76879bc4521019697970bad3bc1dd0bec211f (patch)
tree500c0d702e1f9168668cb3c90b80a9051597aa97 /block/blk-merge.c
parentf6b50160a06d4a0d6a3999ab0c5aec4f52dba248 (diff)
block: avoid scatterlist offsets > PAGE_SIZE
While we generally allow scatterlists to have offsets larger than page size for an entry, and other subsystems like the crypto code make use of that, the block layer isn't quite ready for that. Flip the switch back to avoid them for now, and revisit that decision early in a merge window once the known offenders are fixed. Fixes: 8a96a0e40810 ("block: rewrite blk_bvec_map_sg to avoid a nth_page call") Reviewed-by: Ming Lei <ming.lei@redhat.com> Tested-by: Guenter Roeck <linux@roeck-us.net> Reported-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-merge.c')
-rw-r--r--block/blk-merge.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 247b17f2a0f6..21e87a714a73 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -474,9 +474,21 @@ static unsigned blk_bvec_map_sg(struct request_queue *q,
474 while (nbytes > 0) { 474 while (nbytes > 0) {
475 unsigned offset = bvec->bv_offset + total; 475 unsigned offset = bvec->bv_offset + total;
476 unsigned len = min(get_max_segment_size(q, offset), nbytes); 476 unsigned len = min(get_max_segment_size(q, offset), nbytes);
477 struct page *page = bvec->bv_page;
478
479 /*
480 * Unfortunately a fair number of drivers barf on scatterlists
481 * that have an offset larger than PAGE_SIZE, despite other
482 * subsystems dealing with that invariant just fine. For now
483 * stick to the legacy format where we never present those from
484 * the block layer, but the code below should be removed once
485 * these offenders (mostly MMC/SD drivers) are fixed.
486 */
487 page += (offset >> PAGE_SHIFT);
488 offset &= ~PAGE_MASK;
477 489
478 *sg = blk_next_sg(sg, sglist); 490 *sg = blk_next_sg(sg, sglist);
479 sg_set_page(*sg, bvec->bv_page, len, offset); 491 sg_set_page(*sg, page, len, offset);
480 492
481 total += len; 493 total += len;
482 nbytes -= len; 494 nbytes -= len;