mirror of
https://github.com/torvalds/linux.git
synced 2024-12-04 01:51:34 +00:00
2bea8df0a5
In commitd47fef9342
, we removed the firstrec and firstkey fields of struct xchk_btree because Christoph thought they were unnecessary because we could use the record index in the btree cursor. This is incorrect because bc_ptrs (now bc_levels[].ptr) tracks the cursor position within a specific btree block, not within the entire level. The end result is that scrub no longer detects situations where the rightmost record of a block is identical to the leftmost record of that block's right sibling. Fix this regression by reintroducing record validity booleans so that order checking skips *only* the leftmost record/key in each level. Fixes:d47fef9342
("xfs: don't track firstrec/firstkey separately in xchk_btree") Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com>
71 lines
1.9 KiB
C
71 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright (C) 2017-2023 Oracle. All Rights Reserved.
|
|
* Author: Darrick J. Wong <djwong@kernel.org>
|
|
*/
|
|
#ifndef __XFS_SCRUB_BTREE_H__
|
|
#define __XFS_SCRUB_BTREE_H__
|
|
|
|
/* btree scrub */
|
|
|
|
/* Check for btree operation errors. */
|
|
bool xchk_btree_process_error(struct xfs_scrub *sc,
|
|
struct xfs_btree_cur *cur, int level, int *error);
|
|
|
|
/* Check for btree xref operation errors. */
|
|
bool xchk_btree_xref_process_error(struct xfs_scrub *sc,
|
|
struct xfs_btree_cur *cur, int level, int *error);
|
|
|
|
/* Check for btree corruption. */
|
|
void xchk_btree_set_corrupt(struct xfs_scrub *sc,
|
|
struct xfs_btree_cur *cur, int level);
|
|
void xchk_btree_set_preen(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
|
|
int level);
|
|
|
|
/* Check for btree xref discrepancies. */
|
|
void xchk_btree_xref_set_corrupt(struct xfs_scrub *sc,
|
|
struct xfs_btree_cur *cur, int level);
|
|
|
|
struct xchk_btree;
|
|
typedef int (*xchk_btree_rec_fn)(
|
|
struct xchk_btree *bs,
|
|
const union xfs_btree_rec *rec);
|
|
|
|
struct xchk_btree_key {
|
|
union xfs_btree_key key;
|
|
bool valid;
|
|
};
|
|
|
|
struct xchk_btree {
|
|
/* caller-provided scrub state */
|
|
struct xfs_scrub *sc;
|
|
struct xfs_btree_cur *cur;
|
|
xchk_btree_rec_fn scrub_rec;
|
|
const struct xfs_owner_info *oinfo;
|
|
void *private;
|
|
|
|
/* internal scrub state */
|
|
bool lastrec_valid;
|
|
union xfs_btree_rec lastrec;
|
|
struct list_head to_check;
|
|
|
|
/* this element must come last! */
|
|
struct xchk_btree_key lastkey[];
|
|
};
|
|
|
|
/*
|
|
* 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);
|
|
}
|
|
|
|
int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
|
|
xchk_btree_rec_fn scrub_fn, const struct xfs_owner_info *oinfo,
|
|
void *private);
|
|
|
|
#endif /* __XFS_SCRUB_BTREE_H__ */
|