fs/xfs/xfs_zone_gc.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_zone_gc.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_zone_gc.c- Extension
.c- Size
- 31486 bytes
- Lines
- 1234
- 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_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_btree.hxfs_trans.hxfs_icache.hxfs_rmap.hxfs_rtbitmap.hxfs_rtrmap_btree.hxfs_errortag.hxfs_error.hxfs_zone_alloc.hxfs_zone_priv.hxfs_zones.hxfs_trace.h
Detected Declarations
struct xfs_gc_biostruct xfs_zone_gc_iterstruct xfs_zone_gc_datafunction xfs_zoned_need_gcfunction xfs_zone_gc_data_allocfunction xfs_zone_gc_data_freefunction xfs_zone_gc_iter_initfunction xfs_zone_gc_query_cbfunction xfs_zone_gc_rmap_rec_cmpfunction xfs_zone_gc_queryfunction xfs_zone_gc_iter_irecfunction xfs_zone_gc_iter_advancefunction xfs_zone_gc_pick_victim_fromfunction for_each_set_bitfunction xfs_zone_gc_select_victimfunction xfs_zone_gc_steal_open_zonefunction xfs_zone_gc_select_targetfunction xfs_zone_gc_end_iofunction xfs_zone_gc_alloc_blocksfunction xfs_zone_gc_add_datafunction xfs_zone_gc_can_start_chunkfunction xfs_zone_gc_start_chunkfunction xfs_zone_gc_free_chunkfunction xfs_zone_gc_submit_writefunction xfs_zone_gc_split_writefunction xfs_zone_gc_write_chunkfunction xfs_zone_gc_finish_chunkfunction xfs_zone_gc_finish_resetfunction xfs_submit_zone_reset_biofunction xfs_zone_gc_reset_syncfunction xfs_zone_gc_reset_zonesfunction xfs_zone_gc_queryfunction list_for_each_entry_safefunction list_for_each_entry_safefunction xfs_zoned_gcdfunction xfs_zone_gc_startfunction xfs_zone_gc_stopfunction xfs_zone_gc_wakeupfunction xfs_zone_gc_mountfunction xfs_zone_gc_unmount
Annotated Snippet
struct xfs_gc_bio {
struct xfs_zone_gc_data *data;
/*
* Entry into the reading/writing/resetting list. Only accessed from
* the GC thread, so no locking needed.
*/
struct list_head entry;
/*
* State of this gc_bio. Done means the current I/O completed.
* Set from the bio end I/O handler, read from the GC thread.
*/
enum {
XFS_GC_BIO_NEW,
XFS_GC_BIO_DONE,
} state;
/*
* Pointer to the inode and byte range in the inode that this
* GC chunk is operating on.
*/
struct xfs_inode *ip;
loff_t offset;
unsigned int len;
/*
* Existing startblock (in the zone to be freed) and newly assigned
* daddr in the zone GCed into.
*/
xfs_fsblock_t old_startblock;
xfs_daddr_t new_daddr;
/* Are we writing to a sequential write required zone? */
bool is_seq;
/* Open Zone being written to */
struct xfs_open_zone *oz;
struct xfs_rtgroup *victim_rtg;
/* Bio used for reads and writes, including the bvec used by it */
struct bio bio; /* must be last */
};
#define XFS_ZONE_GC_RECS 1024
/* iterator, needs to be reinitialized for each victim zone */
struct xfs_zone_gc_iter {
struct xfs_rtgroup *victim_rtg;
unsigned int rec_count;
unsigned int rec_idx;
xfs_agblock_t next_startblock;
struct xfs_rmap_irec *recs;
};
/*
* Per-mount GC state.
*/
struct xfs_zone_gc_data {
struct xfs_mount *mp;
struct xfs_open_zone *oz;
/* bioset used to allocate the gc_bios */
struct bio_set bio_set;
/*
* Scratchpad to buffer GC data, organized as a ring buffer over
* discontiguous folios. scratch_head is where the buffer is filled,
* scratch_tail tracks the buffer space freed, and scratch_available
* counts the space available in the ring buffer between the head and
* the tail.
*/
struct folio *scratch_folios[XFS_GC_NR_BUFS];
unsigned int scratch_size;
unsigned int scratch_available;
unsigned int scratch_head;
unsigned int scratch_tail;
/*
* List of bios currently being read, written and reset.
* These lists are only accessed by the GC thread itself, and must only
* be processed in order.
*/
struct list_head reading;
struct list_head writing;
struct list_head resetting;
/*
* Iterator for the victim zone.
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_inode.h`, `xfs_btree.h`.
- Detected declarations: `struct xfs_gc_bio`, `struct xfs_zone_gc_iter`, `struct xfs_zone_gc_data`, `function xfs_zoned_need_gc`, `function xfs_zone_gc_data_alloc`, `function xfs_zone_gc_data_free`, `function xfs_zone_gc_iter_init`, `function xfs_zone_gc_query_cb`, `function xfs_zone_gc_rmap_rec_cmp`, `function xfs_zone_gc_query`.
- 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.