Commit 7f39add3 authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Jens Axboe

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: default avatarSagi 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: default avatarJens Axboe <axboe@fb.com>
parent 5e7c4274
...@@ -204,6 +204,9 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req, ...@@ -204,6 +204,9 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req,
q->limits.max_integrity_segments) q->limits.max_integrity_segments)
return false; return false;
if (integrity_req_gap_back_merge(req, next->bio))
return false;
return true; return true;
} }
EXPORT_SYMBOL(blk_integrity_merge_rq); EXPORT_SYMBOL(blk_integrity_merge_rq);
......
...@@ -440,6 +440,9 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, ...@@ -440,6 +440,9 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req,
{ {
if (req_gap_back_merge(req, bio)) if (req_gap_back_merge(req, bio))
return 0; return 0;
if (blk_integrity_rq(req) &&
integrity_req_gap_back_merge(req, bio))
return 0;
if (blk_rq_sectors(req) + bio_sectors(bio) > if (blk_rq_sectors(req) + bio_sectors(bio) >
blk_rq_get_max_sectors(req)) { blk_rq_get_max_sectors(req)) {
req->cmd_flags |= REQ_NOMERGE; req->cmd_flags |= REQ_NOMERGE;
...@@ -461,6 +464,9 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req, ...@@ -461,6 +464,9 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req,
if (req_gap_front_merge(req, bio)) if (req_gap_front_merge(req, bio))
return 0; return 0;
if (blk_integrity_rq(req) &&
integrity_req_gap_front_merge(req, bio))
return 0;
if (blk_rq_sectors(req) + bio_sectors(bio) > if (blk_rq_sectors(req) + bio_sectors(bio) >
blk_rq_get_max_sectors(req)) { blk_rq_get_max_sectors(req)) {
req->cmd_flags |= REQ_NOMERGE; req->cmd_flags |= REQ_NOMERGE;
......
...@@ -1514,6 +1514,26 @@ queue_max_integrity_segments(struct request_queue *q) ...@@ -1514,6 +1514,26 @@ queue_max_integrity_segments(struct request_queue *q)
return q->limits.max_integrity_segments; return q->limits.max_integrity_segments;
} }
static inline bool integrity_req_gap_back_merge(struct request *req,
struct bio *next)
{
struct bio_integrity_payload *bip = bio_integrity(req->bio);
struct bio_integrity_payload *bip_next = bio_integrity(next);
return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1],
bip_next->bip_vec[0].bv_offset);
}
static inline bool integrity_req_gap_front_merge(struct request *req,
struct bio *bio)
{
struct bio_integrity_payload *bip = bio_integrity(bio);
struct bio_integrity_payload *bip_next = bio_integrity(req->bio);
return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1],
bip_next->bip_vec[0].bv_offset);
}
#else /* CONFIG_BLK_DEV_INTEGRITY */ #else /* CONFIG_BLK_DEV_INTEGRITY */
struct bio; struct bio;
...@@ -1580,6 +1600,16 @@ static inline bool blk_integrity_is_initialized(struct gendisk *g) ...@@ -1580,6 +1600,16 @@ static inline bool blk_integrity_is_initialized(struct gendisk *g)
{ {
return 0; return 0;
} }
static inline bool integrity_req_gap_back_merge(struct request *req,
struct bio *next)
{
return false;
}
static inline bool integrity_req_gap_front_merge(struct request *req,
struct bio *bio)
{
return false;
}
#endif /* CONFIG_BLK_DEV_INTEGRITY */ #endif /* CONFIG_BLK_DEV_INTEGRITY */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment