[PATCH V2] exfat: fdatasync flag should be same like generic_write_sync()

Zhengxu Zhang posted 1 patch 3 months, 3 weeks ago
fs/exfat/file.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
[PATCH V2] exfat: fdatasync flag should be same like generic_write_sync()
Posted by Zhengxu Zhang 3 months, 3 weeks ago
Test: androbench by default setting, use 64GB sdcard.
 the random write speed:
	without this patch 3.5MB/s
	with this patch 7MB/s

After patch "11a347fb6cef", the random write speed decreased significantly.
the .write_iter() interface had been modified, and check the differences with
generic_file_write_iter(), when calling generic_write_sync() and
exfat_file_write_iter() to call vfs_fsync_range(), the fdatasync flag is wrong,
and make not use the fdatasync mode, and make random write speed decreased.

So use generic_write_sync() instead of vfs_fsync_range().

Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength")

Signed-off-by: Zhengxu Zhang <zhengxu.zhang@unisoc.com>
---
 fs/exfat/file.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 841a5b18e3df..7ac5126aa4f1 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -623,9 +623,8 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
 	if (pos > valid_size)
 		pos = valid_size;
 
-	if (iocb_is_dsync(iocb) && iocb->ki_pos > pos) {
-		ssize_t err = vfs_fsync_range(file, pos, iocb->ki_pos - 1,
-				iocb->ki_flags & IOCB_SYNC);
+	if (iocb->ki_pos > pos) {
+		ssize_t err = generic_write_sync(iocb, iocb->ki_pos - pos);
 		if (err < 0)
 			return err;
 	}
-- 
2.25.1
Re: [PATCH V2] exfat: fdatasync flag should be same like generic_write_sync()
Posted by Namjae Jeon 3 months, 2 weeks ago
On Thu, Jun 19, 2025 at 10:34 AM Zhengxu Zhang <zhengxu.zhang@unisoc.com> wrote:
>
> Test: androbench by default setting, use 64GB sdcard.
>  the random write speed:
>         without this patch 3.5MB/s
>         with this patch 7MB/s
>
> After patch "11a347fb6cef", the random write speed decreased significantly.
> the .write_iter() interface had been modified, and check the differences with
> generic_file_write_iter(), when calling generic_write_sync() and
> exfat_file_write_iter() to call vfs_fsync_range(), the fdatasync flag is wrong,
> and make not use the fdatasync mode, and make random write speed decreased.
>
> So use generic_write_sync() instead of vfs_fsync_range().
>
> Fixes: 11a347fb6cef ("exfat: change to get file size from DataLength")
>
> Signed-off-by: Zhengxu Zhang <zhengxu.zhang@unisoc.com>
Applied it to #dev.
Thanks!