According to the definition of statx.stx_mask: It simply informs the caller which values are supported by the kernel and filesystem via the statx.stx_mask field. (quote from the "Linux Programmer's Manual").
Therefore, if the filesystem does not support DIO, it should not set the STATX_DIOALIGN flag. Signed-off-by: Wu Bo <bo...@vivo.com> --- fs/f2fs/file.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 168f08507004..bbb66be0deba 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -908,14 +908,13 @@ int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path, * f2fs sometimes supports DIO reads but not DIO writes. STATX_DIOALIGN * cannot represent that, so in that case we report no DIO support. */ - if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) { + if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode) && + !f2fs_force_buffered_io(inode, WRITE)) { unsigned int bsize = i_blocksize(inode); stat->result_mask |= STATX_DIOALIGN; - if (!f2fs_force_buffered_io(inode, WRITE)) { - stat->dio_mem_align = bsize; - stat->dio_offset_align = bsize; - } + stat->dio_mem_align = bsize; + stat->dio_offset_align = bsize; } flags = fi->i_flags; -- 2.25.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel