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

Heming Zhao heming.zhao at suse.com
Thu Oct 30 05:17:39 MSK 2025


On Thu, Oct 30, 2025 at 07:41:13AM +0530, Deepanshu Kartikey wrote:
> 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)

I prefer 2.

- Heming
> 
> Thanks,
> 
> Deepanshu



More information about the lvc-project mailing list