file system implementation
play

FILE SYSTEM IMPLEMENTATION Sunu Wibirama Outline File-System - PowerPoint PPT Presentation

FILE SYSTEM IMPLEMENTATION Sunu Wibirama Outline File-System Structure File-System Implementation Directory Implementation Allocation Methods Free-Space Management Discussion 11. Outline File-System Structure


  1. FILE SYSTEM IMPLEMENTATION Sunu Wibirama

  2. Outline  File-System Structure  File-System Implementation  Directory Implementation  Allocation Methods  Free-Space Management  Discussion 11.

  3. Outline  File-System Structure  File-System Implementation  Directory Implementation  Allocation Methods  Free-Space Management  Discussion 11.

  4. File System Structure  File system is provided by OS to allow the data to be stored, located, and retrieved easily  Two problems on file system design:  How the file system should look to the user  Algorithms and data structures to map logical file system onto the physical secondary-storage devices  File system organized into layers, uses features from lower levels to create new features for use by higher levels.  I/O Control controls the physical device using device driver  Basic file system needs only to issue generic commands to the device driver to read and write physical block on the disk (ex. drive 1, cylinder 73, track 2, sector 11) 11.

  5. Outline  File-System Structure  File-System Implementation  Directory Implementation  Allocation Methods  Free-Space Management  Discussion 11.

  6. File System Implementation  File organization module knows physical and logical blocks, translating logical block address to physical block address. It also manages free-space on the disk  Logical file system manages metadata information (all file system structure except the actual data or contents of the file).  Logical file system maintains file structure via file-control blocks (FCB)  File control block – storage structure consisting of information about a file  Basic file system and I/O control can be used by multiple file systems.  Recently, OS supports more than one FS 11.

  7. A Typical File Control Block 11.

  8. On-Disk File System Structures  Boot control block contains info needed by system to boot OS from that volume (UNIX: boot block, NTFS: partition boot sector)  Volume control block contains volume details (UNIX: superblock, NTFS: master file table)  Directory structure organizes the files (UNIX: inode numbers, NTFS: master file table)  Per-file File Control Block (FCB) contains many details about the file 11.

  9. In-Memory File System Structures  It is used for file-system management and performance improvement (via caching).  The data are loaded at mount time and discarded at dismount.  The structures including:  In-memory mount table: information of each mounted volume  In-memory directory structure  System-wide open-file table: a copy of FCB of each open file  Per-process open-file table: a pointer to the appropriate entry in the system-wide open-file table, as well as other information based on process that uses the file. 11.

  10. New File Creation Process  Application program calls the logical file system  Logical file system knows the directory structures. It allocates a new FCB.  The system then reads the appropriate directory into memory, updates it with the new file name and FCB, and writes it back to the disk.  Now, the new created file can be used for I/O operation, which will be explained in the next slide 11.

  11. In-Memory File System Structures File open File read 11.

  12. Outline  File-System Structure  File-System Implementation  Directory Implementation  Allocation Methods  Free-Space Management  Discussion 11.

  13. Directory Implementation  Directory-allocation and directory-management algorithms significantly affects the efficiency, performance, and reliability of the file system. There are two impementations: linear list and hash table  Linear list of file names with pointer to the data blocks.  simple to program  time-consuming to execute, because it requires a linear search to create or delete file.  Hash Table – linear list with hash data structure.  decreases directory search time  problem:  collisions (two file names hash to the same location)  fixed size of hash table (for 64 entries, the hash function converts filename into integers from 0 to 63) 11.

  14. Outline  File-System Structure  File-System Implementation  Directory Implementation  Allocation Methods  Free-Space Management  Discussion 11.

  15. Review: Dynamic Storage Allocation and Fragmentation

  16. Dynamic Storage Allocation  At any given time, we have a set of free spaces (holes) of various sizes scattered through the disk.  Dynamic Storage Allocation problem : satisfying a request of size n from a list of free spaces  There are three solutions for dynamic storage allocation problem:  First Fit : allocate the first hole that is big enough. Stop searching the entire list as soon as we find a free hole that is large enough  Best Fit : Allocate the smallest hole that is big enough. We must search the entire list in the storage  Worst Fit : allocate the largest hole. Again, we must search the entire list in the storage  In term of speed and disk utilization : first fit and best fit are better then worst fit 11.

  17. External Fragmentation OS 50k File 3 ? 125k File 9 File 8 100k File 2  First fit and best fit suffer from external fragmentation : there is enough total storage space to satisfy the request, but the available spaces are not contiguous 11.

  18. Internal Fragmentation A (part 1) Room for growth Allocated to A A (part 2) A (part 3) OS  Another approach : break the physical storage into fixed-sized blocks and allocate storage in units based on block size.  The storage space allocated to file may be slightly larger than the requested space, but we get internal fragmentation . 11.

  19. Fragmentation Solution?  Minimize external fragmentation?  Large disk blocks (but internal fragmentation occurs)  Choose the best allocation methods to allocate disk block  Compaction:  Shuffle memory contents to place all free memory together in one large block (example: disk defragmenter)  Only for “execution time address binding” data (dynamic address relocation) (a) (b) OS OS OS 50k File 3 File 3 90k File 8 125k File 9 File 8 60k File 8 100k File 3 File 2 File 2 File 2 11.

  20. Next, we want to allocate disk blocks effectively. But how?

  21. Allocation Methods  An allocation method refers to how disk blocks are allocated for files:  Contiguous allocation  Linked allocation  Indexed allocation 11.

  22. Contiguous Allocation of Disk Space 11.

  23. Contiguous Allocation  OS : IBM VM/CMS  Each file occupies a set of contiguous blocks on the disk  Simple – only starting location (block #) and length (number of blocks) are required  Both sequential and direct access are supported  Disadvantages:  Wasteful of space (dynamic storage-allocation problem)  External fragmentation: free space is broken into chunks  We must determine the size of needed space before we allocated  Preallocation may be inefficient if the file grow slowly over a long period (months or years). The file therefore has a large amount of internal fragmentation 11.

  24. Contiguous Allocation  (a) Contiguous allocation of disk space for 7 files.  (b) The state of the disk after files D and F have been removed. 11.

  25. Contiguous Allocation  One of several solutions: use a modified contiguous allocation scheme (ex. : Veritas file system, replacing standard UNIX UFS)  Initially, a contiguous block of space is allocated  If it is not to be large enough, another block is added, which is called extent .  An extent is a contiguous block of disks  A file consists of one or more extents  Another approach, we use Linked Allocation Method 11.

  26. Linked Allocation  Linked allocation solves all problems of contiguous allocation  Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk.  Ex: File “Jeep”  Start at block 9  Then: block 16, 1, 10  Finally end at block 25 pointer (4 bytes) visible part to user 1 block (512 bytes) 508 bytes 11.

  27. Linked Allocation  Advantages:  Free-space management system – no waste of space  File can grow, depends on available free blocks  Disadvantages:  No random access (only sequential access)  Space required for pointers (0.78 percent of the disk is being used for pointers, rather than for information). Solution, uses clusters ( unit of blocks), so that pointers use much smaller percentage  Clusters operation increase internal fragmentation  Reliability, pointer damage will cause unlinked blocks in a file.  FAT (File Allocation Table): variation on linked allocation (ex.: MS-DOS and OS/2 operating systems)  Located at the beginning of each volume 11.

  28. File-Allocation Table  To do random access: 1. The disk head move to the start of volume to read the FAT 2. Find the location of the desired block 3. Move to the location of the block itself 11.

  29. Indexed Allocation  Linked allocation: solves external fragmentation and size-declaration problem  FAT + Linked Allocation = efficient file retrieval using random access  Without FAT, linked allocation cannot support efficient direct access:  because the pointers to the blocks are scattered with the block themselves all over the disk  the pointers must be retrieved in order ( sequential access ).  How about collecting all pointers together into one location? 11.

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend