[PATCH v2 29/31] ocfs2: check chain list dinodes in online filecheck
From: Joseph Qi
Date: Fri Nov 06 2026 - 06:31:30 EST
Wire the chain-list guard and its three sub-checks into the filecheck
validator: cl_count against ocfs2_chain_recs_per_inode(),
cl_next_free_rec against cl_count, and cl_bpc against the cluster to
block size ratio.
The bits-per-cluster predicate keeps the two bitmap_blkno conditions, so
the global bitmap inode itself remains exempt.
Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 1679ed7d09db..6865f0000e6f 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -2165,6 +2165,37 @@ static int ocfs2_filecheck_validate_inode_block(struct super_block *sb,
}
}
+ if (ocfs2_dinode_has_chain_list(di)) {
+ struct ocfs2_chain_list *cl = &di->id2.i_chain;
+
+ if (ocfs2_dinode_has_bad_chain_count(sb, di)) {
+ mlog(ML_ERROR,
+ "Filecheck: invalid dinode #%llu: chain list count %u\n",
+ (unsigned long long)bh->b_blocknr,
+ le16_to_cpu(cl->cl_count));
+ rc = -OCFS2_FILECHECK_ERR_INVALIDINO;
+ goto bail;
+ }
+
+ if (ocfs2_dinode_has_bad_chain_next_free(di)) {
+ mlog(ML_ERROR,
+ "Filecheck: invalid dinode #%llu: chain list index %u\n",
+ (unsigned long long)bh->b_blocknr,
+ le16_to_cpu(cl->cl_next_free_rec));
+ rc = -OCFS2_FILECHECK_ERR_INVALIDINO;
+ goto bail;
+ }
+
+ if (ocfs2_dinode_has_bad_chain_bpc(sb, di)) {
+ mlog(ML_ERROR,
+ "Filecheck: invalid dinode #%llu: bits per cluster %u\n",
+ (unsigned long long)bh->b_blocknr,
+ le16_to_cpu(cl->cl_bpc));
+ rc = -OCFS2_FILECHECK_ERR_INVALIDINO;
+ goto bail;
+ }
+ }
+
bail:
return rc;
}
--
2.39.3