mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 0/2] ntfs: report filesystem errors to fsnotify
@ 2026-08-26 12:27 Baolin Liu
  2026-08-26 12:27 ` [PATCH v1 1/2] ntfs: report volume " Baolin Liu
  2026-08-26 12:27 ` [PATCH v1 2/2] ntfs: report forced shutdown " Baolin Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Baolin Liu @ 2026-08-26 12:27 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, liubaolin12138, Baolin Liu

From: Baolin Liu <liubaolin@kylinos.cn>

The ntfs driver reports volume errors only to dmesg. These two patches
wire up the generic fserror infrastructure so that health monitoring
daemons watching a mount with fanotify(FAN_FS_ERROR) also learn about
them.

Both hook the flag-setting helpers rather than individual call sites,
so no callers change: NVolSetErrors() for metadata corruption, and
NVolSetShutdown() for forced shutdown, which also covers the
->shutdown super_operation.

Follow-up work, if this direction is acceptable: reporting corrupt
inodes with fserror_report_file_metadata() so that events carry a
useful FID.

Baolin Liu (2):
  ntfs: report volume errors to fsnotify
  ntfs: report forced shutdown to fsnotify

 fs/ntfs/super.c  | 15 +++++++++++++++
 fs/ntfs/volume.h | 29 +++++++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 1/2] ntfs: report volume errors to fsnotify
  2026-08-26 12:27 [PATCH v1 0/2] ntfs: report filesystem errors to fsnotify Baolin Liu
@ 2026-08-26 12:27 ` Baolin Liu
  2026-08-31  6:38   ` Hyunchul Lee
  2026-08-26 12:27 ` [PATCH v1 2/2] ntfs: report forced shutdown " Baolin Liu
  1 sibling, 1 reply; 5+ messages in thread
From: Baolin Liu @ 2026-08-26 12:27 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, liubaolin12138, Baolin Liu

From: Baolin Liu <liubaolin@kylinos.cn>

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@kylinos.cn>
---
 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 2/2] ntfs: report forced shutdown to fsnotify
  2026-08-26 12:27 [PATCH v1 0/2] ntfs: report filesystem errors to fsnotify Baolin Liu
  2026-08-26 12:27 ` [PATCH v1 1/2] ntfs: report volume " Baolin Liu
@ 2026-08-26 12:27 ` Baolin Liu
  1 sibling, 0 replies; 5+ messages in thread
From: Baolin Liu @ 2026-08-26 12:27 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, liubaolin12138, Baolin Liu

From: Baolin Liu <liubaolin@kylinos.cn>

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@kylinos.cn>
---
 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/2] ntfs: report volume errors to fsnotify
  2026-08-26 12:27 ` [PATCH v1 1/2] ntfs: report volume " Baolin Liu
@ 2026-08-31  6:38   ` Hyunchul Lee
  2026-09-01  9:48     ` liubaolin
  0 siblings, 1 reply; 5+ messages in thread
From: Hyunchul Lee @ 2026-08-31  6:38 UTC (permalink / raw)
  To: Baolin Liu; +Cc: linkinjeon, ntfs, linux-kernel, liubaolin12138, Baolin Liu

Hi Baolin,

2026년 8월 26일 (수) 오후 9:28, Baolin Liu <liubaolin12138@163.com>님이 작성:
>
> From: Baolin Liu <liubaolin@kylinos.cn>
>
> 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@kylinos.cn>
> ---
>  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().

-- 
Thanks,
Hyunchul

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/2] ntfs: report volume errors to fsnotify
  2026-08-31  6:38   ` Hyunchul Lee
@ 2026-09-01  9:48     ` liubaolin
  0 siblings, 0 replies; 5+ messages in thread
From: liubaolin @ 2026-09-01  9:48 UTC (permalink / raw)
  To: Hyunchul Lee; +Cc: linkinjeon, ntfs, linux-kernel, liubaolin12138, Baolin Liu



在 2026/8/31 14:38, Hyunchul Lee 写道:
> Hi Baolin,
> 
> 2026년 8월 26일 (수) 오후 9:28, Baolin Liu <liubaolin12138@163.com>님이 작성:
>>
>> From: Baolin Liu <liubaolin@kylinos.cn>
>>
>> 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@kylinos.cn>
>> ---
>>   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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-01  9:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-26 12:27 [PATCH v1 0/2] ntfs: report filesystem errors to fsnotify Baolin Liu
2026-08-26 12:27 ` [PATCH v1 1/2] ntfs: report volume " Baolin Liu
2026-08-31  6:38   ` Hyunchul Lee
2026-09-01  9:48     ` liubaolin
2026-08-26 12:27 ` [PATCH v1 2/2] ntfs: report forced shutdown " Baolin Liu

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®