On Wed, Feb 28, 2024 at 02:08:51PM -0800, Christoph Hellwig wrote: > On Wed, Feb 28, 2024 at 11:55:32AM -0800, Darrick J. Wong wrote: > > static inline bool > > xmi_can_merge_all( > > const struct xfs_bmbt_irec *l, > > const struct xfs_bmbt_irec *m, > > const struct xfs_bmbt_irec *r) > > { > > xfs_filblks_t new_len; > > > > new_len = l->br_blockcount + m->br_blockcount + r->br_blockcount; > > return new_len <= XFS_MAX_BMBT_EXTLEN; > > } > > Dumb question: can the addition overflow? No. Both callsites of xmi_can_merge_all trigger only if both LEFT_CONTIG and RIGHT_CONTIG have been set. Both of thse _CONTIG flags are set only if xmi_can_merge returned true, which it only does for real mappings. Real mappings are derived from ondisk bmbt mappings, which means they won't be larger than 2^21 blocks in length. Therefore, [lmr]->br_blockcount each can only be up to 2^21, and adding them all together only requires 23 bits. The u64 here is overkill, but it matches xfs_bmbt_irec.br_blockcount. --D