220 likes | 259 Views
File Systems. 6.1 Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems. Chapter 6. File System Implementation. A possible file system layout. Implementing Files. Contiguous allocation of disk space for 7 files
E N D
File Systems 6.1 Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems Chapter 6
File System Implementation A possible file system layout
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
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
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
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
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
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
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
Shared Files (a) Situation prior to linking (b) After the link is created (c)After the original owner removes the file
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
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
Disk Space Management – Free Blocks • Storing the free list on a linked list – 16794 blocks of 1K for 16GB • A bit map
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
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)
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
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
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
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
The UNIX V7 File System (1) A UNIX V7 directory entry
The UNIX V7 File System (2) A UNIX i-node
The UNIX V7 File System (3) The steps in looking up /usr/ast/mbox