Chapter 11:  File System Implementation
File-System Structure <ul><li>File structure </li></ul><ul><ul><li>Logical storage unit </li></ul></ul><ul><ul><li>Collect...
Layered File System
A Typical File Control Block
File System Implementation  <ul><li>On-disk structures </li></ul><ul><ul><li>A boot controller block (per volume), contain...
File System Implementation  <ul><li>In memory  structures   </li></ul><ul><ul><li>An In memory mount table for each mounte...
In-Memory File System Structures
Partitions and mounting <ul><li>Cooked disk, contains file system. Raw disk, no file system (in UNIX it is used for swap s...
Virtual File Systems <ul><li>There are many different file systems available on any operating systems </li></ul><ul><ul><l...
Schematic View of Virtual File System
Directory Implementation <ul><li>Linear list  of file names with pointer to the data blocks. </li></ul><ul><ul><li>simple ...
Allocation Methods <ul><li>An allocation method refers to how disk blocks are allocated for files: </li></ul><ul><li>Conti...
Contiguous Allocation <ul><li>Each file occupies a set of contiguous blocks on the disk </li></ul><ul><li>Simple – only st...
Contiguous Allocation of Disk Space
Extent-Based Systems <ul><li>Many newer file systems (I.e. Veritas File System) use a modified contiguous allocation schem...
Linked Allocation <ul><li>Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. </li></...
Linked Allocation
File-Allocation Table
Indexed Allocation <ul><li>Brings all pointers together into the  index block. </li></ul><ul><li>Logical view. </li></ul>i...
Example of Indexed Allocation
Indexed Allocation (Cont.) <ul><li>Need index table </li></ul><ul><li>Random access </li></ul><ul><li>Dynamic access witho...
Indexed Allocation – Mapping (Cont.)  outer-index index table file
Combined Scheme:  UNIX (4K bytes per block)
Free-Space Management <ul><li>Bit vector  ( n  blocks) </li></ul>… 0 1 2 n-1 bit[ i ] =  0    block[ i ] free 1    bl...
Free-Space Management (Cont.) <ul><li>Bit map requires extra space </li></ul><ul><ul><li>Example: </li></ul></ul><ul><li>b...
Free-Space Management (Cont.) <ul><li>Need to protect: </li></ul><ul><ul><li>Pointer to free list </li></ul></ul><ul><ul><...
Linked Free Space List on Disk
Efficiency and Performance <ul><li>Efficiency dependent on: </li></ul><ul><ul><li>disk allocation and directory algorithms...
Page Cache <ul><li>A  page cache  caches pages rather than disk blocks using virtual memory techniques </li></ul><ul><li>M...
I/O Without a Unified Buffer Cache
Unified Buffer Cache <ul><li>A unified buffer cache uses the same page cache to cache both memory-mapped pages and ordinar...
I/O Using a Unified Buffer Cache
Upcoming SlideShare
Loading in...5
×

Ch11

3,451

Published on

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,451
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
444
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Ch11

  1. 1. Chapter 11: File System Implementation
  2. 2. File-System Structure <ul><li>File structure </li></ul><ul><ul><li>Logical storage unit </li></ul></ul><ul><ul><li>Collection of related information </li></ul></ul><ul><li>File system resides on secondary storage (disks) </li></ul><ul><li>File system organized into layers </li></ul><ul><li>File control block – storage structure consisting of information about a file </li></ul>
  3. 3. Layered File System
  4. 4. A Typical File Control Block
  5. 5. File System Implementation <ul><li>On-disk structures </li></ul><ul><ul><li>A boot controller block (per volume), contains information needed to boot an OS (in NTFS is called boot sector). </li></ul></ul><ul><ul><li>A volume controller block (per volume), contains partition details such as number of blocks, size of blocks, etc. (in NTFS is called master file table). </li></ul></ul><ul><ul><li>A directory structure per file system (in NTFS is called master file table). </li></ul></ul><ul><ul><li>A per-file FCB, in Unix called inode, in NTFS information is stored in master file table (i.e. DB). </li></ul></ul>
  6. 6. File System Implementation <ul><li>In memory structures </li></ul><ul><ul><li>An In memory mount table for each mounted volume. </li></ul></ul><ul><ul><li>An In memory directory-structure cache (holds the directory info. Of recently accessed directories. </li></ul></ul><ul><ul><li>The system-wide open file table, contains a copy of FCB of each open file. </li></ul></ul><ul><ul><li>The per-process open file table, contains a pointer to an entry in system-wide table. </li></ul></ul>
  7. 7. In-Memory File System Structures
  8. 8. Partitions and mounting <ul><li>Cooked disk, contains file system. Raw disk, no file system (in UNIX it is used for swap space). </li></ul><ul><li>Root partition (which contains the OS kernel) is mounted at boot time. </li></ul><ul><li>Mount table keeps track of mounted file systems by using pointers to blocks: </li></ul><ul><ul><li>In windows, file systems are mounted in drive letters. Each volume is a separate name space denoted by a letter and a colon. </li></ul></ul><ul><ul><li>In UNIX, file systems are mounted as directories. </li></ul></ul>
  9. 9. Virtual File Systems <ul><li>There are many different file systems available on any operating systems </li></ul><ul><ul><li>Windows: NTFS, FAT, FAT32 </li></ul></ul><ul><ul><li>Linux: ext2/ext3, ufs, vfat, ramfs, tmpfs, reiserfs, xfs ... </li></ul></ul><ul><li>Virtual File Systems (VFS) provide an object-oriented way of implementing file systems. </li></ul><ul><li>VFS allows the same system call interface (the API) to be used for different types of file systems. </li></ul><ul><li>The API is to the VFS interface, rather than any specific type of file system. </li></ul>
  10. 10. Schematic View of Virtual File System
  11. 11. Directory Implementation <ul><li>Linear list of file names with pointer to the data blocks. </li></ul><ul><ul><li>simple to program </li></ul></ul><ul><ul><li>time-consuming to execute </li></ul></ul><ul><li>Hash Table – linear list with hash data structure. </li></ul><ul><ul><li>decreases directory search time </li></ul></ul><ul><ul><li>collisions – situations where two file names hash to the same location </li></ul></ul><ul><ul><li>fixed size </li></ul></ul>
  12. 12. Allocation Methods <ul><li>An allocation method refers to how disk blocks are allocated for files: </li></ul><ul><li>Contiguous allocation </li></ul><ul><li>Linked allocation </li></ul><ul><li>Indexed allocation </li></ul>
  13. 13. Contiguous Allocation <ul><li>Each file occupies a set of contiguous blocks on the disk </li></ul><ul><li>Simple – only starting location (block #) and length (number of blocks) are required </li></ul><ul><li>Random access </li></ul><ul><li>Wasteful of space (dynamic storage-allocation problem) </li></ul><ul><li>Files cannot grow </li></ul>
  14. 14. Contiguous Allocation of Disk Space
  15. 15. Extent-Based Systems <ul><li>Many newer file systems (I.e. Veritas File System) use a modified contiguous allocation scheme </li></ul><ul><li>Extent-based file systems allocate disk blocks in extents </li></ul><ul><li>An extent is a contiguous block of disks </li></ul><ul><ul><li>Extents are allocated for file allocation </li></ul></ul><ul><ul><li>A file consists of one or more extents. </li></ul></ul>
  16. 16. Linked Allocation <ul><li>Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. </li></ul><ul><li>Simple – need only starting address </li></ul><ul><li>Free-space management system – no waste of space </li></ul><ul><li>No random access </li></ul>pointer block =
  17. 17. Linked Allocation
  18. 18. File-Allocation Table
  19. 19. Indexed Allocation <ul><li>Brings all pointers together into the index block. </li></ul><ul><li>Logical view. </li></ul>index table
  20. 20. Example of Indexed Allocation
  21. 21. Indexed Allocation (Cont.) <ul><li>Need index table </li></ul><ul><li>Random access </li></ul><ul><li>Dynamic access without external fragmentation, but have overhead of index block. </li></ul><ul><li>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. </li></ul>
  22. 22. Indexed Allocation – Mapping (Cont.)  outer-index index table file
  23. 23. Combined Scheme: UNIX (4K bytes per block)
  24. 24. Free-Space Management <ul><li>Bit vector ( n blocks) </li></ul>… 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
  25. 25. Free-Space Management (Cont.) <ul><li>Bit map requires extra space </li></ul><ul><ul><li>Example: </li></ul></ul><ul><li>block size = 2 12 bytes </li></ul><ul><li>disk size = 2 30 bytes (1 gigabyte) </li></ul><ul><li>n = 2 30 /2 12 = 2 18 bits (or 32K bytes) </li></ul><ul><li>Easy to get contiguous files </li></ul><ul><li>Linked list (free list) </li></ul><ul><ul><li>Cannot get contiguous space easily </li></ul></ul><ul><ul><li>No waste of space </li></ul></ul><ul><li>Grouping </li></ul><ul><li>Counting </li></ul>
  26. 26. Free-Space Management (Cont.) <ul><li>Need to protect: </li></ul><ul><ul><li>Pointer to free list </li></ul></ul><ul><ul><li>Bit map </li></ul></ul><ul><ul><ul><li>Must be kept on disk </li></ul></ul></ul><ul><ul><ul><li>Copy in memory and disk may differ </li></ul></ul></ul><ul><ul><ul><li>Cannot allow for block[ i ] to have a situation where bit[ i ] = 1 in memory and bit[ i ] = 0 on disk </li></ul></ul></ul><ul><ul><li>Solution: </li></ul></ul><ul><ul><ul><li>Set bit[ i ] = 1 in disk </li></ul></ul></ul><ul><ul><ul><li>Allocate block[ i ] </li></ul></ul></ul><ul><ul><ul><li>Set bit[ i ] = 1 in memory </li></ul></ul></ul>
  27. 27. Linked Free Space List on Disk
  28. 28. Efficiency and Performance <ul><li>Efficiency dependent on: </li></ul><ul><ul><li>disk allocation and directory algorithms </li></ul></ul><ul><ul><li>types of data kept in file’s directory entry </li></ul></ul><ul><li>Performance </li></ul><ul><ul><li>disk cache – separate section of main memory for frequently used blocks </li></ul></ul><ul><ul><li>free-behind and read-ahead – techniques to optimize sequential access </li></ul></ul><ul><ul><li>improve PC performance by dedicating section of memory as virtual disk, or RAM disk </li></ul></ul>
  29. 29. Page Cache <ul><li>A page cache caches pages rather than disk blocks using virtual memory techniques </li></ul><ul><li>Memory-mapped I/O uses a page cache </li></ul><ul><li>Routine I/O through the file system uses the buffer (disk) cache </li></ul><ul><li>This leads to the following figure </li></ul>
  30. 30. I/O Without a Unified Buffer Cache
  31. 31. Unified Buffer Cache <ul><li>A unified buffer cache uses the same page cache to cache both memory-mapped pages and ordinary file system I/O </li></ul>
  32. 32. I/O Using a Unified Buffer Cache
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×