UNIT – 5
FILE SYSTEM IMPLEMENTATION
AND MASS STORAGE STRUCTURE
FILE SYSTEM STRUCTURE
• Disks provide the bulk of secondary storage on
which a file system is maintained.
Characteristics
• 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.
• A disk can access directly any given block of
information it contains.
Layered File System
• Application program layer
• Logical file system layer – Meta data(File
structure)
• File organization modules layer – Information
about files and logical blocks(Mapping)
• Basic file system layer – generates commands
for device driver(To read and write data)
• I/O control interface – consist of device driver
and interrupts.
• Physical h/w devices layer
FILE SYSTEM IMPLEMENTATION
• File-System Implementation are done by the
following
• On-disk structure
• In-memory structure
On-disk
• On-disk is the file system may contain
information about
» How to boot an operating system stored there
» The total number of blocks
» The number and location of free blocks
» The directory structure
» Individual files
On-disk structure:
• The On-disk structure include
» Boot control block
• Contain information needed by the system to boot an
operating system from the volume
• First block of a volume.
» Volume control block
• Contains volume details, such as the number of blocks in the
partition, size of the blocks, free block count and free-block
pointers, and free FCB count and FCB pointers.
» Directory structure
• Used to organize the files.
» FCB
• Contains the details about the file, including file permissions,
ownership, size, and location of the data blocks.
File data blocks
File permissions
File dates (create, access,
write)
File owner, group, ACL
File Size
• In-memory Structure
• The structures may include the ones described
below
» In-memory mount table
• Contains information about each mounted volume
» In-memory directory-structure
• Holds the directory information of recently accessed
directories
» System-wide open-file table
• Contains a copy of the FCB of each open file as well as other
information
» Per-process open file table
• Contains a pointer to the appropriate entry in the system-
wide open file table as well as other information
• In-memory file-system structures for File open.
• In-memory file-system structures for File read
Directory Implementation
• Linear list of file names with pointer to the data blocks
– Simple to program
– Time-consuming to execute
• Linear search time
• Could keep ordered alphabetically via linked list or
use B+ tree
• Hash Table – linear list with hash data structure
– Decreases directory search time
• Collisions – A collision is a situation where two file names
hash to the same location. Alternatively, a chained-overflow
hash table can be used to avoid collisions
Allocation methods
• Allocation methods is a methods used to
allocate space to the files for
-Utilizing the disk space effectively
-Accessing the files quickly
Methods
• Contiguous allocation
• Linked allocation
• Indexed allocation
Allocation Methods - Contiguous
• An allocation method refers to how disk blocks are
allocated for files:
• Contiguous allocation – 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 for file, knowing
file size, external fragmentation, need for
compaction off-line (downtime) or on-line
Contiguous Allocation
• Mapping from logical to physical
Allocation Methods - Linked
• Linked allocation – each file a linked list
of blocks
– File ends at nil pointer
– No external fragmentation
– Each block contains pointer to next block
– No compaction, external fragmentation
Linked Allocation
File-Allocation Table
Allocation Methods - Indexed
• Indexed allocation
– Each file has its own index block(s) of pointers to
its data blocks
• Logical view
index table
Example of Indexed Allocation
Indexed Allocation – Mapping
(Cont.)
Free-Space Management
• Maintaining the free-space list to keep track of free disk space.
• File system maintains free-space list to track available blocks/clusters
– (Using term “block” for simplicity)
• Bit vector or bit map (n blocks)
…
0 1 2 n-1
bit[i] =

1  block[i] free
0  block[i] occupied
3,4,6 free block
• File Creation
– Search the free space list for the required amount of space
– Space is removed from the free space list and allocate it to
the new file
• File Deletion
– Disk space is added to the free space list
• Types of mechanism
• The Free space list can be maintained in the following
ways
– Bit Vector
– Linked List
– Grouping
– Counting
Free-Space Management (Cont.)
• Bit map requires extra space
• Each block is represented by 1 bit. If the block is free the bit is 1 if the
block is allocated the bit is 0.
Linked Free Space List on Disk
 Linked list (free list)
 Cannot get contiguous
