[PATCH 06/30] ocfs2: abstract the dinode suballoc bit check

From: Joseph Qi

Date: Thu Nov 05 2026 - 04:53:15 EST


Fold the i_suballoc_bit against ocfs2_suballoc_bits_per_block() test into
a predicate. The rationale comment stays at the call site, next to the
error it explains.

No functional change intended.

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

diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 412c8149d306..89970378daf4 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -101,6 +101,12 @@ static bool ocfs2_dinode_has_out_of_range_suballoc_slot(struct super_block *sb,
(u32)le16_to_cpu(di->i_suballoc_slot) > OCFS2_SB(sb)->max_slots - 1;
}

+static bool ocfs2_dinode_has_bad_suballoc_bit(struct super_block *sb,
+ struct ocfs2_dinode *di)
+{
+ return le16_to_cpu(di->i_suballoc_bit) >= ocfs2_suballoc_bits_per_block(sb);
+}
+
static bool ocfs2_valid_inode_mode(umode_t mode)
{
return fs_umode_to_ftype(mode) != FT_UNKNOWN;
@@ -1590,7 +1596,7 @@ int ocfs2_validate_inode_block(struct super_block *sb,
* BUG_ON((count + start_bit) > ocfs2_bits_per_group(cl)), since any
* group holds at most ocfs2_suballoc_bits_per_block() bits.
*/
- if (le16_to_cpu(di->i_suballoc_bit) >= ocfs2_suballoc_bits_per_block(sb)) {
+ if (ocfs2_dinode_has_bad_suballoc_bit(sb, di)) {
rc = ocfs2_error(sb, "Invalid dinode %llu: suballoc bit %u\n",
(unsigned long long)bh->b_blocknr,
le16_to_cpu(di->i_suballoc_bit));
--
2.39.3