1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems
2 File System Implementation A possible file system layout
3 Implementing Files Contiguous allocation of disk space for 7 files State of the disk after files D and E have been removed Addr=(disk address+no of blocks); excellent performance Problem: fragmentation => reuse the holes => final size
4 Implementing Files Storing a file as a linked list of disk blocks Addr = disk address; Problems: random access; data in block not a power of 2
5 Implementing Files Put pointers in a table in RAM Linked list allocation using a file allocation table in RAM The entire block can hold data Random access much faster FAT must always be in RAM: e.g. 20GB / 1KB block => 20M entries ( 3 or 4 bytes) Could be paged
6 Implementing Files An example of i-node Need to be in memory only when file is opened Size proportional to the number of opened files
7 Implementing Directories Directory entry: info for (ASCII name => locate the data) A simple directory –fixed size entries –disk addresses and attributes in directory entry Directory in which each entry just refers to an i-node
8 Implementing Directories Two ways of handling long file names in directory –(a) In-line (requires compacting when an entry is deleted) –(b) In a heap
9 Shared Files File system containing a shared file Tree becomes a DAG If directory entries contain disk addresses then a copy must be made If changes are made, not visible both to B and C –i-nodes –symbolic linking: create a new file of type LINK that contains the path name link
10 Shared Files (a) Situation prior to linking (b) After the link is created (c)After the original owner removes the file
11 Shared Files Options: –Remove the file => B’s link will point to an invalid i-node –Do not remove the file => C continues to be billed for file Symbolic linking –When owner removes file, the file is deleted –Extra overhead (extra disk accesses) –Link to files on machines anywhere in the world A general problem: files can have 2 or more paths –Back up and restore
12 Disk Space Management – Block size How big the block should be? Sector,track,cylinder,page? Recent studies in Unix: median file is 2KB (<< 32KB) Small block size means many blocks => seek + rotational delay Dark line (left hand scale) gives data rate of a disk Dotted line (right hand scale) gives disk space efficiency Performance and space utilization are inherently in conflict Block size
13 Disk Space Management – Free Blocks Storing the free list on a linked list – blocks of 1K for 16GB A bit map
14 Disk Space Management – Disk Quotas Sys Admin assigns a max number of files and blocks Quotas for keeping track of each user’s disk use
15 File System Reliability - Backups Back up only specific directories Incremental dump: only files that changed Compress the data before writing them to tape Difficult to perform back up on an active FS Non-technical decisions: security, protection Back up methods –Physical dump (the entire disk, block by block) –Logical dump (starts at one directory and proceeds recursively)
16 File System Reliability- Consistency File system states (a) consistent (b) missing block – add to free list (c) duplicate block in free list – rebuild the free list (d) duplicate data block – copy the contents and insert
17 File System Performance - Caching Check all read request to check if block in block cache Hash the the disk address and use a hash table LRU possible but not – completely – desirable (i-nodes) UNIX: sync, MSDOS: write-through cache
18 File System Performance – Block Read Ahead Get blocks in the cache before needed Many files are read sequentially: –get next block in case is needed Try to determine whether files are in: –Sequential access mode –Random access mode
19 File System Performance– Arm Motion Blocks likely to be accessed in sequence next to each other I-nodes placed at the start of the disk Disk divided into cylinder groups –each with its own blocks and i-nodes
20 The UNIX V7 File System (1) A UNIX V7 directory entry
21 The UNIX V7 File System (2) A UNIX i-node
22 The UNIX V7 File System (3) The steps in looking up /usr/ast/mbox