xfs
[Top] [All Lists]

[PATCH 2/3] repair: add more fresspace btree checks

To: xfs@xxxxxxxxxxx
Subject: [PATCH 2/3] repair: add more fresspace btree checks
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Tue, 01 Dec 2009 10:05:05 -0500
References: <20091201150503.958283878@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: quilt/0.47-1
Port over additional checks for the freespace btrees from xfs_db, to get
the same btree checking coverage as in xfs_check.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Index: xfsprogs-dev/repair/scan.c
===================================================================
--- xfsprogs-dev.orig/repair/scan.c     2009-12-01 13:07:55.000000000 +0000
+++ xfsprogs-dev/repair/scan.c  2009-12-01 13:09:03.000000000 +0000
@@ -462,6 +462,8 @@ scanfunc_allocbt(
        int                     hdr_errors = 0;
        int                     numrecs;
        int                     state;
+       xfs_extlen_t            lastcount = 0;
+       xfs_agblock_t           lastblock = 0;
 
        assert(magic == XFS_ABTB_MAGIC || magic == XFS_ABTC_MAGIC);
 
@@ -508,8 +510,14 @@ _("%s freespace btree block claimed (sta
                        hdr_errors++;
                }
 
-               if (hdr_errors)
+               if (hdr_errors) {
+                       do_warn(
+       _("bad btree nrecs (%u, min=%u, max=%u) in bt%s block %u/%u\n"),
+                               be16_to_cpu(block->bb_numrecs),
+                               mp->m_alloc_mnr[0], mp->m_alloc_mxr[0],
+                               name, agno, bno);
                        suspect++;
+               }
 
                rp = XFS_ALLOC_REC_ADDR(mp, block, 1);
                for (i = 0; i < numrecs; i++) {
@@ -533,6 +541,24 @@ _("%s freespace btree block claimed (sta
                                continue;
                        }
 
+                       if (magic == XFS_ABTB_MAGIC) {
+                               if (b <= lastblock) {
+                                       do_warn(_(
+       "out-of-order bno btree record %d (%u %u) block %u/%u\n"),
+                                               i, b, len, agno, bno);
+                               } else {
+                                       lastblock = b;
+                               }
+                       } else {
+                               if (len < lastcount) {
+                                       do_warn(_(
+       "out-of-order cnt btree record %d (%u %u) block %u/%u\n"),
+                                               i, b, len, agno, bno);
+                               } else {
+                                       lastcount = len;
+                               }
+                       }
+
                        for ( ; b < end; b += blen)  {
                                state = get_bmap_ext(agno, b, end, &blen);
                                switch (state) {
@@ -579,14 +605,17 @@ _("%s freespace btree block claimed (sta
         * don't pass bogus tree flag down further if this block
         * looked ok.  bail out if two levels in a row look bad.
         */
-
-       if (suspect && !hdr_errors)
-               suspect = 0;
-
        if (hdr_errors)  {
+               do_warn(
+       _("bad btree nrecs (%u, min=%u, max=%u) in bt%s block %u/%u\n"),
+                       be16_to_cpu(block->bb_numrecs),
+                       mp->m_alloc_mnr[1], mp->m_alloc_mxr[1],
+                       name, agno, bno);
                if (suspect)
                        return;
-               else suspect++;
+               suspect++;
+       } else if (suspect) {
+               suspect = 0;
        }
 
        for (i = 0; i < numrecs; i++)  {

<Prev in Thread] Current Thread [Next in Thread>