* [PATCH 0/2] ntfs: handle block device cache flush in fsync paths
@ 2026-10-13 14:58 DaeMyung Kang
2026-10-13 14:58 ` [PATCH 1/2] ntfs: report block device flush failures from fsync DaeMyung Kang
2026-10-13 14:58 ` [PATCH 2/2] ntfs: flush the block device when syncing a directory DaeMyung Kang
0 siblings, 2 replies; 3+ messages in thread
From: DaeMyung Kang @ 2026-10-13 14:58 UTC (permalink / raw)
To: Namjae Jeon, Hyunchul Lee; +Cc: ntfs, linux-kernel, DaeMyung Kang
Regular-file fsync currently ignores a block device cache flush failure,
while directory fsync never issues a cache flush. Both can report success
without ensuring that the data and metadata reached stable storage.
The first patch returns and logs flush failures from regular-file fsync.
The second adds a flush to directory fsync and reports its failure. The
syncfs path already handles flush errors.
QEMU blkdebug injected -EIO for flush_to_disk on ntfs-next at
04fb910da2c8. Before these changes, both file and directory fsync
returned success while syncfs returned -EIO. With the respective fixes,
both fsync calls return -EIO. A kretprobe confirmed the flush failures.
DaeMyung Kang (2):
ntfs: report block device flush failures from fsync
ntfs: flush the block device when syncing a directory
fs/ntfs/dir.c | 2 ++
fs/ntfs/file.c | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
base-commit: 04fb910da2c857cdf99a331c576c3e5e7197c6dd
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] ntfs: report block device flush failures from fsync
2026-10-13 14:58 [PATCH 0/2] ntfs: handle block device cache flush in fsync paths DaeMyung Kang
@ 2026-10-13 14:58 ` DaeMyung Kang
2026-10-13 14:58 ` [PATCH 2/2] ntfs: flush the block device when syncing a directory DaeMyung Kang
1 sibling, 0 replies; 3+ messages in thread
From: DaeMyung Kang @ 2026-10-13 14:58 UTC (permalink / raw)
To: Namjae Jeon, Hyunchul Lee; +Cc: ntfs, linux-kernel, DaeMyung Kang, stable
ntfs_file_fsync() calls blkdev_issue_flush() after writeback but discards
its return value. If the device cannot flush its write cache, fsync()
reports success even though the file is not guaranteed to be durable.
Reproduce this with QEMU blkdebug failing flush_to_disk with -EIO.
On ntfs-next at 04fb910da2c8, a kretprobe recorded -EIO from
blkdev_issue_flush() while fsync() returned 0. With this change,
fsync() returns -EIO and logs the failure. The syncfs() path already
reports this error.
Fixes: 9c87959601e8 ("ntfs: update file operations")
Cc: stable@vger.kernel.org
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
---
fs/ntfs/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 58afd310d57b..afc2efb4b699 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -417,14 +417,14 @@ int ntfs_file_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
ntfs_warning(vi->i_sb,
"Failed to f%ssync inode 0x%llx. Error %u.",
datasync ? "data" : "", ni->mft_no, -ret);
- if (!ret)
- blkdev_issue_flush(vi->i_sb->s_bdev);
return ret;
}
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] ntfs: flush the block device when syncing a directory
2026-10-13 14:58 [PATCH 0/2] ntfs: handle block device cache flush in fsync paths DaeMyung Kang
2026-10-13 14:58 ` [PATCH 1/2] ntfs: report block device flush failures from fsync DaeMyung Kang
@ 2026-10-13 14:58 ` DaeMyung Kang
1 sibling, 0 replies; 3+ messages in thread
From: DaeMyung Kang @ 2026-10-13 14:58 UTC (permalink / raw)
To: Namjae Jeon, Hyunchul Lee; +Cc: ntfs, linux-kernel, DaeMyung Kang, stable
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 <charsyam@gmail.com>
---
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
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-13 14:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-13 14:58 [PATCH 0/2] ntfs: handle block device cache flush in fsync paths DaeMyung Kang
2026-10-13 14:58 ` [PATCH 1/2] ntfs: report block device flush failures from fsync DaeMyung Kang
2026-10-13 14:58 ` [PATCH 2/2] ntfs: flush the block device when syncing a directory DaeMyung Kang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®