Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Copyright (C) 2017 Oracle.  All Rights Reserved.
0004  * Author: Darrick J. Wong <darrick.wong@oracle.com>
0005  */
0006 #ifndef __XFS_SCRUB_BTREE_H__
0007 #define __XFS_SCRUB_BTREE_H__
0008 
0009 /* btree scrub */
0010 
0011 /* Check for btree operation errors. */
0012 bool xchk_btree_process_error(struct xfs_scrub *sc,
0013         struct xfs_btree_cur *cur, int level, int *error);
0014 
0015 /* Check for btree xref operation errors. */
0016 bool xchk_btree_xref_process_error(struct xfs_scrub *sc,
0017         struct xfs_btree_cur *cur, int level, int *error);
0018 
0019 /* Check for btree corruption. */
0020 void xchk_btree_set_corrupt(struct xfs_scrub *sc,
0021         struct xfs_btree_cur *cur, int level);
0022 
0023 /* Check for btree xref discrepancies. */
0024 void xchk_btree_xref_set_corrupt(struct xfs_scrub *sc,
0025         struct xfs_btree_cur *cur, int level);
0026 
0027 struct xchk_btree;
0028 typedef int (*xchk_btree_rec_fn)(
0029     struct xchk_btree       *bs,
0030     const union xfs_btree_rec   *rec);
0031 
0032 struct xchk_btree {
0033     /* caller-provided scrub state */
0034     struct xfs_scrub        *sc;
0035     struct xfs_btree_cur        *cur;
0036     xchk_btree_rec_fn       scrub_rec;
0037     const struct xfs_owner_info *oinfo;
0038     void                *private;
0039 
0040     /* internal scrub state */
0041     union xfs_btree_rec     lastrec;
0042     struct list_head        to_check;
0043 
0044     /* this element must come last! */
0045     union xfs_btree_key     lastkey[];
0046 };
0047 
0048 /*
0049  * Calculate the size of a xchk_btree structure.  There are nlevels-1 slots for
0050  * keys because we track leaf records separately in lastrec.
0051  */
0052 static inline size_t
0053 xchk_btree_sizeof(unsigned int nlevels)
0054 {
0055     return struct_size((struct xchk_btree *)NULL, lastkey, nlevels - 1);
0056 }
0057 
0058 int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
0059         xchk_btree_rec_fn scrub_fn, const struct xfs_owner_info *oinfo,
0060         void *private);
0061 
0062 #endif /* __XFS_SCRUB_BTREE_H__ */