summaryrefslogtreecommitdiff
path: root/block/bio.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-04-11 08:23:31 +0200
committerJens Axboe <axboe@kernel.dk>2019-04-12 09:06:42 -0600
commit52d52d1c98a90cfe860b83498e4b6074aad95c15 (patch)
tree98776fc54f50c9a9168162e030ee9db6b89c2d46 /block/bio.c
parent7321ecbfc7cf85211460a1dc6bb0ccfc3dcf9df0 (diff)
block: only allow contiguous page structs in a bio_vec
We currently have to call nth_page when iterating over pages inside a bio_vec. Jens complained a while ago that this is fairly expensive. To mitigate this we can check that that the actual page structures are contiguous when adding them to the bio, and just do check pointer arithmetics later on. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bio.c')
-rw-r--r--block/bio.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/block/bio.c b/block/bio.c
index d3490aeb1a7e..8adc2a20d57d 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -659,8 +659,13 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
return false;
if (xen_domain() && !xen_biovec_phys_mergeable(bv, page))
return false;
- if (same_page && (vec_end_addr & PAGE_MASK) != page_addr)
- return false;
+
+ if ((vec_end_addr & PAGE_MASK) != page_addr) {
+ if (same_page)
+ return false;
+ if (pfn_to_page(PFN_DOWN(vec_end_addr)) + 1 != page)
+ return false;
+ }
return true;
}