[PATCH 07/15] block: blk-merge: fix merging two requests in ll_merge_requests_fn

Jinyoung CHOI
2023-05-03T10:14:01Z

blk_integrity_merge_rq() merges integrity segment information of two
requests. However, it is only a condition check and does not perform the
actual integrity information update. So this was modified.

After it is called, the merge process of the requests may fail
due to other conditions. At this time, there is an error in the integrity
segment information of request. So the call location was also changed.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>

Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
---
block/blk-integrity.c | 2 ++
block/blk-merge.c | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 03a85e1f6d2e..f97b7e8a6d4d 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -181,6 +181,8 @@ bool blk_integrity_merge_rq(struct request_queue *q, struct request *req,
if (integrity_req_gap_back_merge(req, next->bio))
return false;

+ req->nr_integrity_segments += next->nr_integrity_segments;
+
return true;
}

diff --git a/block/blk-merge.c b/block/blk-merge.c
index 8509f468d6d4..c6a0958e8df1 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -711,10 +711,11 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
if (!blk_cgroup_mergeable(req, next->bio))
return 0;

- if (blk_integrity_merge_rq(q, req, next) == false)
+ if (!bio_crypt_ctx_merge_rq(req, next))
return 0;

- if (!bio_crypt_ctx_merge_rq(req, next))
+ /* this will merge integrity segments */
+ if (!blk_integrity_merge_rq(q, req, next))
return 0;

/* Merge is OK... */
--
2.34.1