From: Keith Busch <kbusch@xxxxxxxxxx> If the iterator has an offset, filling a bio to the max bvecs may result in a size that isn't aligned to the block size. Mask off bytes for the bio being constructed. Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx> --- block/bio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/bio.c b/block/bio.c index 4259125e16ab..b42a9e3ff068 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1144,6 +1144,7 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) { unsigned short nr_pages = bio->bi_max_vecs - bio->bi_vcnt; unsigned short entries_left = bio->bi_max_vecs - bio->bi_vcnt; + struct request_queue *q = bdev_get_queue(bio->bi_bdev); struct bio_vec *bv = bio->bi_io_vec + bio->bi_vcnt; struct page **pages = (struct page **)bv; bool same_page = false; @@ -1160,6 +1161,9 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) pages += entries_left * (PAGE_PTRS_PER_BVEC - 1); size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset); + if (size > 0) + size = size & ~(queue_logical_block_size(q) - 1); + if (unlikely(size <= 0)) return size ? size : -EFAULT; -- 2.30.2