SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Part III
    Storage Management
Chapter 11: File System Implementation
Layered
File System
Overview: 1/4
qA file system has on-disk and in-memory
 information.
qA disk may contain the following for
 implementing a file system on it:
  vA boot control block per volume
  vA partition control block per volume
  vA directory structure per file system
  vA file control block per file
qIn-memory information include
  vAn in-memory partition table
  vAn in-memory directory structure
  vThe system-wide open-file table
  vThe per-process open-file table
Overview: 2/4
a typical file control block FCB   qA FCB, file control
                                    block, contains the
 file permission                    details of a file.
 file date                         qIn Unix, a FCB is
 file owner, group, ACL
                                    called an i-node.

 file size

 file data blocks
Overview: 3/4               3: read the directory
     4: update FCB and directory
                         kernel memory                 disk memory
   user program




  open(filename)                                      directory structure
                             directory structure



1: create a new file
                                                            FCB
 5: a file descriptor/file handle
   is returned
                                    2: allocate a new FCB
Overview: 4/4
        index
                   kernel memory       disk memory
user program         per-process
                     open-file table



                                        Data blocks

read(index)          system-wide
                     open-file table




                                          FCB
Directory Implementation
qA File directory is usually implemented as a
 linked-list or a tree (e.g., B-tree), a hash table
 with chaining, or the combination of both.
qThe problem with the linked-list approach is
 the poor performance in searching for a file.
 Directory search is a very frequently
 performed operation.
qThe hash table approach speeds up search;
 however, we must deal with the problem of
 collisions. Thus, chaining is necessary.
Directory Entries: 1/2
qA directory is simply a file!
qA directory entry may be very simple like the
 one used by MS-DOS. Or, it may be quite
 complex like the Unix i-node.




  extended MS-DOS directory entry used in Windows 98
Directory Entries: 2/2

Unix directory entry
                       find /usr/ast/mbox
File Allocation Methods

qThere are three typical file space allocation
 methods:
 vContiguous Allocation
 vLinked Allocation
 vIndexed Allocation
Contiguous Allocation: 1/3
qWith the contiguous allocation method, a user
 must indicate the file size before creating the file.
qThen, the operating system searches the disk to
 find contiguous disk blocks for the file.
qThe directory entry is easy. It contains the initial
 disk address of this file and the number of disk
 blocks.
qTherefore, if the initial address is b and the
 number of blocks is n, the file will occupy blocks b,
 b+1, b+2, 
, b+n-1.
Contiguous Allocation: 2/3

                         directory




               Since blocks are allocated
               contiguously, external
               fragmentation may occur.
               Thus, compaction may be
               needed.
Contiguous Allocation: 3/3
qContiguous allocation is easy to implement.
qIts disadvantages are
  vIt can be considered as a form of dynamic
    memory allocation, and external fragmentation
    may occur and compaction may be needed.
  vIt is difficult to estimate the file size. The size of
    a file may grow at run time and may be larger
    than the specified number of allocated blocks.
    In this case, the OS must move the blocks in
    order to provide mode space. In some systems,
    this is simply an error.
Linked Allocation: 1/3
qWith the linked allocation approach, disk
 blocks of a file are chained together with a
 linked-list.
qThe directory entry of a file contains a pointer
 to the first block and a pointer to the last block.
qTo create a file, we create a new directory entry
 and the pointers are initialized to nil.
qWhen a write occurs, a new disk block is
 allocated and chained to the end of the list.
Linked Allocation: 2/3
            directory

                        28   Last Block




      qFile blocks are chained into a
       linked-list.
      qThe directory entry has pointers
       to the first and last file blocks.
      qAppend is difficult to do without
       the last pointer.
Linked Allocation: 3/3
qAdvantages:
 vFile size does not have to be specified.
 vNo external fragmentation.
qDisadvantages:
 vIt does sequential access efficiently and is not
   for direct access
 vEach block contains a pointer, wasting space
 vBlocks scatter everywhere and a large number
   of disk seeks may be necessary
 vReliability: what if a pointer is lost or damaged?
File Allocation Table (FAT)
                          FAT
                    0                 q This is a variation of the
                                        linked allocation by
                                        pulling all pointers into a
                  217      618          table, the file allocation
directory                               table (FAT).
   test                               q Large no. of disk seeks.
                  339   end-of-file
                                      q Can do direct access.
                                      q FAT needs space.
   217                                q The left diagram shows
                  618      339          file test has its first
                                        block at 217, followed by
                                        618, 339 (end of file).
      no. of blocks-1                 q What if FAT is damaged?
                                        We all know it well!
Indexed Allocation: 1/4
qEach file has an index block that is an array of
 disk block addresses.
qThe i-th entry in the index block points to the i-th
 block of the file.
qA file’s directory entry contains a pointer to its
 index. Hence, the index block of an indexed
 allocation plays the same role as the page table.
qIndex allocation supports both sequential and
 direct access without external fragmentation.
Indexed Allocation: 2/4

                   directory




             index block
Indexed Allocation: 3/4
qThe indexed allocation suffers from wasted space.
 The index block may not be fully used (i.e., internal
 fragmentation).
qThe number of entries of an index table determines
 the size of a file. To overcome this problem, we can
  vHave multiple index blocks and chain them into
    a linked-list
  vHave multiple index blocks, but make them a
    tree just like the indexed access method
  vA combination of both
Indexed Allocation: 4/4

 i-node
  10 direct blocks




256 entries per index table.
What is the maximum size of a file?
Free Space Management
qHow do we keep track free blocks on a disk?
qA free-list is maintained. When a new block is
 requested, we search this list to find one.
qThe following are commonly used techniques:
  vBit Vector
  vLinked List
  vLinked List + Grouping
  vLinked List+Address+Count
Bit Vector
qEach block is represented by a bit in a table. Thus,
 if there are n disk blocks, the table has n bits.
qIf a block is free, its corresponding bit is 1.
qWhen a block is needed, the table is searched. If a 1
 bit is found in position k, block k is free.
qIf the disk capacity is small, the whole bit vector can
 be stored in memory. For a large disk, this bit
 vector will consume too much memory.
qWe could group a few blocks into a cluster and
 allocate clusters. This saves space and may cause
 internal fragmentation.
qAnother possibility is the use of a summary table.
Linked List
qLike the linked allocation method, free blocks can
 be chained into a linked list.
qWhen a free block is needed, the first in the chain is
 allocated.
qHowever, this method has the same disadvantages
 of the linked allocation method.
qWe can use a FAT for the disk and chain the free
 block pointers together. Keep in mind that the
 FAT may be very large and consume space if it is
 stored in memory.
Grouping
qThe first free block contains the addresses of n
 other free blocks.
qFor each group, the first n-1 blocks are actually
 free and the last (i.e., n-th) block contains the
 addresses of the next group.
qIn this way, we can quickly locate free blocks.

    3     8 50        3                         6
   (3 & 8 are free)
      8
                            12

           20
                                                50
                            (6 & 12 are free)   6 12 20
Address + Counting
qWe can make the list short with the following trick:
 vBlocks are often allocated and freed in groups
 vWe can store the address of the first free block
  and the number of the following n free blocks.


  free block list



             5


             3
                                      disk

Weitere Àhnliche Inhalte

Was ist angesagt?

Free space managment46
Free space managment46Free space managment46
Free space managment46
myrajendra
 
Allocation methods continuous method.47
Allocation methods continuous method.47 Allocation methods continuous method.47
Allocation methods continuous method.47
myrajendra
 
Block Storage For VMs With Ceph
Block Storage For VMs With CephBlock Storage For VMs With Ceph
Block Storage For VMs With Ceph
The Linux Foundation
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
koolkampus
 
Introduction to distributed file systems
Introduction to distributed file systemsIntroduction to distributed file systems
Introduction to distributed file systems
Viet-Trung TRAN
 

Was ist angesagt? (20)

Free space managment46
Free space managment46Free space managment46
Free space managment46
 
Allocation methods continuous method.47
Allocation methods continuous method.47 Allocation methods continuous method.47
Allocation methods continuous method.47
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Revisiting CephFS MDS and mClock QoS Scheduler
Revisiting CephFS MDS and mClock QoS SchedulerRevisiting CephFS MDS and mClock QoS Scheduler
Revisiting CephFS MDS and mClock QoS Scheduler
 
NTFS file system
NTFS file systemNTFS file system
NTFS file system
 
Amazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and Optimization
 
Block Storage For VMs With Ceph
Block Storage For VMs With CephBlock Storage For VMs With Ceph
Block Storage For VMs With Ceph
 
Raid : Redundant Array of Inexpensive Disks
Raid : Redundant Array of Inexpensive DisksRaid : Redundant Array of Inexpensive Disks
Raid : Redundant Array of Inexpensive Disks
 
Os
OsOs
Os
 
11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS11. Storage and File Structure in DBMS
11. Storage and File Structure in DBMS
 
Introduction to distributed file systems
Introduction to distributed file systemsIntroduction to distributed file systems
Introduction to distributed file systems
 
File System and File allocation tables
File System and File allocation tablesFile System and File allocation tables
File System and File allocation tables
 
CephFS Update
CephFS UpdateCephFS Update
CephFS Update
 
Storage Technology Overview
Storage Technology OverviewStorage Technology Overview
Storage Technology Overview
 
Dynamic storage allocation techniques in Compiler design
Dynamic storage allocation techniques in Compiler designDynamic storage allocation techniques in Compiler design
Dynamic storage allocation techniques in Compiler design
 
Linux file system
Linux file systemLinux file system
Linux file system
 
Raid
RaidRaid
Raid
 
11. dfs
11. dfs11. dfs
11. dfs
 
Directory implementation and allocation methods
Directory implementation and allocation methodsDirectory implementation and allocation methods
Directory implementation and allocation methods
 
Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files Course 102: Lecture 24: Archiving and Compression of Files
Course 102: Lecture 24: Archiving and Compression of Files
 

Andere mochten auch

File management ppt
File management pptFile management ppt
File management ppt
marotti
 
Intermediate Operating Systems
Intermediate Operating SystemsIntermediate Operating Systems
Intermediate Operating Systems
John Cutajar
 
File system
File systemFile system
File system
Mohd Arif
 
Linked allocation 48
Linked  allocation 48Linked  allocation 48
Linked allocation 48
myrajendra
 
Overview of System Virtualization
Overview of System VirtualizationOverview of System Virtualization
Overview of System Virtualization
Andre Odendaal
 
File management
File managementFile management
File management
Mohd Arif
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
tittuajay
 

Andere mochten auch (14)

Htcia an introduction to the microsoft ex fat file system 1.01 final
Htcia   an introduction to the microsoft ex fat file system 1.01 finalHtcia   an introduction to the microsoft ex fat file system 1.01 final
Htcia an introduction to the microsoft ex fat file system 1.01 final
 
File management
File managementFile management
File management
 
File management ppt
File management pptFile management ppt
File management ppt
 
Operating Systems - File Management
Operating Systems -  File ManagementOperating Systems -  File Management
Operating Systems - File Management
 
Ch11: File System Interface
Ch11: File System InterfaceCh11: File System Interface
Ch11: File System Interface
 
Intermediate Operating Systems
Intermediate Operating SystemsIntermediate Operating Systems
Intermediate Operating Systems
 
Deepak's green computing
Deepak's green computingDeepak's green computing
Deepak's green computing
 
File system
File systemFile system
File system
 
Linked allocation 48
Linked  allocation 48Linked  allocation 48
Linked allocation 48
 
Overview of System Virtualization
Overview of System VirtualizationOverview of System Virtualization
Overview of System Virtualization
 
File management
File managementFile management
File management
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
 
file system in operating system
file system in operating systemfile system in operating system
file system in operating system
 
File system
File systemFile system
File system
 

Ähnlich wie File implementation

Ch12 OS
Ch12 OSCh12 OS
Ch12 OS
C.U
 
Query processing and optimization
Query processing and optimizationQuery processing and optimization
Query processing and optimization
Arif A.
 

Ähnlich wie File implementation (20)

File System Implementation.pptx
File System Implementation.pptxFile System Implementation.pptx
File System Implementation.pptx
 
Ch 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashingCh 17 disk storage, basic files structure, and hashing
Ch 17 disk storage, basic files structure, and hashing
 
Chapter13
Chapter13Chapter13
Chapter13
 
Ch11
Ch11Ch11
Ch11
 
OSCh12
OSCh12OSCh12
OSCh12
 
Ch12 OS
Ch12 OSCh12 OS
Ch12 OS
 
OS_Ch12
OS_Ch12OS_Ch12
OS_Ch12
 
Query processing and optimization
Query processing and optimizationQuery processing and optimization
Query processing and optimization
 
File Allocation Methods.ppt
File Allocation Methods.pptFile Allocation Methods.ppt
File Allocation Methods.ppt
 
6 chapter 6 record storage and primary file organization
6 chapter 6  record storage and primary file organization6 chapter 6  record storage and primary file organization
6 chapter 6 record storage and primary file organization
 
file management_part2_os_notes.ppt
file management_part2_os_notes.pptfile management_part2_os_notes.ppt
file management_part2_os_notes.ppt
 
OS_Assignment for Disk Space & File System & File allocation table(FAT)
OS_Assignment for Disk Space & File System & File allocation table(FAT)OS_Assignment for Disk Space & File System & File allocation table(FAT)
OS_Assignment for Disk Space & File System & File allocation table(FAT)
 
Allocation and free space management
Allocation and free space managementAllocation and free space management
Allocation and free space management
 
File System Implementation
File System ImplementationFile System Implementation
File System Implementation
 
Updates
UpdatesUpdates
Updates
 
Updates
UpdatesUpdates
Updates
 
File Access & File System & File Allocation Table
File Access & File System & File Allocation TableFile Access & File System & File Allocation Table
File Access & File System & File Allocation Table
 
Free Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFSFree Space Management, Efficiency & Performance, Recovery and NFS
Free Space Management, Efficiency & Performance, Recovery and NFS
 
File Management.ppt
File Management.pptFile Management.ppt
File Management.ppt
 
Ch12_OS_Lecture 5.pdf
Ch12_OS_Lecture 5.pdfCh12_OS_Lecture 5.pdf
Ch12_OS_Lecture 5.pdf
 

Mehr von Mohd Arif

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcp
Mohd Arif
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
Mohd Arif
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocol
Mohd Arif
 
Project identification
Project identificationProject identification
Project identification
Mohd Arif
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniques
Mohd Arif
 
Presentation
PresentationPresentation
Presentation
Mohd Arif
 
Pointers in c
Pointers in cPointers in c
Pointers in c
Mohd Arif
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peer
Mohd Arif
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systems
Mohd Arif
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
Mohd Arif
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgeting
Mohd Arif
 
Network management
Network managementNetwork management
Network management
Mohd Arif
 
Networing basics
Networing basicsNetworing basics
Networing basics
Mohd Arif
 
Loaders
LoadersLoaders
Loaders
Mohd Arif
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platform
Mohd Arif
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and ssl
Mohd Arif
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psec
Mohd Arif
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardware
Mohd Arif
 
Heap sort
Heap sortHeap sort
Heap sort
Mohd Arif
 

Mehr von Mohd Arif (20)

Bootp and dhcp
Bootp and dhcpBootp and dhcp
Bootp and dhcp
 
Arp and rarp
Arp and rarpArp and rarp
Arp and rarp
 
User datagram protocol
User datagram protocolUser datagram protocol
User datagram protocol
 
Project identification
Project identificationProject identification
Project identification
 
Project evalaution techniques
Project evalaution techniquesProject evalaution techniques
Project evalaution techniques
 
