Re: [PATCH v2] xfs: zero newly allocated btree root space

From: Darrick J. Wong

Date: Wed Jul 01 2026 - 11:52:43 EST


On Wed, Jul 01, 2026 at 03:56:17AM -0700, Christoph Hellwig wrote:
> On Tue, Jun 30, 2026 at 01:39:35PM -0700, Yousef Alhouseen wrote:
> > Yes. The KMSAN report traces the allocation through
> > xfs_bmap_extents_to_btree(), which calls xfs_bmap_broot_realloc(...,
> > 1). With no existing root, that reaches krealloc(NULL, new_size). The
> > conversion initializes the block header, first key, and end-anchored
> > pointer, but does not initialize the layout/alignment gap within the
> > full if_broot_bytes allocation. XFS_ILOG_DBROOT later copies that
> > complete byte count into the log.
> >
> > So the observed bytes are root-layout slack from the extents-to-btree
> > conversion, rather than record storage that a later insertion should
> > have filled.
>
> This almost sounds like we should explicitly zero this case just for that
> particular case. Although Darrick was kinda heading in a different
> direction and I don't want to start a fight here.

I'm fine with either solution; I simply prefer the one that fixes all
the current and future "oops we forgot to zero a hidden padding" bugs in
one action.

Carlos? :D

--D