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

From: Baolin Liu

Date: Wed Aug 26 2026 - 08:32:03 EST


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);
+}
+
void ntfs_handle_error(struct super_block *sb)
{
struct ntfs_volume *vol = NTFS_SB(sb);
diff --git a/fs/ntfs/volume.h b/fs/ntfs/volume.h
index 65fd3908af26..cf1a75066157 100644
--- a/fs/ntfs/volume.h
+++ b/fs/ntfs/volume.h
@@ -218,7 +218,19 @@ static inline void NVolClear##flag(struct ntfs_volume *vol) \
}

/* Emit the ntfs volume bitops functions. */
-DEFINE_NVOL_BIT_OPS(Errors)
+static inline int NVolErrors(struct ntfs_volume *vol)
+{
+ return test_bit(NV_Errors, &vol->flags);
+}
+
+/* Out of line, it also reports the corruption to fsnotify. */
+void NVolSetErrors(struct ntfs_volume *vol);
+
+static inline void NVolClearErrors(struct ntfs_volume *vol)
+{
+ clear_bit(NV_Errors, &vol->flags);
+}
+
DEFINE_NVOL_BIT_OPS(ShowSystemFiles)
DEFINE_NVOL_BIT_OPS(CaseSensitive)
DEFINE_NVOL_BIT_OPS(LogFileEmpty)
--
2.51.0