linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 3/4] FIXUP: iomap: also apply IOMAP_DIO_FSBLOCK_ALIGNED to the iomap range
Date: Thu, 23 Oct 2025 15:55:44 +0200	[thread overview]
Message-ID: <20251023135559.124072-4-hch@lst.de> (raw)
In-Reply-To: <20251023135559.124072-1-hch@lst.de>

Not just the bios created by bio_iov_iter_get_pages need to be aligned
to the file system block size when IOMAP_DIO_FSBLOCK_ALIGNED is used,
but also the iomap mapped region.  Use the local alignment variable
for this check as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/iomap/direct-io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 8d094d6f5f3e..13def8418659 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -338,9 +338,6 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
 	size_t orig_count;
 	unsigned int alignment;
 
-	if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1))
-		return -EINVAL;
-
 	/*
 	 * 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.
@@ -350,6 +347,9 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
 	else
 		alignment = bdev_logical_block_size(iomap->bdev);
 
+	if ((pos | length) & (alignment - 1))
+		return -EINVAL;
+
 	if (dio->flags & IOMAP_DIO_WRITE) {
 		bio_opf |= REQ_OP_WRITE;
 
-- 
2.47.3


  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 ` [PATCH 2/4] FIXUP: iomap: aligning to larger than fs block size doesn't make sense Christoph Hellwig
2025-10-27 16:11   ` Darrick J. Wong
2025-10-23 13:55 ` Christoph Hellwig [this message]
2025-10-27 16:12   ` [PATCH 3/4] FIXUP: iomap: also apply IOMAP_DIO_FSBLOCK_ALIGNED to the iomap range 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-4-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).