[PATCH v1 2/2] ntfs: report forced shutdown to fsnotify

From: Baolin Liu

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


From: Baolin Liu <liubaolin@xxxxxxxxxx>

Wire up fserror_report_shutdown() at NVolSetShutdown(), so that
shutting a volume down also emits an FS_ERROR event. This covers the
FS_IOC_SHUTDOWN ioctl as well as the ->shutdown super_operation, which
the VFS calls when the backing device is marked dead.

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

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 5229eb27bb30..c61992506845 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -338,6 +338,13 @@ void NVolSetErrors(struct ntfs_volume *vol)
fserror_report_metadata(vol->sb, -EFSCORRUPTED, GFP_ATOMIC);
}

+/* Shut the volume down and notify fanotify(FAN_FS_ERROR) listeners. */
+void NVolSetShutdown(struct ntfs_volume *vol)
+{
+ set_bit(NV_Shutdown, &vol->flags);
+ fserror_report_shutdown(vol->sb, 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 cf1a75066157..fac7e90dbfa6 100644
--- a/fs/ntfs/volume.h
+++ b/fs/ntfs/volume.h
@@ -238,7 +238,20 @@ DEFINE_NVOL_BIT_OPS(UsnJrnlStamped)
DEFINE_NVOL_BIT_OPS(ReadOnly)
DEFINE_NVOL_BIT_OPS(Compression)
DEFINE_NVOL_BIT_OPS(FreeClusterKnown)
-DEFINE_NVOL_BIT_OPS(Shutdown)
+
+static inline int NVolShutdown(struct ntfs_volume *vol)
+{
+ return test_bit(NV_Shutdown, &vol->flags);
+}
+
+/* Out of line, it also reports the shutdown to fsnotify. */
+void NVolSetShutdown(struct ntfs_volume *vol);
+
+static inline void NVolClearShutdown(struct ntfs_volume *vol)
+{
+ clear_bit(NV_Shutdown, &vol->flags);
+}
+
DEFINE_NVOL_BIT_OPS(SysImmutable)
DEFINE_NVOL_BIT_OPS(ShowHiddenFiles)
DEFINE_NVOL_BIT_OPS(HideDotFiles)
--
2.51.0