[PATCH v2 18/31] ocfs2: abstract the dinode refcount location check

From: Joseph Qi

Date: Fri Nov 06 2026 - 06:28:23 EST


Fold the OCFS2_HAS_REFCOUNT_FL without i_refcount_loc test into a
predicate. The flag test stays inside it, since i_refcount_loc is only
meaningful for a reflink-capable inode.

No functional change intended.

Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 34129e25a6ac..501a11d2b071 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -254,6 +254,12 @@ static bool ocfs2_dinode_has_bad_chain_bpc(struct super_block *sb,
le16_to_cpu(di->id2.i_chain.cl_bpc) != bpc;
}

+static bool ocfs2_dinode_has_refcount_without_loc(struct ocfs2_dinode *di)
+{
+ return (le16_to_cpu(di->i_dyn_features) & OCFS2_HAS_REFCOUNT_FL) &&
+ !di->i_refcount_loc;
+}
+
void ocfs2_set_inode_flags(struct inode *inode)
{
unsigned int flags = OCFS2_I(inode)->ip_attr;
@@ -1891,8 +1897,7 @@ int ocfs2_validate_inode_block(struct super_block *sb,
}
}

- if ((le16_to_cpu(di->i_dyn_features) & OCFS2_HAS_REFCOUNT_FL) &&
- !di->i_refcount_loc) {
+ if (ocfs2_dinode_has_refcount_without_loc(di)) {
rc = ocfs2_error(sb, "Inode #%llu has refcount flag but no i_refcount_loc\n",
(unsigned long long)bh->b_blocknr);
goto bail;
--
2.39.3