space easily
 No waste of space
 No need to traverse the
entire list (if # free blocks
recorded)
Free-Space Management (Cont.)
• Grouping
• A modification of the free list approach is to store the
addresses of n free blocks in the first free block.
• plus a pointer to next block that contains free-block-pointers
(like this one)
• Counting
• Keep address of first free block and count of following
free blocks
• Free space list then has entries containing addresses and
counts
DISK STRUCTURE
• The traditional head-sector-cylinder, HSC
numbers are mapped to linear block
addresses by numbering the first sector on the
first head on the outermost track as sector 0.
• Numbering proceeds with the rest of the
sectors on that same track, and then the rest
of the tracks on the same cylinder before
proceeding through the rest of the cylinders to
the centre of the disk
Disk Scheduling
• Minimize seek time
• Seek time  seek distance
• Disk bandwidth is the total number of
bytes transferred, divided by the total
time between the first request for
service and the completion of the last
transfer
Disk Scheduling (Cont.)
• To service a requset,a disk system requires that
the head to be moved the desired track,then a
wait for latency and finally transfer it
• Several algorithms exist to schedule the
servicing of disk I/O requests
1. FIFO
2. Shortest seek time first
3. Scan
4. Circular scan
5. LOOK
6. Circular LOOK
• The analysis is true for one or many platters
• We illustrate scheduling algorithms with a
request queue (0-199)
98, 183, 37, 122, 14, 124, 65, 67
Head pointer 53
FCFS
Illustration shows total head movement of 640 cylinders
SSTF
• Shortest Seek Time First selects the request
with the minimum seek time from the
current head position
• SSTF scheduling is a form of SJF scheduling
• Illustration shows total head movement of
236 cylinders
SCAN
• The disk arm starts at one end of the
disk, and moves toward the other end,
servicing requests until it gets to the
other end of the disk, where the head
movement is reversed and servicing
continues.
• SCAN algorithm Sometimes called the
elevator algorithm
SCAN (Cont.)
C-SCAN
• The head moves from one end of the disk to
the other, servicing requests as it goes
– When it reaches the other end, however, it
immediately returns to the beginning of the
disk, without servicing any requests on the
return trip
• Treats the cylinders as a circular list that
wraps around from the last cylinder to the
first one
• Total number of cylinders?
C-SCAN (Cont.)
LOOK
• Similar to SCAN beginning direction
• it reverses the direction immediately,
without going all the way to the end of
the disk
C-LOOK
• C-LOOK a version of C-SCAN
• Arm only goes as far as the last
request in each direction, then
reverses direction immediately,
without first going all the way to the
end of the disk
C-LOOK (Cont.)
Linux
File system
• Computer network is used to support RFS
• File transfer protocol(FTP) and Secure shell
protocol(SSP)
Client-server model:
1.Client
2.Server
3.Service
• Clients -mount remote file system from server
• Client open communication channel using IP
address of the remote host and port address
• Server opens to start service
• Network File system(NFS) – standard for UNIX
client server file sharing protocol
• Common Internet File system – WINDOWS
Failure modes
Reason for local file system failure
• Media fails where the file system is stored
• Corruption of directory structure
• Power cable and hard disk cable failure
• Disk controller failure
• Host adapter failure
Consistency semantics
• Related with file sharing
• When does the changes of original file reflect to
other users
1.Unix – Writes to open file immediately visible
2.Session - Writes to open file not visible. Once the
file is closed, the changes are visible only to new
sessions
3.Immutable – Becomes immutable and read only
4.Transaction like semantics
Record blocking
• File is a collection of data records
1.Fixed blocking
2.Variable length spanned blocking – records are
packed into blocks without wastage of space
3.Variable length unspanned – Large wastage

