Filing Systems At the outset we identified long-term storage as desirable characteristic of an OS. EG: On-line storage for an MIS. Convenience of not having to re-write programs. Sharing of data in an efficient manner. For reasons of economy, such storage is provide by media such as disk, tape and CD-ROM. Requires a filing system to provide means of organising and accessing data in a convenient manner for the user. 1 Filing Systems Users typically operate with an abstraction called a file. A file is merely a collection of data, regarded as an entity by the user. It may be a program, a collection of information, the results of an experiment etc. The file is thus the logical unit to be stored and manipulated by the filing system. The file size may vary. The medium on which the file is stored (the disk) is usually divided into fixed length blocks. The filing system must allocate the appropriate number of blocks to a file. 2 1
Filing Systems Requirements for a filing system Allow for creation and deletion of files. Allow access to files for reading and writing. Automatically manage the storage space - exact locations should be of no concern to the user. Allow reference to files by symbolic name (as above) Protect against system failure Allow for both sharing and protection. 3 Filing Systems File Directories In order to access a file, OS must map symbolic name to a physical location. This mapping is achieved by means of a file directory. A directory (or table) containing information about locations of files. MS-DOS, Windows 95, NetWare and UNIX extend this concept to a multilevel structure. i.e. An entry within the directory may point to another directory rather than a specific file. Results in an easy to use tree-like classification. Increased amount of directory access though to follow path to file. 4 2
Filing Systems Security and sharing can be achieved by listing a set of access privileges (or protection mask) in the directory entry table for each file. EG : Novells Trustee Assignments, Windows NT uses ACL s Secondary Memory Organisation File storage space is generally allocated in blocks. We will assume that blocks on a disk are numbered in some way. EG : from 1 to Total in increments of 1. There are, then, many ways to organise the blocks of a file. 5 Disk Organisation Contiguous Files - All blocks in the file are adjacent. - Directory entry just needs to point to first disk block and record size of file. - Suffers from fragmentation over time. Block Linkage - Some bytes in each block of the file are used as a pointer to the next block. - Low overhead, but requires many disk accesses for large files. - Fault tolerance is questionable. 6 3
Disk Organisation File Map The state of the disk is recorded in a file map or file allocation table. Each disk block has a single entry in this table. The Directory Entry Table (containing symbolic names of files) points to the location in the FAT which represents the first block in the file. This in turn points to the location in the map representing the next block in the file etc.. Amount of overhead will depend on the size and number of map entries. Generally the file map is stored on disk and brought into memory as necessary (e.g NetWare Mounts a volume). 7 Damage to the map can result in loss of data. Secondary Storage Management Need to allocate blocks to files and keep track of free blocks. Pre-allocation or dynamic allocation? Disk Portion Size? Larger blocks require smaller mgt tables. Variable sized blocks minimises over-allocation of space. Contiguous portions should improve performance. Small blocks provide greatest flexibility. 8 4
Secondary Storage Management : Free Space Need to also manage the space not currently allocated. What blocks are available? Need a disk allocation table as well as a file allocation table. EG: Bit table - A vector (or linear array) containing one bit for each block on the disk. A zero bit represents a free block, a 1 bit represents a used block. 00111000000111110000111001100110111001110000011111 9 Disk Management RAID Technologies The separation of logical volumes from physical disk partitions makes it possible for some operating systems to support higher performance than that of the underlying hardware. Striping A striped logical volume is one that is built over a number of partitions, placing the blocks of the volume on each partition in turn. Note that the partitions are located on different disks. (See diagram) 10 5
Striping RAID 0 Partition 1 0-7 24-31 48-55.. Partition 2 8-15 32-39 56-63.. Partition 3 16-23 40-57 64-71.. The above illustrates the case of a volume striped over three partitions. If we assume that a file is being read sequentially, then this organisation allows for groups of blocks to be read from each disk. In the above scenario, performance / throughput can be improved by up to three times that of a single disk. 11 Mirroring Although a striped volume is stored across a number of disks it does not provide additional resilience to disk failures if any constituent disk becomes unavailable then the entires file system is lost. In contrast a mirrored volume does provide resilience to disk failures. Mirroring involves replicating data across a number of disks so that each holds a complete copy of the logical volume. - See diagram. 12 6
Mirroring Partition 1 0-7 8-15 16-23.. Partition 2 0-7 8-15 16-23.. Partition 3 0-7 8-15 16-23.. While mirroring adds resilience, it does impose a penalty to write operations as all disks must be updated (These updates can usually be performed asunchronously though, so this write penalty may not be a cause of concern). 13 RAID Collectively, striping and mirroring are two modes of operating a Redundant Array of Inexpensive Disks, or RAID. The RAID Cateogrisations are as follows: Striping : RAID 0 Mirroring : RAID 1 Striping and mirroring are combined in RAID 5 to provide a degree of fault tolerance without the high overhead that simple mirroring imposes. 14 7
RAID 5 RAID 5 augments a striped volume with additional space to a parity check for each position on the disks. Partition 1 0-7 24-31 Parity 48-55.. Partition 2 8-15 Parity 32-39 56-63.. Partition 3 Parity 16-23 40-47 Parity.. For each block position, two of the disks will hold data, and the third will hold the exclusive-or of the other two s content. XOR is selected because it means that if one disk fails its content can be recovered by forming the XOR of the remaining two. 15 RAID 5 Disks hold the parity check information cyclically to avoid any one disk becoming the bottleneck since a parity block must be updated for any write performed. Data blocks are also placed cyclically to balance the load between disks during sequential operations. 16 8