xfs: create agblock bitmap helper to count the number of set regions
authorDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:43:37 +0000 (12:43 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 22 Feb 2024 20:43:37 +0000 (12:43 -0800)
commite4fd1def30987bbf0fb00867d22cc2634b8dacf0
treee05b6828572d7d27ccb334288e53b2242d5284cd
parent5049ff4d140c8f6545464811409302cab017321a
xfs: create agblock bitmap helper to count the number of set regions

In the next patch, the rmap btree repair code will need to estimate the
size of the new ondisk rmapbt.  The size is a function of the number of
records that will be written to disk, and the size of the recordset is
the number of observations made while scanning the filesystem plus the
number of OWN_AG records that will be injected into the rmap btree.

OWN_AG rmap records track the free space btrees, the AGFL, and the new
rmap btree itself.  The repair tool uses a bitmap to record the space
used for all four structures, which is why we need a function to count
the number of set regions.

A reviewer requested that this be pulled into a separate patch with its
own justification, so here it is.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/agb_bitmap.h
fs/xfs/scrub/bitmap.c
fs/xfs/scrub/bitmap.h