Indexed Allocation

Indexed allocation 把一個 file 的 data-block pointers 集中放在 index block 或 inode。它像 file system 版的 page table:用 logical block number 查 physical block。

index[0] → logical block 0 的 physical block
index[1] → logical block 1 的 physical block
index[2] → logical block 2 的 physical block

Directory entry / FCB 保存 index block 位置;read logical block i 時查 index[i]。它避免 D-OS-Ch14db-Linked_Allocation 的 pointer chasing,也不像 D-OS-Ch14da-Contiguous_Allocation 要求整段連續空間。

Index Size Problem

SchemeIdeaCost
linked index blocksindex block 不夠就串下一個lookup 可能追 chain
multilevel indexindex 指向 index blocks可能多層 metadata reads
combined schemeinode 放 direct + indirect pointersimplementation 較複雜

UNIX inode 常見 combined scheme:direct pointers for small files,再用 single/double/triple indirect pointers 支援 large files。

Indexed allocation 支援 direct access 與 dynamic growth,但需要 index metadata;若 index block 未 cache,讀 data 前可能先讀 metadata。