Presentation
PresentationPresentation
Presentation
 
Pointers in c
Pointers in cPointers in c
Pointers in c
 
Peer to-peer
Peer to-peerPeer to-peer
Peer to-peer
 
Overview of current communications systems
Overview of current communications systemsOverview of current communications systems
Overview of current communications systems
 
Overall 23 11_2007_hdp
Overall 23 11_2007_hdpOverall 23 11_2007_hdp
Overall 23 11_2007_hdp
 
Objectives of budgeting
Objectives of budgetingObjectives of budgeting
Objectives of budgeting
 
Network management
Network managementNetwork management
Network management
 
Networing basics
Networing basicsNetworing basics
Networing basics
 
Loaders
LoadersLoaders
Loaders
 
Lists
ListsLists
Lists
 
Iris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platformIris ngx next generation ip based switching platform
Iris ngx next generation ip based switching platform
 
Ip sec and ssl
Ip sec and  sslIp sec and  ssl
Ip sec and ssl
 
Ip security in i psec
Ip security in i psecIp security in i psec
Ip security in i psec
 
Intro to comp. hardware
Intro to comp. hardwareIntro to comp. hardware
Intro to comp. hardware
 
Heap sort
Heap sortHeap sort
Heap sort
 

KĂŒrzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

KĂŒrzlich hochgeladen (20)

Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

File implementation

  • 1. Part III Storage Management Chapter 11: File System Implementation
  • 3. Overview: 1/4 qA file system has on-disk and in-memory information. qA disk may contain the following for implementing a file system on it: vA boot control block per volume vA partition control block per volume vA directory structure per file system vA file control block per file qIn-memory information include vAn in-memory partition table vAn in-memory directory structure vThe system-wide open-file table vThe per-process open-file table
  • 4. Overview: 2/4 a typical file control block FCB qA FCB, file control block, contains the file permission details of a file. file date qIn Unix, a FCB is file owner, group, ACL called an i-node. file size file data blocks
  • 5. Overview: 3/4 3: read the directory 4: update FCB and directory kernel memory disk memory user program open(filename) directory structure directory structure 1: create a new file FCB 5: a file descriptor/file handle is returned 2: allocate a new FCB
  • 6. Overview: 4/4 index kernel memory disk memory user program per-process open-file table Data blocks read(index) system-wide open-file table FCB
  • 7. Directory Implementation qA File directory is usually implemented as a linked-list or a tree (e.g., B-tree), a hash table with chaining, or the combination of both. qThe problem with the linked-list approach is the poor performance in searching for a file. Directory search is a very frequently performed operation. qThe hash table approach speeds up search; however, we must deal with the problem of collisions. Thus, chaining is necessary.
  • 8. Directory Entries: 1/2 qA directory is simply a file! qA directory entry may be very simple like the one used by MS-DOS. Or, it may be quite complex like the Unix i-node. extended MS-DOS directory entry used in Windows 98
  • 9. Directory Entries: 2/2 Unix directory entry find /usr/ast/mbox
  • 10. File Allocation Methods qThere are three typical file space allocation methods: vContiguous Allocation vLinked Allocation vIndexed Allocation
  • 11. Contiguous Allocation: 1/3 qWith the contiguous allocation method, a user must indicate the file size before creating the file. qThen, the operating system searches the disk to find contiguous disk blocks for the file. qThe directory entry is easy. It contains the initial disk address of this file and the number of disk blocks. qTherefore, if the initial address is b and the number of blocks is n, the file will occupy blocks b, b+1, b+2, 
