Annotation of cci/usr/src/man/man5/fs.5, revision 1.1.1.1

1.1       root        1: .TH FS 5 "18 July 1983"
                      2: .UC 4
                      3: .SH NAME
                      4: fs, inode \- format of file system volume
                      5: .SH SYNOPSIS
                      6: .B #include <sys/types.h>
                      7: .br
                      8: .B #include <sys/fs.h>
                      9: .br
                     10: .B #include <sys/inode.h>
                     11: .SH DESCRIPTION
                     12: Every file system storage volume (disk, nine-track tape, for instance)
                     13: has a common format for certain vital information.
                     14: Every such volume is divided into a certain number of blocks.
                     15: The block size is a parameter of the file system.
                     16: Sectors 0 to 15 on a file system are used to contain primary
                     17: and secondary bootstrapping programs.
                     18: .PP
                     19: The actual file system begins at sector 16 with the
                     20: .I "super block."
                     21: The layout of the super block as defined by the include file
                     22: .RI < sys/fs.h >
                     23: is:
                     24: .PP
                     25: .nf
                     26: #define        FS_MAGIC        0x011954
                     27: struct fs {
                     28:        struct  fs *fs_link;            /* linked list of file systems */
                     29:        struct  fs *fs_rlink;           /*     used for incore super blocks */
                     30:        daddr_t fs_sblkno;              /* addr of super-block in filesys */
                     31:        daddr_t fs_cblkno;              /* offset of cyl-block in filesys */
                     32:        daddr_t fs_iblkno;              /* offset of inode-blocks in filesys */
                     33:        daddr_t fs_dblkno;              /* offset of first data after cg */
                     34:        long    fs_cgoffset;            /* cylinder group offset in cylinder */
                     35:        long    fs_cgmask;              /* used to calc mod fs_ntrak */
                     36:        time_t  fs_time;                /* last time written */
                     37:        long    fs_size;                /* number of blocks in fs */
                     38:        long    fs_dsize;               /* number of data blocks in fs */
                     39:        long    fs_ncg;                 /* number of cylinder groups */
                     40:        long    fs_bsize;               /* size of basic blocks in fs */
                     41:        long    fs_fsize;               /* size of frag blocks in fs */
                     42:        long    fs_frag;                /* number of frags in a block in fs */
                     43: /* these are configuration parameters */
                     44:        long    fs_minfree;             /* minimum percentage of free blocks */
                     45:        long    fs_rotdelay;            /* num of ms for optimal next block */
                     46:        long    fs_rps;                 /* disk revolutions per second */
                     47: /* these fields can be computed from the others */
                     48:        long    fs_bmask;               /* ``blkoff'' calc of blk offsets */
                     49:        long    fs_fmask;               /* ``fragoff'' calc of frag offsets */
                     50:        long    fs_bshift;              /* ``lblkno'' calc of logical blkno */
                     51:        long    fs_fshift;              /* ``numfrags'' calc number of frags */
                     52: /* these are configuration parameters */
                     53:        long    fs_maxcontig;           /* max number of contiguous blks */
                     54:        long    fs_maxbpg;              /* max number of blks per cyl group */
                     55: /* these fields can be computed from the others */
                     56:        long    fs_fragshift;           /* block to frag shift */
                     57:        long    fs_fsbtodb;             /* fsbtodb and dbtofsb shift constant */
                     58:        long    fs_sbsize;              /* actual size of super block */
                     59:        long    fs_csmask;              /* csum block offset */
                     60:        long    fs_csshift;             /* csum block number */
                     61:        long    fs_nindir;              /* value of NINDIR */
                     62:        long    fs_inopb;               /* value of INOPB */
                     63:        long    fs_nspf;                /* value of NSPF */
                     64:        long    fs_sparecon[6];         /* reserved for future constants */
                     65: /* sizes determined by number of cylinder groups and their sizes */
                     66:        daddr_t fs_csaddr;              /* blk addr of cyl grp summary area */
                     67:        long    fs_cssize;              /* size of cyl grp summary area */
                     68:        long    fs_cgsize;              /* cylinder group size */
                     69: /* these fields should be derived from the hardware */
                     70:        long    fs_ntrak;               /* tracks per cylinder */
                     71:        long    fs_nsect;               /* sectors per track */
                     72:        long    fs_spc;                 /* sectors per cylinder */
                     73: /* this comes from the disk driver partitioning */
                     74:        long    fs_ncyl;                /* cylinders in file system */
                     75: /* these fields can be computed from the others */
                     76:        long    fs_cpg;                 /* cylinders per group */
                     77:        long    fs_ipg;                 /* inodes per group */
                     78:        long    fs_fpg;                 /* blocks per group * fs_frag */
                     79: /* this data must be re-computed after crashes */
                     80:        struct  csum fs_cstotal;        /* cylinder summary information */
                     81: /* these fields are cleared at mount time */
                     82:        char    fs_fmod;                /* super block modified flag */
                     83:        char    fs_clean;               /* file system is clean flag */
                     84:        char    fs_ronly;               /* mounted read-only flag */
                     85:        char    fs_flags;               /* currently unused flag */
                     86:        char    fs_fsmnt[MAXMNTLEN];    /* name mounted on */
                     87: /* these fields retain the current block allocation info */
                     88:        long    fs_cgrotor;             /* last cg searched */
                     89:        struct  csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */
                     90:        long    fs_cpc;                 /* cyl per cycle in postbl */
                     91:        short   fs_postbl[MAXCPG][NRPOS];/* head of blocks for each rotation */
                     92:        long    fs_magic;               /* magic number */
                     93:        u_char  fs_rotbl[1];            /* list of blocks for each rotation */
                     94: /* actually longer */
                     95: };
                     96: .fi
                     97: .LP
                     98: Each disk drive contains some number of file systems.
                     99: A file system consists of a number of cylinder groups.
                    100: Each cylinder group has inodes and data.
                    101: .LP
                    102: A file system is described by its super-block, which in turn
                    103: describes the cylinder groups.  The super-block is critical
                    104: data and is replicated in each cylinder group to protect against
                    105: catastrophic loss.  This is done at file system creation
                    106: time and the critical
                    107: super-block data does not change, so the copies need not be
                    108: referenced further unless disaster strikes.
                    109: .LP
                    110: Addresses stored in inodes are capable of addressing fragments
                    111: of `blocks'. File system blocks of at most size MAXBSIZE can 
                    112: be optionally broken into 2, 4, or 8 pieces, each of which is
                    113: addressable; these pieces may be DEV_BSIZE, or some multiple of
                    114: a DEV_BSIZE unit.
                    115: .LP
                    116: Large files consist of exclusively large data blocks.  To avoid
                    117: undue wasted disk space, the last data block of a small file is
                    118: allocated as only as many fragments of a large block as are
                    119: necessary.  The file system format retains only a single pointer
                    120: to such a fragment, which is a piece of a single large block that
                    121: has been divided.  The size of such a fragment is determinable from
                    122: information in the inode, using the ``blksize(fs, ip, lbn)'' macro.
                    123: .LP
                    124: The file system records space availability at the fragment level;
                    125: to determine block availability, aligned fragments are examined.
                    126: .LP
                    127: The root inode is the root of the file system.
                    128: Inode 0 can't be used for normal purposes and
                    129: historically bad blocks were linked to inode 1,
                    130: thus the root inode is 2 (inode 1 is no longer used for
                    131: this purpose, however numerous dump tapes make this
                    132: assumption, so we are stuck with it).
                    133: The
                    134: .I lost+found
                    135: directory is given the next available
                    136: inode when it is initially created by
                    137: .IR mkfs .
                    138: .LP
                    139: .I fs_minfree
                    140: gives the minimum acceptable percentage of file system
                    141: blocks which may be free. If the freelist drops below this level
                    142: only the super-user may continue to allocate blocks. This may
                    143: be set to 0 if no reserve of free blocks is deemed necessary,
                    144: however severe performance degradations will be observed if the
                    145: file system is run at greater than 90% full; thus the default
                    146: value of
                    147: .I fs_minfree
                    148: is 10%.
                    149: .LP
                    150: Empirically the best trade-off between block fragmentation and
                    151: overall disk utilization at a loading of 90% comes with a
                    152: fragmentation of 4, thus the default fragment size is a fourth
                    153: of the block size.
                    154: .LP
                    155: .I Cylinder group related
                    156: .IR limits :
                    157: Each cylinder keeps track of the availability of blocks at different
                    158: rotational positions, so that sequential blocks can be laid out
                    159: with minimum rotational latency.  NRPOS is the number of rotational
                    160: positions which are distinguished.  With NRPOS 8 the resolution of the
                    161: summary information is 2ms for a typical 3600 rpm drive.
                    162: .LP
                    163: .I fs_rotdelay
                    164: gives the minimum number of milliseconds to initiate
                    165: another disk transfer on the same cylinder.  It is used in
                    166: determining the rotationally optimal layout for disk blocks
                    167: within a file; the default value for
                    168: .I fs_rotdelay
                    169: is 2ms.
                    170: .LP
                    171: Each file system has a statically allocated number of inodes.
                    172: An inode is allocated for each NBPI bytes of disk space.
                    173: The inode allocation strategy is extremely conservative.
                    174: .LP
                    175: MAXIPG bounds the number of inodes per cylinder group, and
                    176: is needed only to keep the structure simpler by having the
                    177: only a single variable size element (the free bit map).
                    178: .LP
                    179: .B N.B.:
                    180: MAXIPG must be a multiple of INOPB(fs).
                    181: .LP
                    182: MINBSIZE is the smallest allowable block size.
                    183: With a MINBSIZE of 4096
                    184: it is possible to create files of size
                    185: 2^32 with only two levels of indirection.
                    186: MINBSIZE must be big enough to hold a cylinder group block,
                    187: thus changes to (struct cg) must keep its size within MINBSIZE.
                    188: MAXCPG is limited only to dimension an array in (struct cg);
                    189: it can be made larger as long as that structure's size remains
                    190: within the bounds dictated by MINBSIZE.
                    191: Note that super blocks are never more than size SBSIZE.
                    192: .LP
                    193: The path name on which the file system is mounted is maintained
                    194: in
                    195: .IR fs_fsmnt .
                    196: MAXMNTLEN defines the amount of space allocated in 
                    197: the super block for this name.
                    198: The limit on the amount of summary information per file system
                    199: is defined by MAXCSBUFS. It is currently parameterized for a
                    200: maximum of two million cylinders.
                    201: .LP
                    202: Per cylinder group information is summarized in blocks allocated
                    203: from the first cylinder group's data blocks. 
                    204: These blocks are read in from
                    205: .I fs_csaddr
                    206: (size
                    207: .IR fs_cssize )
                    208: in addition to the super block.
                    209: .LP
                    210: .B N.B.:
                    211: sizeof (struct csum) must be a power of two in order for
                    212: the ``fs_cs'' macro to work.
                    213: .LP
                    214: .I Super block for a file
                    215: .IR system :
                    216: MAXBPC bounds the size of the rotational layout tables and
                    217: is limited by the fact that the super block is of size SBSIZE.
                    218: The size of these tables is
                    219: .B inversely
                    220: proportional to the block
                    221: size of the file system. The size of the tables is
                    222: increased when sector sizes are not powers of two,
                    223: as this increases the number of cylinders
                    224: included before the rotational pattern repeats (
                    225: .IR fs_cpc ).
                    226: The size of the rotational layout
                    227: tables is derived from the number of bytes remaining in (struct fs).
                    228: .LP
                    229: MAXBPG bounds the number of blocks of data per cylinder group,
                    230: and is limited by the fact that cylinder groups are at most one block.
                    231: The size of the free block table
                    232: is derived from the size of blocks and the number
                    233: of remaining bytes in the cylinder group structure (struct cg).
                    234: .LP
                    235: .IR Inode :
                    236: The inode is the focus of all file activity in the
                    237: UNIX file system.  There is a unique inode allocated
                    238: for each active file,
                    239: each current directory, each mounted-on file,
                    240: text file, and the root.
                    241: An inode is `named' by its device/i-number pair.
                    242: For further information, see the include file
                    243: .RI < sys/inode.h >.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.