Free-Space Management

Free-space management 追蹤哪些 storage blocks 沒被 file / directory 使用。Allocation 要從這裡拿 blocks;delete / truncate 要把 blocks 放回來。

file grows → allocate free blocks
file deleted → return blocks to free-space structure

Major Techniques

TechniqueGood atMain cost
D-OS-Ch14ea-Bit_Vector_Free_Space_Management找 free / contiguous bitsbitmap 可能大,分散更新多
D-OS-Ch14eb-Free_Space_List_Variants簡單取得 free blocks找 contiguous ranges 較弱
D-OS-Ch14ec-Space_Maplarge pool、range-based free spaceimplementation 複雜
D-OS-Ch14ed-TRIM告知 SSD/NVM 哪些 logical blocks 已不用hint batching / command overhead

Interaction with Allocation

  • Contiguous / extent allocation 需要 large contiguous holes。
  • Linked allocation 只需要任意 free block。
  • Indexed allocation 需要 data blocks,也可能需要 index blocks。

核心 tradeoff:metadata size、allocation speed、deallocation speed、locality、crash recovery。Free-space metadata 本身也需要 journal / COW 保護。