From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org
Subject: [PATCH 3/3] block: move same page handling from __bio_add_pc_page to the callers
Date: Wed, 3 Jul 2019 06:00:36 -0700 [thread overview]
Message-ID: <20190703130036.4105-4-hch@lst.de> (raw)
In-Reply-To: <20190703130036.4105-1-hch@lst.de>
Hiding page refcount manipulation inside a low-level bio helper is
somewhat awkward. Instead return the same page information to the
callers, where it fits in much better.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/bio.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 1db626f99bcb..631b590a479f 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -668,7 +668,7 @@ static bool bio_try_merge_pc_page(struct request_queue *q, struct bio *bio,
* @page: page to add
* @len: vec entry length
* @offset: vec entry offset
- * @put_same_page: put the page if it is same with last added page
+ * @same_page: return if the merge happen inside the same page
*
* Attempt to add a page to the bio_vec maplist. This can fail for a
* number of reasons, such as the bio being full or target block device
@@ -679,10 +679,9 @@ static bool bio_try_merge_pc_page(struct request_queue *q, struct bio *bio,
*/
static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
struct page *page, unsigned int len, unsigned int offset,
- bool put_same_page)
+ bool *same_page)
{
struct bio_vec *bvec;
- bool same_page = false;
/*
* cloned bio must not modify vec list
@@ -694,12 +693,8 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
return 0;
if (bio->bi_vcnt > 0) {
- if (bio_try_merge_pc_page(q, bio, page, len, offset,
- &same_page)) {
- if (put_same_page && same_page)
- put_page(page);
+ if (bio_try_merge_pc_page(q, bio, page, len, offset, same_page))
return len;
- }
/*
* If the queue doesn't support SG gaps and adding this segment
@@ -728,7 +723,8 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
int bio_add_pc_page(struct request_queue *q, struct bio *bio,
struct page *page, unsigned int len, unsigned int offset)
{
- return __bio_add_pc_page(q, bio, page, len, offset, false);
+ bool same_page = false;
+ return __bio_add_pc_page(q, bio, page, len, offset, &same_page);
}
EXPORT_SYMBOL(bio_add_pc_page);
@@ -1369,13 +1365,17 @@ struct bio *bio_map_user_iov(struct request_queue *q,
for (j = 0; j < npages; j++) {
struct page *page = pages[j];
unsigned int n = PAGE_SIZE - offs;
+ bool same_page = false;
if (n > bytes)
n = bytes;
if (!__bio_add_pc_page(q, bio, page, n, offs,
- true))
+ &same_page)) {
+ if (same_page)
+ put_page(page);
break;
+ }
added += n;
bytes -= n;
--
2.20.1
next prev parent reply other threads:[~2019-07-03 13:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 13:00 bio_add_pc_page cleanups Christoph Hellwig
2019-07-03 13:00 ` [PATCH 1/3] block: improve the gap check in __bio_add_pc_page Christoph Hellwig
2019-07-03 14:40 ` Johannes Thumshirn
2019-07-03 13:00 ` [PATCH 2/3] block: create bio_try_merge_pc_page helper __bio_add_pc_page Christoph Hellwig
2019-07-03 13:34 ` Johannes Thumshirn
2019-07-03 14:34 ` Christoph Hellwig
2019-07-03 14:40 ` Johannes Thumshirn
2019-07-03 13:00 ` Christoph Hellwig [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-08-12 15:39 bio_add_pc_page cleanups Christoph Hellwig
2019-08-12 15:39 ` [PATCH 3/3] block: move same page handling from __bio_add_pc_page to the callers Christoph Hellwig
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=20190703130036.4105-4-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--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