2018-06-05 19:42:14 -07:00
// SPDX-License-Identifier: GPL-2.0+
2017-10-17 21:37:37 -07: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 12:29:12 -07:00
bool xchk_btree_process_error ( struct xfs_scrub * sc ,
2017-10-17 21:37:37 -07:00
struct xfs_btree_cur * cur , int level , int * error ) ;
2018-01-16 18:52:14 -08:00
/* Check for btree xref operation errors. */
2018-07-19 12:29:12 -07:00
bool xchk_btree_xref_process_error ( struct xfs_scrub * sc ,
2018-07-19 12:29:12 -07:00
struct xfs_btree_cur * cur , int level , int * error ) ;
2018-01-16 18:52:14 -08:00
2017-10-17 21:37:37 -07:00
/* Check for btree corruption. */
2018-07-19 12:29:12 -07:00
void xchk_btree_set_corrupt ( struct xfs_scrub * sc ,
2017-10-17 21:37:37 -07:00
struct xfs_btree_cur * cur , int level ) ;
2018-01-16 18:52:14 -08:00
/* Check for btree xref discrepancies. */
2018-07-19 12:29:12 -07:00
void xchk_btree_xref_set_corrupt ( struct xfs_scrub * sc ,
2018-01-16 18:52:14 -08:00
struct xfs_btree_cur * cur , int level ) ;
2018-07-19 12:29:11 -07:00
struct xchk_btree ;
typedef int ( * xchk_btree_rec_fn ) (
2021-08-10 17:02:17 -07:00
struct xchk_btree * bs ,
const union xfs_btree_rec * rec ) ;
2017-10-17 21:37:37 -07:00
2018-07-19 12:29:11 -07:00
struct xchk_btree {
2017-10-17 21:37:37 -07:00
/* caller-provided scrub state */
2018-12-12 08:46:23 -08: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-17 21:37:37 -07:00
/* internal scrub state */
2018-12-12 08:46:23 -08:00
union xfs_btree_rec lastrec ;
struct list_head to_check ;
2021-09-16 12:21:55 -07:00
/* this element must come last! */
union xfs_btree_key lastkey [ ] ;
2017-10-17 21:37:37 -07:00
} ;
2021-09-16 12:21:55 -07: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 12:29:12 -07:00
int xchk_btree ( struct xfs_scrub * sc , struct xfs_btree_cur * cur ,
2018-12-12 08:46:23 -08:00
xchk_btree_rec_fn scrub_fn , const struct xfs_owner_info * oinfo ,
2018-07-19 12:29:12 -07:00
void * private ) ;
2017-10-17 21:37:37 -07:00
# endif /* __XFS_SCRUB_BTREE_H__ */