From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Ming Lei <ming.lei@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
linux-block@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH 5/5] block: use __bio_try_merge_page in __bio_try_merge_pc_page
Date: Tue, 11 Jun 2019 17:10:07 +0200 [thread overview]
Message-ID: <20190611151007.13625-6-hch@lst.de> (raw)
In-Reply-To: <20190611151007.13625-1-hch@lst.de>
Passsthrough bio handling should be the same as normal bio handling,
except that we need to take hardware limitations into account. Thus
use the common try_merge implementation after checking the hardware
limits.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/bio.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index 0d841ba4373a..7db7186eab1c 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -661,20 +661,11 @@ static bool bio_try_merge_pc_page(struct request_queue *q, struct bio *bio,
phys_addr_t addr1 = page_to_phys(bv->bv_page) + bv->bv_offset;
phys_addr_t addr2 = page_to_phys(page) + off + len - 1;
- if (page == bv->bv_page && off == bv->bv_offset + bv->bv_len) {
- *same_page = true;
- goto done;
- }
-
if ((addr1 | mask) != (addr2 | mask))
return false;
if (bv->bv_len + len > queue_max_segment_size(q))
return false;
- if (!page_is_mergeable(bv, page, len, off, false))
- return false;
-done:
- bv->bv_len += len;
- return true;
+ return __bio_try_merge_page(bio, page, len, off, same_page);
}
/**
@@ -737,8 +728,8 @@ static int __bio_add_pc_page(struct request_queue *q, struct bio *bio,
bvec->bv_len = len;
bvec->bv_offset = offset;
bio->bi_vcnt++;
- done:
bio->bi_iter.bi_size += len;
+ done:
bio->bi_phys_segments = bio->bi_vcnt;
bio_set_flag(bio, BIO_SEG_VALID);
return len;
--
2.20.1
next prev parent reply other threads:[~2019-06-11 15:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-11 15:10 alternative take on the same page merging leak fix Christoph Hellwig
2019-06-11 15:10 ` [PATCH 1/5] block: fix gap checking in __bio_add_pc_page Christoph Hellwig
2019-06-11 15:10 ` [PATCH 2/5] block: factor out a bio_try_merge_pc_page helper Christoph Hellwig
2019-06-11 15:10 ` [PATCH 3/5] block: return from __bio_try_merge_page if merging occured in the same page Christoph Hellwig
2019-06-12 10:14 ` Ming Lei
2019-06-11 15:10 ` [PATCH 4/5] block: fix page leak when merging to " Christoph Hellwig
2019-06-12 10:18 ` Ming Lei
2019-06-11 15:10 ` Christoph Hellwig [this message]
2019-06-12 1:09 ` alternative take on the same page merging leak fix Ming Lei
2019-06-12 7:45 ` Christoph Hellwig
2019-06-12 10:11 ` Ming Lei
2019-06-13 9:02 ` Jens Axboe
2019-06-13 9:02 ` Christoph Hellwig
2019-06-13 9:11 ` Jens Axboe
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=20190611151007.13625-6-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=darrick.wong@oracle.com \
--cc=david@gibson.dropbear.id.au \
--cc=linux-block@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ming.lei@redhat.com \
/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