From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Keith Busch <kbusch@kernel.org>, Qu Wenruo <wqu@suse.com>,
Neptune <z1281552865@gmail.com>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/3] block: simplify minsize alignment in bio_iov_iter_bounce_write
Date: Tue, 14 Jul 2026 15:11:59 +0200 [thread overview]
Message-ID: <20260714131318.2670042-3-hch@lst.de> (raw)
In-Reply-To: <20260714131318.2670042-1-hch@lst.de>
Don't allow partial copies to create unaligned length, which the file
systems can't handle, and remove thee need for the separate
bio_iov_iter_align_down() pass.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/bio.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/block/bio.c b/block/bio.c
index 23f739d5321d..7f707ecf328e 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1399,7 +1399,12 @@ static int bio_iov_iter_bounce_write(struct bio *bio, struct iov_iter *iter,
* bytes as @this_len is queued but only advanced
* less than that.
* Need to compensate that for the revert.
+ *
+ * Round down the amount copied to the minimum size /
+ * aligned required by the file system so that we don't
+ * create unaligned bios.
*/
+ copied = rounddown(copied, minsize);
iov_iter_revert(iter, bio->bi_iter.bi_size - this_len +
copied);
bio_free_folios(bio);
@@ -1410,7 +1415,7 @@ static int bio_iov_iter_bounce_write(struct bio *bio, struct iov_iter *iter,
if (!bio->bi_iter.bi_size)
return -ENOMEM;
- return bio_iov_iter_align_down(bio, iter, minsize - 1);
+ return 0;
}
static int bio_iov_iter_bounce_read(struct bio *bio, struct iov_iter *iter,
--
2.53.0
next prev parent reply other threads:[~2026-07-14 13:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 13:11 bio bounce buffering fixes Christoph Hellwig
2026-07-14 13:11 ` [PATCH 1/3] block: handle huge zero folios in bio_free_folios Christoph Hellwig
2026-07-14 13:11 ` Christoph Hellwig [this message]
2026-07-14 13:12 ` [PATCH 3/3] block,iov_iter: move bio_iov_iter_align_down into iov_iter_extract_bvecs Christoph Hellwig
2026-07-14 14:26 ` Keith Busch
2026-07-14 14:50 ` Christoph Hellwig
2026-07-14 16:44 ` Keith Busch
2026-07-15 4:34 ` 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=20260714131318.2670042-3-hch@lst.de \
--to=hch@lst.de \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=wqu@suse.com \
--cc=z1281552865@gmail.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