xfs_repair: add per-AG btree blocks to rmap data and add to rmapbt
Since we can't know the location of the new per-AG btree blocks prior
to constructing the rmapbt, we must record raw reverse-mapping data for
btree blocks while the new btrees are under construction. After the
rmapbt has been rebuilt, merge the btree rmap entries into the rmapbt
with the libxfs code.
Also refactor the freelist fixing code since we need it to tidy up
the AGFL after each rmapbt allocation.
Use libxfs_rmap_alloc to add rmap records for AG metadata blocks
because it knows how to merge adjacent rmaps. This particular bug was
discovered while running xfs_repair twice on generic/175 wherein block
X was originally allocated to the rmapbt, then X+1 got allocated to
the rmapbt when we expanded it to hold all the entries for the rmapbt
blocks.
[dchinner: libxfs'ify the libxfs calls.]
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>