/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (c) 2023-2024 Oracle. All Rights Reserved. * Author: Darrick J. Wong <djwong@kernel.org>
*/ #ifndef __XFS_SCRUB_DIRTREE_H__ #define __XFS_SCRUB_DIRTREE_H__
/* * Each of these represents one parent pointer path step in a chain going * up towards the directory tree root. These are stored inside an xfarray.
*/ struct xchk_dirpath_step { /* Directory entry name associated with this parent link. */
xfblob_cookie name_cookie; unsignedint name_len;
/* Handle of the parent directory. */ struct xfs_parent_rec pptr_rec;
};
enum xchk_dirpath_outcome {
XCHK_DIRPATH_SCANNING = 0, /* still being put together */
XCHK_DIRPATH_DELETE, /* delete this path */
XCHK_DIRPATH_CORRUPT, /* corruption detected in path */
XCHK_DIRPATH_LOOP, /* cycle detected further up */
XCHK_DIRPATH_STALE, /* path is stale */
XCHK_DIRPATH_OK, /* path reaches the root */
XREP_DIRPATH_DELETING, /* path is being deleted */
XREP_DIRPATH_DELETED, /* path has been deleted */
XREP_DIRPATH_ADOPTING, /* path is being adopted */
XREP_DIRPATH_ADOPTED, /* path has been adopted */
};
/* * Each of these represents one parent pointer path out of the directory being * scanned. These exist in-core, and hopefully there aren't more than a * handful of them.
*/ struct xchk_dirpath { struct list_head list;
/* Index of the first step in this path. */
xfarray_idx_t first_step;
/* Index of the second step in this path. */
xfarray_idx_t second_step;
/* Inodes seen while walking this path. */ struct xino_bitmap seen_inodes;
/* Number of steps in this path. */ unsignedint nr_steps;
/* Which path is this? */ unsignedint path_nr;
/* What did we conclude from following this path? */ enum xchk_dirpath_outcome outcome;
};
struct xchk_dirtree_outcomes { /* Number of XCHK_DIRPATH_DELETE */ unsignedint bad;
/* Number of XCHK_DIRPATH_CORRUPT or XCHK_DIRPATH_LOOP */ unsignedint suspect;
/* Number of XCHK_DIRPATH_OK */ unsignedint good;
/* Directory needs to be added to lost+found */ bool needs_adoption;
};
struct xchk_dirtree { struct xfs_scrub *sc;
/* Root inode that we're looking for. */
xfs_ino_t root_ino;
/* * This is the inode that we're scanning. The live update hook can * continue to be called after xchk_teardown drops sc->ip but before * it calls buf_cleanup, so we keep a copy.
*/
xfs_ino_t scan_ino;
/* * If we start deleting redundant paths to this subdirectory, this is * the inode number of the surviving parent and the dotdot entry will * be set to this value. If the value is NULLFSINO, then use @root_ino * as a stand-in until the orphanage can adopt the subdirectory.
*/
xfs_ino_t parent_ino;
/* lock for everything below here */ struct mutex lock;
/* buffer for the live update functions to use for dirent names */ struct xfs_name hook_xname; unsignedchar hook_namebuf[MAXNAMELEN];
/* * All path steps observed during this scan. Each of the path * steps for a particular pathwalk are recorded in sequential * order in the xfarray. A pathwalk ends either with a step * pointing to the root directory (success) or pointing to NULLFSINO * (loop detected, empty dir detected, etc).
*/ struct xfarray *path_steps;
/* All names observed during this scan. */ struct xfblob *path_names;
/* All paths being tracked by this scanner. */ struct list_head path_list;
/* Number of paths in path_list. */ unsignedint nr_paths;
/* Number of parents found by a pptr scan. */ unsignedint parents_found;
/* Have the path data been invalidated by a concurrent update? */ bool stale:1;
/* Has the scan been aborted? */ bool aborted:1;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.