]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: scrub the shape of a metadata btree
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 17 Nov 2017 04:11:31 +0000 (22:11 -0600)
committerEric Sandeen <sandeen@redhat.com>
Fri, 17 Nov 2017 04:11:31 +0000 (22:11 -0600)
Source kernel commit: cc3e0948d2686f30f49166660cf85b7e0194f365

Create a function that can check the shape of a btree -- each block
passes basic inspection and all the pointers look ok.  In the next patch
we'll add the ability to check the actual keys and records stored within
the btree.  Add some helper functions so that we report detailed scrub
errors in a uniform manner in dmesg.  These are helper functions for
subsequent patches.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_btree.c
libxfs/xfs_btree.h

index 96236e1eedef785920f285ae66d46bd8c6c3324c..371720465fbe4f0adee8bbdb2f4a56786d8b70f7 100644 (file)
@@ -1049,7 +1049,7 @@ xfs_btree_setbuf(
        }
 }
 
-STATIC int
+bool
 xfs_btree_ptr_is_null(
        struct xfs_btree_cur    *cur,
        union xfs_btree_ptr     *ptr)
@@ -1074,7 +1074,7 @@ xfs_btree_set_ptr_null(
 /*
  * Get/set/init sibling pointers
  */
-STATIC void
+void
 xfs_btree_get_sibling(
        struct xfs_btree_cur    *cur,
        struct xfs_btree_block  *block,
@@ -4940,3 +4940,15 @@ xfs_btree_count_blocks(
        return xfs_btree_visit_blocks(cur, xfs_btree_count_blocks_helper,
                        blocks);
 }
+
+/* Compare two btree pointers. */
+int64_t
+xfs_btree_diff_two_ptrs(
+       struct xfs_btree_cur            *cur,
+       const union xfs_btree_ptr       *a,
+       const union xfs_btree_ptr       *b)
+{
+       if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
+               return (int64_t)be64_to_cpu(a->l) - be64_to_cpu(b->l);
+       return (int64_t)be32_to_cpu(a->s) - be32_to_cpu(b->s);
+}
index afabc6e5bd71c8684214b80f4e24d218536b08ba..fba4a928a1e9eaac5e763ac87dc3d6ac48091049 100644 (file)
@@ -534,5 +534,12 @@ int xfs_btree_lookup_get_block(struct xfs_btree_cur *cur, int level,
                union xfs_btree_ptr *pp, struct xfs_btree_block **blkp);
 struct xfs_btree_block *xfs_btree_get_block(struct xfs_btree_cur *cur,
                int level, struct xfs_buf **bpp);
+bool xfs_btree_ptr_is_null(struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr);
+int64_t xfs_btree_diff_two_ptrs(struct xfs_btree_cur *cur,
+                               const union xfs_btree_ptr *a,
+                               const union xfs_btree_ptr *b);
+void xfs_btree_get_sibling(struct xfs_btree_cur *cur,
+                          struct xfs_btree_block *block,
+                          union xfs_btree_ptr *ptr, int lr);
 
 #endif /* __XFS_BTREE_H__ */