diff options
author | Sagi Grimberg <sagig@mellanox.com> | 2015-09-11 11:03:04 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-09-11 11:03:04 -0400 |
commit | 7f39add3b08cbbdb99abe50e6d7c342e6800d684 (patch) | |
tree | dd495ebf5446f531d88aee04f00857cff243e586 | |
parent | 5e7c4274a70aa2d6f485996d0ca1dad52d0039ca (diff) |
block: Refuse request/bio merges with gaps in the integrity payload
If a driver sets the block queue virtual boundary mask, it means that
it cannot handle gaps so we must not allow those in the integrity
payload as well.
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Fixed up by me to have duplicate integrity merge functions, depending
on whether block integrity is enabled or not. Fixes a compilations
issue with CONFIG_BLK_DEV_INTEGRITY unset.
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | block/blk-integrity.c | 3 | ||||
-rw-r--r-- | block/blk-merge.c | 6 | ||||
-rw-r--r-- | include/linux/blkdev.h | 30 |
3 files changed, 39 insertions, 0 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index f548b64be092..75f29cf70188 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c | |||
@@ -204,6 +204,9 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req, | |||
204 | q->limits.max_integrity_segments) | 204 | q->limits.max_integrity_segments) |
205 | return false; | 205 | return false; |
206 | 206 | ||
207 | if (integrity_req_gap_back_merge(req, next->bio)) | ||
208 | return false; | ||
209 | |||
207 | return true; | 210 | return true; |
208 | } | 211 | } |
209 | EXPORT_SYMBOL(blk_integrity_merge_rq); | 212 | EXPORT_SYMBOL(blk_integrity_merge_rq); |
diff --git a/block/blk-merge.c b/block/blk-merge.c index d9eddbc189f5..574ea7c0468f 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c | |||
@@ -440,6 +440,9 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, | |||
440 | { | 440 | { |
441 | if (req_gap_back_merge(req, bio)) | 441 | if (req_gap_back_merge(req, bio)) |
442 | return 0; | 442 | return 0; |
443 | if (blk_integrity_rq(req) && | ||
444 | integrity_req_gap_back_merge(req, bio)) | ||
445 | return 0; | ||
443 | if (blk_rq_sectors(req) + bio_sectors(bio) > | 446 | if (blk_rq_sectors(req) + bio_sectors(bio) > |
444 | blk_rq_get_max_sectors(req)) { | 447 | blk_rq_get_max_sectors(req)) { |
445 | req->cmd_flags |= REQ_NOMERGE; | 448 | req->cmd_flags |= REQ_NOMERGE; |
@@ -461,6 +464,9 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req, | |||
461 | 464 | ||
462 | if (req_gap_front_merge(req, bio)) | 465 | if (req_gap_front_merge(req, bio)) |
463 | return 0; | 466 | return 0; |
467 | if (blk_integrity_rq(req) && | ||
468 | integrity_req_gap_front_merge(req, bio)) | ||
469 | return 0; | ||
464 | if (blk_rq_sectors(req) + bio_sectors(bio) > | 470 | if (blk_rq_sectors(req) + bio_sectors(bio) > |
465 | blk_rq_get_max_sectors(req)) { | 471 | blk_rq_get_max_sectors(req)) { |
466 | req->cmd_flags |= REQ_NOMERGE; | 472 | req->cmd_flags |= REQ_NOMERGE; |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2ff94def041e..1aac7316a4b5 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -1514,6 +1514,26 @@ queue_max_integrity_segments(struct request_queue *q) | |||
1514 | return q->limits.max_integrity_segments; | 1514 | return q->limits.max_integrity_segments; |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | static inline bool integrity_req_gap_back_merge(struct request *req, | ||
1518 | struct bio *next) | ||
1519 | { | ||
1520 | struct bio_integrity_payload *bip = bio_integrity(req->bio); | ||
1521 | struct bio_integrity_payload *bip_next = bio_integrity(next); | ||
1522 | |||
1523 | return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1], | ||
1524 | bip_next->bip_vec[0].bv_offset); | ||
1525 | } | ||
1526 | |||
1527 | static inline bool integrity_req_gap_front_merge(struct request *req, | ||
1528 | struct bio *bio) | ||
1529 | { | ||
1530 | struct bio_integrity_payload *bip = bio_integrity(bio); | ||
1531 | struct bio_integrity_payload *bip_next = bio_integrity(req->bio); | ||
1532 | |||
1533 | return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1], | ||
1534 | bip_next->bip_vec[0].bv_offset); | ||
1535 | } | ||
1536 | |||
1517 | #else /* CONFIG_BLK_DEV_INTEGRITY */ | 1537 | #else /* CONFIG_BLK_DEV_INTEGRITY */ |
1518 | 1538 | ||
1519 | struct bio; | 1539 | struct bio; |
@@ -1580,6 +1600,16 @@ static inline bool blk_integrity_is_initialized(struct gendisk *g) | |||
1580 | { | 1600 | { |
1581 | return 0; | 1601 | return 0; |
1582 | } | 1602 | } |
1603 | static inline bool integrity_req_gap_back_merge(struct request *req, | ||
1604 | struct bio *next) | ||
1605 | { | ||
1606 | return false; | ||
1607 | } | ||
1608 | static inline bool integrity_req_gap_front_merge(struct request *req, | ||
1609 | struct bio *bio) | ||
1610 | { | ||
1611 | return false; | ||
1612 | } | ||
1583 | 1613 | ||
1584 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ | 1614 | #endif /* CONFIG_BLK_DEV_INTEGRITY */ |
1585 | 1615 | ||