@@ -505,10 +505,18 @@ rmap_store_ag_btree_rec(
if (error)
goto err;
+ /*
+ * Sometimes, the blocks at the beginning of the AGFL are there
+ * because we overestimated how many blocks we needed to rebuild
+ * the freespace btrees. ar_flcount records the number of
+ * blocks in this situation. Since those blocks already have an
+ * rmap, we only need to add rmap records for AGFL blocks past
+ * that point in the AGFL because those blocks are a result of a
+ * no-rmap no-shrink freelist fixup that we did earlier.
+ */
agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, agflbp);
- agfl_bno += ag_rmaps[agno].ar_flcount;
- b = agfl_bno;
- while (*b != NULLAGBLOCK && b - agfl_bno <= XFS_AGFL_SIZE(mp)) {
+ b = agfl_bno + ag_rmaps[agno].ar_flcount;
+ while (*b != NULLAGBLOCK && b - agfl_bno < XFS_AGFL_SIZE(mp)) {
error = rmap_add_ag_rec(mp, agno, be32_to_cpu(*b), 1,
XFS_RMAP_OWN_AG);
if (error)
@@ -566,7 +574,6 @@ rmap_store_ag_btree_rec(
err:
if (agflbp)
libxfs_putbuf(agflbp);
- printf("FAIL err %d\n", error);
return error;
}
When repair rebuilds the AGFL, the blocks can come either from the in-core free space tree or they can come as a result of overestimating the number of blocks needed to rebuild the on-disk free space btree. The code in here was trying to only create rmap records for AGFL blocks that did /not/ come from free space btree rebuild overestimation, but was totally broken. The initial and check conditions were totally wrong if there was any overflow. Remove a stray debug printf too. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> --- repair/rmap.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html