From: Baolin Liu <liubaolin12138@163.com>
To: linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
Baolin Liu <liubaolin@kylinos.cn>
Subject: [PATCH v3 1/6] ntfs: report allocation metadata errors to fsnotify
Date: Thu, 24 Sep 2026 17:00:57 +0800 [thread overview]
Message-ID: <20260924090102.2865942-2-liubaolin12138@163.com> (raw)
In-Reply-To: <20260924090102.2865942-1-liubaolin12138@163.com>
From: Baolin Liu <liubaolin@kylinos.cn>
Cluster allocation and free rollbacks can leave volume metadata
inconsistent without notifying filesystem health monitors.
Add a volume-level helper that records the error and reports it through
fsnotify after mount activation. Report each failed rollback where it
is detected and leave event merging to fanotify.
Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
---
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 716ba775f1f3..827313df0e28 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"
@@ -394,6 +395,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 fdb57279de84..5bcd0dd2a19d 100644
--- a/fs/ntfs/volume.h
+++ b/fs/ntfs/volume.h
@@ -254,6 +254,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
next prev parent reply other threads:[~2026-09-24 9:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 9:00 [PATCH v3 0/6] ntfs: report filesystem errors through fsnotify Baolin Liu
2026-09-24 9:00 ` Baolin Liu [this message]
2026-09-24 9:00 ` [PATCH v3 2/6] ntfs: report attribute errors to fsnotify Baolin Liu
2026-09-24 9:00 ` [PATCH v3 3/6] ntfs: report inode metadata " Baolin Liu
2026-09-24 9:01 ` [PATCH v3 4/6] ntfs: report MFT metadata and recovery " Baolin Liu
2026-09-26 0:36 ` Hyunchul Lee
2026-09-26 12:43 ` liubaolin
2026-09-24 9:01 ` [PATCH v3 5/6] ntfs: report MFT writeback " Baolin Liu
2026-09-24 9:01 ` [PATCH v3 6/6] ntfs: report shutdown " Baolin Liu
2026-09-26 0:40 ` Hyunchul Lee
2026-09-26 12:52 ` liubaolin
2026-09-26 0:33 ` [PATCH v3 0/6] ntfs: report filesystem errors through fsnotify Hyunchul Lee
2026-09-26 13:49 ` liubaolin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924090102.2865942-2-liubaolin12138@163.com \
--to=liubaolin12138@163.com \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liubaolin@kylinos.cn \
--cc=ntfs@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®