Skip to content

Commit

Permalink
block: prevent request-to-request merging with gaps if not allowed
Browse files Browse the repository at this point in the history
If the queue has SG_GAPS set, we must not merge across an sg gap.
This is caught for the bio case, but currently not for the
more rare case of merging two requests directly.

Signed-off-by: Keith Busch <[email protected]>

Cut the dm bits, those will go through the dm tree, and fixed
the test_bit() test.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Keith Busch authored and axboe committed Feb 11, 2015
1 parent 201f201 commit 854fbb9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@ static bool req_no_special_merge(struct request *req)
return !q->mq_ops && req->special;
}

static int req_gap_to_prev(struct request *req, struct request *next)
{
struct bio *prev = req->biotail;

return bvec_gap_to_prev(&prev->bi_io_vec[prev->bi_vcnt - 1],
next->bio->bi_io_vec[0].bv_offset);
}

static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
struct request *next)
{
Expand All @@ -399,6 +407,10 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
if (req_no_special_merge(req) || req_no_special_merge(next))
return 0;

if (test_bit(QUEUE_FLAG_SG_GAPS, &q->queue_flags) &&
req_gap_to_prev(req, next))
return 0;

/*
* Will it become too large?
*/
Expand Down

0 comments on commit 854fbb9

Please sign in to comment.