From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Jinyoung Choi <j-young.choi@samsung.com>, linux-block@vger.kernel.org
Subject: [PATCH 8/8] block: don't pass a bio to bio_try_merge_hw_seg
Date: Mon, 24 Jul 2023 09:54:33 -0700 [thread overview]
Message-ID: <20230724165433.117645-9-hch@lst.de> (raw)
In-Reply-To: <20230724165433.117645-1-hch@lst.de>
There is no good reason to pass the bio to bio_try_merge_hw_seg. Just
pass the current bvec and rename the function to bvec_try_merge_hw_page.
This will allow reusing this function for supporting multi-page integrity
payload bvecs.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jinyoung Choi <j-young.choi@samsung.com>
---
block/bio.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 23b7a001b5005d..c92dda962449b0 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -934,11 +934,10 @@ static bool bvec_try_merge_page(struct bio_vec *bv, struct page *page,
* size limit. This is not for normal read/write bios, but for passthrough
* or Zone Append operations that we can't split.
*/
-static bool bio_try_merge_hw_seg(struct request_queue *q, struct bio *bio,
- struct page *page, unsigned len,
- unsigned offset, bool *same_page)
+static bool bvec_try_merge_hw_page(struct request_queue *q, struct bio_vec *bv,
+ struct page *page, unsigned len, unsigned offset,
+ bool *same_page)
{
- struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
unsigned long mask = queue_segment_boundary(q);
phys_addr_t addr1 = page_to_phys(bv->bv_page) + bv->bv_offset;
phys_addr_t addr2 = page_to_phys(page) + offset + len - 1;
@@ -967,8 +966,6 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
struct page *page, unsigned int len, unsigned int offset,
unsigned int max_sectors, bool *same_page)
{
- struct bio_vec *bvec;
-
if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
return 0;
@@ -976,7 +973,9 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
return 0;
if (bio->bi_vcnt > 0) {
- if (bio_try_merge_hw_seg(q, bio, page, len, offset,
+ struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
+
+ if (bvec_try_merge_hw_page(q, bv, page, len, offset,
same_page)) {
bio->bi_iter.bi_size += len;
return len;
@@ -990,8 +989,7 @@ int bio_add_hw_page(struct request_queue *q, struct bio *bio,
* If the queue doesn't support SG gaps and adding this segment
* would create a gap, disallow it.
*/
- bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
- if (bvec_gap_to_prev(&q->limits, bvec, offset))
+ if (bvec_gap_to_prev(&q->limits, bv, offset))
return 0;
}
--
2.39.2
next prev parent reply other threads:[~2023-07-24 16:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 16:54 rationalize the flow in bio_add_page and friends v2 Christoph Hellwig
2023-07-24 16:54 ` [PATCH 1/8] block: tidy up the bio full checks in bio_add_hw_page Christoph Hellwig
2023-07-25 1:41 ` Jinyoung Choi
2023-07-24 16:54 ` [PATCH 2/8] block: use SECTOR_SHIFT bio_add_hw_page Christoph Hellwig
2023-07-24 16:54 ` [PATCH 3/8] block: move the BIO_CLONED checks out of __bio_try_merge_page Christoph Hellwig
2023-07-24 16:54 ` [PATCH 4/8] block: move the bi_vcnt check " Christoph Hellwig
2023-07-24 16:54 ` [PATCH 5/8] block: move the bi_size overflow check in __bio_try_merge_page Christoph Hellwig
2023-07-24 16:54 ` [PATCH 6/8] block: downgrade a bio_full call in bio_add_page Christoph Hellwig
2023-07-24 16:54 ` [PATCH 7/8] block: move the bi_size update out of __bio_try_merge_page Christoph Hellwig
2023-07-24 16:54 ` Christoph Hellwig [this message]
2023-07-25 1:55 ` rationalize the flow in bio_add_page and friends v2 Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2023-05-12 13:38 rationalize the flow in bio_add_page and friends Christoph Hellwig
2023-05-12 13:39 ` [PATCH 8/8] block: don't pass a bio to bio_try_merge_hw_seg Christoph Hellwig
2023-05-19 6:30 ` 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=20230724165433.117645-9-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=j-young.choi@samsung.com \
--cc=linux-block@vger.kernel.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