From: Darrick J. Wong Date: Sun, 2 Oct 2016 23:40:32 +0000 (+1100) Subject: xfs_repair: fix bogosity when rmapping new AGFL blocks X-Git-Tag: v4.8.0-rc3~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=636f06d882cfc06ffd2933af86a16dec1fc8a59f;p=thirdparty%2Fxfsprogs-dev.git xfs_repair: fix bogosity when rmapping new AGFL blocks 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 Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/repair/rmap.c b/repair/rmap.c index 0baf4ebab..645af311f 100644 --- a/repair/rmap.c +++ b/repair/rmap.c @@ -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 @@ err_slab: err: if (agflbp) libxfs_putbuf(agflbp); - printf("FAIL err %d\n", error); return error; }