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 01/14] block: bio: separation to reuse a part of the function
Date: Wed, 10 May 2023 17:46:57 +0900 [thread overview]
Message-ID: <20230510084657epcms2p69b0c426899251151a5cc7d84cedeacc7@epcms2p6> (raw)
In-Reply-To: <20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p1>
__bio_try_merge_page(), which is called by the general page-add functions
and the function considering the constraints of hw, was separated.
Condition tests for general page-add functions were performed in
bio_try_merge_page(). And when the parameters of __bio_try_merge_page()
were changed, there were fewer functions affected by this.
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/bio.c | 49 ++++++++++++++++++++++++++++++-------------------
1 file changed, 30 insertions(+), 19 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index fd11614bba4d..1be17dea603a 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -926,8 +926,28 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
return (bv->bv_page + bv_end / PAGE_SIZE) == (page + off / PAGE_SIZE);
}
+static bool __bio_try_merge_page(struct bio *bio, struct page *page,
+ unsigned int len, unsigned int off,
+ bool *same_page)
+{
+ struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
+
+ if (!page_is_mergeable(bv, page, len, off, same_page))
+ return false;
+
+ if (bio->bi_iter.bi_size > UINT_MAX - len) {
+ *same_page = false;
+ return false;
+ }
+
+ bv->bv_len += len;
+ bio->bi_iter.bi_size += len;
+
+ return true;
+}
+
/**
- * __bio_try_merge_page - try appending data to an existing bvec.
+ * bio_try_merge_page - try appending data to an existing bvec.
* @bio: destination bio
* @page: start page to add
* @len: length of the data to add
@@ -942,26 +962,17 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
*
* Return %true on success or %false on failure.
*/
-static bool __bio_try_merge_page(struct bio *bio, struct page *page,
- unsigned int len, unsigned int off, bool *same_page)
+static bool bio_try_merge_page(struct bio *bio, struct page *page,
+ unsigned int len, unsigned int off,
+ bool *same_page)
{
if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
return false;
- if (bio->bi_vcnt > 0) {
- struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
-
- if (page_is_mergeable(bv, page, len, off, same_page)) {
- if (bio->bi_iter.bi_size > UINT_MAX - len) {
- *same_page = false;
- return false;
- }
- bv->bv_len += len;
- bio->bi_iter.bi_size += len;
- return true;
- }
- }
- return false;
+ if (!bio->bi_vcnt)
+ return false;
+
+ return __bio_try_merge_page(bio, page, len, off, same_page);
}
/*
@@ -1129,7 +1140,7 @@ int bio_add_page(struct bio *bio, struct page *page,
{
bool same_page = false;
- if (!__bio_try_merge_page(bio, page, len, offset, &same_page)) {
+ if (!bio_try_merge_page(bio, page, len, offset, &same_page)) {
if (bio_full(bio, len))
return 0;
__bio_add_page(bio, page, len, offset);
@@ -1199,7 +1210,7 @@ static int bio_iov_add_page(struct bio *bio, struct page *page,
{
bool same_page = false;
- if (!__bio_try_merge_page(bio, page, len, offset, &same_page)) {
+ if (!bio_try_merge_page(bio, page, len, offset, &same_page)) {
__bio_add_page(bio, page, len, offset);
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2023-05-10 8:47 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
[not found] ` <CGME20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p7>
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-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 9:01 ` [PATCH v2 14/14] block: blk-integrity: remove blk_rq_count_integrity_sg() Jinyoung CHOI
[not found] ` <CGME20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p2>
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-16 13:24 ` RE:(2) [PATCH v2 05/14] block: blk-merge: fix to add the number of integrity segments to the request twice Jinyoung CHOI
[not found] ` <CGME20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p3>
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
[not found] ` <CGME20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p8>
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 12/14] block: add helper function for iteration of bip's bvec Jinyoung CHOI
2023-05-12 13:54 ` hch
2023-05-16 12:54 ` RE:(2) [PATCH v2 02/14] block: bio-integrity: modify bio_integrity_add_page() Jinyoung CHOI
[not found] ` <CGME20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p6>
2023-05-10 8:46 ` Jinyoung CHOI [this message]
2023-05-10 9:00 ` [PATCH v2 13/14] block: blk-integrity: change sg-table configuration method for integrity Jinyoung CHOI
2023-05-17 2:35 ` RE:(2) [PATCH v2 12/14] block: add helper function for iteration of bip's bvec Jinyoung CHOI
[not found] ` <CGME20230510084407epcms2p123f17696d3c30c749897eeaf2c4de684@epcms2p5>
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:52 ` [PATCH v2 05/14] block: blk-merge: fix to add the number of integrity segments to the request twice Jinyoung CHOI
2023-05-12 13:51 ` hch
2023-05-10 8:53 ` [PATCH v2 07/14] block: add helper function to get the number of integrity segments Jinyoung CHOI
2023-05-17 2:20 ` RE:(2) [PATCH v2 08/14] scsi: add scsi_alloc_integrity_sgtables() for integrity process 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
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=20230510084657epcms2p69b0c426899251151a5cc7d84cedeacc7@epcms2p6 \
--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
all inboxes | Powered by JetHome®