fs(4)fs(4)NAME
fs, inode - Specifies the format of the file system volume
SYNOPSIS
#include <sys/types.h>
#include <sys/fs.h>
#include <ufs/inode.h>
DESCRIPTION
Every file system storage volume (disk, nine-track tape, for instance)
has a common format for certain vital information. Each such volume is
divided into a certain number of blocks. The block size is a parameter
of the file system. Sectors beginning at BBLOCK and continuing for
BBSIZE are used to contain a label and for some hardware primary and
secondary bootstrapping programs.
Each disk drive contains some number of file systems. A file system
consists of a number of cylinder groups. Each cylinder group has inodes
and data.
A file system is described by its superblock, which in turn describes
the cylinder groups. The superblock is critical data and is replicated
in each cylinder group to protect against loss of data. This is done
at file system creation time and the critical superblock data does not
change, so the copies need not be referenced further until necessary.
Addresses stored in inodes are capable of addressing fragments of
blocks. File system blocks of at most MAXBSIZE size can be optionally
broken into 2, 4, or 8 pieces, each of which is addressable; these
pieces may be DEV_BSIZE, or some multiple of a DEV_BSIZE unit.
Large files consist exclusively of large data blocks. To avoid wasted
disk space, the last data block of a small file is allocated only as
many fragments of a large block as are necessary. The file system for‐
mat retains only a single pointer to such a fragment, which is a piece
of a single large block that has been divided. The size of such a
fragment is determined from information in the inode, using the blk‐
size(fs, ip, lbn) macro.
The file system records space availability at the fragment level; to
determine block availability, aligned fragments are examined.
The root inode is the root of the file system. Inode 0 (zero) can't be
used for normal purposes and, historically, bad blocks were linked to
inode 1. Thus, the root inode is 2 (inode 1 is no longer used for this
purpose, but numerous dump tapes make this assumption).
Some fields to the fs structure are as follows: Gives the minimum
acceptable percentage of file system blocks that may be free. If the
freelist drops below this level only the superuser may continue to
allocate blocks. The fs_minfree field may be set to 0 (zero) if no
reserve of free blocks is deemed necessary. However, severe performance
degradations will be observed if the file system is run at greater than
90% full; thus the default value of the fs_minfree field is 10%.
Empirically the best trade-off between block fragmentation and
overall disk utilization at a loading of 90% comes with a frag‐
mentation of 8, thus the default fragment size is an eighth of
the block size. Specifies whether the file system should try to
minimize the time spent allocating blocks, or if it should
attempt to minimize the space fragmentation on the disk. If the
value of fs_minfree is less than 10%, then the file system
defaults to optimizing for space to avoid running out of full
sized blocks. If the value of fs_minfree is greater than or
equal to 10%, fragmentation is unlikely to be problematical, and
the file system defaults to optimizing for time.
Cylinder group related limits: Each cylinder keeps track of the
availability of blocks at different positions of rotation, so
that sequential blocks can be laid out with minimum rotational
latency. With the default of 8 distinguished rotational posi‐
tions, the resolution of the summary information is 2 millisec‐
onds for a typical 3600 rpm drive. Gives the minimum number of
milliseconds to initiate another disk transfer on the same
cylinder. The fs_rotdelay field is used in determining the
rotationally optimal layout for disk blocks within a file; the
default value for fs_rotdelay is 2 milliseconds.
Each file system has a statically allocated number of inodes. An inode
is allocated for each NBPI bytes of disk space. The inode allocation
strategy is extremely conservative.
MINBSIZE is the smallest allowable block size. With a MINBSIZE of 4096
it is possible to create files of size 2^32 with only two levels of
indirection.MINBSIZE must be big enough to hold a cylinder group block,
thus changes to struct cg must keep its size within MINBSIZE. Note that
superblocks are never more than size SBSIZE.
The pathname on which the file system is mounted is maintained in
fs_fsmnt. MAXMNTLEN defines the amount of space allocated in the
superblock for this name. The limit on the amount of summary informa‐
tion per file system is defined by MAXCSBUFS. For a 4096 byte block
size, it is currently parameterized for a maximum of two million cylin‐
ders.
Per cylinder group information is summarized in blocks allocated from
the first cylinder group's data blocks. These blocks are read in from
fs_csaddr (size fs_cssize) in addition to the superblock.
Superblock for a file system: The size of the rotational layout tables
is limited by the fact that the superblock is of size SBSIZE. The size
of these tables is inversely proportional to the block size of the file
system. The size of the tables is increased when sector sizes are not
powers of two, as this increases the number of cylinders included
before the rotational pattern repeats (fs_cpc). The size of the rota‐
tional layout tables is derived from the number of bytes remaining in
(struct fs).
The number of blocks of data per cylinder group is limited because
cylinder groups are at most one block. The inode and free block tables
must fit into a single block after deducting space for the cylinder
group structure struct cg.
Inode: The inode is the focus of all file activity in the UNIX file
system. There is a unique inode allocated for each active file, each
current directory, each mounted-on file, text file, and the root. An
inode is `named' by its device/i-number pair.
NOTES
sizeof (struct csum) must be a power of two in order for the fs_cs
macro to work.
fs(4)