20.11 Resource Allocation

Our attention now turns to the management of the resources of an individual FSV (file system volume).

Storage blocks are allocated from the free list by “alloc” at the request of “bmap”. Storage blocks are returned to the free list by “free” at the behest of “itrunc” (which is called by “core”, “openl” and “iput”).

Entries in the FSV “inode” tables are made by “ialloc”, which is called by “maknode” and “pipe”. Entries in this table are cancelled by “ifree”, which is called by “iput”.

The “super block” for the FSV is central to the resource management procedures. The “super block” (5561) contains:

If the list in core of available “inode” entries for the file system volume ever becomes exhausted, then the entire table on the FSV is read and searched to rebuild the list. Conversely if the available “inode” table overflows, additional entries are simply forgotten to be rediscovered later.

A different strategy is used for the list of available storage blocks. These blocks are arranged in groups of up to one hundred blocks. The first block in each group (except the very first) is used to store the addresses of the blocks belonging to the previous group. Addresses of blocks in the last incomplete group are stored in the “super block”.

The first entry in the first list of block numbers is zero, which acts as a sentinel. Since the whole list is subject to a LIFO discipline, discovery of a block number of zero in the list signifies that the list is in fact empty.