[PATCH 09/30] ocfs2: abstract the inline data dinode guard and cluster check
From: Joseph Qi
Date: Thu Nov 05 2026 - 04:57:40 EST
Introduce ocfs2_dinode_has_inline_data() for the OCFS2_INLINE_DATA_FL
test that selects the id2.i_data union arm, and
ocfs2_dinode_has_inline_clusters() for the rule that an inline-data
inode must not also have allocated clusters.
The guard stays above the sub-checks: reading id_count or i_clusters
against the wrong id2 arm would produce false positives on valid inodes.
No functional change intended.
Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 8c23170bb595..96e4d5c5bfa8 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -154,6 +154,16 @@ static bool ocfs2_dinode_has_size_without_clusters(struct super_block *sb,
return !ocfs2_sparse_alloc(OCFS2_SB(sb)) && S_ISREG(mode);
}
+static bool ocfs2_dinode_has_inline_data(struct ocfs2_dinode *di)
+{
+ return le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL;
+}
+
+static bool ocfs2_dinode_has_inline_clusters(struct ocfs2_dinode *di)
+{
+ return le32_to_cpu(di->i_clusters) != 0;
+}
+
void ocfs2_set_inode_flags(struct inode *inode)
{
unsigned int flags = OCFS2_I(inode)->ip_attr;
@@ -1715,10 +1725,10 @@ int ocfs2_validate_inode_block(struct super_block *sb,
if (rc)
goto bail;
- if (le16_to_cpu(di->i_dyn_features) & OCFS2_INLINE_DATA_FL) {
+ if (ocfs2_dinode_has_inline_data(di)) {
struct ocfs2_inline_data *data = &di->id2.i_data;
- if (le32_to_cpu(di->i_clusters)) {
+ if (ocfs2_dinode_has_inline_clusters(di)) {
rc = ocfs2_error(sb,
"Invalid dinode %llu: %u clusters\n",
(unsigned long long)bh->b_blocknr,
--
2.39.3