* [PATCH v2] f2fs: avoid false shutdown fserror reports
@ 2026-05-21 10:37 Wenjie Qi
2026-05-22 4:30 ` [f2fs-dev] " patchwork-bot+f2fs
0 siblings, 1 reply; 2+ messages in thread
From: Wenjie Qi @ 2026-05-21 10:37 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: stable, linux-f2fs-devel, linux-kernel, qiwenjie, qwjhust
F2FS records image errors and checkpoint-stop reasons through the same
s_error_work worker. The ordinary f2fs_handle_error() path only updates
s_errors, but the worker still calls fserror_report_shutdown()
unconditionally after committing the superblock.
As a result, a metadata corruption report can be followed by a synthetic
FAN_FS_ERROR event with ESHUTDOWN and an invalid superblock file handle,
even though no stop reason was recorded.
Track whether save_stop_reason() actually changed the stop_reason array
and only report the shutdown fserror for that case. Pure s_errors updates
still commit the superblock, but no longer generate a false shutdown event.
Fixes: 50faed607d32 ("f2fs: support to report fserror")
Cc: stable@kernel.org
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
Changes in v2:
- Add Cc: stable@kernel.org.
- Add Reviewed-by tag from Chao Yu.
fs/f2fs/f2fs.h | 1 +
fs/f2fs/super.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index f0a54883b882..fffb516b78f4 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1990,6 +1990,7 @@ struct f2fs_sb_info {
unsigned char stop_reason[MAX_STOP_REASON]; /* stop reason */
spinlock_t error_lock; /* protect errors/stop_reason array */
bool error_dirty; /* errors of sb is dirty */
+ bool stop_reason_dirty; /* stop reason of sb is dirty */
/* For reclaimed segs statistics per each GC mode */
unsigned int gc_segment_mode; /* GC state for reclaimed segments */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ada8098f8b33..718feb854b18 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -4616,6 +4616,7 @@ static void save_stop_reason(struct f2fs_sb_info *sbi, unsigned char reason)
spin_lock_irqsave(&sbi->error_lock, flags);
if (sbi->stop_reason[reason] < GENMASK(BITS_PER_BYTE - 1, 0))
sbi->stop_reason[reason]++;
+ sbi->stop_reason_dirty = true;
spin_unlock_irqrestore(&sbi->error_lock, flags);
}
@@ -4623,6 +4624,7 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
{
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
unsigned long flags;
+ bool report_shutdown = false;
int err;
f2fs_down_write(&sbi->sb_lock);
@@ -4634,6 +4636,10 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
sbi->error_dirty = false;
}
memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON);
+ if (sbi->stop_reason_dirty) {
+ report_shutdown = true;
+ sbi->stop_reason_dirty = false;
+ }
spin_unlock_irqrestore(&sbi->error_lock, flags);
err = f2fs_commit_super(sbi, false);
@@ -4644,7 +4650,8 @@ static void f2fs_record_stop_reason(struct f2fs_sb_info *sbi)
"f2fs_commit_super fails to record stop_reason, err:%d",
err);
- fserror_report_shutdown(sbi->sb, GFP_NOFS);
+ if (report_shutdown)
+ fserror_report_shutdown(sbi->sb, GFP_NOFS);
}
void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag)
base-commit: 520760b9f9156bf9698de38dc44c614fad68a1f9
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: avoid false shutdown fserror reports
2026-05-21 10:37 [PATCH v2] f2fs: avoid false shutdown fserror reports Wenjie Qi
@ 2026-05-22 4:30 ` patchwork-bot+f2fs
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+f2fs @ 2026-05-22 4:30 UTC (permalink / raw)
To: Wenjie Qi; +Cc: jaegeuk, chao, linux-kernel, qiwenjie, stable, linux-f2fs-devel
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Thu, 21 May 2026 18:37:48 +0800 you wrote:
> F2FS records image errors and checkpoint-stop reasons through the same
> s_error_work worker. The ordinary f2fs_handle_error() path only updates
> s_errors, but the worker still calls fserror_report_shutdown()
> unconditionally after committing the superblock.
>
> As a result, a metadata corruption report can be followed by a synthetic
> FAN_FS_ERROR event with ESHUTDOWN and an invalid superblock file handle,
> even though no stop reason was recorded.
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2] f2fs: avoid false shutdown fserror reports
https://git.kernel.org/jaegeuk/f2fs/c/e10b499e702c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-22 4:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-21 10:37 [PATCH v2] f2fs: avoid false shutdown fserror reports Wenjie Qi
2026-05-22 4:30 ` [f2fs-dev] " patchwork-bot+f2fs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome