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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_trans_resv.hxfs_mount.hxfs_log_format.hxfs_trans.hxfs_inode.hxfs_metafile.hxfs_quota.hxfs_qm.hxfs_dir2.hxfs_parent.hxfs_bmap_btree.hxfs_trans_space.hxfs_attr.hxfs_rtgroup.hxfs_rtrmap_btree.hxfs_rtrefcount_btree.hscrub/scrub.hscrub/common.hscrub/trace.hscrub/readdir.hscrub/repair.h
Detected Declarations
struct xchk_metapathfunction xchk_metapath_cleanupfunction xchk_setup_metapath_scanfunction xchk_setup_metapath_rtdirfunction xchk_setup_metapath_rtginodefunction xchk_setup_metapath_quotadirfunction xchk_setup_metapath_dqinodefunction xchk_setup_metapathfunction xchk_metapath_ilock_bothfunction xchk_metapath_iunlockfunction xchk_metapathfunction xrep_metapath_linkfunction xrep_metapath_unlinkfunction xrep_metapath_try_linkfunction xchk_metapath_ilock_parent_and_childfunction xrep_metapath_try_unlinkfunction xrep_metapath
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
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_log_format.h`, `xfs_trans.h`.
- Detected declarations: `struct xchk_metapath`, `function xchk_metapath_cleanup`, `function xchk_setup_metapath_scan`, `function xchk_setup_metapath_rtdir`, `function xchk_setup_metapath_rtginode`, `function xchk_setup_metapath_quotadir`, `function xchk_setup_metapath_dqinode`, `function xchk_setup_metapath`, `function xchk_metapath_ilock_both`, `function xchk_metapath_iunlock`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.