[PATCH 18/30] ocfs2: abstract the zero extent list count check
From: Joseph Qi
Date: Thu Nov 05 2026 - 04:58:23 EST
Fold the l_count == 0 test into a predicate, the first of the extent list
group guarded by ocfs2_dinode_has_extents().
No functional change intended.
Signed-off-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index b4ef4077e09c..70fb032ce891 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -250,6 +250,11 @@ static bool ocfs2_dinode_has_refcount_without_loc(struct ocfs2_dinode *di)
!di->i_refcount_loc;
}
+static bool ocfs2_dinode_has_zero_extent_count(struct ocfs2_dinode *di)
+{
+ return le16_to_cpu(di->id2.i_list.l_count) == 0;
+}
+
void ocfs2_set_inode_flags(struct inode *inode)
{
unsigned int flags = OCFS2_I(inode)->ip_attr;
@@ -1897,7 +1902,7 @@ int ocfs2_validate_inode_block(struct super_block *sb,
u16 count = le16_to_cpu(el->l_count);
u16 next_free = le16_to_cpu(el->l_next_free_rec);
- if (count == 0) {
+ if (ocfs2_dinode_has_zero_extent_count(di)) {
rc = ocfs2_error(sb,
"Invalid dinode %llu: extent list l_count is zero\n",
(unsigned long long)bh->b_blocknr);
--
2.39.3