From: Ming Lei <ming.lei@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Kundan Kumar <kundan.kumar@samsung.com>,
Christoph Hellwig <hch@lst.de>,
Luis Chamberlain <mcgrof@kernel.org>,
Gavin Shan <gshan@redhat.com>
Subject: Re: [PATCH] block: fix adding folio to bio
Date: Wed, 12 Mar 2025 22:02:48 +0800 [thread overview]
Message-ID: <Z9GUCBzE8wtHQhFe@fedora> (raw)
In-Reply-To: <Z9F7wOB0PqouJfss@casper.infradead.org>
On Wed, Mar 12, 2025 at 12:19:12PM +0000, Matthew Wilcox wrote:
> On Wed, Mar 12, 2025 at 07:38:05PM +0800, Ming Lei wrote:
> > +++ b/block/bio.c
> > @@ -1026,9 +1026,17 @@ EXPORT_SYMBOL(bio_add_page);
> > void bio_add_folio_nofail(struct bio *bio, struct folio *folio, size_t len,
> > size_t off)
> > {
> > + struct page *page = &folio->page;
> > +
> > WARN_ON_ONCE(len > UINT_MAX);
> > - WARN_ON_ONCE(off > UINT_MAX);
> > - __bio_add_page(bio, &folio->page, len, off);
> > + if (unlikely(off > UINT_MAX)) {
>
> I think we should probably make this:
>
> if (unlikely(off + len > UINT_MAX))
>
> because I'm not sure that everything will cope well with an I/O that
> crosses the 4GB boundary.
If hardware doesn't support it, the bio will be splitted before submitting
to the disk, so I think the check isn't needed here.
>
> Actually, why bother with the conditional? Let's just do it always.
>
> {
> + unsigned long nr = off / PAGE_SIZE;
> WARN_ON_ONCE(len > UINT_MAX);
> - WARN_ON_ONCE(off > UINT_MAX);
> - __bio_add_page(bio, &folio->page, len, off);
> + off = off % PAGE_SIZE;
> + __bio_add_page(bio, folio_page(folio, nr), len, off);
> }
>
> Also you need to do bio_add_folio(), not just the _nofail variant.
OK, will cover bio_add_folio() in V2 by the unconditional way.
Thanks,
Ming
prev parent reply other threads:[~2025-03-12 14:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-12 11:38 [PATCH] block: fix adding folio to bio Ming Lei
2025-03-12 12:19 ` Matthew Wilcox
2025-03-12 14:02 ` Ming Lei [this message]
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=Z9GUCBzE8wtHQhFe@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=gshan@redhat.com \
--cc=hch@lst.de \
--cc=kundan.kumar@samsung.com \
--cc=linux-block@vger.kernel.org \
--cc=mcgrof@kernel.org \
--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