fs/xfs/scrub/metapath.c

Source file repositories/reference/linux-study-clean/fs/xfs/scrub/metapath.c

File Facts

System
Linux kernel
Corpus path
fs/xfs/scrub/metapath.c
Extension
.c
Size
16001 bytes
Lines
678
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_metapath {
	struct xfs_scrub		*sc;

	/* Name for lookup */
	struct xfs_name			xname;

	/* Directory update for repairs */
	struct xfs_dir_update		du;

	/* Path down to this metadata file from the parent directory */
	const char			*path;

	/* Directory parent of the metadata file. */
	struct xfs_inode		*dp;

	/* Locks held on dp */
	unsigned int			dp_ilock_flags;

	/* Transaction block reservations */
	unsigned int			link_resblks;
	unsigned int			unlink_resblks;

	/* Parent pointer updates */
	struct xfs_parent_args		link_ppargs;
	struct xfs_parent_args		unlink_ppargs;

	/* Scratchpads for removing links */
	struct xfs_da_args		pptr_args;
};

/* Release resources tracked in the buffer. */
static inline void
xchk_metapath_cleanup(
	void			*buf)
{
	struct xchk_metapath	*mpath = buf;

	if (mpath->dp_ilock_flags)
		xfs_iunlock(mpath->dp, mpath->dp_ilock_flags);
	kfree_const(mpath->path);
}

/* Set up a metadir path scan.  @path must be dynamically allocated. */
static inline int
xchk_setup_metapath_scan(
	struct xfs_scrub	*sc,
	struct xfs_inode	*dp,
	const char		*path,
	struct xfs_inode	*ip)
{
	struct xchk_metapath	*mpath;
	int			error;

	if (!path)
		return -ENOMEM;

	error = xchk_install_live_inode(sc, ip);
	if (error) {
		kfree_const(path);
		return error;
	}

	mpath = kzalloc_obj(struct xchk_metapath, XCHK_GFP_FLAGS);
	if (!mpath) {
		kfree_const(path);
		return -ENOMEM;
	}

	mpath->sc = sc;
	sc->buf = mpath;
	sc->buf_cleanup = xchk_metapath_cleanup;

	mpath->dp = dp;
	mpath->path = path; /* path is now owned by mpath */

	mpath->xname.name = mpath->path;
	mpath->xname.len = strlen(mpath->path);
	mpath->xname.type = xfs_mode_to_ftype(VFS_I(ip)->i_mode);

	return 0;
}

#ifdef CONFIG_XFS_RT
/* Scan the /rtgroups directory itself. */
static int
xchk_setup_metapath_rtdir(
	struct xfs_scrub	*sc)
{
	if (!sc->mp->m_rtdirip)
		return -ENOENT;

Annotation

Implementation Notes