diff mbox series

[v1,1/1] revert "iomap: add support for dma aligned direct-io"

Message ID 20240625093851.73331-1-chunjie.zhu@cloud.com (mailing list archive)
State New
Headers show
Series [v1,1/1] revert "iomap: add support for dma aligned direct-io" | expand

Commit Message

Chunjie Zhu June 25, 2024, 9:38 a.m. UTC
This reverts commit bf8d08532bc19a14cfb54ae61099dccadefca446 as it
causes applications unable to probe a consistent value for direct
io buffer alignment, see an example,

                                 buffer alignment: 512
                                          |
                                         ext3
                                          |
   buffer alignment: 4          lvm (dma_alignment: 511)
           |                              |
          xfs                       device mapper
           |                              |
         sda1                            sda2
           |                              |
           ---  sda (dma_alignment: 3)  ---

Signed-off-by: Chunjie Zhu <chunjie.zhu@cloud.com>
---
 fs/iomap/direct-io.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig June 25, 2024, 9:55 a.m. UTC | #1
On Tue, Jun 25, 2024 at 09:38:51AM +0000, Chunjie Zhu wrote:
> This reverts commit bf8d08532bc19a14cfb54ae61099dccadefca446 as it
> causes applications unable to probe a consistent value for direct
> io buffer alignment, see an example,

The required alignment is available in the stx_dio_mem_align field of
struct statx (and for XFS also through the older XFS_IOC_DIOINFO ioctl).
No need to probe anything.  And if you don't want to use that just use
a conservativ block size alignment, no need to probe anything.
diff mbox series

Patch

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index bcd3f8cf5ea4..448b563a634c 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -277,7 +277,9 @@  static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,
 {
 	const struct iomap *iomap = &iter->iomap;
 	struct inode *inode = iter->inode;
+	unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev));
 	unsigned int fs_block_size = i_blocksize(inode), pad;
+	unsigned int align = iov_iter_alignment(dio->submit.iter);
 	loff_t length = iomap_length(iter);
 	loff_t pos = iter->pos;
 	blk_opf_t bio_opf;
@@ -288,8 +290,7 @@  static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,
 	size_t copied = 0;
 	size_t orig_count;
 
-	if ((pos | length) & (bdev_logical_block_size(iomap->bdev) - 1) ||
-	    !bdev_iter_is_aligned(iomap->bdev, dio->submit.iter))
+	if ((pos | length | align) & ((1 << blkbits) - 1))
 		return -EINVAL;
 
 	if (iomap->type == IOMAP_UNWRITTEN) {