fs/xfs/scrub/findparent.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/findparent.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/findparent.c- Extension
.c- Size
- 12087 bytes
- Lines
- 470
- 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.
- 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_defer.hxfs_bit.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_inode.hxfs_icache.hxfs_da_format.hxfs_da_btree.hxfs_dir2.hxfs_bmap_btree.hxfs_dir2_priv.hxfs_trans_space.hxfs_health.hxfs_exchmaps.hxfs_parent.hscrub/xfs_scrub.hscrub/scrub.hscrub/common.hscrub/trace.hscrub/repair.hscrub/iscan.hscrub/findparent.hscrub/readdir.hscrub/tempfile.hscrub/listxattr.h
Detected Declarations
struct xrep_findparent_infofunction xrep_findparent_direntfunction xrep_findparent_walk_directoryfunction xrep_findparent_live_updatefunction xchk_iscan_want_live_updatefunction __xrep_findparent_scan_startfunction xrep_findparent_scanfunction xrep_findparent_scan_teardownfunction xrep_findparent_scan_finish_earlyfunction xrep_findparent_confirmfunction xrep_findparent_self_referencefunction xrep_findparent_from_dcache
Annotated Snippet
struct xrep_findparent_info {
/* The directory currently being scanned. */
struct xfs_inode *dp;
/*
* Scrub context. We're looking for a @dp containing a directory
* entry pointing to I_INO(sc->ip).
*/
struct xfs_scrub *sc;
/* Optional scan information for a xrep_findparent_scan call. */
struct xrep_parent_scan_info *parent_scan;
/*
* Parent that we've found for sc->ip. If we're scanning the entire
* directory tree, we need this to ensure that we only find /one/
* parent directory.
*/
xfs_ino_t found_parent;
/*
* This is set to true if @found_parent was not observed directly from
* the directory scan but by noticing a change in dotdot entries after
* cycling the sc->ip IOLOCK.
*/
bool parent_tentative;
};
/*
* If this directory entry points to the scrub target inode, then the directory
* we're scanning is the parent of the scrub target inode.
*/
STATIC int
xrep_findparent_dirent(
struct xfs_scrub *sc,
struct xfs_inode *dp,
xfs_dir2_dataptr_t dapos,
const struct xfs_name *name,
xfs_ino_t ino,
void *priv)
{
struct xrep_findparent_info *fpi = priv;
int error = 0;
if (xchk_should_terminate(fpi->sc, &error))
return error;
if (ino != I_INO(fpi->sc->ip))
return 0;
/* Ignore garbage directory entry names. */
if (name->len == 0 || !xfs_dir2_namecheck(name->name, name->len))
return -EFSCORRUPTED;
/*
* Ignore dotdot and dot entries -- we're looking for parent -> child
* links only.
*/
if (name->name[0] == '.' && (name->len == 1 ||
(name->len == 2 && name->name[1] == '.')))
return 0;
/* Uhoh, more than one parent for a dir? */
if (fpi->found_parent != NULLFSINO &&
!(fpi->parent_tentative && fpi->found_parent == I_INO(fpi->dp))) {
trace_xrep_findparent_dirent(fpi->sc->ip, 0);
return -EFSCORRUPTED;
}
/* We found a potential parent; remember this. */
trace_xrep_findparent_dirent(fpi->sc->ip, I_INO(fpi->dp));
fpi->found_parent = I_INO(fpi->dp);
fpi->parent_tentative = false;
if (fpi->parent_scan)
xrep_findparent_scan_found(fpi->parent_scan, I_INO(fpi->dp));
return 0;
}
/*
* If this is a directory, walk the dirents looking for any that point to the
* scrub target inode.
*/
STATIC int
xrep_findparent_walk_directory(
struct xrep_findparent_info *fpi)
{
struct xfs_scrub *sc = fpi->sc;
struct xfs_inode *dp = fpi->dp;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_defer.h`, `xfs_bit.h`.
- Detected declarations: `struct xrep_findparent_info`, `function xrep_findparent_dirent`, `function xrep_findparent_walk_directory`, `function xrep_findparent_live_update`, `function xchk_iscan_want_live_update`, `function __xrep_findparent_scan_start`, `function xrep_findparent_scan`, `function xrep_findparent_scan_teardown`, `function xrep_findparent_scan_finish_early`, `function xrep_findparent_confirm`.
- 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.