diff mbox series

[f2fs-dev] f2fs: do not set STATX_DIOALIGN if dio is not supported

Message ID 20240923063732.2730521-1-bo.wu@vivo.com (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs: do not set STATX_DIOALIGN if dio is not supported | expand

Commit Message

Wu Bo Sept. 23, 2024, 6:37 a.m. UTC
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.wu@vivo.com>
---
 fs/f2fs/file.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Eric Biggers Sept. 23, 2024, 7:43 a.m. UTC | #1
On Mon, Sep 23, 2024 at 12:37:32AM -0600, Wu Bo via Linux-f2fs-devel wrote:
> Therefore, if the filesystem does not support DIO, it should not set
> the STATX_DIOALIGN flag.

No, that's incorrect.  STATX_DIOALIGN supports reporting that DIO is
unsupported, via the alignments being 0.  See the statx man page.

- Eric
diff mbox series

Patch

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;