[PATCH v3 09/31] ocfs2: abstract the dinode DIO orphaned slot check
From: Joseph Qi
Date: Mon Nov 09 2026 - 07:25:36 EST
Fold the OCFS2_DIO_ORPHANED_FL guarded i_dio_orphaned_slot range test
into a predicate, mirroring the orphaned slot one. The flag test stays
inside it for the same reason: the slot field is only meaningful while
the inode is DIO orphaned.
No functional change intended.
Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index fd9613a95802..17d546a9245d 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -124,6 +124,13 @@ static bool ocfs2_dinode_has_bad_orphaned_slot(struct super_block *sb,
le16_to_cpu(di->i_orphaned_slot) >= OCFS2_SB(sb)->max_slots;
}
+static bool ocfs2_dinode_has_bad_dio_orphaned_slot(struct super_block *sb,
+ struct ocfs2_dinode *di)
+{
+ return (le32_to_cpu(di->i_flags) & OCFS2_DIO_ORPHANED_FL) &&
+ le16_to_cpu(di->i_dio_orphaned_slot) >= OCFS2_SB(sb)->max_slots;
+}
+
static bool ocfs2_valid_inode_mode(umode_t mode)
{
return fs_umode_to_ftype(mode) != FT_UNKNOWN;
@@ -1628,8 +1635,7 @@ int ocfs2_validate_inode_block(struct super_block *sb,
goto bail;
}
- if ((le32_to_cpu(di->i_flags) & OCFS2_DIO_ORPHANED_FL) &&
- le16_to_cpu(di->i_dio_orphaned_slot) >= OCFS2_SB(sb)->max_slots) {
+ if (ocfs2_dinode_has_bad_dio_orphaned_slot(sb, di)) {
rc = ocfs2_error(sb, "Invalid dinode %llu: DIO orphaned slot %u\n",
(unsigned long long)bh->b_blocknr,
le16_to_cpu(di->i_dio_orphaned_slot));
--
2.39.3