From: Keith Busch <kbusch@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org
Subject: Re: [PATCH 2/2] block: support adding less than len in bio_add_hw_page
Date: Tue, 5 Dec 2023 09:37:47 -0700 [thread overview]
Message-ID: <ZW9R29OUl3j8BH43@kbusch-mbp> (raw)
In-Reply-To: <20231204173419.782378-3-hch@lst.de>
On Mon, Dec 04, 2023 at 06:34:19PM +0100, Christoph Hellwig wrote:
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index cef830adbc06e0..335d81398991b3 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -966,10 +966,13 @@ 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)
> {
> + unsigned int max_size = max_sectors << SECTOR_SHIFT;
> +
> if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
> return 0;
>
> - if (((bio->bi_iter.bi_size + len) >> SECTOR_SHIFT) > max_sectors)
> + len = min3(len, max_size, queue_max_segment_size(q));
> + if (len > max_size - bio->bi_iter.bi_size)
> return 0;
>
> if (bio->bi_vcnt > 0) {
Not related to your patch, but noticed while reviewing: would it not be
beneficial to truncate 'len' down to what can fit in the current-segment
instead of assuming the max segment size?
next prev parent reply other threads:[~2023-12-05 16:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-04 17:34 fix bio_add_hw_page for larger folios / compound pages Christoph Hellwig
2023-12-04 17:34 ` [PATCH 1/2] block: prevent an integer overflow in bvec_try_merge_hw_page Christoph Hellwig
2023-12-04 17:34 ` [PATCH 2/2] block: support adding less than len in bio_add_hw_page Christoph Hellwig
2023-12-05 16:34 ` Johannes Thumshirn
2023-12-05 18:52 ` Christoph Hellwig
2023-12-05 16:37 ` Keith Busch [this message]
2023-12-05 18:52 ` Christoph Hellwig
2023-12-05 16:35 ` fix bio_add_hw_page for larger folios / compound pages Johannes Thumshirn
2023-12-11 17:01 ` Christoph Hellwig
2023-12-15 14:35 ` 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=ZW9R29OUl3j8BH43@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--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