[lvc-project] [PATCH 2/2] ocfs2: validate cl_bpc in allocator inodes to prevent divide-by-zero

Deepanshu Kartikey kartikey406 at gmail.com
Thu Oct 30 05:11:13 MSK 2025


Hi Heming,

Thank you for the detailed explanation! I understand the issue now.

cl_bpc stores "bits per cluster" (the log2 of cluster size in bytes),
not "blocks per cluster".

The bug in the validation code is: u16 bpc = 1 <<
(OCFS2_SB(sb)->s_clustersize_bits - sb->s_blocksize_bits);

This calculates "blocks per cluster" (e.g., 4 for 4KB clusters with
1KB blocks), but cl_bpc on disk stores "bits" (e.g., 12 for 4KB
clusters).

The correct validation should be: if (le16_to_cpu(cl->cl_bpc) !=
OCFS2_SB(sb)->s_clustersize_bits)

Since cl_bpc should directly equal s_clustersize_bits.

I'll send a v4 patch with this fix. Should I:

1. Send it as a standalone patch, or
2. Work with Dmitry to update the combined series? (Dmitry : Please advice)

Thanks,

Deepanshu



More information about the lvc-project mailing list