Chapter 11 File System Implementation Operating System Concepts
- Slides: 36
Chapter 11: File System Implementation Operating System Concepts – 8 th Edition, Silberschatz, Galvin and Gagne © 2009
Chapter 11: File System Implementation n File-System Structure n File-System Implementation n Directory Implementation n Allocation Methods n Free-Space Management n Efficiency and Performance n Recovery n Log-Structured File Systems n NFS n Example: WAFL File System Operating System Concepts – 8 th Edition 11. 2 Silberschatz, Galvin and Gagne © 2009
Objectives n To describe the details of implementing local file systems and directory structures n To describe the implementation of remote file systems n To discuss block allocation and free-block algorithms and trade-offs Operating System Concepts – 8 th Edition 11. 3 Silberschatz, Galvin and Gagne © 2009
File-System Structure n File structure l Logical storage unit l Collection of related information n File system resides on secondary storage (disks) n File system organized into layers n File control block – storage structure consisting of information about a file Operating System Concepts – 8 th Edition 11. 4 Silberschatz, Galvin and Gagne © 2009
Layered File System Operating System Concepts – 8 th Edition 11. 5 Silberschatz, Galvin and Gagne © 2009
A Typical File Control Block Operating System Concepts – 8 th Edition 11. 6 Silberschatz, Galvin and Gagne © 2009
In-Memory File System Structures n The following figure illustrates the necessary file system structures provided by the operating systems. n Figure 12 -3(a) refers to opening a file. n Figure 12 -3(b) refers to reading a file. Operating System Concepts – 8 th Edition 11. 7 Silberschatz, Galvin and Gagne © 2009
In-Memory File System Structures Operating System Concepts – 8 th Edition 11. 8 Silberschatz, Galvin and Gagne © 2009
Virtual File Systems n Virtual File Systems (VFS) provide an object-oriented way of implementing file systems. n VFS allows the same system call interface (the API) to be used for different types of file systems. n The API is to the VFS interface, rather than any specific type of file system. Operating System Concepts – 8 th Edition 11. 9 Silberschatz, Galvin and Gagne © 2009
Schematic View of Virtual File System Operating System Concepts – 8 th Edition 11. 10 Silberschatz, Galvin and Gagne © 2009
Directory Implementation n Linear list of file names with pointer to the data blocks. l simple to program l time-consuming to execute n Hash Table – linear list with hash data structure. l decreases directory search time l collisions – situations where two file names hash to the same location l fixed size Operating System Concepts – 8 th Edition 11. 11 Silberschatz, Galvin and Gagne © 2009
Allocation methods Operating System Concepts – 8 th Edition 11. 12 Silberschatz, Galvin and Gagne © 2009
Allocation Methods n An allocation method refers to how disk blocks are allocated for files: n Contiguous allocation n Linked allocation n Indexed allocation Operating System Concepts – 8 th Edition 11. 13 Silberschatz, Galvin and Gagne © 2009
Contiguous Allocation n Each file occupies a set of contiguous blocks on the disk n Simple – only starting location (block #) and length (number of blocks) are required n Random access n Wasteful of space (dynamic storage-allocation problem) n Files cannot grow Operating System Concepts – 8 th Edition 11. 14 Silberschatz, Galvin and Gagne © 2009
Contiguous Allocation n Mapping from logical to physical Q LA/512 R Block to be accessed = ! + starting address Displacement into block = R Operating System Concepts – 8 th Edition 11. 15 Silberschatz, Galvin and Gagne © 2009
Contiguous Allocation of Disk Space Operating System Concepts – 8 th Edition 11. 16 Silberschatz, Galvin and Gagne © 2009
Extent-Based Systems n Many newer file systems use a modified contiguous allocation scheme n Extent-based file systems allocate disk blocks in extents n An extent is a contiguous block of disk l Extents are allocated for file allocation l A file consists of one or more extents. n Most modern file systems support it: l Linux: Ext 4, Reiser 4 l Windows: NTFS l Apple: HFS Plus Operating System Concepts – 8 th Edition 11. 17 Silberschatz, Galvin and Gagne © 2009
Linked Allocation n Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. block Operating System Concepts – 8 th Edition = pointer 11. 18 Silberschatz, Galvin and Gagne © 2009
Linked Allocation (Cont. ) n Simple – need only starting address n Free-space management system – no waste of space n No random access n Mapping Q LA/511 R Block to be accessed is the Qth block in the linked chain of blocks representing the file. Displacement into block = R + 1 File-allocation table (FAT) – disk-space allocation used by MS-DOS and OS/2. Operating System Concepts – 8 th Edition 11. 19 Silberschatz, Galvin and Gagne © 2009
Linked Allocation Operating System Concepts – 8 th Edition 11. 20 Silberschatz, Galvin and Gagne © 2009
File-Allocation Table Operating System Concepts – 8 th Edition 11. 21 Silberschatz, Galvin and Gagne © 2009
Indexed Allocation n Brings all pointers together into the index block. n Logical view. index table Operating System Concepts – 8 th Edition 11. 22 Silberschatz, Galvin and Gagne © 2009
Example of Indexed Allocation Operating System Concepts – 8 th Edition 11. 23 Silberschatz, Galvin and Gagne © 2009
Indexed Allocation (Cont. ) n Need index table n Random access n Dynamic access without external fragmentation, but have overhead of index block. n Mapping from logical to physical in a file of maximum size of 256 K words and block size of 512 words. We need only 1 block for index table. Q LA/512 R Q = displacement into index table R = displacement into block Operating System Concepts – 8 th Edition 11. 24 Silberschatz, Galvin and Gagne © 2009
Indexed Allocation – Mapping (Cont. ) n Mapping from logical to physical in a file of unbounded length (block size of 512 words). n Linked scheme – Link blocks of index table (no limit on size). Q 1 LA / (512 x 511) R 1 Q 1 = block of index table R 1 is used as follows: Q 2 R 1 / 512 R 2 Q 2 = displacement into block of index table R 2 displacement into block of file: Operating System Concepts – 8 th Edition 11. 25 Silberschatz, Galvin and Gagne © 2009
Indexed Allocation – Mapping (Cont. ) n Two-level index (maximum file size is 5123) Q 1 LA / (512 x 512) R 1 Q 1 = displacement into outer-index R 1 is used as follows: R 1 / 512 Q 2 R 2 Q 2 = displacement into block of index table R 2 displacement into block of file: Operating System Concepts – 8 th Edition 11. 26 Silberschatz, Galvin and Gagne © 2009
Indexed Allocation – Mapping (Cont. ) outer-index table Operating System Concepts – 8 th Edition 11. 27 file Silberschatz, Galvin and Gagne © 2009
Combined Scheme: UNIX (4 K bytes per block) Operating System Concepts – 8 th Edition 11. 28 Silberschatz, Galvin and Gagne © 2009
Free-Space Management n Bit vector (n blocks) 0 1 2 n-1 … bit[i] = 0 block[i] free 1 block[i] occupied Block number calculation (number of bits per word) * (number of 0 -value words) + offset of first 1 bit Operating System Concepts – 8 th Edition 11. 29 Silberschatz, Galvin and Gagne © 2009
Free-Space Management (Cont. ) n Bit map requires extra space l Example: block size = 212 bytes disk size = 230 bytes (1 gigabyte) n = 230/212 = 218 bits (or 32 K bytes) n Easy to get contiguous files n Linked list (free list) l Cannot get contiguous space easily l No waste of space n Grouping n Counting Operating System Concepts – 8 th Edition 11. 30 Silberschatz, Galvin and Gagne © 2009
Free-Space Management (Cont. ) n Need to protect: Pointer to free list l Bit map 4 Must be kept on disk 4 Copy in memory and disk may differ 4 Cannot allow for block[i] to have a situation where bit[i] = 1 in memory and bit[i] = 0 on disk l Solution: 4 Set bit[i] = 1 in disk 4 Allocate block[i] l 4 Set bit[i] = 1 in memory Operating System Concepts – 8 th Edition 11. 31 Silberschatz, Galvin and Gagne © 2009
Directory Implementation n Linear list of file names with pointer to the data blocks l simple to program l time-consuming to execute n Hash Table – linear list with hash data structure l decreases directory search time l collisions – situations where two file names hash to the same location l fixed size Operating System Concepts – 8 th Edition 11. 32 Silberschatz, Galvin and Gagne © 2009
Linked Free Space List on Disk Operating System Concepts – 8 th Edition 11. 33 Silberschatz, Galvin and Gagne © 2009
Recovery n Consistency checking – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies n Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape, other magnetic disk, optical) n Recover lost file or disk by restoring data from backup Operating System Concepts – 8 th Edition 11. 34 Silberschatz, Galvin and Gagne © 2009
Crash consistency n To write a piece of data, you need to update in three places on the disk l Data, Inode, Bitmap n What happens if the system crash: l Data only: no consistency problem (but lost data) l Inode only: garbage readings… l Bitmap only: space leak l Inode and bitmap only: garbage in the file l Inode and data only: inconsistency, data not mapped as occupied… l Bitmap and data only: we don’t know where it belongs, data only n One solution: file system consistency check (fsck) Operating System Concepts – 8 th Edition 11. 35 Silberschatz, Galvin and Gagne © 2009
Log Structured File Systems n Log structured (or journaling) file systems record each update to the file system as a transaction n All transactions are written to a log l A transaction is considered committed once it is written to the log l However, the file system may not yet be updated n The transactions in the log are asynchronously written to the file system l When the file system is modified, the transaction is removed from the log n If the file system crashes, all remaining transactions in the log must still be performed Operating System Concepts – 8 th Edition 11. 36 Silberschatz, Galvin and Gagne © 2009
- File-file yang dibuat oleh user pada jenis file di linux
- Operating system concepts chapter 8 solutions
- Operating system concepts chapter 5 solutions
- Operating system concepts chapter 5 solutions
- File system in operating system
- Ufs4.0
- File system in operating system
- Implementation of process in operating system
- Distributed file system implementation
- Operating system concepts, 10th edition
- Linux operating system concepts
- Operating system concepts with java
- Operating system concepts 6th edition
- Type 0 hypervisor
- Real time operating system concepts
- 교보 drm
- Basic operating system concepts
- Operating system concepts 11th
- Operating system concepts essentials
- Operating system concepts essentials
- Abraham silberschatz
- Management files for
- File management in android operating system
- File management in operating system
- Remote file access in distributed file system
- In a file-oriented information system, a transaction file
- Operating systems
- Geography: realms, regions, and concepts (doc or html) file
- Module 4 operating systems and file management
- Physical image vs logical image
- Fungsi dari create file pada operasi-operasi file (cont.)
- An html file is a text file containing small markup tags.
- Operating system chapter 5
- Understanding operating systems
- Chapter 4 operating system
- Concurrency vs parallelism in os
- Device management system calls