fs/xfs/scrub/attr_repair.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/attr_repair.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/attr_repair.c- Extension
.c- Size
- 43518 bytes
- Lines
- 1656
- 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_defer.hxfs_btree.hxfs_bit.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_inode.hxfs_da_format.hxfs_da_btree.hxfs_dir2.hxfs_attr.hxfs_attr_leaf.hxfs_attr_sf.hxfs_attr_remote.hxfs_bmap.hxfs_bmap_util.hxfs_exchmaps.hxfs_exchrange.hxfs_acl.hxfs_parent.hscrub/xfs_scrub.hscrub/scrub.hscrub/common.hscrub/trace.hscrub/repair.hscrub/tempfile.h
Detected Declarations
struct xrep_xattr_keystruct xrep_xattrstruct xrep_xattr_pptrfunction xrep_setup_xattrfunction xrep_xattr_want_salvagefunction xrep_xattr_salvage_keyfunction xrep_xattr_salvage_sf_attrfunction xrep_xattr_salvage_local_attrfunction xrep_xattr_salvage_remote_attrfunction xrep_xattr_recover_leaffunction xrep_xattr_recover_sffunction buffersfunction xrep_xattr_recover_blockfunction xrep_xattr_insert_recfunction xrep_xattr_flush_stashedfunction xrep_xattr_want_flush_stashedfunction xrep_xattr_saw_pptr_conflictfunction xrep_xattr_full_resetfunction xrep_xattr_recoverfunction xrep_xattr_fork_removefunction for_each_xfs_iextfunction xrep_xattr_reset_forkfunction xrep_xattr_reset_tempfile_forkfunction xrep_xattr_salvage_attributesfunction xrep_xattr_replay_pptr_updatefunction xrep_xattr_replay_pptr_updatesfunction xrep_xattr_stash_parentaddfunction xrep_xattr_stash_parentremovefunction xrep_xattr_live_dirent_updatefunction xrep_xattr_swap_prepfunction xrep_xattr_swapfunction xrep_xattr_finalize_tempfilefunction datafunction xrep_xattr_teardownfunction xrep_xattr_setup_scanfunction xrep_xattr
Annotated Snippet
struct xrep_xattr_key {
/* Cookie for retrieval of the xattr name. */
xfblob_cookie name_cookie;
/* Cookie for retrieval of the xattr value. */
xfblob_cookie value_cookie;
/* XFS_ATTR_* flags */
int flags;
/* Length of the value and name. */
uint32_t valuelen;
uint16_t namelen;
};
/*
* Stash up to 8 pages of attrs in xattr_records/xattr_blobs before we write
* them to the temp file.
*/
#define XREP_XATTR_MAX_STASH_BYTES (PAGE_SIZE * 8)
struct xrep_xattr {
struct xfs_scrub *sc;
/* Information for exchanging attr fork mappings at the end. */
struct xrep_tempexch tx;
/* xattr keys */
struct xfarray *xattr_records;
/* xattr values */
struct xfblob *xattr_blobs;
/* Number of attributes that we are salvaging. */
unsigned long long attrs_found;
/* Can we flush stashed attrs to the tempfile? */
bool can_flush;
/* Did the live update fail, and hence the repair is now out of date? */
bool live_update_aborted;
/* Lock protecting parent pointer updates */
struct mutex lock;
/* Fixed-size array of xrep_xattr_pptr structures. */
struct xfarray *pptr_recs;
/* Blobs containing parent pointer names. */
struct xfblob *pptr_names;
/* Hook to capture parent pointer updates. */
struct xfs_dir_hook dhook;
/* Scratch buffer for capturing parent pointers. */
struct xfs_da_args pptr_args;
/* Name buffer */
struct xfs_name xname;
char namebuf[MAXNAMELEN];
};
/* Create a parent pointer in the tempfile. */
#define XREP_XATTR_PPTR_ADD (1)
/* Remove a parent pointer from the tempfile. */
#define XREP_XATTR_PPTR_REMOVE (2)
/* A stashed parent pointer update. */
struct xrep_xattr_pptr {
/* Cookie for retrieval of the pptr name. */
xfblob_cookie name_cookie;
/* Parent pointer record. */
struct xfs_parent_rec pptr_rec;
/* Length of the pptr name. */
uint8_t namelen;
/* XREP_XATTR_PPTR_{ADD,REMOVE} */
uint8_t action;
};
/* Set up to recreate the extended attributes. */
int
xrep_setup_xattr(
struct xfs_scrub *sc)
{
if (xfs_has_parent(sc->mp))
xchk_fsgates_enable(sc, XCHK_FSGATES_DIRENTS);
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_btree.h`.
- Detected declarations: `struct xrep_xattr_key`, `struct xrep_xattr`, `struct xrep_xattr_pptr`, `function xrep_setup_xattr`, `function xrep_xattr_want_salvage`, `function xrep_xattr_salvage_key`, `function xrep_xattr_salvage_sf_attr`, `function xrep_xattr_salvage_local_attr`, `function xrep_xattr_salvage_remote_attr`, `function xrep_xattr_recover_leaf`.
- 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.