fs/xfs/scrub/dirtree.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/dirtree.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/dirtree.c- Extension
.c- Size
- 26551 bytes
- Lines
- 1009
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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_icache.hxfs_dir2.hxfs_dir2_priv.hxfs_attr.hxfs_parent.hscrub/scrub.hscrub/common.hscrub/bitmap.hscrub/ino_bitmap.hscrub/xfile.hscrub/xfarray.hscrub/xfblob.hscrub/listxattr.hscrub/trace.hscrub/repair.hscrub/orphanage.hscrub/dirtree.h
Detected Declarations
function Copyrightfunction xchk_dirtree_for_each_path_safefunction xchk_setup_dirtreefunction xchk_dirpath_appendfunction xchk_dirtree_create_pathfunction xchk_dirpath_revalidatefunction xchk_dirpath_find_next_stepfunction xchk_dirpath_set_outcomefunction xchk_dirpath_step_upfunction xchk_dirpath_walk_upwardsfunction xchk_dirpath_step_is_stalefunction xchk_dirpath_is_stalefunction xchk_dirtree_live_updatefunction xchk_dirtree_for_each_pathfunction xchk_dirtree_resetfunction xchk_dirtree_for_each_path_safefunction xchk_dirtree_load_pathfunction xchk_dirtree_find_paths_to_rootfunction xchk_dirtree_for_each_pathfunction xchk_dirtree_evaluatefunction xchk_dirtreefunction xchk_dirtree_parentless
Annotated Snippet
if (ret < 0) {
dl->aborted = true;
break;
}
if (ret == 1) {
dl->stale = true;
break;
}
}
out_unlock:
mutex_unlock(&dl->lock);
return NOTIFY_DONE;
}
/* Delete all the collected path information. */
STATIC void
xchk_dirtree_reset(
void *buf)
{
struct xchk_dirtree *dl = buf;
struct xchk_dirpath *path, *n;
ASSERT(dl->sc->ilock_flags & XFS_ILOCK_EXCL);
xchk_dirtree_for_each_path_safe(dl, path, n) {
list_del_init(&path->list);
xino_bitmap_destroy(&path->seen_inodes);
kfree(path);
}
dl->nr_paths = 0;
xfarray_truncate(dl->path_steps);
xfblob_truncate(dl->path_names);
dl->stale = false;
}
/*
* Load the name/pptr from the first step in this path into @dl->pptr_rec and
* @dl->xname.
*/
STATIC int
xchk_dirtree_load_path(
struct xchk_dirtree *dl,
struct xchk_dirpath *path)
{
struct xchk_dirpath_step step;
int error;
error = xfarray_load(dl->path_steps, path->first_step, &step);
if (error)
return error;
error = xfblob_loadname(dl->path_names, step.name_cookie, &dl->xname,
step.name_len);
if (error)
return error;
dl->pptr_rec = step.pptr_rec; /* struct copy */
return 0;
}
/*
* For each parent pointer of this subdir, trace a path upwards towards the
* root directory and record what we find. Returns 0 for success;
* -EFSCORRUPTED if walking the parent pointers of @sc->ip failed, -ELNRNG if a
* path was too deep; -ENOSR if there were too many parent pointers; or
* a negative errno.
*/
int
xchk_dirtree_find_paths_to_root(
struct xchk_dirtree *dl)
{
struct xfs_scrub *sc = dl->sc;
struct xchk_dirpath *path;
int error = 0;
do {
if (xchk_should_terminate(sc, &error))
return error;
xchk_dirtree_reset(dl);
/*
* If the extended attributes look as though they has been
* zapped by the inode record repair code, we cannot scan for
* parent pointers.
*/
if (xchk_pptr_looks_zapped(sc->ip)) {
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: `function Copyright`, `function xchk_dirtree_for_each_path_safe`, `function xchk_setup_dirtree`, `function xchk_dirpath_append`, `function xchk_dirtree_create_path`, `function xchk_dirpath_revalidate`, `function xchk_dirpath_find_next_step`, `function xchk_dirpath_set_outcome`, `function xchk_dirpath_step_up`, `function xchk_dirpath_walk_upwards`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.