page 112/7/2015 cse 30341: operating systems principles chapter 11: file system implementation ...
TRANSCRIPT
![Page 1: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/1.jpg)
page 104/21/23 CSE 30341: Operating Systems Principles
Chapter 11: File System Implementation
Overview File system structure – layered, block based FS Implementation: FCB, mounting, VFS Directory implementation: Linear, hash table, B-tree Allocation methods: Contiguous, Linked, Indexed, FAT Free-space management: Bit vector, Linked list
![Page 2: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/2.jpg)
page 204/21/23 CSE 30341: Operating Systems Principles
Chapter 11: File System Implementation
File structure Logical storage unit Collection of related information
File system resides on secondary storage (such as disks)
1. Boot control block - information needed to boot
2. Volume control block - information about volume/partitions (# blocks, size of blocks, free block count, free block pointers)
3. Directory structure (inode)
4. Per file control blocks File system organized into layers
![Page 3: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/3.jpg)
page 304/21/23 CSE 30341: Operating Systems Principles
Layered File System
![Page 4: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/4.jpg)
page 404/21/23 CSE 30341: Operating Systems Principles
A Typical File Control Block
File control block – storage structure consisting of information about a file
![Page 5: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/5.jpg)
page 504/21/23 CSE 30341: Operating Systems Principles
In-Memory File System Structures
![Page 6: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/6.jpg)
page 604/21/23 CSE 30341: Operating Systems Principles
Virtual File Systems
There are many different file systems available on any operating systems Windows: NTFS, FAT, FAT32 Linux: ext2/ext3, ufs, vfat, ramfs, tmpfs, reiserfs, xfs ...
Virtual File Systems (VFS) provide an object-oriented way of implementing file systems
VFS allows the same system call interface (the API) to be used for different types of file systems
The API is to the VFS interface, rather than any specific type of file system
![Page 7: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/7.jpg)
page 704/21/23 CSE 30341: Operating Systems Principles
Schematic View of Virtual File System
![Page 8: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/8.jpg)
page 804/21/23 CSE 30341: Operating Systems Principles
Directory Implementation
Directories hold information about files Linear list of file names with pointer to the data
blocks. simple to program time-consuming to execute
Hash Table – linear list with hash data structure. decreases directory search time collisions – situations where two file names hash to the
same location fixed size
![Page 9: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/9.jpg)
page 904/21/23 CSE 30341: Operating Systems Principles
Allocation Methods
An allocation method refers to how disk blocks are allocated for files:
Contiguous allocation
Linked allocation
Indexed allocation
![Page 10: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/10.jpg)
page 1004/21/23 CSE 30341: Operating Systems Principles
Contiguous Allocation
Each file occupies a set of contiguous blocks on the disk
Simple – only starting location (block #) and length (number of blocks) are required
Random access
Wasteful of space (dynamic storage-allocation problem)
Files cannot grow
![Page 11: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/11.jpg)
page 1104/21/23 CSE 30341: Operating Systems Principles
Contiguous Allocation of Disk Space
![Page 12: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/12.jpg)
page 1204/21/23 CSE 30341: Operating Systems Principles
Extent-Based Systems
Many newer file systems (I.e. Veritas File System) use a modified contiguous allocation scheme
Extent-based file systems allocate disk blocks in extents
An extent is a contiguous block of disks Extents are allocated for file allocation A file consists of one or more extents.
![Page 13: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/13.jpg)
page 1304/21/23 CSE 30341: Operating Systems Principles
Linked Allocation
Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk.
Simple – need only starting address Free-space management system – no waste of space No random access
pointerblock =
![Page 14: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/14.jpg)
page 1404/21/23 CSE 30341: Operating Systems Principles
Linked Allocation
![Page 15: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/15.jpg)
page 1504/21/23 CSE 30341: Operating Systems Principles
File-Allocation Table (DOS FAT)
![Page 16: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/16.jpg)
page 1604/21/23 CSE 30341: Operating Systems Principles
Indexed Allocation
Brings all pointers together into the index block. Logical view.
index table
![Page 17: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/17.jpg)
page 1704/21/23 CSE 30341: Operating Systems Principles
Example of Indexed Allocation
![Page 18: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/18.jpg)
page 1804/21/23 CSE 30341: Operating Systems Principles
Indexed Allocation (Cont.)
Need index table Random access Dynamic access without external fragmentation,
but have overhead of index block. Mapping from logical to physical in a file of
maximum size of 256K words and block size of 512 words. We need only 1 block for index table.
![Page 19: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/19.jpg)
page 1904/21/23 CSE 30341: Operating Systems Principles
Indexed Allocation – Mapping (Cont.)
outer-index
index table file
![Page 20: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/20.jpg)
page 2004/21/23 CSE 30341: Operating Systems Principles
Combined Scheme: UNIX (4K bytes per block)
![Page 21: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/21.jpg)
page 2104/21/23 CSE 30341: Operating Systems Principles
…
0 1 2 n-1
bit[i] = 0 block[i] free
1 block[i] occupied
Free-Space Management
Bit vector (n blocks)
Block number calculation = (number of bits per word) * (number of 0-value words) + offset of first 1 bit
![Page 22: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/22.jpg)
page 2204/21/23 CSE 30341: Operating Systems Principles
Free-Space Management (Cont.)
Bit map requires extra space Example:
block size = 212 bytes
disk size = 238 bytes (256 Gigabyte)
n = 238/212 = 226 bits (or 8 Mbytes) Easy to get contiguous files Linked list (free list)
Cannot get contiguous space easily No waste of space
Grouping Counting
![Page 23: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/23.jpg)
page 2304/21/23 CSE 30341: Operating Systems Principles
Linked Free Space List on Disk
![Page 24: Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation Overview File system structure – layered, block based](https://reader035.vdocuments.net/reader035/viewer/2022081515/5697bf781a28abf838c8208a/html5/thumbnails/24.jpg)
page 2404/21/23 CSE 30341: Operating Systems Principles
Free-Space Management (Cont.)
Need to protect against inconsistency: Pointer to free list Bit map
Must be kept on disk Copy in memory and disk may differ Cannot allow for block[i] to have a situation where bit[i] = 1
in memory and bit[i] = 0 on disk
Solution: Set bit[i] = 1 in disk Allocate block[i] Set bit[i] = 1 in memory