fs/xfs/scrub/dirtree.h

Source file repositories/reference/linux-study-clean/fs/xfs/scrub/dirtree.h

File Facts

System
Linux kernel
Corpus path
fs/xfs/scrub/dirtree.h
Extension
.h
Size
4858 bytes
Lines
169
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct xchk_dirpath_step {
	/* Directory entry name associated with this parent link. */
	xfblob_cookie		name_cookie;
	unsigned int		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. */
	unsigned int		nr_steps;

	/* Which path is this? */
	unsigned int		path_nr;

	/* What did we conclude from following this path? */
	enum xchk_dirpath_outcome outcome;
};

struct xchk_dirtree_outcomes {
	/* Number of XCHK_DIRPATH_DELETE */
	unsigned int		bad;

	/* Number of XCHK_DIRPATH_CORRUPT or XCHK_DIRPATH_LOOP */
	unsigned int		suspect;

	/* Number of XCHK_DIRPATH_OK */
	unsigned int		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;

	/* Scratch buffer for scanning pptr xattrs */
	struct xfs_parent_rec	pptr_rec;
	struct xfs_da_args	pptr_args;

	/* Name buffer */

Annotation

Implementation Notes