Re: [PATCH 2/2] ntfs: flush the block device when syncing a directory

From: liubaolin

Date: Tue Oct 13 2026 - 19:25:46 EST




在 2026/10/13 22:58, DaeMyung Kang 写道:
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@xxxxxxxxxxxxxxx
Signed-off-by: DaeMyung Kang <charsyam@xxxxxxxxx>
---
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


Looks good to me.

Reviewed-by: Baolin Liu <liubaolin@xxxxxxxxxx>