Basic Solution File System - BSFS
Loading...
Searching...
No Matches
rec_gc_bsfs.h File Reference

Recovery garbage collection (GC) routines for BSFS. More...

Functions

size_t rec_gc_purge_until (FILE *disk, superblock_t *sb, uint32_t needed_blocks, uint64_t now)
 Purge Recovery entries until at least a target number of blocks are freed.

Detailed Description

Recovery garbage collection (GC) routines for BSFS.

Provides on-demand purge functions that reclaim disk space occupied by recovery entries (snapshots of deleted files). These are intended to be invoked from allocation paths when the filesystem runs out of free blocks.

Function Documentation

◆ rec_gc_purge_until()

size_t rec_gc_purge_until ( FILE * disk,
superblock_t * sb,
uint32_t needed_blocks,
uint64_t now )

Purge Recovery entries until at least a target number of blocks are freed.

Attempts to reclaim space by first removing expired entries (those with retention_until <= now). If that is insufficient, continues by removing the oldest remaining entries (ascending deleted_at) until at least needed_blocks have been freed or there are no more entries.

For each purged entry, this routine deallocates blocks described by its 16 direct spans and, if present, traverses the per-file bspan B-tree to deallocate the remaining spans. Finally, it removes the metadata entry from the Recovery B-tree.

Parameters
diskOpen filesystem image.
sbLoaded superblock (used for bitmap updates and recovery root).
needed_blocksMinimum number of blocks to free.
nowCurrent timestamp used for retention checks.
Returns
Number of blocks actually freed (can be less than requested).