From: Christoph Hellwig <hch@lst.de>
To: Christian Brauner <brauner@kernel.org>, Carlos Maiolino <cem@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>, Qu Wenruo <wqu@suse.com>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/4] FIXUP: iomap: aligning to larger than fs block size doesn't make sense
Date: Thu, 23 Oct 2025 15:55:43 +0200 [thread overview]
Message-ID: <20251023135559.124072-3-hch@lst.de> (raw)
In-Reply-To: <20251023135559.124072-1-hch@lst.de>
All of the VFS and helpers assume that the file system block size must
be larger or equal to the device block size. So doing a max of both
doesn't really make much sense. Siplify the code in iomap_dio_bio_iter
to do a simple if/else.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/iomap/direct-io.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index ce9cbd2bace0..8d094d6f5f3e 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -336,17 +336,19 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
int nr_pages, ret = 0;
u64 copied = 0;
size_t orig_count;
- unsigned int alignment = bdev_logical_block_size(iomap->bdev);
+ unsigned int alignment;
if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1))
return -EINVAL;
/*
- * Align to the larger one of bdev and fs block size, to meet the
- * alignment requirement of both layers.
+ * File systems that write out of place and always allocate new blocks
+ * need each bio to be block aligned as that's the unit of allocation.
*/
if (dio->flags & IOMAP_DIO_FSBLOCK_ALIGNED)
- alignment = max(alignment, fs_block_size);
+ alignment = fs_block_size;
+ else
+ alignment = bdev_logical_block_size(iomap->bdev);
if (dio->flags & IOMAP_DIO_WRITE) {
bio_opf |= REQ_OP_WRITE;
--
2.47.3
next prev parent reply other threads:[~2025-10-23 13:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 13:55 alloc misaligned vectors for zoned XFS Christoph Hellwig
2025-10-23 13:55 ` [PATCH 1/4] iomap: add IOMAP_DIO_FSBLOCK_ALIGNED flag Christoph Hellwig
2025-10-27 16:10 ` Darrick J. Wong
2025-10-27 21:41 ` Qu Wenruo
2025-10-27 21:56 ` Darrick J. Wong
2025-10-29 7:44 ` Christoph Hellwig
2025-10-29 8:00 ` Qu Wenruo
2025-10-29 8:15 ` Christoph Hellwig
2025-10-31 12:40 ` Christian Brauner
2025-10-23 13:55 ` Christoph Hellwig [this message]
2025-10-27 16:11 ` [PATCH 2/4] FIXUP: iomap: aligning to larger than fs block size doesn't make sense Darrick J. Wong
2025-10-23 13:55 ` [PATCH 3/4] FIXUP: iomap: also apply IOMAP_DIO_FSBLOCK_ALIGNED to the iomap range Christoph Hellwig
2025-10-27 16:12 ` Darrick J. Wong
2025-10-23 13:55 ` [PATCH 4/4] xfs: support sub-block aligned vectors in always COW mode Christoph Hellwig
2025-10-27 16:15 ` Darrick J. Wong
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=20251023135559.124072-3-hch@lst.de \
--to=hch@lst.de \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=wqu@suse.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;
as well as URLs for NNTP newsgroup(s).