From nobody Sun May 24 21:40:16 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3310352C4F for ; Thu, 21 May 2026 10:37:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779359877; cv=none; b=HJmTnmeXN8LeJ4W/U3RlDk5IdZi9vjrvDIKzWDF96tI0GKbew0R424VqYrscGEJj6faa0wgn4Jpu1V4StK9E/2yfph3eW6YpnOiZs4qS8Wr7P3bJ38ZEH4+Mw0jzHcNZshXHjsSjg8aqgBY0cqBWf83leLuZRwHJ5Yg/Dg+OrUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779359877; c=relaxed/simple; bh=XbaR1BiaKs/MY+BQNEu58Xez2zhwBTXIUbPhHVvskTQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NbtV5YrsbA3empB2DHMdKmu6FwdWyzCLIk1HlDqoh0yMAeF/9TbLtDEe7Bv/lSZiqkUSYbw0zJE89DItoa6AjUnyCAcq0Oj4Jzr8rYyQ+YIX05AG2C2c0QBCrkADwDP15bcekPxbQUQBQQl8lkRAXdHaN46BZDsQXBQgbTAab2s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QcoMe/pU; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QcoMe/pU" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-835399c11e0so2727407b3a.0 for ; Thu, 21 May 2026 03:37:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779359875; x=1779964675; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bX9jxgAxFaBc5uY2GbAKfiZoFYnFAq+cwQmmEbrvRP4=; b=QcoMe/pUd6oFjnfAL+7JfSDzIbIdmDRL5sIBGJgK8I/xJlJzpghKZKwBh7Bua1wGM1 dMcbpWh8SCYQ/QgYG9eF6ZjQ9k7tL8ipAZnDQAycpD3klIZu8ZBaHjcROjdwWvFQN1bW ztF6Hm5/Pj1eoJ6ThPuFoZDjWxyXbOHCMCLboFfc2dQTLe5rdyXxf/eBP67pziPUF8Nb TsnXrTGP5M18tzJgPQYtN/eZoFo9G+C2xJMmU/0k8bUtuTlArwFu/UHgte81pPg2E03+ Ezu+vXR2/X4DFkJ0oiDp/GT+T5fyjHSMRpLt9pXiQW1uHJJI2ITejUh+GzxDfpMiFT6+ XYuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779359875; x=1779964675; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bX9jxgAxFaBc5uY2GbAKfiZoFYnFAq+cwQmmEbrvRP4=; b=LP2YQ1JQQPpPG/yhGfe+dL7BJdBWpJ/9FYvbkEBirzOGM21LqfYceCBy5vUpdSQc4f 8J1IbkF1xN97dJdcW/HIzc3PlEYfYXjcYQPq84kNtyCWFIbd1lDXEs11ol6a+5j8NI0p wG6iLxiFoXvK+pUvSAWVZJfQh/EHkESQxd7GSMFXGUUL8gPMHiUH0/B0xSIbZHVnErd+ pibwK6+3mwds/PEgk0wO+F/NP+WGBJ/IgZqaV/BFOdd9WJgU0g/hFkDNxl0S1hSKqI7o s5sMKm2iZRUEeudc1zbK4cCau3DwK061gN3r6NV2dQq8uhNKKxito47UYJ50F4X7swuh o1Ww== X-Forwarded-Encrypted: i=1; AFNElJ/eAZbooRLrXs+3/v03PkRRDIXkqC/OgRZZRAjGmcfS7l7VmEjI3UC3pvjxYFPoZ3V8H7fSt/TI0+PdEOA=@vger.kernel.org X-Gm-Message-State: AOJu0YyaAyqyRT0wlkEDKwUomu9Doeu4dKIUvM2KP5ZT3vHQeVxA3a8Q BvZyMI3GZlEiz0UdkbR7ajhbbJzl7tPQteyV7cGd2wIrEC2M/MNZOqbo X-Gm-Gg: Acq92OED1vYZU+72UQOQmT62crQaIMwybt3TIUOwufkhvUuB54K3S9YCTSzKukCvxPo 4q1fzGUifWLoATSqoNBuJReUcv59D+dNvOwxSLWB/eVjtXUV14eSqAXV3N4FfTfAQRvewhgud2H RlDlAdleuu8fS8OQy2Q6yeqT4Hv/92BKJ7kOUWcZH7ed/qHoZw3S68WvrAnwRF0fREQuBBluXUu ZgJ8lE13Xfhdr05PK1WRrOJ7CSZXOBMrlzUFnWkWoiapDzyZO5epTqjGxaAJ6vzRP+wk+vfQDR/ q4jZR335s6NzOu3pGbll/OMVbGV38BQZrZ9VAQHj2r1p5THynZlRMvqNpl1RryGV2/v0CLR8lHU qnrpYzFYZwIEMcGrs6c3ACykun7eqlt9Tb06NcVvBryQb6Ca06OhI0fNGgnWKrkAtBy4whd/6D5 ObPwqahitVnS1Hxskh01JTphsUACilOkJcUt8YnokD0xM7CnJI7qq6IdYG6gFSPboEEOeONg== X-Received: by 2002:a05:6a00:1885:b0:82d:62ed:b01d with SMTP id d2e1a72fcca58-8414ae57e42mr2514804b3a.45.1779359874799; Thu, 21 May 2026 03:37:54 -0700 (PDT) Received: from qiwenjie-ThinkCentre-M760t.mioffice.cn ([43.224.245.241]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-841549c4b82sm893074b3a.3.2026.05.21.03.37.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2026 03:37:54 -0700 (PDT) From: Wenjie Qi X-Google-Original-From: Wenjie Qi To: jaegeuk@kernel.org, chao@kernel.org Cc: stable@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com, qwjhust@gmail.com Subject: [PATCH v2] f2fs: avoid false shutdown fserror reports Date: Thu, 21 May 2026 18:37:48 +0800 Message-ID: <20260521103748.1954748-1-qiwenjie@xiaomi.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Wenjie Qi --- 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 */ =20 /* 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 =3D true; spin_unlock_irqrestore(&sbi->error_lock, flags); } =20 @@ -4623,6 +4624,7 @@ static void f2fs_record_stop_reason(struct f2fs_sb_in= fo *sbi) { struct f2fs_super_block *raw_super =3D F2FS_RAW_SUPER(sbi); unsigned long flags; + bool report_shutdown =3D false; int err; =20 f2fs_down_write(&sbi->sb_lock); @@ -4634,6 +4636,10 @@ static void f2fs_record_stop_reason(struct f2fs_sb_i= nfo *sbi) sbi->error_dirty =3D false; } memcpy(raw_super->s_stop_reason, sbi->stop_reason, MAX_STOP_REASON); + if (sbi->stop_reason_dirty) { + report_shutdown =3D true; + sbi->stop_reason_dirty =3D false; + } spin_unlock_irqrestore(&sbi->error_lock, flags); =20 err =3D f2fs_commit_super(sbi, false); @@ -4644,7 +4650,8 @@ static void f2fs_record_stop_reason(struct f2fs_sb_in= fo *sbi) "f2fs_commit_super fails to record stop_reason, err:%d", err); =20 - fserror_report_shutdown(sbi->sb, GFP_NOFS); + if (report_shutdown) + fserror_report_shutdown(sbi->sb, GFP_NOFS); } =20 void f2fs_save_errors(struct f2fs_sb_info *sbi, unsigned char flag) base-commit: 520760b9f9156bf9698de38dc44c614fad68a1f9 --=20 2.43.0