]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: add inode bmbt block rmaps
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 19 Aug 2016 00:10:15 +0000 (10:10 +1000)
committerDave Chinner <david@fromorbit.com>
Fri, 19 Aug 2016 00:10:15 +0000 (10:10 +1000)
Record BMBT blocks in the raw rmap list.

[dchinner: remove unused lastowner/lastoffset variables from scan.c]

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
repair/rmap.h
repair/scan.c

index 18517424527379ede832f18fd13f3acf0f44bebc..e30e99b3561782c80ee8c6fc414fa610b1d3ca83 100644 (file)
@@ -229,6 +229,32 @@ __add_raw_rmap(
        return slab_add(ag_rmaps[agno].ar_raw_rmaps, &rmap);
 }
 
+/*
+ * Add a reverse mapping for an inode fork's block mapping btree block.
+ */
+int
+add_bmbt_rmap(
+       struct xfs_mount        *mp,
+       xfs_ino_t               ino,
+       int                     whichfork,
+       xfs_fsblock_t           fsbno)
+{
+       xfs_agnumber_t          agno;
+       xfs_agblock_t           agbno;
+
+       if (!needs_rmap_work(mp))
+               return 0;
+
+       agno = XFS_FSB_TO_AGNO(mp, fsbno);
+       agbno = XFS_FSB_TO_AGBNO(mp, fsbno);
+       ASSERT(agno != NULLAGNUMBER);
+       ASSERT(agno < mp->m_sb.sb_agcount);
+       ASSERT(agbno + 1 <= mp->m_sb.sb_agblocks);
+
+       return __add_raw_rmap(mp, agno, agbno, 1, ino,
+                       whichfork == XFS_ATTR_FORK, true);
+}
+
 /*
  * Add a reverse mapping for a per-AG fixed metadata extent.
  */
index ca92623b15f4287be3489449b02eb98da38e772a..6a3a0a43af360b6ea5c2c1ad8497206873b17aa5 100644 (file)
@@ -30,6 +30,7 @@ extern void free_rmaps(struct xfs_mount *);
 extern int add_rmap(struct xfs_mount *, xfs_ino_t, int, struct xfs_bmbt_irec *);
 extern int add_ag_rmap(struct xfs_mount *, xfs_agnumber_t agno,
                xfs_agblock_t agbno, xfs_extlen_t len, uint64_t owner);
+extern int add_bmbt_rmap(struct xfs_mount *, xfs_ino_t, int, xfs_fsblock_t);
 extern int fold_raw_rmaps(struct xfs_mount *mp, xfs_agnumber_t agno);
 extern bool mergeable_rmaps(struct xfs_rmap_irec *r1, struct xfs_rmap_irec *r2);
 
index a54ef748a233119f055f7846063b05344edc6618..d22dca3debef39f0a6bb7ba454036710425edb7e 100644 (file)
@@ -29,6 +29,7 @@
 #include "bmap.h"
 #include "progress.h"
 #include "threads.h"
+#include "rmap.h"
 
 static xfs_mount_t     *mp = NULL;
 
@@ -197,6 +198,7 @@ scan_bmapbt(
        xfs_agnumber_t          agno;
        xfs_agblock_t           agbno;
        int                     state;
+       int                     error;
 
        /*
         * unlike the ag freeblock btrees, if anything looks wrong
@@ -378,6 +380,15 @@ _("bad state %d, inode %" PRIu64 " bmap block 0x%" PRIx64 "\n"),
        (*tot)++;
        numrecs = be16_to_cpu(block->bb_numrecs);
 
+       /* Record BMBT blocks in the reverse-mapping data. */
+       if (check_dups && collect_rmaps) {
+               error = add_bmbt_rmap(mp, ino, whichfork, bno);
+               if (error)
+                       do_error(
+_("couldn't add inode %"PRIu64" bmbt block %"PRIu64" reverse-mapping data."),
+                               ino, bno);
+       }
+
        if (level == 0) {
                if (numrecs > mp->m_bmap_dmxr[0] || (isroot == 0 && numrecs <
                                                        mp->m_bmap_dmnr[0])) {
@@ -878,8 +889,6 @@ scan_rmapbt(
        int                     numrecs;
        int                     state;
        xfs_agblock_t           lastblock = 0;
-       int64_t                 lastowner = 0;
-       int64_t                 lastoffset = 0;
 
        if (magic != XFS_RMAP_CRC_MAGIC) {
                name = "(unknown)";
@@ -980,8 +989,6 @@ _("%s rmap btree block claimed (state %d), agno %d, bno %d, suspect %d\n"),
                        if (i == 0) {
 advance:
                                lastblock = b;
-                               lastowner = owner;
-                               lastoffset = offset;
                        } else {
                                bool bad;