Module 4 File System Implemenattion
Module 4 File System Implemenattion
File System
Implementation
File-System Structure
• Disks provide the bulk of secondary storage on which a file system is
maintained.
• They have two characteristics that make them a convenient medium for storing
multiple files:
1. 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.
2. A disk can access directly any given block of information it contains.
• I/O transfers between memory and disk are performed in units of blocks.
• A file system poses two quite different design problems.
1. Defining how the file system should look to the user.
2. Creating algorithms and data structures to map the logical file system onto
the physical secondary-storage devices.
• The file system itself is generally composed of many different levels.
• The file-organization module knows about files and their logical blocks, as well as
physical blocks.
• The logical file system manages metadata information(via FCB).
File-System Structure
• The lowest level, the I/O control, consists
of device drivers and interrupt handlers to
transfer information between the main
memory and the disk system.
• The basic file system needs only to issue
generic commands to the appropriate
device driver to read and write physical
blocks on the disk
LA/512
Q
LA/511
R
index table
Indexed Allocation – Small Files
• 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 bytes and
block size of 512 bytes. We need only 1 block for index table
Q
LA/512
• Calculation:
• Q = displacement into index table
• R = displacement into block
Indexed Allocation – Large Files
• Mapping from logical to physical in a file of unbounded length (block size of
512 words)
• Linked scheme – Link blocks of index table (no limit on size)
• Multi-level indexing
• Combination of both linked and multi-level scheme
Performance
• Best method depends on file access type
• Contiguous great for sequential and random
• Linked good for sequential, not random
• Declare access type at creation
• Select either contiguous or linked
• Indexed more complex
• Single block access could require 2 index block reads then data block read
• Clustering can help improve throughput, reduce CPU overhead
Free-Space Management
• File system maintains free-space list to track available blocks
• Bit vector or bit map (n blocks)
01 2 n-1
…
1 block[i] free
bit[i] =
0 block[i] occupied
• Bit map requires extra space
• Example:
block size = 4KB = 212 bytes
disk size = 240 bytes (1 terabyte)
n = 240/212 = 228 bits (or 32MB)
if clusters of 4 blocks -> 8MB of memory
• Counting
• Because space is frequently contiguously used and freed, with
contiguous-allocation allocation, extents, or clustering
• Keep address of first free block and count of following free blocks
• Free space list then has entries containing addresses and counts