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.

Dependency Surface

Detected Declarations

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

Implementation Notes