From 569f514f0ec74c4162241e10b7893bff109f8aca Mon Sep 17 00:00:00 2001 From: DaeMyung Kang Date: Tue, 13 Oct 2026 23:58:46 +0900 Subject: [PATCH] ntfs: flush the block device when syncing a directory ntfs_dir_fsync() writes directory metadata and calls sync_blockdev(), but does not flush the block device write cache. A successful fsync() can therefore leave the directory's metadata in a volatile device cache. Issue a cache flush after successful writeback and return any flush error. This matches the regular-file fsync and syncfs paths. With QEMU blkdebug injecting -EIO for flush_to_disk, fsync() on an NTFS directory returned 0 before this change while syncfs() returned -EIO. After this change, both return -EIO. A kretprobe confirmed the flush error in the directory fsync path. Fixes: 1e9ea7e04472 ("Revert "fs: Remove NTFS classic"") Cc: stable@vger.kernel.org Signed-off-by: DaeMyung Kang Reviewed-by: Baolin Liu Signed-off-by: Namjae Jeon --- fs/ntfs/dir.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c index 5a0e21e7c283..fce10baa2b93 100644 --- a/fs/ntfs/dir.c +++ b/fs/ntfs/dir.c @@ -1192,6 +1192,8 @@ static int ntfs_dir_fsync(struct file *filp, loff_t start, loff_t end, err = sync_blockdev(vi->i_sb->s_bdev); if (unlikely(err && !ret)) ret = err; + if (!ret) + ret = blkdev_issue_flush(vi->i_sb->s_bdev); if (likely(!ret)) ntfs_debug("Done."); else