[PATCH 14/30] ocfs2: abstract the chain list dinode guard and count check
From: Joseph Qi
Date: Thu Nov 05 2026 - 04:55:02 EST
Introduce ocfs2_dinode_has_chain_list() for the OCFS2_CHAIN_FL test that
selects the id2.i_chain union arm, and ocfs2_dinode_has_bad_chain_count()
for the cl_count against ocfs2_chain_recs_per_inode() test.
This mirrors the guard predicates already used for the inline-data and
fast symlink groups, and ocfs2_dinode_has_extents() for the extent list
group.
No functional change intended.
Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 9cf2541b82ba..f3ee6491c141 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -216,6 +216,18 @@ static bool ocfs2_dinode_has_unterminated_fast_symlink(struct super_block *sb,
return strnlen((char *)di->id2.i_symlink, i_size + 1) != i_size;
}
+static bool ocfs2_dinode_has_chain_list(struct ocfs2_dinode *di)
+{
+ return le32_to_cpu(di->i_flags) & OCFS2_CHAIN_FL;
+}
+
+static bool ocfs2_dinode_has_bad_chain_count(struct super_block *sb,
+ struct ocfs2_dinode *di)
+{
+ return le16_to_cpu(di->id2.i_chain.cl_count) !=
+ ocfs2_chain_recs_per_inode(sb);
+}
+
void ocfs2_set_inode_flags(struct inode *inode)
{
unsigned int flags = OCFS2_I(inode)->ip_attr;
@@ -1829,12 +1841,12 @@ int ocfs2_validate_inode_block(struct super_block *sb,
}
}
- if (le32_to_cpu(di->i_flags) & OCFS2_CHAIN_FL) {
+ if (ocfs2_dinode_has_chain_list(di)) {
struct ocfs2_chain_list *cl = &di->id2.i_chain;
u16 bpc = 1 << (OCFS2_SB(sb)->s_clustersize_bits -
sb->s_blocksize_bits);
- if (le16_to_cpu(cl->cl_count) != ocfs2_chain_recs_per_inode(sb)) {
+ if (ocfs2_dinode_has_bad_chain_count(sb, di)) {
rc = ocfs2_error(sb, "Invalid dinode %llu: chain list count %u\n",
(unsigned long long)bh->b_blocknr,
le16_to_cpu(cl->cl_count));
--
2.39.3