fs/xfs/scrub/dirtree_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/dirtree_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/dirtree_repair.c- Extension
.c- Size
- 19379 bytes
- Lines
- 822
- 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_trans_space.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.hscrub/readdir.h
Detected Declarations
function Copyrightfunction xrep_dirpath_set_outcomefunction xrep_dirtree_delete_all_pathsfunction xchk_dirtree_for_each_pathfunction xrep_dirpath_retain_parentfunction xrep_dirtree_find_surviving_pathfunction xchk_dirtree_for_each_pathfunction xrep_dirtree_keep_one_good_pathfunction xchk_dirtree_for_each_pathfunction xrep_dirtree_keep_one_suspect_pathfunction xchk_dirtree_for_each_pathfunction xrep_dirtree_decide_fatefunction xrep_dirtree_prep_pathfunction xrep_dirtree_purge_dentryfunction xrep_dirtree_unlink_iolockfunction xrep_dirtree_unlinkfunction xrep_dirtree_delete_pathfunction xrep_dirtree_create_adoption_pathfunction childfunction xrep_dirtree_adoptfunction xrep_dirtree_move_to_orphanagefunction xrep_dirtree_fix_problemsfunction xrep_dirtree
Annotated Snippet
switch (path->outcome) {
case XCHK_DIRPATH_CORRUPT:
case XCHK_DIRPATH_LOOP:
oc->suspect--;
oc->bad++;
xrep_dirpath_set_outcome(dl, path, XCHK_DIRPATH_DELETE);
break;
case XCHK_DIRPATH_OK:
oc->good--;
oc->bad++;
xrep_dirpath_set_outcome(dl, path, XCHK_DIRPATH_DELETE);
break;
default:
break;
}
}
ASSERT(oc->suspect == 0);
ASSERT(oc->good == 0);
}
/* Since this is the surviving path, set the dotdot entry to this value. */
STATIC void
xrep_dirpath_retain_parent(
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;
dl->parent_ino = be64_to_cpu(step.pptr_rec.p_ino);
}
/* Find the one surviving path so we know how to set dotdot. */
STATIC void
xrep_dirtree_find_surviving_path(
struct xchk_dirtree *dl,
struct xchk_dirtree_outcomes *oc)
{
struct xchk_dirpath *path;
bool foundit = false;
xchk_dirtree_for_each_path(dl, path) {
switch (path->outcome) {
case XCHK_DIRPATH_CORRUPT:
case XCHK_DIRPATH_LOOP:
case XCHK_DIRPATH_OK:
if (!foundit) {
xrep_dirpath_retain_parent(dl, path);
foundit = true;
continue;
}
ASSERT(foundit == false);
break;
default:
break;
}
}
ASSERT(oc->suspect + oc->good == 1);
}
/* Delete all paths except for the one good one. */
STATIC void
xrep_dirtree_keep_one_good_path(
struct xchk_dirtree *dl,
struct xchk_dirtree_outcomes *oc)
{
struct xchk_dirpath *path;
bool foundit = false;
xchk_dirtree_for_each_path(dl, path) {
switch (path->outcome) {
case XCHK_DIRPATH_CORRUPT:
case XCHK_DIRPATH_LOOP:
oc->suspect--;
oc->bad++;
xrep_dirpath_set_outcome(dl, path, XCHK_DIRPATH_DELETE);
break;
case XCHK_DIRPATH_OK:
if (!foundit) {
xrep_dirpath_retain_parent(dl, path);
foundit = true;
continue;
}
oc->good--;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_trans_space.h`, `xfs_mount.h`, `xfs_log_format.h`.
- Detected declarations: `function Copyright`, `function xrep_dirpath_set_outcome`, `function xrep_dirtree_delete_all_paths`, `function xchk_dirtree_for_each_path`, `function xrep_dirpath_retain_parent`, `function xrep_dirtree_find_surviving_path`, `function xchk_dirtree_for_each_path`, `function xrep_dirtree_keep_one_good_path`, `function xchk_dirtree_for_each_path`, `function xrep_dirtree_keep_one_suspect_path`.
- 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.