OS Unit5.pptx

  • 1.
    UNIT – 5 FILESYSTEM IMPLEMENTATION AND MASS STORAGE STRUCTURE
  • 2.
    FILE SYSTEM STRUCTURE •Disks provide the bulk of secondary storage on which a file system is maintained. Characteristics • 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. • A disk can access directly any given block of information it contains.
  • 3.
  • 4.
    • Application programlayer • Logical file system layer – Meta data(File structure) • File organization modules layer – Information about files and logical blocks(Mapping) • Basic file system layer – generates commands for device driver(To read and write data) • I/O control interface – consist of device driver and interrupts. • Physical h/w devices layer
  • 5.
    FILE SYSTEM IMPLEMENTATION •File-System Implementation are done by the following • On-disk structure • In-memory structure On-disk • On-disk is the file system may contain information about » How to boot an operating system stored there » The total number of blocks » The number and location of free blocks » The directory structure » Individual files
  • 6.
    On-disk structure: • TheOn-disk structure include » Boot control block • Contain information needed by the system to boot an operating system from the volume • First block of a volume. » Volume control block • Contains volume details, such as the number of blocks in the partition, size of the blocks, free block count and free-block pointers, and free FCB count and FCB pointers. » Directory structure • Used to organize the files. » FCB • Contains the details about the file, including file permissions, ownership, size, and location of the data blocks. File data blocks File permissions File dates (create, access, write) File owner, group, ACL File Size
  • 7.
    • In-memory Structure •The structures may include the ones described below » In-memory mount table • Contains information about each mounted volume » In-memory directory-structure • Holds the directory information of recently accessed directories » System-wide open-file table • Contains a copy of the FCB of each open file as well as other information » Per-process open file table • Contains a pointer to the appropriate entry in the system- wide open file table as well as other information
  • 8.
    • In-memory file-systemstructures for File open.
  • 9.
    • In-memory file-systemstructures for File read
  • 10.
    Directory Implementation • Linearlist of file names with pointer to the data blocks – Simple to program – Time-consuming to execute • Linear search time • Could keep ordered alphabetically via linked list or use B+ tree • Hash Table – linear list with hash data structure – Decreases directory search time • Collisions – A collision is a situation where two file names hash to the same location. Alternatively, a chained-overflow hash table can be used to avoid collisions
  • 11.
    Allocation methods • Allocationmethods is a methods used to allocate space to the files for -Utilizing the disk space effectively -Accessing the files quickly Methods • Contiguous allocation • Linked allocation • Indexed allocation
  • 12.
    Allocation Methods -Contiguous • An allocation method refers to how disk blocks are allocated for files: • Contiguous allocation – 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 for file, knowing file size, external fragmentation, need for compaction off-line (downtime) or on-line
  • 13.
    Contiguous Allocation • Mappingfrom logical to physical
  • 14.
    Allocation Methods -Linked • Linked allocation – each file a linked list of blocks – File ends at nil pointer – No external fragmentation – Each block contains pointer to next block – No compaction, external fragmentation
  • 15.
  • 16.
  • 17.
    Allocation Methods -Indexed • Indexed allocation – Each file has its own index block(s) of pointers to its data blocks • Logical view index table
  • 18.
  • 19.
    Indexed Allocation –Mapping (Cont.)
  • 20.
    Free-Space Management • Maintainingthe free-space list to keep track of free disk space. • File system maintains free-space list to track available blocks/clusters – (Using term “block” for simplicity) • Bit vector or bit map (n blocks) … 0 1 2 n-1 bit[i] =  1  block[i] free 0  block[i] occupied 3,4,6 free block
  • 21.
    • File Creation –Search the free space list for the required amount of space – Space is removed from the free space list and allocate it to the new file • File Deletion – Disk space is added to the free space list • Types of mechanism • The Free space list can be maintained in the following ways – Bit Vector – Linked List – Grouping – Counting
  • 22.
    Free-Space Management (Cont.) •Bit map requires extra space • Each block is represented by 1 bit. If the block is free the bit is 1 if the block is allocated the bit is 0.
  • 23.
    Linked Free SpaceList on Disk  Linked list (free list)  Cannot get contiguous space easily  No waste of space  No need to traverse the entire list (if # free blocks recorded)
  • 24.
    Free-Space Management (Cont.) •Grouping • A modification of the free list approach is to store the addresses of n free blocks in the first free block. • plus a pointer to next block that contains free-block-pointers (like this one) • Counting • Keep address of first free block and count of following free blocks • Free space list then has entries containing addresses and counts
  • 25.
    DISK STRUCTURE • Thetraditional head-sector-cylinder, HSC numbers are mapped to linear block addresses by numbering the first sector on the first head on the outermost track as sector 0. • Numbering proceeds with the rest of the sectors on that same track, and then the rest of the tracks on the same cylinder before proceeding through the rest of the cylinders to the centre of the disk
  • 26.
    Disk Scheduling • Minimizeseek time • Seek time  seek distance • Disk bandwidth is the total number of bytes transferred, divided by the total time between the first request for service and the completion of the last transfer
  • 27.
    Disk Scheduling (Cont.) •To service a requset,a disk system requires that the head to be moved the desired track,then a wait for latency and finally transfer it • Several algorithms exist to schedule the servicing of disk I/O requests 1. FIFO 2. Shortest seek time first 3. Scan 4. Circular scan 5. LOOK 6. Circular LOOK
  • 28.
    • The analysisis true for one or many platters • We illustrate scheduling algorithms with a request queue (0-199) 98, 183, 37, 122, 14, 124, 65, 67 Head pointer 53
  • 29.
    FCFS Illustration shows totalhead movement of 640 cylinders
  • 31.
    SSTF • Shortest SeekTime First selects the request with the minimum seek time from the current head position • SSTF scheduling is a form of SJF scheduling • Illustration shows total head movement of 236 cylinders
  • 34.
    SCAN • The diskarm starts at one end of the disk, and moves toward the other end, servicing requests until it gets to the other end of the disk, where the head movement is reversed and servicing continues. • SCAN algorithm Sometimes called the elevator algorithm
  • 35.
  • 37.
    C-SCAN • The headmoves from one end of the disk to the other, servicing requests as it goes – When it reaches the other end, however, it immediately returns to the beginning of the disk, without servicing any requests on the return trip • Treats the cylinders as a circular list that wraps around from the last cylinder to the first one • Total number of cylinders?
  • 38.
  • 39.
    LOOK • Similar toSCAN beginning direction • it reverses the direction immediately, without going all the way to the end of the disk
  • 40.
    C-LOOK • C-LOOK aversion of C-SCAN • Arm only goes as far as the last request in each direction, then reverses direction immediately, without first going all the way to the end of the disk
  • 41.
  • 42.
    Linux File system • Computernetwork is used to support RFS • File transfer protocol(FTP) and Secure shell protocol(SSP) Client-server model: 1.Client 2.Server 3.Service
  • 43.
    • Clients -mountremote file system from server • Client open communication channel using IP address of the remote host and port address • Server opens to start service • Network File system(NFS) – standard for UNIX client server file sharing protocol • Common Internet File system – WINDOWS
  • 44.
    Failure modes Reason forlocal file system failure • Media fails where the file system is stored • Corruption of directory structure • Power cable and hard disk cable failure • Disk controller failure • Host adapter failure
  • 45.
    Consistency semantics • Relatedwith file sharing • When does the changes of original file reflect to other users 1.Unix – Writes to open file immediately visible 2.Session - Writes to open file not visible. Once the file is closed, the changes are visible only to new sessions 3.Immutable – Becomes immutable and read only 4.Transaction like semantics
  • 46.
    Record blocking • Fileis a collection of data records 1.Fixed blocking 2.Variable length spanned blocking – records are packed into blocks without wastage of space 3.Variable length unspanned – Large wastage