From: Jinyoung CHOI <j-young.choi@samsung.com>
To: Jinyoung CHOI <j-young.choi@samsung.com>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"kbusch@kernel.org" <kbusch@kernel.org>,
"hch@lst.de" <hch@lst.de>, "sagi@grimberg.me" <sagi@grimberg.me>,
"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"johannes.thumshirn@wdc.com" <johannes.thumshirn@wdc.com>,
"kch@nvidia.com" <kch@nvidia.com>,
"willy@infradead.org" <willy@infradead.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 05/14] block: blk-merge: fix to add the number of integrity segments to the request twice
Date: Wed, 10 May 2023 17:52:08 +0900 [thread overview]
Message-ID: <20230510085208epcms2p52a6dec8da80152ec2101f11ce2ea5321@epcms2p5> (raw)
In-Reply-To: <20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p1>
blk_integrity_merge_bio() not only performs conditional tests, but also
updates the integrity segment information of request.
It can be called twice when merging the bio into an existing request.
bio_attempt_bio_merge() or blk_mq_sched_try_merge()
blk_rq_merge_ok()
blk_integrity_merge_bio() - 1
bio_attemp_{back|front}_merge()
ll_{back|front}_merge_fn()
ll_new_hw_segments()
blk_integrity_merge_bio() - 2
The part of checking the conditions and the code to update the
information of the actual request were separated. At this time, the
ll_back_merge_fn was called by passth-path, so the condition check was
called by all the separated functions.
And after success in blk_integrity_merge_bio(), the information of the
request may be wrong if it is impossible to merge due to other
conditional tests. Thus, it was changed to be called immediately before
merging the bio's segments.
Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Fixes: 4eaf99beadce ("block: Don't merge requests if integrity flags differ")
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
---
block/blk-integrity.c | 34 +++++++++++++++++++++++++++++-----
block/blk-merge.c | 9 +++++----
block/blk.h | 7 +++++++
3 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index d4e9b4556d14..03a85e1f6d2e 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -184,19 +184,43 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req,
return true;
}
+static inline bool blk_integrity_bypass_check(struct request *req,
+ struct bio *bio)
+{
+ return blk_integrity_rq(req) == 0 && bio_integrity(bio) == NULL;
+}
+
+static bool __blk_integrity_mergeable(struct request_queue *q,
+ struct request *req, struct bio *bio)
+{
+ if (blk_integrity_rq(req) == 0 || bio_integrity(bio) == NULL)
+ return false;
+
+ if (bio_integrity(req->bio)->bip_flags != bio_integrity(bio)->bip_flags)
+ return false;
+
+ return true;
+}
+
+bool blk_integrity_mergeable(struct request_queue *q, struct request *req,
+ struct bio *bio)
+{
+ if (blk_integrity_bypass_check(req, bio))
+ return true;
+
+ return __blk_integrity_mergeable(q, req, bio);
+}
+
bool blk_integrity_merge_bio(struct request_queue *q, struct request *req,
struct bio *bio)
{
int nr_integrity_segs;
struct bio *next = bio->bi_next;
- if (blk_integrity_rq(req) == 0 && bio_integrity(bio) == NULL)
+ if (blk_integrity_bypass_check(req, bio))
return true;
- if (blk_integrity_rq(req) == 0 || bio_integrity(bio) == NULL)
- return false;
-
- if (bio_integrity(req->bio)->bip_flags != bio_integrity(bio)->bip_flags)
+ if (!__blk_integrity_mergeable(q, req, bio))
return false;
bio->bi_next = NULL;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 65e75efa9bd3..8509f468d6d4 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -611,9 +611,6 @@ static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
if (!blk_cgroup_mergeable(req, bio))
goto no_merge;
- if (blk_integrity_merge_bio(req->q, req, bio) == false)
- goto no_merge;
-
/* discard request merge won't add new segment */
if (req_op(req) == REQ_OP_DISCARD)
return 1;
@@ -621,6 +618,10 @@ static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
goto no_merge;
+ /* This will merge integrity segments */
+ if (!blk_integrity_merge_bio(req->q, req, bio))
+ goto no_merge;
+
/*
* This will form the start of a new hw segment. Bump both
* counters.
@@ -934,7 +935,7 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
return false;
/* only merge integrity protected bio into ditto rq */
- if (blk_integrity_merge_bio(rq->q, rq, bio) == false)
+ if (!blk_integrity_mergeable(rq->q, rq, bio))
return false;
/* Only merge if the crypt contexts are compatible */
diff --git a/block/blk.h b/block/blk.h
index dd7cbb57ce43..b7677a5bdff1 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -202,6 +202,8 @@ static inline bool bio_integrity_endio(struct bio *bio)
bool blk_integrity_merge_rq(struct request_queue *, struct request *,
struct request *);
+bool blk_integrity_mergeable(struct request_queue *rq, struct request *r,
+ struct bio *b);
bool blk_integrity_merge_bio(struct request_queue *, struct request *,
struct bio *);
@@ -234,6 +236,11 @@ static inline bool blk_integrity_merge_rq(struct request_queue *rq,
{
return true;
}
+static inline bool blk_integrity_mergeable(struct request_queue *rq,
+ struct request *r, struct bio *b)
+{
+ return true;
+}
static inline bool blk_integrity_merge_bio(struct request_queue *rq,
struct request *r, struct bio *b)
{
--
2.34.1
next prev parent reply other threads:[~2023-05-10 8:53 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p1>
2023-05-10 8:44 ` [PATCH v2 00/14] Change the integrity configuration method in block Jinyoung CHOI
2023-05-10 8:46 ` [PATCH v2 01/14] block: bio: separation to reuse a part of the function Jinyoung CHOI
2023-05-10 8:48 ` [PATCH v2 02/14] block: bio-integrity: modify bio_integrity_add_page() Jinyoung CHOI
2023-05-12 13:43 ` hch
2023-05-16 12:54 ` Jinyoung CHOI
2023-05-10 8:50 ` [PATCH v2 03/14] block: bio-integrity: cleanup bio_integrity_prep Jinyoung CHOI
2023-05-12 13:45 ` hch
2023-05-10 8:51 ` [PATCH v2 04/14] block: fix not to apply bip information in blk_rq_bio_prep() Jinyoung CHOI
2023-05-12 13:47 ` hch
2023-05-10 8:52 ` Jinyoung CHOI [this message]
2023-05-12 13:51 ` [PATCH v2 05/14] block: blk-merge: fix to add the number of integrity segments to the request twice hch
2023-05-16 13:24 ` Jinyoung CHOI
2023-05-10 8:53 ` [PATCH v2 06/14] block: blk-merge: fix merging two requests in ll_merge_requests_fn Jinyoung CHOI
2023-05-10 8:53 ` [PATCH v2 07/14] block: add helper function to get the number of integrity segments Jinyoung CHOI
2023-05-10 8:56 ` [PATCH v2 08/14] scsi: add scsi_alloc_integrity_sgtables() for integrity process Jinyoung CHOI
2023-05-12 13:52 ` hch
2023-05-17 2:20 ` Jinyoung CHOI
2023-05-10 8:56 ` [PATCH v2 09/14] scsi: change to use blk_rq_nr_integrity_segments() instead of blk_rq_count_integrity_sg() Jinyoung CHOI
2023-05-10 8:58 ` [PATCH v2 10/14] block: blk-integrity: change how to find the number of integrity of bio Jinyoung CHOI
2023-05-10 8:59 ` [PATCH v2 11/14] nvme: rdma: change how to find the number of integrity of request Jinyoung CHOI
2023-05-10 8:59 ` [PATCH v2 12/14] block: add helper function for iteration of bip's bvec Jinyoung CHOI
2023-05-12 13:54 ` hch
2023-05-17 2:35 ` Jinyoung CHOI
2023-05-10 9:00 ` [PATCH v2 13/14] block: blk-integrity: change sg-table configuration method for integrity Jinyoung CHOI
2023-05-10 9:01 ` [PATCH v2 14/14] block: blk-integrity: remove blk_rq_count_integrity_sg() Jinyoung CHOI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230510085208epcms2p52a6dec8da80152ec2101f11ce2ea5321@epcms2p5 \
--to=j-young.choi@samsung.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=jejb@linux.ibm.com \
--cc=johannes.thumshirn@wdc.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=sagi@grimberg.me \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox