2018-06-06 02:42:14 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-10-18 04:37:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Oracle. All Rights Reserved.
|
|
|
|
* Author: Darrick J. Wong <darrick.wong@oracle.com>
|
|
|
|
*/
|
|
|
|
#ifndef __XFS_SCRUB_BTREE_H__
|
|
|
|
#define __XFS_SCRUB_BTREE_H__
|
|
|
|
|
|
|
|
/* btree scrub */
|
|
|
|
|
|
|
|
/* Check for btree operation errors. */
|
2018-07-19 19:29:12 +00:00
|
|
|
bool xchk_btree_process_error(struct xfs_scrub *sc,
|
2017-10-18 04:37:37 +00:00
|
|
|
struct xfs_btree_cur *cur, int level, int *error);
|
|
|
|
|
2018-01-17 02:52:14 +00:00
|
|
|
/* Check for btree xref operation errors. */
|
2018-07-19 19:29:12 +00:00
|
|
|
bool xchk_btree_xref_process_error(struct xfs_scrub *sc,
|
2018-07-19 19:29:12 +00:00
|
|
|
struct xfs_btree_cur *cur, int level, int *error);
|
2018-01-17 02:52:14 +00:00
|
|
|
|
2017-10-18 04:37:37 +00:00
|
|
|
/* Check for btree corruption. */
|
2018-07-19 19:29:12 +00:00
|
|
|
void xchk_btree_set_corrupt(struct xfs_scrub *sc,
|
2017-10-18 04:37:37 +00:00
|
|
|
struct xfs_btree_cur *cur, int level);
|
|
|
|
|
2018-01-17 02:52:14 +00:00
|
|
|
/* Check for btree xref discrepancies. */
|
2018-07-19 19:29:12 +00:00
|
|
|
void xchk_btree_xref_set_corrupt(struct xfs_scrub *sc,
|
2018-01-17 02:52:14 +00:00
|
|
|
struct xfs_btree_cur *cur, int level);
|
|
|
|
|
2018-07-19 19:29:11 +00:00
|
|
|
struct xchk_btree;
|
|
|
|
typedef int (*xchk_btree_rec_fn)(
|
2021-08-11 00:02:17 +00:00
|
|
|
struct xchk_btree *bs,
|
|
|
|
const union xfs_btree_rec *rec);
|
2017-10-18 04:37:37 +00:00
|
|
|
|
2018-07-19 19:29:11 +00:00
|
|
|
struct xchk_btree {
|
2017-10-18 04:37:37 +00:00
|
|
|
/* caller-provided scrub state */
|
2018-12-12 16:46:23 +00:00
|
|
|
struct xfs_scrub *sc;
|
|
|
|
struct xfs_btree_cur *cur;
|
|
|
|
xchk_btree_rec_fn scrub_rec;
|
|
|
|
const struct xfs_owner_info *oinfo;
|
|
|
|
void *private;
|
2017-10-18 04:37:37 +00:00
|
|
|
|
|
|
|
/* internal scrub state */
|
2018-12-12 16:46:23 +00:00
|
|
|
union xfs_btree_rec lastrec;
|
|
|
|
struct list_head to_check;
|
2021-09-16 19:21:55 +00:00
|
|
|
|
|
|
|
/* this element must come last! */
|
|
|
|
union xfs_btree_key lastkey[];
|
2017-10-18 04:37:37 +00:00
|
|
|
};
|
2021-09-16 19:21:55 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the size of a xchk_btree structure. There are nlevels-1 slots for
|
|
|
|
* keys because we track leaf records separately in lastrec.
|
|
|
|
*/
|
|
|
|
static inline size_t
|
|
|
|
xchk_btree_sizeof(unsigned int nlevels)
|
|
|
|
{
|
|
|
|
return struct_size((struct xchk_btree *)NULL, lastkey, nlevels - 1);
|
|
|
|
}
|
|
|
|
|
2018-07-19 19:29:12 +00:00
|
|
|
int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
|
2018-12-12 16:46:23 +00:00
|
|
|
xchk_btree_rec_fn scrub_fn, const struct xfs_owner_info *oinfo,
|
2018-07-19 19:29:12 +00:00
|
|
|
void *private);
|
2017-10-18 04:37:37 +00:00
|
|
|
|
|
|
|
#endif /* __XFS_SCRUB_BTREE_H__ */
|