1 / 27

Chapter 11: File System Implementation

Chapter 11: File System Implementation. Chapter 11: File System Implementation. File-System Structure File-System Implementation Directory Implementation Allocation Methods Free-Space Management Efficiency and Performance. Objectives.

Télécharger la présentation

Chapter 11: File System Implementation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 11: File System Implementation

  2. Chapter 11: File System Implementation • File-System Structure • File-System Implementation • Directory Implementation • Allocation Methods • Free-Space Management • Efficiency and Performance

  3. Objectives • To describe the details of implementing local file systems and directory structures • To describe the implementation of remote file systems • To discuss block allocation and free-block algorithms and trade-offs

  4. About disk • a convenient medium for storing multiple files: • A disk can be rewritten in place; it is possible to read a block from the disk, modify the block, and write it back into the same place. • A disk can access directly any given block of information it contains. Thus, it is simple to access any file either sequentially or randomly, and switching from one file to another requires only moving the read-write heads and waiting for the disk to rotate. • to improve efficiency I/O transfers between memory and disk are performed in units of blocks. Each block has one or more sectors. P411

  5. Two different design problems of File system • defining how the file system should look to the user. • This task involving defining a file and its attributes, the operations allowed on a file, and the directory structure for organizing files. • Creating algorithms and data structures to map the logical file system onto the physical secondary-storage devices. P412

  6. Layered File System

  7. logical file system • manages the directory structure to provide the file organization module with the information the latter needs, given a symbolic file name. It maintains file structure via file-control blocks. • A file-control block (FCB) contains information about the file, including ownership, permissions, and location of the file contents. • The logical file system is also responsible for protection and security. P413

  8. A Typical File Control Block

  9. Directory Implementation • 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 P420

  10. Allocation Methods • An allocation method refers to how disk blocks are allocated for files: • Contiguous allocation • Linked allocation • Indexed allocation P421

  11. Contiguous Allocation • Each file occupies a set of contiguous blocks on the disk • 文件目录中存放起始盘块号和块数。 • 优点:访问容易,速度快 • 缺点: • 分配算法复杂(最先适应、 最优适应) • 外碎片问题 • 必须事先知道文件的长度, Files cannot grow P421

  12. Contiguous Allocation of Disk Space

  13. Linked Allocation • 基本思想:每个文件由磁盘块链表组成,每一个盘块含有指向下一盘块的指针。Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. • 文件目录中存放指向第一个盘块和最后一个盘块的指针。 • 优点:实现了离散分配;无外碎片;文件大小可变。 • 缺点:只能顺序访问;指针占空间;链断致命。 • 改进措施1:按簇分配 • 改进措施2:链接信息专门存放,形成FAT;双FAT更安全。 P423

  14. Linked Allocation 10 25 16 1

  15. File-Allocation Table end of file

  16. Indexed Allocation • 基本思想:为每个文件分配一个索引块,把分配给该文件的所有盘块号,都记录在该索引块中。 • 优点:支持直接访问;无外碎片。 • 缺点:浪费空间;索引块的大小问题 • 管理大文件的改进措施 • 链接(linked scheme) • 多级索引(Multilevel index) • 组合策略(Combined scheme)UNIX采用 P425-426

  17. Example of Indexed Allocation

  18. Indexed Allocation – Mapping (Cont.)  outer-index file index table

  19. Combined Scheme: UNIX (4K bytes per block)

  20. Free-Space Management • Bit vector (n blocks) 0 1 2 n-1 … 0  block[i] free 1  block[i] occupied bit[i] =  For example, consider a disk where blocks 2, 3, 3, 5, 8, 9, 10, 11, 12, 13/ 17,15,25,26, and 27 arc free and the rest of the blocks are allocated. The free-space bit map would be P429

  21. Free-Space Management (Cont.) • Bit map requires extra space • Example: block size = 212 bytes disk size = 230 bytes (1 gigabyte) n = 230/212 = 218 bits (or 32K bytes) • Easy to get contiguous files

  22. Free-Space Management (Cont.) • Linked list (free list) • Cannot get contiguous space easily • No waste of space P430

  23. Linked Free Space List on Disk

  24. Free-Space Management (Cont.) • Grouping: store the addresses of nfree blocks in the first free block. The first n-1 of these blocks are actually free. The last block contains the addresses of another n free blocks, and so on. The addresses of a large number of free blocks can now be found quickly • Counting: keep the address of the first free block and the number nof free contiguous blocks that follow the first block. Each entry in the free-space list then consists of a disk address and a count. P431

  25. Efficiency and Performance • Efficiency dependent on: • disk allocation and directory algorithms • types of data kept in file’s directory entry • Performance • disk cache – separate section of main memory for frequently used blocks • free-behind – removes a page from the buffer as sum as the next page is requested, the previous pages are not likely to be used again and waste buffer space. • read-ahead – a requested page and several subsequent pages are read and cached. These pages are likely to be requested after the current page is processed. • improve PC performance by dedicating section of memory as virtual disk, or RAM disk P431

  26. Recovery • Consistency checking – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies • Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape, other magnetic disk, optical) • Recover lost file or disk by restoring data from backup P435

  27. Homework:1、2、3、4、6End of Chapter 11

More Related