linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] revert "iomap: add support for dma aligned direct-io"
@ 2024-06-25  9:38 Chunjie Zhu
  2024-06-25  9:55 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Chunjie Zhu @ 2024-06-25  9:38 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Chunjie Zhu, linux-xfs, linux-fsdevel, linux-kernel

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(-)

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) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 1/1] revert "iomap: add support for dma aligned direct-io"
  2024-06-25  9:38 [PATCH v1 1/1] revert "iomap: add support for dma aligned direct-io" Chunjie Zhu
@ 2024-06-25  9:55 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2024-06-25  9:55 UTC (permalink / raw)
  To: Chunjie Zhu; +Cc: Darrick J. Wong, linux-xfs, linux-fsdevel, linux-kernel

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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-25  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-25  9:38 [PATCH v1 1/1] revert "iomap: add support for dma aligned direct-io" Chunjie Zhu
2024-06-25  9:55 ` Christoph Hellwig

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).