[LTP] [PATCH 2/3] syscalls/statx10: Add basic test for STATX_DIOALIGN

Eric Biggers ebiggers@kernel.org
Fri Mar 31 21:29:07 CEST 2023


On Fri, Mar 31, 2023 at 12:56:47PM +0000, xuyang2018.jy@fujitsu.com wrote:
> > Thanks for writing a test for STATX_DIOALIGN!
> > 
> > However, the above code isn't actually a valid test, since stx_dio_mem_align and
> > stx_dio_offset_align will be 0 if the file doesn't support DIO.  This is
> > documented in the statx(2) manual page. 
> 
>   I have reported TCONF in setup when fail to open a file with O_DIRECT.

Unfortunately that does not work either, as the behavior for when direct I/O is
unsupported is not standardized.  Some filesystems do indeed return -EINVAL for
open(O_DIRECT).  However, others just treat O_DIRECT as a hint and fall back to
buffered I/O.  And some filesystems even implement the former behavior for some
files and the latter behavior for other files...

Note that this was actually one of the motivations for STATX_DIOALIGN.
STATX_DIOALIGN tells you whether direct I/O is "really" supported, as opposed to
being "supported" with a buffered I/O fallback.

> > Filesystems aren't guaranteed to
> > support DIO, if they do, they aren't guaranteed to support it on all files.
> 
> In this case, I only test a regular file.

It is possible that on a single filesystem, direct I/O is supported on some
regular files but not others.  It is also possible that files on the same
filesystem have different direct I/O alignment restrictions.

Likewise, this was part of the motivation for STATX_DIOALIGN.

- Eric


More information about the ltp mailing list