Re: [PATCH v1 1/2] ntfs: report volume errors to fsnotify

From: liubaolin

Date: Tue Sep 01 2026 - 06:21:51 EST




在 2026/8/31 14:38, Hyunchul Lee 写道:
Hi Baolin,

2026년 8월 26일 (수) 오후 9:28, Baolin Liu <liubaolin12138@xxxxxxx>님이 작성:

From: Baolin Liu <liubaolin@xxxxxxxxxx>

The ntfs driver reports volume corruption only to dmesg. Wire up the
generic fserror infrastructure at NVolSetErrors(), the point where the
driver concludes the volume metadata is inconsistent, so that an
FS_ERROR event is emitted as well. This lets health monitoring daemons
watching the mount with fanotify(FAN_FS_ERROR) learn about corruption
without scraping kernel logs.

Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
fs/ntfs/super.c | 8 ++++++++
fs/ntfs/volume.h | 14 +++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index cd8fa2c13370..5229eb27bb30 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -14,6 +14,7 @@
#include <linux/sched/mm.h>
#include <linux/fs_context.h>
#include <linux/fs_parser.h>
+#include <linux/fserror.h>

#include "sysctl.h"
#include "logfile.h"
@@ -330,6 +331,13 @@ const struct option_t on_errors_arr[] = {
{ 0, NULL }
};

+/* Mark the volume as corrupt and notify fanotify(FAN_FS_ERROR) listeners. */
+void NVolSetErrors(struct ntfs_volume *vol)
+{
+ set_bit(NV_Errors, &vol->flags);
+ fserror_report_metadata(vol->sb, -EFSCORRUPTED, GFP_ATOMIC);
+}

NVolSetErrors() is also reached when some functions
return -EIO. Could you preserve the original errno?

And in some situations, fserror_report_file_metadata()
can be useful instead of fserror_report_metadata().


Hi Hyunchul,

You are right, reporting -EFSCORRUPTED unconditionally loses that
distinction - a media failure and genuine metadata corruption should not look the same to a listener.
Agreed on fserror_report_file_metadata() too, several call sites do have the inode at hand.

I will rework the implementation along both lines and send a v2.
Thanks for the review.

Thanks,
Baolin