, b+n-1.
  • 12. Contiguous Allocation: 2/3 directory Since blocks are allocated contiguously, external fragmentation may occur. Thus, compaction may be needed.
  • 13. Contiguous Allocation: 3/3 qContiguous allocation is easy to implement. qIts disadvantages are vIt can be considered as a form of dynamic memory allocation, and external fragmentation may occur and compaction may be needed. vIt is difficult to estimate the file size. The size of a file may grow at run time and may be larger than the specified number of allocated blocks. In this case, the OS must move the blocks in order to provide mode space. In some systems, this is simply an error.
  • 14. Linked Allocation: 1/3 qWith the linked allocation approach, disk blocks of a file are chained together with a linked-list. qThe directory entry of a file contains a pointer to the first block and a pointer to the last block. qTo create a file, we create a new directory entry and the pointers are initialized to nil. qWhen a write occurs, a new disk block is allocated and chained to the end of the list.
  • 15. Linked Allocation: 2/3 directory 28 Last Block qFile blocks are chained into a linked-list. qThe directory entry has pointers to the first and last file blocks. qAppend is difficult to do without the last pointer.
  • 16. Linked Allocation: 3/3 qAdvantages: vFile size does not have to be specified. vNo external fragmentation. qDisadvantages: vIt does sequential access efficiently and is not for direct access vEach block contains a pointer, wasting space vBlocks scatter everywhere and a large number of disk seeks may be necessary vReliability: what if a pointer is lost or damaged?
  • 17. File Allocation Table (FAT) FAT 0 q This is a variation of the linked allocation by pulling all pointers into a 217 618 table, the file allocation directory table (FAT). test q Large no. of disk seeks. 339 end-of-file q Can do direct access. q FAT needs space. 217 q The left diagram shows 618 339 file test has its first block at 217, followed by 618, 339 (end of file). no. of blocks-1 q What if FAT is damaged? We all know it well!
  • 18. Indexed Allocation: 1/4 qEach file has an index block that is an array of disk block addresses. qThe i-th entry in the index block points to the i-th block of the file. qA file’s directory entry contains a pointer to its index. Hence, the index block of an indexed allocation plays the same role as the page table. qIndex allocation supports both sequential and direct access without external fragmentation.
  • 19. Indexed Allocation: 2/4 directory index block
  • 20. Indexed Allocation: 3/4 qThe indexed allocation suffers from wasted space. The index block may not be fully used (i.e., internal fragmentation). qThe number of entries of an index table determines the size of a file. To overcome this problem, we can vHave multiple index blocks and chain them into a linked-list vHave multiple index blocks, but make them a tree just like the indexed access method vA combination of both
  • 21. Indexed Allocation: 4/4 i-node 10 direct blocks 256 entries per index table. What is the maximum size of a file?
  • 22. Free Space Management qHow do we keep track free blocks on a disk? qA free-list is maintained. When a new block is requested, we search this list to find one. qThe following are commonly used techniques: vBit Vector vLinked List vLinked List + Grouping vLinked List+Address+Count
  • 23. Bit Vector qEach block is represented by a bit in a table. Thus, if there are n disk blocks, the table has n bits. qIf a block is free, its corresponding bit is 1. qWhen a block is needed, the table is searched. If a 1 bit is found in position k, block k is free. qIf the disk capacity is small, the whole bit vector can be stored in memory. For a large disk, this bit vector will consume too much memory. qWe could group a few blocks into a cluster and allocate clusters. This saves space and may cause internal fragmentation. qAnother possibility is the use of a summary table.
  • 24. Linked List qLike the linked allocation method, free blocks can be chained into a linked list. qWhen a free block is needed, the first in the chain is allocated. qHowever, this method has the same disadvantages of the linked allocation method. qWe can use a FAT for the disk and chain the free block pointers together. Keep in mind that the FAT may be very large and consume space if it is stored in memory.
  • 25. Grouping qThe first free block contains the addresses of n other free blocks. qFor each group, the first n-1 blocks are actually free and the last (i.e., n-th) block contains the addresses of the next group. qIn this way, we can quickly locate free blocks. 3 8 50 3 6 (3 & 8 are free) 8 12 20 50 (6 & 12 are free) 6 12 20
  • 26. Address + Counting qWe can make the list short with the following trick: vBlocks are often allocated and freed in groups vWe can store the address of the first free block and the number of the following n free blocks. free block list 5 3 disk