diff options
Diffstat (limited to 'block/bio.c')
-rw-r--r-- | block/bio.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/block/bio.c b/block/bio.c index 97e832cc9b9c..2d64488e51c6 100644 --- a/block/bio.c +++ b/block/bio.c @@ -849,8 +849,13 @@ int bio_add_page(struct bio *bio, struct page *page, unsigned int len, unsigned int offset) { struct request_queue *q = bdev_get_queue(bio->bi_bdev); + unsigned int max_sectors; - return __bio_add_page(q, bio, page, len, offset, blk_max_size_offset(q, bio->bi_iter.bi_sector)); + max_sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector); + if ((max_sectors < (len >> 9)) && !bio->bi_iter.bi_size) + max_sectors = len >> 9; + + return __bio_add_page(q, bio, page, len, offset, max_sectors); } EXPORT_SYMBOL(bio_add_page); |