[PATCH 21/30] ocfs2: report unrepairable corruption from online filecheck fix

From: Joseph Qi

Date: Thu Nov 05 2026 - 04:52:28 EST


ocfs2_filecheck_repair_inode_block() starts with

if (!ocfs2_filecheck_validate_inode_block(sb, bh))
return 0;

so it proceeds when validation fails, but then returns 0 unconditionally
after repairing only i_blkno, fs_generation and l_next_free_rec. An
inode that fails any other check passes the signature and OCFS2_VALID_FL
gates, leaves changed at 0, and since its ecc was valid the final
recompute is skipped too. Nothing is written and userspace is told
SUCCESS for an inode that is still corrupt.

This already happens for the mode, i_rdev and size-without-clusters
checks. Re-validate after the repairs and return the residual code, so
the fix interface reports what it could not fix.
Documentation/filesystems/ocfs2-online-filecheck.rst already describes
this: "the inode must first be checked for errors before performing a
final fix".

Three consequences worth noting:

- Inodes failing those three existing checks now report INVALIDINO
instead of SUCCESS. No new error code is introduced, so the
ocfs2_filecheck_errs[] table and its userspace-visible names are
unchanged.

- A partial repair still marks the buffer dirty and is written back even
when an error is returned. The fields that were fixed are real
improvements and are not rolled back.

- The revalidation runs ocfs2_validate_meta_ecc() a second time, which
increments osb_ecc_stats again and emits a second
ocfs2_filecheck_validate_inode_block trace event per fix request.

Fixes: d56a8f32e4c6 ("ocfs2: check/fix inode block for online file check")
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 115aad1b8926..cfa545981310 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -2122,7 +2122,11 @@ static int ocfs2_filecheck_repair_inode_block(struct super_block *sb,
(unsigned long long)bh->b_blocknr);
}

- return 0;
+ /*
+ * Only i_blkno, fs_generation and l_next_free_rec are repairable here,
+ * so report whatever is still wrong instead of claiming success.
+ */
+ return ocfs2_filecheck_validate_inode_block(sb, bh);
}

static int
--
2.39.3