fs/xfs/scrub/reap.c
Source file repositories/reference/linux-study-clean/fs/xfs/scrub/reap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/scrub/reap.c- Extension
.c- Size
- 47714 bytes
- Lines
- 1695
- 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_btree.hxfs_log_format.hxfs_trans.hxfs_sb.hxfs_inode.hxfs_alloc.hxfs_alloc_btree.hxfs_ialloc.hxfs_ialloc_btree.hxfs_rmap.hxfs_rmap_btree.hxfs_refcount.hxfs_refcount_btree.hxfs_extent_busy.hxfs_ag.hxfs_ag_resv.hxfs_quota.hxfs_qm.hxfs_bmap.hxfs_da_format.hxfs_da_btree.hxfs_attr.hxfs_attr_remote.hxfs_defer.hxfs_metafile.hxfs_rtgroup.h
Detected Declarations
struct xreap_statefunction xreap_put_freelistfunction xreap_is_dirtyfunction xreap_want_binval_rollfunction xreap_binval_resetfunction xreap_inc_binvalfunction xreap_want_defer_finishfunction xreap_defer_finish_resetfunction xreap_inc_deferfunction xreap_force_defer_finishfunction xrep_binval_max_fsblocksfunction scanfunction xrep_bufscan_advancefunction xreap_agextent_binvalfunction xreap_agextent_selectfunction xreap_agextent_iterfunction recordsfunction xreap_configure_limitsfunction xreap_configure_agextent_limitsfunction xreap_configure_agcow_limitsfunction xreap_agmeta_extentfunction xrep_reap_agblocksfunction xreap_fsmeta_extentfunction xrep_reap_fsblocksfunction xreap_rgextent_selectfunction xreap_rgextent_iterfunction xreap_configure_rgcow_limitsfunction xreap_rtmeta_extentfunction xrep_reap_rtblocksfunction xrep_reap_metadir_fsblocksfunction xreap_bmapi_selectfunction xreap_buf_loggablefunction xreap_bmapi_binvalfunction xrep_reap_bmapi_iterfunction xreap_bmapi_binval_mapcountfunction xreap_bmapi_binval_blocksizefunction xreap_configure_bmapi_limitsfunction xreap_ifork_extentfunction xrep_reap_ifork
Annotated Snippet
struct xreap_state {
struct xfs_scrub *sc;
union {
struct {
/*
* For AG blocks, this is reverse mapping owner and
* metadata reservation type.
*/
const struct xfs_owner_info *oinfo;
enum xfs_ag_resv_type resv;
};
struct {
/* For file blocks, this is the inode and fork. */
struct xfs_inode *ip;
int whichfork;
};
};
/* Number of invalidated buffers logged to the current transaction. */
unsigned int nr_binval;
/* Maximum number of buffers we can invalidate in a single tx. */
unsigned int max_binval;
/* Number of deferred reaps attached to the current transaction. */
unsigned int nr_deferred;
/* Maximum number of intents we can reap in a single transaction. */
unsigned int max_deferred;
};
/* Put a block back on the AGFL. */
STATIC int
xreap_put_freelist(
struct xfs_scrub *sc,
xfs_agblock_t agbno)
{
struct xfs_buf *agfl_bp;
int error;
/* Make sure there's space on the freelist. */
error = xrep_fix_freelist(sc, 0);
if (error)
return error;
/*
* Since we're "freeing" a lost block onto the AGFL, we have to
* create an rmap for the block prior to merging it or else other
* parts will break.
*/
error = xfs_rmap_alloc(sc->tp, sc->sa.agf_bp, sc->sa.pag, agbno, 1,
&XFS_RMAP_OINFO_AG);
if (error)
return error;
/* Put the block on the AGFL. */
error = xfs_alloc_read_agfl(sc->sa.pag, sc->tp, &agfl_bp);
if (error)
return error;
error = xfs_alloc_put_freelist(sc->sa.pag, sc->tp, sc->sa.agf_bp,
agfl_bp, agbno, 0);
if (error)
return error;
xfs_extent_busy_insert(sc->tp, pag_group(sc->sa.pag), agbno, 1,
XFS_EXTENT_BUSY_SKIP_DISCARD);
return 0;
}
/* Are there any uncommitted reap operations? */
static inline bool xreap_is_dirty(const struct xreap_state *rs)
{
return rs->nr_binval > 0 || rs->nr_deferred > 0;
}
/*
* Decide if we need to roll the transaction to clear out the the log
* reservation that we allocated to buffer invalidations.
*/
static inline bool xreap_want_binval_roll(const struct xreap_state *rs)
{
return rs->nr_binval >= rs->max_binval;
}
/* Reset the buffer invalidation count after rolling. */
static inline void xreap_binval_reset(struct xreap_state *rs)
{
rs->nr_binval = 0;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_btree.h`, `xfs_log_format.h`.
- Detected declarations: `struct xreap_state`, `function xreap_put_freelist`, `function xreap_is_dirty`, `function xreap_want_binval_roll`, `function xreap_binval_reset`, `function xreap_inc_binval`, `function xreap_want_defer_finish`, `function xreap_defer_finish_reset`, `function xreap_inc_defer`, `function xreap_force_defer_finish`.
- 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.