[PATCH 3/3] block: Refuse adding appending a gapped integrity page to a bio
Jens Axboe
axboe at kernel.dk
Wed Sep 2 12:18:53 PDT 2015
On Wed, Sep 02 2015, Sagi Grimberg wrote:
> >Does the below work for you?
>
> It's not on top of Keith virt_boundary patch right?
> First glance looks ok though.
Updated for that.
diff --git a/block/blk-merge.c b/block/blk-merge.c
index b2625271a572..5f35a05337b1 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -436,9 +436,27 @@ no_merge:
return 0;
}
+static bool req_gap_to_prev(struct request *req, struct bio *next)
+{
+ struct bio *prev = req->biotail;
+
+ return bvec_gap_to_prev(req->q, &prev->bi_io_vec[prev->bi_vcnt - 1],
+ next->bi_io_vec[0].bv_offset);
+}
+
+static bool req_gap_to_next(struct request *req, struct bio *bio)
+{
+ struct bio *next = req->bio;
+
+ return bvec_gap_to_prev(req->q, &bio->bi_io_vec[bio->bi_vcnt - 1],
+ next->bi_io_vec[0].bv_offset);
+}
+
int ll_back_merge_fn(struct request_queue *q, struct request *req,
struct bio *bio)
{
+ if (bio_has_data(bio) && req_gap_to_prev(req, bio))
+ return 0;
if (blk_rq_sectors(req) + bio_sectors(bio) >
blk_rq_get_max_sectors(req)) {
req->cmd_flags |= REQ_NOMERGE;
@@ -457,6 +475,9 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req,
int ll_front_merge_fn(struct request_queue *q, struct request *req,
struct bio *bio)
{
+
+ if (bio_has_data(bio) && req_gap_to_next(req, bio))
+ return 0;
if (blk_rq_sectors(req) + bio_sectors(bio) >
blk_rq_get_max_sectors(req)) {
req->cmd_flags |= REQ_NOMERGE;
@@ -483,14 +504,6 @@ 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 bio *next)
-{
- struct bio *prev = req->biotail;
-
- return bvec_gap_to_prev(req->q, &prev->bi_io_vec[prev->bi_vcnt - 1],
- next->bi_io_vec[0].bv_offset);
-}
-
static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
struct request *next)
{
@@ -713,10 +726,6 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
!blk_write_same_mergeable(rq->bio, bio))
return false;
- /* Only check gaps if the bio carries data */
- if (bio_has_data(bio) && req_gap_to_prev(rq, bio))
- return false;
-
return true;
}
--
Jens Axboe
More information about the Linux-nvme
mailing list