Download File System Implementation - pnu-cs-os

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
Transcript
Princess Nora University
Faculty of Computer & Information Systems
Computer science Department
Operating Systems
(CS 340 D)
File System
Implementation
Chapter 12: File System Implementation
1. Allocation Methods
2. Free Space Management
3
OBJECTIVES:
 Introduction to file system structure.
 To discuss block allocation and free-block algorithms
4
File-System Structure
5
File systems
Disks:


A disk can access directly any block of information it contains.
Thus, it is simple to access any file either sequentially or
randomly,
File systems


6
file system resides permanently on secondary storage,
File systems
A file system poses two different design problems:

The first problem is defining how the file system
should look to the user.
1.

2.
7
This task involves defining a file and its attributes, the
operations allowed on a file, and the directory structure for
organizing files.
The second problem is creating algorithms and data
structures to map the logical file system onto the
physical secondary-storage devices
File-System Structure
File structure
 Logical storage unit
 Collection of related information
File system resides on secondary storage (disks)
 Provided user interface to storage,
 mapping logical file system to physical
 Provides efficient and convenient access to disk by
allowing data to be stored, located retrieved easily
File control block–storage structure consisting of information
about a file
Device driver controls the physical device
8
File-System Implementation
9
File-System Implementation


Several on-disk and in-memory structures are used to implement a file
system.
On-disk structures :

Boot control block: (per volume) - contains info. needed by system to boot
OS from that volume

If the disk does not contain an OS, this block can be empty.

Volume control block (superblock /master file table): (per volume)contains volume details such as total # of blocks, # of free blocks, block size,
free block pointers .

Directory structure: (per file system) - is used to organize the files.

File Control Block (FCB): (per file)- contains many details about the file
10
Allocation Methods
11
Allocation Methods
 An allocation method refers to how disk blocks are
allocated for files:
1. Contiguous allocation
2. Linked allocation
3. Indexed allocation
12
1-Contiguous Allocation
13
Contiguous Allocation

Basic Idea:


Each file occupies a set
of contiguous blocks
on the disk
The directory entry for
each file indicates :


14
address of the starting
block
length of the area
allocated for this file
Contiguous Allocation (cont.)

Pros. (++):




Simple
Good performance-the number of disk head seeks required for
accessing contiguously allocated files is minimal
It support sequential and direct access efficiently
Cons. (--):

Dynamic storage-allocation problem (how to satisfy a request of size n
from a list of free holes).


External fragmentation



15
First fit and best fit are the most common strategies used
One solution is compaction (/defragmentation) which is time consuming
File is difficult to grow
Size declaration problem :How does the creator know the size of the
file to be created?
Contiguous Allocation (cont.)

Many newer file systems use a modified contiguousallocation scheme:

a contiguous chunk of space is allocated initially; then, if that
amount proves not to be large enough, another chunk of
contiguous space, known as an extent, is added (i.e. A file
consists of one or more extents)

The location of a file’s blocks is then recorded as:




16
a location
a block count
a link to the first block of the next extent
This scheme is used to improve performance
2-Linked Allocation
17
Linked Allocation

Basic Idea:


Each file is a linked list
of disk blocks: blocks
may be scattered
anywhere on the disk
The directory contains
a pointer to the first and
last blocks of the file.
block
18
=
pointer
Linked Allocation

Pros. (++):






Simple – need only starting address
No external fragmentation
A file can grow - no need for disk compaction
no size declaration problem
It is efficient for sequential access
Cons. (--):




19
It is inefficient for direct access
low performance-It may required multiple disk head seeks to
access single file’s blocks because the block is scattered
A space is required for the pointers.
Low reliability: what happen if a pointer damaged or
lost??
3-Indexed Allocation
20
Indexed Allocation Method

Basic Idea:



21
Each file has its own
index block which is an
array of disk-block
addresses
The directory contains
the address of the
index block.
To find and read the ith
block, we use the
pointer in the ith indexblock entry.
Indexed Allocation (cont.)

Pros. (++):



wasted space is
more than pointers’
space used in linked
allocation method
Efficient for direct access
No external fragmentation
Cons. (--):


It needs index table….(wasted space)
low performance-It may required multiple disk head seeks to
access single file’s blocks because the block is scattered
Same as performance
problem of linked
allocation method
22
Thank you
The End
23