]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: fix bogosity when rmapping new AGFL blocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Sun, 2 Oct 2016 23:40:32 +0000 (10:40 +1100)
committerDave Chinner <david@fromorbit.com>
Sun, 2 Oct 2016 23:40:32 +0000 (10:40 +1100)
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>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
repair/rmap.c

index 0baf4ebab6a3dfd7e48556b35c47d50e04128f1f..645af311f8a2eae700bda25b613873c75c59b5e4 100644 (file)
@@ -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;
 }