0% found this document useful (0 votes)
4 views

4753957

The document discusses various file allocation methods used in file systems, including contiguous, linked, and indexed allocation. Each method has its advantages and disadvantages, such as performance, fragmentation, and complexity in accessing files. It also covers specific allocation techniques like extent-based systems and the File Allocation Table (FAT), along with examples and calculations related to file size limits in UNIX UFS.

Uploaded by

vayaso2650
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

4753957

The document discusses various file allocation methods used in file systems, including contiguous, linked, and indexed allocation. Each method has its advantages and disadvantages, such as performance, fragmentation, and complexity in accessing files. It also covers specific allocation techniques like extent-based systems and the File Allocation Table (FAT), along with examples and calculations related to file size limits in UNIX UFS.

Uploaded by

vayaso2650
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

File System:

File-System Interface
Contents

Quick Recap File Allocation Methods


File Allocation Methods
➢ An allocation method refers to how disk blocks are allocated for files:
1. Contiguous
2. Linked (Non-contiguous allocation)
3. Indexed allocation/ File Allocation Table (FAT)
Contiguous Allocation Method
➢An allocation method refers to how disk blocks are allocated for files:

➢Each file occupies set of contiguous blocks


➢Best performance in most cases
➢Simple – only starting location (block #) and length (number of blocks) are required
➢Problems include:
➢Finding space on the disk for a file,
➢Knowing file size,
➢External fragmentation, need for compaction off-line (downtime) or on-line
Contiguous Allocation Cont..
➢Mapping from logical to physical (block size =512 bytes)

LA/512

➢Block to be accessed = starting address + Q (Offset)


➢Displacement into block = R
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
Linked Allocation
➢Each file is a linked list of blocks
➢File ends at nil pointer
➢No external fragmentation
➢Each block contains pointer to next block
➢No compaction, external fragmentation
➢Free space management system called when new block needed
➢Improve efficiency by clustering blocks into groups but increases internal
fragmentation
➢Reliability can be a problem
➢Locating a block can take many I/Os and disk seeks
Linked Allocation Example
Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk Scheme
Linked Allocation Cont..
Mapping

Q
LA/511
R
➢Block to be accessed is the Qth block in the linked chain of blocks representing the file.
➢Displacement into block = R + 1
FAT Allocation Method

➢Beginning of volume has table, indexed by block number


➢Much like a linked list, but faster on disk and cacheable
➢New block allocation simple
File-Allocation Table
Indexed Allocation Method
Each file has its own index block(s) of pointers to its data blocks

Logical view

index table
Example of Indexed Allocation
Indexed Allocation – Small Files
➢Need index table

➢Advantages:
➢Random access
➢Dynamic access without external fragmentation, but have overhead of index block
➢Disadvantages:
➢Pointers overhead
➢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
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
Indexed Allocation – Linked Scheme
➢Link blocks of index table (no limit on size)

Q1
LA / (512 x 511)
R1

➢Outer-level mapping scheme


➢Q1 = block of index table
➢R1 is used as follows Q2
R1 / 512
R2

➢Inner-level mapping scheme


➢Q2 = displacement into block of index table
➢R2 displacement into block of file
Indexed Allocation – Two-level Scheme
Two-level index (4K blocks could store 1,024 four-byte pointers in outer index ->
1,048,567 data blocks and file size of up to 4GB)
Q1
LA / (512 x 512)
R1

Mapping scheme for outer-index:


◦ Q1 = displacement into outer-index
◦ R1 is used as follows:
Q2
R1 / 512
R2

◦ Mapping scheme for index level:


◦ Q2 = displacement into block of index table
◦ R2 displacement into block of file
Indexed Allocation – Two-Level Scheme
Combined Scheme : UNIX UFS
4K bytes per block, 32-bit addresses
Numerical on UFS
Ques: The inode of UFS has 12 direct, 1 single indirect & 1 double indirect pointers. The disk block
size is 4KB and disk block address is 32 bit long. What is the maximum file size possible?
Ans: Disk block address =32 bit
disk block entry size= 4 Bytes
Disk block Size = 4KB
Number of entries in a block = 4KB/4B =2^10
File size = (12 direct+ 1 single indirect + 1 double indirect)* Block size
= (12*1 + 1*2^10+1*2^10*2^10) * 4KB
= 48KB+4MB+4GB
= 4.003952GB ~ 4GB
Upcoming topics
➢Disk Structure
➢Disk Scheduling Algorithms

You might also like