[PATCH v2 1/5] ntfs: report allocation metadata errors to fsnotify
From: Baolin Liu
Date: Tue Sep 15 2026 - 22:24:25 EST
From: Baolin Liu <liubaolin@xxxxxxxxxx>
Add a volume-level helper that records metadata failures and notifies
FAN_FS_ERROR listeners after mount activation. Use it for cluster
allocation and free rollbacks that leave volume metadata inconsistent.
Signed-off-by: Baolin Liu <liubaolin@xxxxxxxxxx>
---
fs/ntfs/lcnalloc.c | 4 ++--
fs/ntfs/super.c | 8 ++++++++
fs/ntfs/volume.h | 2 ++
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/fs/ntfs/lcnalloc.c b/fs/ntfs/lcnalloc.c
index 0d6cd08ee2e7..347f9e152588 100644
--- a/fs/ntfs/lcnalloc.c
+++ b/fs/ntfs/lcnalloc.c
@@ -763,7 +763,7 @@ switch_to_data1_zone: search_zone = 2;
ntfs_error(vol->sb,
"Failed to rollback (error %i). Leaving inconsistent metadata! Unmount and run chkdsk.",
err2);
- NVolSetErrors(vol);
+ ntfs_report_metadata_error(vol, err2);
}
/* Free the runlist. */
kvfree(rl);
@@ -1044,7 +1044,7 @@ s64 __ntfs_cluster_free(struct ntfs_inode *ni, const s64 start_vcn, s64 count,
ntfs_error(vol->sb,
"Failed to rollback (error %i). Leaving inconsistent metadata! Unmount and run chkdsk.",
(int)delta);
- NVolSetErrors(vol);
+ ntfs_report_metadata_error(vol, delta);
} else {
ntfs_dec_free_clusters(vol, delta);
}
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index b8bb2268e609..340aad497b88 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"
@@ -337,6 +338,13 @@ const struct option_t on_errors_arr[] = {
{ 0, NULL }
};
+void ntfs_report_metadata_error(struct ntfs_volume *vol, int error)
+{
+ NVolSetErrors(vol);
+ if (vol->sb->s_flags & SB_ACTIVE)
+ fserror_report_metadata(vol->sb, error, 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 8c17a66b4f22..55d08319820e 100644
--- a/fs/ntfs/volume.h
+++ b/fs/ntfs/volume.h
@@ -250,6 +250,8 @@ DEFINE_NVOL_BIT_OPS(DisableSparse)
DEFINE_NVOL_BIT_OPS(NativeSymlinkRel)
DEFINE_NVOL_BIT_OPS(SymlinkNative)
+void ntfs_report_metadata_error(struct ntfs_volume *vol, int error);
+
static inline void ntfs_inc_free_clusters(struct ntfs_volume *vol, s64 nr)
{
if (!NVolFreeClusterKnown(vol))
--
2.51.0