blk_recalc_rq_segments assumes that any segments can be merged in the case of BIOVEC_VIRT_MERGEABLE && !BIOVEC_VIRT_OVERSIZE. However, an IOMMU can't merge segments if the total length of the segments is larger than max_segment_size (the LLD restriction). Due to this bug, a LLD may get the larger number of segments than nr_hw_segments because the block layer puts more segments in a request than it should do. This bug could happen on alpha, parisc, and sparc, which use VMERGE. Like blk_hw_contig_segment() does, this patch uses hw_seg_size for simplicity, which is a bit larger than an exact value (we don't need BIOVEC_VIRT_START_SIZE here). Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> Cc: Jens Axboe <jens.axboe@xxxxxxxxxx> Cc: Mikulas Patocka <mpatocka@xxxxxxxxxx> Cc: David Miller <davem@xxxxxxxxxxxxx> --- block/blk-merge.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index 5efc9e7..39a22f8 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -83,7 +83,8 @@ void blk_recalc_rq_segments(struct request *rq) continue; } new_segment: - if (BIOVEC_VIRT_MERGEABLE(bvprv, bv) && + if (hw_seg_size + bv->bv_len <= q->max_segment_size && + BIOVEC_VIRT_MERGEABLE(bvprv, bv) && !BIOVEC_VIRT_OVERSIZE(hw_seg_size + bv->bv_len)) hw_seg_size += bv->bv_len; else { -- 1.5.5.GIT -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html