summaryrefslogtreecommitdiffstats
path: root/include/linux/blkdev.h
diff options
context:
space:
mode:
authorMing Lei <ming.lei@canonical.com>2016-02-26 10:40:51 -0500
committerJens Axboe <axboe@fb.com>2016-03-03 16:42:49 -0500
commite0af29171aa8912e1ca95023b75ef336cd70d661 (patch)
tree0e8bd6fdfb2b96eb505f71f306afbab72d4f3c88 /include/linux/blkdev.h
parent7bcd79ac50d9d83350a835bdb91c04ac9e098412 (diff)
block: check virt boundary in bio_will_gap()
In the following patch, the way for figuring out the last bvec will be changed with a bit cost introduced, so return immediately if the queue doesn't have virt boundary limit. Actually most of devices have not this limit. Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@canonical.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'include/linux/blkdev.h')
-rw-r--r--include/linux/blkdev.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 4571ef1a12a9..cd06a41581b3 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1372,6 +1372,13 @@ static inline void put_dev_sector(Sector p)
1372 page_cache_release(p.v); 1372 page_cache_release(p.v);
1373} 1373}
1374 1374
1375static inline bool __bvec_gap_to_prev(struct request_queue *q,
1376 struct bio_vec *bprv, unsigned int offset)
1377{
1378 return offset ||
1379 ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q));
1380}
1381
1375/* 1382/*
1376 * Check if adding a bio_vec after bprv with offset would create a gap in 1383 * Check if adding a bio_vec after bprv with offset would create a gap in
1377 * the SG list. Most drivers don't care about this, but some do. 1384 * the SG list. Most drivers don't care about this, but some do.
@@ -1381,18 +1388,17 @@ static inline bool bvec_gap_to_prev(struct request_queue *q,
1381{ 1388{
1382 if (!queue_virt_boundary(q)) 1389 if (!queue_virt_boundary(q))
1383 return false; 1390 return false;
1384 return offset || 1391 return __bvec_gap_to_prev(q, bprv, offset);
1385 ((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q));
1386} 1392}
1387 1393
1388static inline bool bio_will_gap(struct request_queue *q, struct bio *prev, 1394static inline bool bio_will_gap(struct request_queue *q, struct bio *prev,
1389 struct bio *next) 1395 struct bio *next)
1390{ 1396{
1391 if (!bio_has_data(prev)) 1397 if (!bio_has_data(prev) || !queue_virt_boundary(q))
1392 return false; 1398 return false;
1393 1399
1394 return bvec_gap_to_prev(q, &prev->bi_io_vec[prev->bi_vcnt - 1], 1400 return __bvec_gap_to_prev(q, &prev->bi_io_vec[prev->bi_vcnt - 1],
1395 next->bi_io_vec[0].bv_offset); 1401 next->bi_io_vec[0].bv_offset);
1396} 1402}
1397 1403
1398static inline bool req_gap_back_merge(struct request *req, struct bio *bio) 1404static inline bool req_gap_back_merge(struct request *req, struct bio *bio)