0% found this document useful (0 votes)
77 views33 pages

Chapter 10: File System Implementation

The document discusses various aspects of file system implementation including file system structure, directory implementation using linear lists and hash tables, allocation methods like contiguous, linked and indexed allocation, free space management using bit vectors and linked lists, recovery methods, and log structured file systems. It provides examples and diagrams to explain concepts like in-memory file system structures, virtual file systems, allocation mapping, and linked free space lists.

Uploaded by

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

Chapter 10: File System Implementation

The document discusses various aspects of file system implementation including file system structure, directory implementation using linear lists and hash tables, allocation methods like contiguous, linked and indexed allocation, free space management using bit vectors and linked lists, recovery methods, and log structured file systems. It provides examples and diagrams to explain concepts like in-memory file system structures, virtual file systems, allocation mapping, and linked free space lists.

Uploaded by

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

Al-Mansour University College

Software Engineering and Information Technology Department

week10
CHAPTER 10: FILE SYSTEM
IMPLEMENTATION

Name: Sinan Sameer


Lecture-10
CHAPTER 11: FILE SYSTEM IMPLEMENTATION
No Content
1 File-System Structure

2 File-System Implementation

3 Directory Implementation

4 Allocation Methods

5 Free-Space Management

6 Efficiency and Performance

7 Recovery

8 Log-Structured File Systems

9 NFS

10 Example: WAFL File System


FILE-SYSTEM STRUCTURE
 File structure
 Logical storage unit
 Collection of related information

 File system resides on secondary storage (disks)


 File system organized into layers

 File control block – storage structure consisting of information


about a file
LAYERED FILE SYSTEM
A TYPICAL FILE CONTROL BLOCK
IN-MEMORY FILE SYSTEM
STRUCTURES
 The following figure illustrates the necessary file system
structures provided by the operating systems.

 Figure 12-3(a) refers to opening a file.

 Figure 12-3(b) refers to reading a file.


IN-MEMORY FILE SYSTEM STRUCTURES
VIRTUAL FILE SYSTEMS

 Virtual File Systems (VFS) provide an object-oriented way of


implementing file systems.

 VFS allows the same system call interface (the API) to be used
for different types of file systems.

 The API is to the VFS interface, rather than any specific type of
file system.
SCHEMATIC VIEW OF VIRTUAL FILE SYSTEM
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
 fixed size
ALLOCATION METHODS
 An allocation method refers to how disk blocks are allocated for
files:

 Contiguous allocation

 Linked allocation

 Indexed allocation
CONTIGUOUS ALLOCATION
 Each file occupies a set of contiguous blocks on the disk

 Simple – only starting location (block #) and length (number of


blocks) are required

 Random access

 Wasteful of space (dynamic storage-allocation problem)

 Files cannot grow


CONTIGUOUS ALLOCATION
 Mapping from logical to physical

LA/512

Block to be accessed = ! + starting address


Displacement into block = R
CONTIGUOUS ALLOCATION OF DISK SPACE
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 disk blocks: blocks may be scattered
anywhere on the disk.

block = pointer
LINKED ALLOCATION (CONT.)
 Simple – need only starting address
 Free-space management system – no waste of space

 No random access

 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
File-allocation table (FAT) – disk-space allocation used by MS-DOS
and OS/2.
LINKED ALLOCATION
FILE-ALLOCATION TABLE
INDEXED ALLOCATION
 Brings all pointers together into the index block.
 Logical view.

index table
EXAMPLE OF INDEXED ALLOCATION
INDEXED ALLOCATION (CONT.)
 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 words and block size of 512 words. We need only 1 block
for index table.
Q
LA/512
R

Q = displacement into index table


R = displacement into block
INDEXED ALLOCATION – MAPPING
(CONT.)
 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).

Q1
LA / (512 x 511)
R1
Q1 = block of index table
R1 is used as follows:
Q2
R1 / 512
R2

Q2 = displacement into block of index table


R2 displacement into block of file:
INDEXED ALLOCATION – MAPPING
(CONT.)
 Two-level index (maximum file size is 5123)

Q1
LA / (512 x 512)
R1

Q1 = displacement into outer-index


R1 is used as follows:
Q2
R1 / 512
R2

Q2 = displacement into block of index table


R2 displacement into block of file:
INDEXED ALLOCATION – MAPPING
(CONT.)

outer-index

index table file


COMBINED SCHEME: UNIX (4K BYTES PER BLOCK)
FREE-SPACE MANAGEMENT
 Bit vector (n blocks)
0 1 2 n-1

0  block[i] free


bit[i] =
1  block[i] occupied

Block number calculation

(number of bits per word) *


(number of 0-value words) +
offset of first 1 bit
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

 Linked list (free list)


 Cannot get contiguous space easily
 No waste of space

 Grouping
 Counting
FREE-SPACE MANAGEMENT (CONT.)
 Need to protect:
 Pointer to free list
 Bit map
 Must be kept on disk

 Copy in memory and disk may differ

 Cannot allow for block[i] to have a situation where bit[i] = 1 in

memory and bit[i] = 0 on disk


 Solution:
 Set bit[i] = 1 in disk

 Allocate block[i]

 Set bit[i] = 1 in memory


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
 fixed size
LINKED FREE SPACE LIST ON DISK
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


LOG STRUCTURED FILE SYSTEMS
 Log structured (or journaling) file systems record each update
to the file system as a transaction

 All transactions are written to a log


 A transaction is considered committed once it is written to the log
 However, the file system may not yet be updated

 The transactions in the log are asynchronously written to the file


system
 When the file system is modified, the transaction is removed from the
log

 If the file system crashes, all remaining transactions in the log


must still be performed

You might also like