fs/xfs/scrub/dir_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/dir_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/dir_repair.c- Extension
.c- Size
- 50376 bytes
- Lines
- 1964
- 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.
- 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_dir2_priv.hxfs_bmap.hxfs_quota.hxfs_bmap_btree.hxfs_trans_space.hxfs_bmap_util.hxfs_exchmaps.hxfs_exchrange.hxfs_ag.hxfs_parent.hscrub/xfs_scrub.hscrub/scrub.hscrub/common.hscrub/trace.hscrub/repair.hscrub/tempfile.h
Detected Declarations
struct xrep_direntstruct xrep_dirfunction xrep_dir_teardownfunction xrep_setup_directoryfunction xrep_dir_lookup_parentfunction xrep_dir_dcache_parentfunction xrep_dir_find_parentfunction xrep_dir_want_salvagefunction xrep_dir_stash_createnamefunction xrep_dir_stash_removenamefunction xrep_dir_salvage_entryfunction xrep_dir_salvage_sf_entryfunction xrep_dir_salvage_data_entryfunction xrep_dir_recover_datafunction xrep_dir_recover_sffunction xrep_dir_guess_formatfunction XFS_FSB_TO_Bfunction xrep_dir_recover_dirblockfunction xrep_dir_init_argsfunction xrep_dir_replay_createnamefunction xrep_dir_replay_removenamefunction xrep_dir_replay_updatefunction xrep_dir_replay_updatesfunction xrep_dir_flush_stashedfunction xrep_dir_want_flush_stashedfunction xrep_dir_recoverfunction xrep_dir_find_entriesfunction xrep_dir_salvage_entriesfunction xrep_dir_scan_pptrfunction xrep_dir_scan_direntfunction xrep_dir_want_scanfunction xrep_dir_scan_ilockfunction xrep_dir_scan_filefunction xrep_dir_scan_dirtreefunction xrep_dir_live_updatefunction xchk_iscan_want_live_updatefunction xchk_iscan_want_live_updatefunction xrep_dir_reset_forkfunction xrep_dir_swap_prepfunction xrep_dir_replacefunction xrep_dir_set_nlinkfunction xrep_dir_finalize_tempdirfunction xrep_dir_swapfunction contentsfunction xrep_dir_setup_scanfunction xrep_dir_move_to_orphanagefunction xrep_directory
Annotated Snippet
struct xrep_dirent {
/* Cookie for retrieval of the dirent name. */
xfblob_cookie name_cookie;
/* Target inode number. */
xfs_ino_t ino;
/* Length of the dirent name. */
uint8_t namelen;
/* File type of the dirent. */
uint8_t ftype;
/* XREP_DIRENT_{ADD,REMOVE} */
uint8_t action;
};
/*
* Stash up to 8 pages of recovered dirent data in dir_entries and dir_names
* before we write them to the temp dir.
*/
#define XREP_DIR_MAX_STASH_BYTES (PAGE_SIZE * 8)
struct xrep_dir {
struct xfs_scrub *sc;
/* Fixed-size array of xrep_dirent structures. */
struct xfarray *dir_entries;
/* Blobs containing directory entry names. */
struct xfblob *dir_names;
/* Information for exchanging data forks at the end. */
struct xrep_tempexch tx;
/* Preallocated args struct for performing dir operations */
struct xfs_da_args args;
/*
* Information used to scan the filesystem to find the inumber of the
* dotdot entry for this directory. For directory salvaging when
* parent pointers are not enabled, we use the findparent_* functions
* on this object and access only the parent_ino field directly.
*
* When parent pointers are enabled, however, the pptr scanner uses the
* iscan, hooks, lock, and parent_ino fields of this object directly.
* @pscan.lock coordinates access to dir_entries, dir_names,
* parent_ino, subdirs, dirents, and args. This reduces the memory
* requirements of this structure.
*/
struct xrep_parent_scan_info pscan;
/*
* Context information for attaching this directory to the lost+found
* if this directory does not have a parent.
*/
struct xrep_adoption adoption;
/* How many subdirectories did we find? */
uint64_t subdirs;
/* How many dirents did we find? */
unsigned int dirents;
/* Should we move this directory to the orphanage? */
bool needs_adoption;
/* Directory entry name, plus the trailing null. */
struct xfs_name xname;
unsigned char namebuf[MAXNAMELEN];
};
/* Tear down all the incore stuff we created. */
static void
xrep_dir_teardown(
struct xfs_scrub *sc)
{
struct xrep_dir *rd = sc->buf;
xrep_findparent_scan_teardown(&rd->pscan);
if (rd->dir_names)
xfblob_destroy(rd->dir_names);
rd->dir_names = NULL;
if (rd->dir_entries)
xfarray_destroy(rd->dir_entries);
rd->dir_entries = NULL;
}
/* Set up for a directory repair. */
int
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_dirent`, `struct xrep_dir`, `function xrep_dir_teardown`, `function xrep_setup_directory`, `function xrep_dir_lookup_parent`, `function xrep_dir_dcache_parent`, `function xrep_dir_find_parent`, `function xrep_dir_want_salvage`, `function xrep_dir_stash_createname`, `function xrep_dir_stash_removename`.
- 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.