SlideShare uma empresa Scribd logo
1 de 133
Baixar para ler offline
File System Implementation (Part I)
Amir H. Payberah
amir@sics.se
Amirkabir University of Technology
(Tehran Polytechnic)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 1 / 57
Motivation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 2 / 57
Motivation
The file system resides permanently on secondary storage.
How to
• structure file use
• allocate disk space
• recover free space
• track the locations of data
• interface other parts of the OS to secondary storage
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 3 / 57
File System Structure
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 4 / 57
File-System Structure
Disk provides in-place rewrite and random access
• I/O transfers performed in blocks of sectors (usually 512 bytes)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 5 / 57
File-System Structure
Disk provides in-place rewrite and random access
• I/O transfers performed in blocks of sectors (usually 512 bytes)
File system resides on secondary storage
• User interface to storage, mapping logical to physical
• Efficient and convenient access to disk
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 5 / 57
File-System Structure
Disk provides in-place rewrite and random access
• I/O transfers performed in blocks of sectors (usually 512 bytes)
File system resides on secondary storage
• User interface to storage, mapping logical to physical
• Efficient and convenient access to disk
File structure
• Logical storage unit
• Collection of related information
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 5 / 57
File-System Design Problems
How the file system should look to the user?
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 6 / 57
File-System Design Problems
How the file system should look to the user?
• Defining a file and its attributes
• The operations allowed on a file
• The directory structure for organizing files
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 6 / 57
File-System Design Problems
How the file system should look to the user?
• Defining a file and its attributes
• The operations allowed on a file
• The directory structure for organizing files
Algorithms and data structures to map the logical file system onto
the physical secondary-storage devices.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 6 / 57
File System Layers (1/6)
Different levels
Each level uses the features of lower
levels to create new features for use
by higher levels.
Reducing complexity and redundancy,
but adds overhead and can decrease
performance.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 7 / 57
File System Layers (2/6)
Device drivers manage I/O devices
at the I/O control layer.
Translates high-level commands to
low-level hardware-specific instructions.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 8 / 57
File System Layers (3/6)
Basic file system translates given command
like retrieve block 123 to device driver.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 9 / 57
File System Layers (3/6)
Basic file system translates given command
like retrieve block 123 to device driver.
Also manages memory buffers and
caches (allocation, freeing, replacement)
• Buffers hold data in transit
• Caches hold frequently used data
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 9 / 57
File System Layers (4/6)
File organization understands files, logical
address, and physical blocks.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 10 / 57
File System Layers (4/6)
File organization understands files, logical
address, and physical blocks.
Translates logical block number to physical
block number.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 10 / 57
File System Layers (4/6)
File organization understands files, logical
address, and physical blocks.
Translates logical block number to physical
block number.
Manages free space and disk allocation.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 10 / 57
File System Layers (5/6)
Logical file system manages metadata
information.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 11 / 57
File System Layers (5/6)
Logical file system manages metadata
information.
Translates file name into file number, file
handle, location by maintaining file
control blocks (inodes in Unix)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 11 / 57
File System Layers (5/6)
Logical file system manages metadata
information.
Translates file name into file number, file
handle, location by maintaining file
control blocks (inodes in Unix)
Directory management
Protection
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 11 / 57
File System Layers (6/6)
Many file systems, sometimes many within an OS
Each with its own format
• CD-ROM: ISO 9660
• Unix: UFS, FFS
• Windows: FAT, FAT32, NTFS
• Linux: more than 40 types, with extended file system (ext2, ext3,
ext4)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 12 / 57
File System Implementation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 13 / 57
File-System Implementation
Based on several on-disk and in-memory structures.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 14 / 57
File-System Implementation
Based on several on-disk and in-memory structures.
On-disk
• Boot control block (per volume)
• Volume control block (per volume)
• Directory structure (per file system)
• File control block (per file)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 14 / 57
File-System Implementation
Based on several on-disk and in-memory structures.
On-disk
• Boot control block (per volume)
• Volume control block (per volume)
• Directory structure (per file system)
• File control block (per file)
In-memory
• Mount table
• Directory structure cache
• The open-file table (system-wide and per process)
• Buffers of the file-system blocks
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 14 / 57
On-Disk File System Structures (1/2)
Boot control block contains information needed by system to boot
OS from that volume.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
On-Disk File System Structures (1/2)
Boot control block contains information needed by system to boot
OS from that volume.
• Needed if volume contains OS, usually first block of volume.
• In UFS, it is called boot block, and in NTFS partition boot sector.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
On-Disk File System Structures (1/2)
Boot control block contains information needed by system to boot
OS from that volume.
• Needed if volume contains OS, usually first block of volume.
• In UFS, it is called boot block, and in NTFS partition boot sector.
Volume control block contains volume details.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
On-Disk File System Structures (1/2)
Boot control block contains information needed by system to boot
OS from that volume.
• Needed if volume contains OS, usually first block of volume.
• In UFS, it is called boot block, and in NTFS partition boot sector.
Volume control block contains volume details.
• Total num. of blocks, num. of free blocks, block size, free block
pointers or array
• In UFS, it is called super block, and in NTFS master file table.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
On-Disk File System Structures (2/2)
Directory structure organizes the files.
• In UFS, this includes file names and associated inode numbers.
• In NTFS, it is stored in the master file table.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 16 / 57
On-Disk File System Structures (2/2)
Directory structure organizes the files.
• In UFS, this includes file names and associated inode numbers.
• In NTFS, it is stored in the master file table.
File control block contains many details about the file.
• In UFS, inode number, permissions, size, dates.
• In NFTS stores into in master file table.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 16 / 57
In-Memory File System Structures
Mount table contains information about each mounted volume.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
In-Memory File System Structures
Mount table contains information about each mounted volume.
Directory structure cache holds the directory information of recently
accessed directories.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
In-Memory File System Structures
Mount table contains information about each mounted volume.
Directory structure cache holds the directory information of recently
accessed directories.
System-wide open-file table contains a copy of the FCB of each open
file.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
In-Memory File System Structures
Mount table contains information about each mounted volume.
Directory structure cache holds the directory information of recently
accessed directories.
System-wide open-file table contains a copy of the FCB of each open
file.
Per-process open-file table contains a pointer to the appropriate
entry in the system-wide open-file table.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
In-Memory File System Structures
Mount table contains information about each mounted volume.
Directory structure cache holds the directory information of recently
accessed directories.
System-wide open-file table contains a copy of the FCB of each open
file.
Per-process open-file table contains a pointer to the appropriate
entry in the system-wide open-file table.
Buffers hold file-system blocks when they are being read from disk
or written to disk.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
Create a File
A program calls the logical file system.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 18 / 57
Create a File
A program calls the logical file system.
The logical file system knows the format of the directory structures,
and allocates a new FCB.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 18 / 57
Create a File
A program calls the logical file system.
The logical file system knows the format of the directory structures,
and allocates a new FCB.
The system, then, reads the appropriate directory into memory, up-
dates it with the new file name and FCB, and writes it back to the
disk.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 18 / 57
Open a File
The file must be opened.
• The open() passes a file name to the logical file system.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
Open a File
The file must be opened.
• The open() passes a file name to the logical file system.
The open() first searches the system-wide open-file: if the file is
already in use by another process.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
Open a File
The file must be opened.
• The open() passes a file name to the logical file system.
The open() first searches the system-wide open-file: if the file is
already in use by another process.
• If yes: a per-process open-file table entry is created.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
Open a File
The file must be opened.
• The open() passes a file name to the logical file system.
The open() first searches the system-wide open-file: if the file is
already in use by another process.
• If yes: a per-process open-file table entry is created.
• If no: the directory structure is searched for the given file name:
once the file is found, the FCB is copied into a system-wide
open-file table in memory.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
Open a File
The file must be opened.
• The open() passes a file name to the logical file system.
The open() first searches the system-wide open-file: if the file is
already in use by another process.
• If yes: a per-process open-file table entry is created.
• If no: the directory structure is searched for the given file name:
once the file is found, the FCB is copied into a system-wide
open-file table in memory.
This table stores the FCB as well as the number of processes that
have the file open.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
Read From a File
The open() returns a pointer to the appropriate entry in the per-
process file-system table.
All file operations are then performed via this pointer.
This pointer is called file descriptor in Unix and file handle in Win-
dows.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 20 / 57
Close a File
When a process closes the file:
• The per-process table entry is removed.
• The system-wide entry’s open count is decremented.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 21 / 57
Close a File
When a process closes the file:
• The per-process table entry is removed.
• The system-wide entry’s open count is decremented.
When all users that have opened the file close it, any updated meta-
data is copied back to the disk-based directory structure, and the
system-wide open-file table entry is removed.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 21 / 57
Partitions and Mounting (1/2)
Partition can be a volume containing a file system or raw.
• Raw partition: just a sequence of blocks with no file system.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 22 / 57
Partitions and Mounting (1/2)
Partition can be a volume containing a file system or raw.
• Raw partition: just a sequence of blocks with no file system.
Boot block points to boot volume or boot loader.
• Boot loader: knows enough about the file-system structure to be
able to find and load the kernel and start it executing.
• Dual-boot that allows to install multiple OS on a single system.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 22 / 57
Partitions and Mounting (2/2)
Root partition contains the OS
• Mounted at boot time
• Other partitions can hold other OSes, other file systems, or be raw
• Other partitions can mount automatically or manually
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 23 / 57
Partitions and Mounting (2/2)
Root partition contains the OS
• Mounted at boot time
• Other partitions can hold other OSes, other file systems, or be raw
• Other partitions can mount automatically or manually
At mount time, file system consistency checked.
• Is all metadata correct? if not, fix it, try again, if yes, add to mount
table, allow access
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 23 / 57
Virtual File Systems
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 24 / 57
Virtual File Systems (1/2)
Virtual File Systems (VFS) on Unix provide an object-oriented way
of implementing file systems.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 25 / 57
Virtual File Systems (1/2)
Virtual File Systems (VFS) on Unix 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.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 25 / 57
Virtual File Systems (1/2)
Virtual File Systems (VFS) on Unix 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.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 25 / 57
Virtual File Systems (2/2)
VFS layer serves two important functions:
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
Virtual File Systems (2/2)
VFS layer serves two important functions:
1 It separates file-system-generic operations from their implementa-
tion, and allows transparent access to different types of file systems
mounted locally.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
Virtual File Systems (2/2)
VFS layer serves two important functions:
1 It separates file-system-generic operations from their implementa-
tion, and allows transparent access to different types of file systems
mounted locally.
2 It provides a mechanism for uniquely representing a file throughout
a network.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
Virtual File Systems (2/2)
VFS layer serves two important functions:
1 It separates file-system-generic operations from their implementa-
tion, and allows transparent access to different types of file systems
mounted locally.
2 It provides a mechanism for uniquely representing a file throughout
a network.
The VFS is based on a structure, called a vnode.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
Virtual File Systems (2/2)
VFS layer serves two important functions:
1 It separates file-system-generic operations from their implementa-
tion, and allows transparent access to different types of file systems
mounted locally.
2 It provides a mechanism for uniquely representing a file throughout
a network.
The VFS is based on a structure, called a vnode.
• Contains a numerical designator for a network-wide unique file.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
Virtual File Systems (2/2)
VFS layer serves two important functions:
1 It separates file-system-generic operations from their implementa-
tion, and allows transparent access to different types of file systems
mounted locally.
2 It provides a mechanism for uniquely representing a file throughout
a network.
The VFS is based on a structure, called a vnode.
• Contains a numerical designator for a network-wide unique file.
• Unix inodes are unique within only a single file system.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
Virtual File Systems (2/2)
VFS layer serves two important functions:
1 It separates file-system-generic operations from their implementa-
tion, and allows transparent access to different types of file systems
mounted locally.
2 It provides a mechanism for uniquely representing a file throughout
a network.
The VFS is based on a structure, called a vnode.
• Contains a numerical designator for a network-wide unique file.
• Unix inodes are unique within only a single file system.
• The kernel maintains one vnode structure for each active node.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 27 / 57
VFS in Linux (1/2)
The four main object types defined by the Linux VFS are:
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
VFS in Linux (1/2)
The four main object types defined by the Linux VFS are:
• The inode object: represents an individual file
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
VFS in Linux (1/2)
The four main object types defined by the Linux VFS are:
• The inode object: represents an individual file
• The file object: represents an open file
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
VFS in Linux (1/2)
The four main object types defined by the Linux VFS are:
• The inode object: represents an individual file
• The file object: represents an open file
• The super block object: represents an entire file system
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
VFS in Linux (1/2)
The four main object types defined by the Linux VFS are:
• The inode object: represents an individual file
• The file object: represents an open file
• The super block object: represents an entire file system
• The dentry object: represents an individual directory entry
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
VFS in Linux (2/2)
VFS defines a set of operations on the objects that must be imple-
mented.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
VFS in Linux (2/2)
VFS defines a set of operations on the objects that must be imple-
mented.
Every object has a pointer to a function table.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
VFS in Linux (2/2)
VFS defines a set of operations on the objects that must be imple-
mented.
Every object has a pointer to a function table.
• Function table has addresses of routines to implement that function
on that object.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
VFS in Linux (2/2)
VFS defines a set of operations on the objects that must be imple-
mented.
Every object has a pointer to a function table.
• Function table has addresses of routines to implement that function
on that object.
• For example:
int open(...): open a file
int close(...): close an already-open file
ssize t read(...): read from a file
ssize t write(...): write to a file
int mmap(...): memory-map a file
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
Directory Implementation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 30 / 57
Directory Implementation
Linear list
Hash table
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 31 / 57
Directory Implementation - Linear List
Linear list of file names with pointer to the data blocks.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
Directory Implementation - Linear List
Linear list of file names with pointer to the data blocks.
Simple to program.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
Directory Implementation - Linear List
Linear list of file names with pointer to the data blocks.
Simple to program.
Time-consuming to execute.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
Directory Implementation - Linear List
Linear list of file names with pointer to the data blocks.
Simple to program.
Time-consuming to execute.
Linear search time.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
Directory Implementation - Linear List
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:
binary search, but heavy
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
Directory Implementation - Hash Table
Hash Table: linear list with hash data structure
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
Directory Implementation - Hash Table
Hash Table: linear list with hash data structure
Decreases directory search time
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
Directory Implementation - Hash Table
Hash Table: linear list with hash data structure
Decreases directory search time
Collisions: situations where two file names hash to the same location
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
Directory Implementation - Hash Table
Hash Table: linear list with hash data structure
Decreases directory search time
Collisions: situations where two file names hash to the same location
Chained-overflow method.
• Each hash entry can be a linked list instead of an individual value.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
Allocation Methods
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 34 / 57
Allocation Methods
How disk blocks are allocated to files?
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 35 / 57
Allocation Methods
How disk blocks are allocated to files?
Methods:
• Contiguous allocation
• Linked allocation
• Indexed allocation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 35 / 57
Contiguous Allocation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 36 / 57
Contiguous Allocation (1/2)
Contiguous allocation: each file occupies set of contiguous blocks.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
Contiguous Allocation (1/2)
Contiguous allocation: each file occupies set of contiguous blocks.
• Best performance in most cases
• Simple: only starting location (block number) and length (number
of blocks) are required.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
Contiguous Allocation (1/2)
Contiguous allocation: each file occupies set of contiguous blocks.
• Best performance in most cases
• Simple: only starting location (block number) and length (number
of blocks) are required.
• Supports both sequential and direct access.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
Contiguous Allocation (1/2)
Contiguous allocation: each file occupies set of contiguous blocks.
• Best performance in most cases
• Simple: only starting location (block number) and length (number
of blocks) are required.
• Supports both sequential and direct access.
Allocation strategies like contiguous memory allocation:
• First fit
• Best fit
• Worst fit
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
Contiguous Allocation (2/2)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 38 / 57
Contiguous Allocation Problems
Finding space for file
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
Contiguous Allocation Problems
Finding space for file
External fragmentation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
Contiguous Allocation Problems
Finding space for file
External fragmentation
Need for compaction (fragmentation) off-line or on-line: lose of
performance
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
Contiguous Allocation Problems
Finding space for file
External fragmentation
Need for compaction (fragmentation) off-line or on-line: lose of
performance
Knowing file size
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
Extent-Based Systems
A modified contiguous allocation scheme.
• E.g., Veritas file system
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 40 / 57
Extent-Based Systems
A modified contiguous allocation scheme.
• E.g., Veritas file system
Extent-based file systems allocate disk blocks in extents.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 40 / 57
Extent-Based Systems
A modified contiguous allocation scheme.
• E.g., Veritas file system
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.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 40 / 57
Linked Allocation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 41 / 57
Linked Allocation (1/2)
Linked allocation: each file is a linked list of blocks.
• Each block contains pointer to next block.
• File ends at null pointer.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 42 / 57
Linked Allocation (1/2)
Linked allocation: each file is a linked list of blocks.
• Each block contains pointer to next block.
• File ends at null pointer.
No external fragmentation, no compaction.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 42 / 57
Linked Allocation (1/2)
Linked allocation: each file is a linked list of blocks.
• Each block contains pointer to next block.
• File ends at null pointer.
No external fragmentation, no compaction.
Free space management system called when new block needed.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 42 / 57
Linked Allocation (2/2)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 43 / 57
Linked Allocation Problems
Locating a block can take many I/Os and disk seeks.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 44 / 57
Linked Allocation Problems
Locating a block can take many I/Os and disk seeks.
Reliability can be a problem.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 44 / 57
Linked Allocation Problems
Locating a block can take many I/Os and disk seeks.
Reliability can be a problem.
The space required for the pointers.
• Efficiency can be improved by clustering blocks into groups but
increases internal fragmentation.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 44 / 57
File-Allocation Table (FAT)
Beginning of volume has a table, indexed by block number.
Much like a linked list, but faster on disk and cacheable.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 45 / 57
Indexed Allocation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 46 / 57
Indexed Allocation (1/2)
Indexed allocation: each file has its own index block(s) of pointers
to its data blocks.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
Indexed Allocation (1/2)
Indexed allocation: each file has its own index block(s) of pointers
to its data blocks.
Need index table
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
Indexed Allocation (1/2)
Indexed allocation: each file has its own index block(s) of pointers
to its data blocks.
Need index table
Random access
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
Indexed Allocation (1/2)
Indexed allocation: each file has its own index block(s) of pointers
to its data blocks.
Need index table
Random access
Dynamic access without external fragmentation, but have overhead
of index block
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
Indexed Allocation (2/2)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 48 / 57
Indexed Allocation Problems
Wasted space: overhead of the index blocks.
For example, even with a file of only one or two blocks, we need an
an entire index block.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 49 / 57
Index Block Size
How large the index block should be?
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 50 / 57
Index Block Size
How large the index block should be?
Keep the index block as small as possible.
• We need a mechanism to hold pointers for large files.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 50 / 57
Index Block Size
How large the index block should be?
Keep the index block as small as possible.
• We need a mechanism to hold pointers for large files.
Mechanisms for this purpose include the following:
• Linked scheme
• Multi-level index
• Combined scheme
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 50 / 57
Linked Scheme
Linked scheme: link blocks of index table (no limit on size)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 51 / 57
Linked Scheme
Linked scheme: link blocks of index table (no limit on size)
For example, an index block might contain a small header giving the
name of the file and a set of the first 100 disk-block addresses.
The next address is null or is a pointer to another index block.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 51 / 57
Multi-Level Index
Two-level index
A first-level index block to point to a set of second-level index blocks,
which in turn point to the file blocks.
Could be continued to a third or fourth level.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 52 / 57
Combined Scheme
Combine scheme: used in Unix/Linux FS
The first 12 pointers point to direct blocks
• The data for small files do not need a separate index block.
The next 3 pointers point to indirect blocks.
• Single indirect
• Double indirect
• Triple indirect
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 53 / 57
Performance
Best method depends on file access type.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
Performance
Best method depends on file access type.
Contiguous is great for sequential and random.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
Performance
Best method depends on file access type.
Contiguous is great for sequential and random.
Linked is good for sequential, not random.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
Performance
Best method depends on file access type.
Contiguous is great for sequential and random.
Linked is good for sequential, not random.
Indexed is more complex
• Single block access could require 2 index block reads then data
block read
• Clustering can help improve throughput, reduce CPU overhead
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
Summary
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 55 / 57
Summary
FS layers: device, I/O control, basic FS, file-organization, logical
FS, application
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
Summary
FS layers: device, I/O control, basic FS, file-organization, logical
FS, application
FS implementation:
• On-disk structures: boot control block, volume control block,
directory structure, and file control block
• In-memory structures: mount table, directory structure, open-file
tables, and buffers
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
Summary
FS layers: device, I/O control, basic FS, file-organization, logical
FS, application
FS implementation:
• On-disk structures: boot control block, volume control block,
directory structure, and file control block
• In-memory structures: mount table, directory structure, open-file
tables, and buffers
Virtual file system (VFS)
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
Summary
FS layers: device, I/O control, basic FS, file-organization, logical
FS, application
FS implementation:
• On-disk structures: boot control block, volume control block,
directory structure, and file control block
• In-memory structures: mount table, directory structure, open-file
tables, and buffers
Virtual file system (VFS)
Directory implementation: linear list, and hash table
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
Summary
FS layers: device, I/O control, basic FS, file-organization, logical
FS, application
FS implementation:
• On-disk structures: boot control block, volume control block,
directory structure, and file control block
• In-memory structures: mount table, directory structure, open-file
tables, and buffers
Virtual file system (VFS)
Directory implementation: linear list, and hash table
Allocation methods: contiguous allocation, linked allocation, and
indexed allocation
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
Questions?
Acknowledgements
Some slides were derived from Avi Silberschatz slides.
Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 57 / 57

Mais conteúdo relacionado

Mais procurados

Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)Sandesh Jonchhe
 
Operating System-Ch8 memory management
Operating System-Ch8 memory managementOperating System-Ch8 memory management
Operating System-Ch8 memory managementSyaiful Ahdan
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating SystemJanki Shah
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Ravindra Raju Kolahalam
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System ImplementationWayne Jones Jnr
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)Sohaib Danish
 
Process management os concept
Process management os conceptProcess management os concept
Process management os conceptpriyadeosarkar91
 
Storage management in operating system
Storage management in operating systemStorage management in operating system
Storage management in operating systemDeepikaT13
 
Operating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsOperating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsMukesh Chinta
 
Synchronization hardware
Synchronization hardwareSynchronization hardware
Synchronization hardwareSaeram Butt
 

Mais procurados (20)

File system structure
File system structureFile system structure
File system structure
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
 
Operating System-Ch8 memory management
Operating System-Ch8 memory managementOperating System-Ch8 memory management
Operating System-Ch8 memory management
 
File Management in Operating System
File Management in Operating SystemFile Management in Operating System
File Management in Operating System
 
Disk structure
Disk structureDisk structure
Disk structure
 
RAID
RAIDRAID
RAID
 
Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]Inter Process Communication Presentation[1]
Inter Process Communication Presentation[1]
 
I/O Management
I/O ManagementI/O Management
I/O Management
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Distributed Operating System_4
Distributed Operating System_4Distributed Operating System_4
Distributed Operating System_4
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
 
Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
System call
System callSystem call
System call
 
Operating system concepts (notes)
Operating system concepts (notes)Operating system concepts (notes)
Operating system concepts (notes)
 
Process management os concept
Process management os conceptProcess management os concept
Process management os concept
 
Storage management in operating system
Storage management in operating systemStorage management in operating system
Storage management in operating system
 
Operating Systems - Implementing File Systems
Operating Systems - Implementing File SystemsOperating Systems - Implementing File Systems
Operating Systems - Implementing File Systems
 
Synchronization hardware
Synchronization hardwareSynchronization hardware
Synchronization hardware
 
System call
System callSystem call
System call
 

Semelhante a File System Implementation - Part1

File System Implementation - Part2
File System Implementation - Part2File System Implementation - Part2
File System Implementation - Part2Amir Payberah
 
File System Interface
File System InterfaceFile System Interface
File System InterfaceAmir Payberah
 
Ch11 file system implementation
Ch11   file system implementationCh11   file system implementation
Ch11 file system implementationWelly Dian Astika
 
Introduction to filesystems and computer forensics
Introduction to filesystems and computer forensicsIntroduction to filesystems and computer forensics
Introduction to filesystems and computer forensicsMayank Chaudhari
 
File Management & Access Control
File Management & Access Control File Management & Access Control
File Management & Access Control YuvrajWadavale
 
Course 102: Lecture 27: FileSystems in Linux (Part 2)
Course 102: Lecture 27: FileSystems in Linux (Part 2)Course 102: Lecture 27: FileSystems in Linux (Part 2)
Course 102: Lecture 27: FileSystems in Linux (Part 2)Ahmed El-Arabawy
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copyShay Cohen
 
Ch11 file system implementation
Ch11 file system implementationCh11 file system implementation
Ch11 file system implementationAbdullah Al Shiam
 
file management_part2_os_notes.ppt
file management_part2_os_notes.pptfile management_part2_os_notes.ppt
file management_part2_os_notes.pptHelalMirzad
 
chapter5-file system implementation.ppt
chapter5-file system implementation.pptchapter5-file system implementation.ppt
chapter5-file system implementation.pptBUSHRASHAIKH804312
 
Xfs file system for linux
Xfs file system for linuxXfs file system for linux
Xfs file system for linuxAjay Sood
 
Poking The Filesystem For Fun And Profit
Poking The Filesystem For Fun And ProfitPoking The Filesystem For Fun And Profit
Poking The Filesystem For Fun And Profitssusera432ea1
 
CASPUR Staging System II
CASPUR Staging System IICASPUR Staging System II
CASPUR Staging System IIAndrea PETRUCCI
 
File management in OS
File management in OSFile management in OS
File management in OSBhavik Vashi
 

Semelhante a File System Implementation - Part1 (20)

File System Implementation - Part2
File System Implementation - Part2File System Implementation - Part2
File System Implementation - Part2
 
File System Interface
File System InterfaceFile System Interface
File System Interface
 
File Management
File ManagementFile Management
File Management
 
Storage
StorageStorage
Storage
 
File management
File managementFile management
File management
 
Ch11 file system implementation
Ch11   file system implementationCh11   file system implementation
Ch11 file system implementation
 
Introduction to filesystems and computer forensics
Introduction to filesystems and computer forensicsIntroduction to filesystems and computer forensics
Introduction to filesystems and computer forensics
 
File Management & Access Control
File Management & Access Control File Management & Access Control
File Management & Access Control
 
Course 102: Lecture 27: FileSystems in Linux (Part 2)
Course 102: Lecture 27: FileSystems in Linux (Part 2)Course 102: Lecture 27: FileSystems in Linux (Part 2)
Course 102: Lecture 27: FileSystems in Linux (Part 2)
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 
11 linux filesystem copy
11 linux filesystem copy11 linux filesystem copy
11 linux filesystem copy
 
File system
File systemFile system
File system
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Ch11 file system implementation
Ch11 file system implementationCh11 file system implementation
Ch11 file system implementation
 
file management_part2_os_notes.ppt
file management_part2_os_notes.pptfile management_part2_os_notes.ppt
file management_part2_os_notes.ppt
 
chapter5-file system implementation.ppt
chapter5-file system implementation.pptchapter5-file system implementation.ppt
chapter5-file system implementation.ppt
 
Xfs file system for linux
Xfs file system for linuxXfs file system for linux
Xfs file system for linux
 
Poking The Filesystem For Fun And Profit
Poking The Filesystem For Fun And ProfitPoking The Filesystem For Fun And Profit
Poking The Filesystem For Fun And Profit
 
CASPUR Staging System II
CASPUR Staging System IICASPUR Staging System II
CASPUR Staging System II
 
File management in OS
File management in OSFile management in OS
File management in OS
 

Mais de Amir Payberah

P2P Content Distribution Network
P2P Content Distribution NetworkP2P Content Distribution Network
P2P Content Distribution NetworkAmir Payberah
 
Data Intensive Computing Frameworks
Data Intensive Computing FrameworksData Intensive Computing Frameworks
Data Intensive Computing FrameworksAmir Payberah
 
The Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics PlatformThe Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics PlatformAmir Payberah
 
The Spark Big Data Analytics Platform
The Spark Big Data Analytics PlatformThe Spark Big Data Analytics Platform
The Spark Big Data Analytics PlatformAmir Payberah
 
Linux Module Programming
Linux Module ProgrammingLinux Module Programming
Linux Module ProgrammingAmir Payberah
 
Virtual Memory - Part2
Virtual Memory - Part2Virtual Memory - Part2
Virtual Memory - Part2Amir Payberah
 
Virtual Memory - Part1
Virtual Memory - Part1Virtual Memory - Part1
Virtual Memory - Part1Amir Payberah
 
CPU Scheduling - Part2
CPU Scheduling - Part2CPU Scheduling - Part2
CPU Scheduling - Part2Amir Payberah
 
CPU Scheduling - Part1
CPU Scheduling - Part1CPU Scheduling - Part1
CPU Scheduling - Part1Amir Payberah
 
Process Synchronization - Part2
Process Synchronization -  Part2Process Synchronization -  Part2
Process Synchronization - Part2Amir Payberah
 
Process Synchronization - Part1
Process Synchronization -  Part1Process Synchronization -  Part1
Process Synchronization - Part1Amir Payberah
 
Process Management - Part3
Process Management - Part3Process Management - Part3
Process Management - Part3Amir Payberah
 

Mais de Amir Payberah (20)

P2P Content Distribution Network
P2P Content Distribution NetworkP2P Content Distribution Network
P2P Content Distribution Network
 
Cloud Computing
Cloud ComputingCloud Computing
Cloud Computing
 
Data Intensive Computing Frameworks
Data Intensive Computing FrameworksData Intensive Computing Frameworks
Data Intensive Computing Frameworks
 
The Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics PlatformThe Stratosphere Big Data Analytics Platform
The Stratosphere Big Data Analytics Platform
 
The Spark Big Data Analytics Platform
The Spark Big Data Analytics PlatformThe Spark Big Data Analytics Platform
The Spark Big Data Analytics Platform
 
Security
SecuritySecurity
Security
 
Protection
ProtectionProtection
Protection
 
Linux Module Programming
Linux Module ProgrammingLinux Module Programming
Linux Module Programming
 
IO Systems
IO SystemsIO Systems
IO Systems
 
Virtual Memory - Part2
Virtual Memory - Part2Virtual Memory - Part2
Virtual Memory - Part2
 
Virtual Memory - Part1
Virtual Memory - Part1Virtual Memory - Part1
Virtual Memory - Part1
 
Main Memory - Part2
Main Memory - Part2Main Memory - Part2
Main Memory - Part2
 
Main Memory - Part1
Main Memory - Part1Main Memory - Part1
Main Memory - Part1
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
CPU Scheduling - Part2
CPU Scheduling - Part2CPU Scheduling - Part2
CPU Scheduling - Part2
 
CPU Scheduling - Part1
CPU Scheduling - Part1CPU Scheduling - Part1
CPU Scheduling - Part1
 
Process Synchronization - Part2
Process Synchronization -  Part2Process Synchronization -  Part2
Process Synchronization - Part2
 
Process Synchronization - Part1
Process Synchronization -  Part1Process Synchronization -  Part1
Process Synchronization - Part1
 
Threads
ThreadsThreads
Threads
 
Process Management - Part3
Process Management - Part3Process Management - Part3
Process Management - Part3
 

Último

Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 

Último (20)

Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 

File System Implementation - Part1

  • 1. File System Implementation (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 1 / 57
  • 2. Motivation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 2 / 57
  • 3. Motivation The file system resides permanently on secondary storage. How to • structure file use • allocate disk space • recover free space • track the locations of data • interface other parts of the OS to secondary storage Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 3 / 57
  • 4. File System Structure Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 4 / 57
  • 5. File-System Structure Disk provides in-place rewrite and random access • I/O transfers performed in blocks of sectors (usually 512 bytes) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 5 / 57
  • 6. File-System Structure Disk provides in-place rewrite and random access • I/O transfers performed in blocks of sectors (usually 512 bytes) File system resides on secondary storage • User interface to storage, mapping logical to physical • Efficient and convenient access to disk Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 5 / 57
  • 7. File-System Structure Disk provides in-place rewrite and random access • I/O transfers performed in blocks of sectors (usually 512 bytes) File system resides on secondary storage • User interface to storage, mapping logical to physical • Efficient and convenient access to disk File structure • Logical storage unit • Collection of related information Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 5 / 57
  • 8. File-System Design Problems How the file system should look to the user? Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 6 / 57
  • 9. File-System Design Problems How the file system should look to the user? • Defining a file and its attributes • The operations allowed on a file • The directory structure for organizing files Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 6 / 57
  • 10. File-System Design Problems How the file system should look to the user? • Defining a file and its attributes • The operations allowed on a file • The directory structure for organizing files Algorithms and data structures to map the logical file system onto the physical secondary-storage devices. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 6 / 57
  • 11. File System Layers (1/6) Different levels Each level uses the features of lower levels to create new features for use by higher levels. Reducing complexity and redundancy, but adds overhead and can decrease performance. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 7 / 57
  • 12. File System Layers (2/6) Device drivers manage I/O devices at the I/O control layer. Translates high-level commands to low-level hardware-specific instructions. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 8 / 57
  • 13. File System Layers (3/6) Basic file system translates given command like retrieve block 123 to device driver. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 9 / 57
  • 14. File System Layers (3/6) Basic file system translates given command like retrieve block 123 to device driver. Also manages memory buffers and caches (allocation, freeing, replacement) • Buffers hold data in transit • Caches hold frequently used data Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 9 / 57
  • 15. File System Layers (4/6) File organization understands files, logical address, and physical blocks. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 10 / 57
  • 16. File System Layers (4/6) File organization understands files, logical address, and physical blocks. Translates logical block number to physical block number. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 10 / 57
  • 17. File System Layers (4/6) File organization understands files, logical address, and physical blocks. Translates logical block number to physical block number. Manages free space and disk allocation. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 10 / 57
  • 18. File System Layers (5/6) Logical file system manages metadata information. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 11 / 57
  • 19. File System Layers (5/6) Logical file system manages metadata information. Translates file name into file number, file handle, location by maintaining file control blocks (inodes in Unix) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 11 / 57
  • 20. File System Layers (5/6) Logical file system manages metadata information. Translates file name into file number, file handle, location by maintaining file control blocks (inodes in Unix) Directory management Protection Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 11 / 57
  • 21. File System Layers (6/6) Many file systems, sometimes many within an OS Each with its own format • CD-ROM: ISO 9660 • Unix: UFS, FFS • Windows: FAT, FAT32, NTFS • Linux: more than 40 types, with extended file system (ext2, ext3, ext4) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 12 / 57
  • 22. File System Implementation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 13 / 57
  • 23. File-System Implementation Based on several on-disk and in-memory structures. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 14 / 57
  • 24. File-System Implementation Based on several on-disk and in-memory structures. On-disk • Boot control block (per volume) • Volume control block (per volume) • Directory structure (per file system) • File control block (per file) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 14 / 57
  • 25. File-System Implementation Based on several on-disk and in-memory structures. On-disk • Boot control block (per volume) • Volume control block (per volume) • Directory structure (per file system) • File control block (per file) In-memory • Mount table • Directory structure cache • The open-file table (system-wide and per process) • Buffers of the file-system blocks Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 14 / 57
  • 26. On-Disk File System Structures (1/2) Boot control block contains information needed by system to boot OS from that volume. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
  • 27. On-Disk File System Structures (1/2) Boot control block contains information needed by system to boot OS from that volume. • Needed if volume contains OS, usually first block of volume. • In UFS, it is called boot block, and in NTFS partition boot sector. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
  • 28. On-Disk File System Structures (1/2) Boot control block contains information needed by system to boot OS from that volume. • Needed if volume contains OS, usually first block of volume. • In UFS, it is called boot block, and in NTFS partition boot sector. Volume control block contains volume details. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
  • 29. On-Disk File System Structures (1/2) Boot control block contains information needed by system to boot OS from that volume. • Needed if volume contains OS, usually first block of volume. • In UFS, it is called boot block, and in NTFS partition boot sector. Volume control block contains volume details. • Total num. of blocks, num. of free blocks, block size, free block pointers or array • In UFS, it is called super block, and in NTFS master file table. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 15 / 57
  • 30. On-Disk File System Structures (2/2) Directory structure organizes the files. • In UFS, this includes file names and associated inode numbers. • In NTFS, it is stored in the master file table. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 16 / 57
  • 31. On-Disk File System Structures (2/2) Directory structure organizes the files. • In UFS, this includes file names and associated inode numbers. • In NTFS, it is stored in the master file table. File control block contains many details about the file. • In UFS, inode number, permissions, size, dates. • In NFTS stores into in master file table. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 16 / 57
  • 32. In-Memory File System Structures Mount table contains information about each mounted volume. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
  • 33. In-Memory File System Structures Mount table contains information about each mounted volume. Directory structure cache holds the directory information of recently accessed directories. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
  • 34. In-Memory File System Structures Mount table contains information about each mounted volume. Directory structure cache holds the directory information of recently accessed directories. System-wide open-file table contains a copy of the FCB of each open file. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
  • 35. In-Memory File System Structures Mount table contains information about each mounted volume. Directory structure cache holds the directory information of recently accessed directories. System-wide open-file table contains a copy of the FCB of each open file. Per-process open-file table contains a pointer to the appropriate entry in the system-wide open-file table. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
  • 36. In-Memory File System Structures Mount table contains information about each mounted volume. Directory structure cache holds the directory information of recently accessed directories. System-wide open-file table contains a copy of the FCB of each open file. Per-process open-file table contains a pointer to the appropriate entry in the system-wide open-file table. Buffers hold file-system blocks when they are being read from disk or written to disk. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 17 / 57
  • 37. Create a File A program calls the logical file system. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 18 / 57
  • 38. Create a File A program calls the logical file system. The logical file system knows the format of the directory structures, and allocates a new FCB. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 18 / 57
  • 39. Create a File A program calls the logical file system. The logical file system knows the format of the directory structures, and allocates a new FCB. The system, then, reads the appropriate directory into memory, up- dates it with the new file name and FCB, and writes it back to the disk. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 18 / 57
  • 40. Open a File The file must be opened. • The open() passes a file name to the logical file system. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
  • 41. Open a File The file must be opened. • The open() passes a file name to the logical file system. The open() first searches the system-wide open-file: if the file is already in use by another process. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
  • 42. Open a File The file must be opened. • The open() passes a file name to the logical file system. The open() first searches the system-wide open-file: if the file is already in use by another process. • If yes: a per-process open-file table entry is created. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
  • 43. Open a File The file must be opened. • The open() passes a file name to the logical file system. The open() first searches the system-wide open-file: if the file is already in use by another process. • If yes: a per-process open-file table entry is created. • If no: the directory structure is searched for the given file name: once the file is found, the FCB is copied into a system-wide open-file table in memory. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
  • 44. Open a File The file must be opened. • The open() passes a file name to the logical file system. The open() first searches the system-wide open-file: if the file is already in use by another process. • If yes: a per-process open-file table entry is created. • If no: the directory structure is searched for the given file name: once the file is found, the FCB is copied into a system-wide open-file table in memory. This table stores the FCB as well as the number of processes that have the file open. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 19 / 57
  • 45. Read From a File The open() returns a pointer to the appropriate entry in the per- process file-system table. All file operations are then performed via this pointer. This pointer is called file descriptor in Unix and file handle in Win- dows. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 20 / 57
  • 46. Close a File When a process closes the file: • The per-process table entry is removed. • The system-wide entry’s open count is decremented. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 21 / 57
  • 47. Close a File When a process closes the file: • The per-process table entry is removed. • The system-wide entry’s open count is decremented. When all users that have opened the file close it, any updated meta- data is copied back to the disk-based directory structure, and the system-wide open-file table entry is removed. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 21 / 57
  • 48. Partitions and Mounting (1/2) Partition can be a volume containing a file system or raw. • Raw partition: just a sequence of blocks with no file system. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 22 / 57
  • 49. Partitions and Mounting (1/2) Partition can be a volume containing a file system or raw. • Raw partition: just a sequence of blocks with no file system. Boot block points to boot volume or boot loader. • Boot loader: knows enough about the file-system structure to be able to find and load the kernel and start it executing. • Dual-boot that allows to install multiple OS on a single system. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 22 / 57
  • 50. Partitions and Mounting (2/2) Root partition contains the OS • Mounted at boot time • Other partitions can hold other OSes, other file systems, or be raw • Other partitions can mount automatically or manually Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 23 / 57
  • 51. Partitions and Mounting (2/2) Root partition contains the OS • Mounted at boot time • Other partitions can hold other OSes, other file systems, or be raw • Other partitions can mount automatically or manually At mount time, file system consistency checked. • Is all metadata correct? if not, fix it, try again, if yes, add to mount table, allow access Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 23 / 57
  • 52. Virtual File Systems Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 24 / 57
  • 53. Virtual File Systems (1/2) Virtual File Systems (VFS) on Unix provide an object-oriented way of implementing file systems. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 25 / 57
  • 54. Virtual File Systems (1/2) Virtual File Systems (VFS) on Unix 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. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 25 / 57
  • 55. Virtual File Systems (1/2) Virtual File Systems (VFS) on Unix 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. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 25 / 57
  • 56. Virtual File Systems (2/2) VFS layer serves two important functions: Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
  • 57. Virtual File Systems (2/2) VFS layer serves two important functions: 1 It separates file-system-generic operations from their implementa- tion, and allows transparent access to different types of file systems mounted locally. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
  • 58. Virtual File Systems (2/2) VFS layer serves two important functions: 1 It separates file-system-generic operations from their implementa- tion, and allows transparent access to different types of file systems mounted locally. 2 It provides a mechanism for uniquely representing a file throughout a network. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
  • 59. Virtual File Systems (2/2) VFS layer serves two important functions: 1 It separates file-system-generic operations from their implementa- tion, and allows transparent access to different types of file systems mounted locally. 2 It provides a mechanism for uniquely representing a file throughout a network. The VFS is based on a structure, called a vnode. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
  • 60. Virtual File Systems (2/2) VFS layer serves two important functions: 1 It separates file-system-generic operations from their implementa- tion, and allows transparent access to different types of file systems mounted locally. 2 It provides a mechanism for uniquely representing a file throughout a network. The VFS is based on a structure, called a vnode. • Contains a numerical designator for a network-wide unique file. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
  • 61. Virtual File Systems (2/2) VFS layer serves two important functions: 1 It separates file-system-generic operations from their implementa- tion, and allows transparent access to different types of file systems mounted locally. 2 It provides a mechanism for uniquely representing a file throughout a network. The VFS is based on a structure, called a vnode. • Contains a numerical designator for a network-wide unique file. • Unix inodes are unique within only a single file system. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
  • 62. Virtual File Systems (2/2) VFS layer serves two important functions: 1 It separates file-system-generic operations from their implementa- tion, and allows transparent access to different types of file systems mounted locally. 2 It provides a mechanism for uniquely representing a file throughout a network. The VFS is based on a structure, called a vnode. • Contains a numerical designator for a network-wide unique file. • Unix inodes are unique within only a single file system. • The kernel maintains one vnode structure for each active node. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 26 / 57
  • 63. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 27 / 57
  • 64. VFS in Linux (1/2) The four main object types defined by the Linux VFS are: Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
  • 65. VFS in Linux (1/2) The four main object types defined by the Linux VFS are: • The inode object: represents an individual file Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
  • 66. VFS in Linux (1/2) The four main object types defined by the Linux VFS are: • The inode object: represents an individual file • The file object: represents an open file Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
  • 67. VFS in Linux (1/2) The four main object types defined by the Linux VFS are: • The inode object: represents an individual file • The file object: represents an open file • The super block object: represents an entire file system Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
  • 68. VFS in Linux (1/2) The four main object types defined by the Linux VFS are: • The inode object: represents an individual file • The file object: represents an open file • The super block object: represents an entire file system • The dentry object: represents an individual directory entry Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 28 / 57
  • 69. VFS in Linux (2/2) VFS defines a set of operations on the objects that must be imple- mented. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
  • 70. VFS in Linux (2/2) VFS defines a set of operations on the objects that must be imple- mented. Every object has a pointer to a function table. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
  • 71. VFS in Linux (2/2) VFS defines a set of operations on the objects that must be imple- mented. Every object has a pointer to a function table. • Function table has addresses of routines to implement that function on that object. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
  • 72. VFS in Linux (2/2) VFS defines a set of operations on the objects that must be imple- mented. Every object has a pointer to a function table. • Function table has addresses of routines to implement that function on that object. • For example: int open(...): open a file int close(...): close an already-open file ssize t read(...): read from a file ssize t write(...): write to a file int mmap(...): memory-map a file Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 29 / 57
  • 73. Directory Implementation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 30 / 57
  • 74. Directory Implementation Linear list Hash table Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 31 / 57
  • 75. Directory Implementation - Linear List Linear list of file names with pointer to the data blocks. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
  • 76. Directory Implementation - Linear List Linear list of file names with pointer to the data blocks. Simple to program. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
  • 77. Directory Implementation - Linear List Linear list of file names with pointer to the data blocks. Simple to program. Time-consuming to execute. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
  • 78. Directory Implementation - Linear List Linear list of file names with pointer to the data blocks. Simple to program. Time-consuming to execute. Linear search time. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
  • 79. Directory Implementation - Linear List 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: binary search, but heavy Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 32 / 57
  • 80. Directory Implementation - Hash Table Hash Table: linear list with hash data structure Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
  • 81. Directory Implementation - Hash Table Hash Table: linear list with hash data structure Decreases directory search time Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
  • 82. Directory Implementation - Hash Table Hash Table: linear list with hash data structure Decreases directory search time Collisions: situations where two file names hash to the same location Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
  • 83. Directory Implementation - Hash Table Hash Table: linear list with hash data structure Decreases directory search time Collisions: situations where two file names hash to the same location Chained-overflow method. • Each hash entry can be a linked list instead of an individual value. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 33 / 57
  • 84. Allocation Methods Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 34 / 57
  • 85. Allocation Methods How disk blocks are allocated to files? Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 35 / 57
  • 86. Allocation Methods How disk blocks are allocated to files? Methods: • Contiguous allocation • Linked allocation • Indexed allocation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 35 / 57
  • 87. Contiguous Allocation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 36 / 57
  • 88. Contiguous Allocation (1/2) Contiguous allocation: each file occupies set of contiguous blocks. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
  • 89. Contiguous Allocation (1/2) Contiguous allocation: each file occupies set of contiguous blocks. • Best performance in most cases • Simple: only starting location (block number) and length (number of blocks) are required. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
  • 90. Contiguous Allocation (1/2) Contiguous allocation: each file occupies set of contiguous blocks. • Best performance in most cases • Simple: only starting location (block number) and length (number of blocks) are required. • Supports both sequential and direct access. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
  • 91. Contiguous Allocation (1/2) Contiguous allocation: each file occupies set of contiguous blocks. • Best performance in most cases • Simple: only starting location (block number) and length (number of blocks) are required. • Supports both sequential and direct access. Allocation strategies like contiguous memory allocation: • First fit • Best fit • Worst fit Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 37 / 57
  • 92. Contiguous Allocation (2/2) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 38 / 57
  • 93. Contiguous Allocation Problems Finding space for file Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
  • 94. Contiguous Allocation Problems Finding space for file External fragmentation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
  • 95. Contiguous Allocation Problems Finding space for file External fragmentation Need for compaction (fragmentation) off-line or on-line: lose of performance Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
  • 96. Contiguous Allocation Problems Finding space for file External fragmentation Need for compaction (fragmentation) off-line or on-line: lose of performance Knowing file size Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 39 / 57
  • 97. Extent-Based Systems A modified contiguous allocation scheme. • E.g., Veritas file system Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 40 / 57
  • 98. Extent-Based Systems A modified contiguous allocation scheme. • E.g., Veritas file system Extent-based file systems allocate disk blocks in extents. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 40 / 57
  • 99. Extent-Based Systems A modified contiguous allocation scheme. • E.g., Veritas file system 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. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 40 / 57
  • 100. Linked Allocation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 41 / 57
  • 101. Linked Allocation (1/2) Linked allocation: each file is a linked list of blocks. • Each block contains pointer to next block. • File ends at null pointer. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 42 / 57
  • 102. Linked Allocation (1/2) Linked allocation: each file is a linked list of blocks. • Each block contains pointer to next block. • File ends at null pointer. No external fragmentation, no compaction. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 42 / 57
  • 103. Linked Allocation (1/2) Linked allocation: each file is a linked list of blocks. • Each block contains pointer to next block. • File ends at null pointer. No external fragmentation, no compaction. Free space management system called when new block needed. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 42 / 57
  • 104. Linked Allocation (2/2) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 43 / 57
  • 105. Linked Allocation Problems Locating a block can take many I/Os and disk seeks. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 44 / 57
  • 106. Linked Allocation Problems Locating a block can take many I/Os and disk seeks. Reliability can be a problem. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 44 / 57
  • 107. Linked Allocation Problems Locating a block can take many I/Os and disk seeks. Reliability can be a problem. The space required for the pointers. • Efficiency can be improved by clustering blocks into groups but increases internal fragmentation. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 44 / 57
  • 108. File-Allocation Table (FAT) Beginning of volume has a table, indexed by block number. Much like a linked list, but faster on disk and cacheable. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 45 / 57
  • 109. Indexed Allocation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 46 / 57
  • 110. Indexed Allocation (1/2) Indexed allocation: each file has its own index block(s) of pointers to its data blocks. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
  • 111. Indexed Allocation (1/2) Indexed allocation: each file has its own index block(s) of pointers to its data blocks. Need index table Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
  • 112. Indexed Allocation (1/2) Indexed allocation: each file has its own index block(s) of pointers to its data blocks. Need index table Random access Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
  • 113. Indexed Allocation (1/2) Indexed allocation: each file has its own index block(s) of pointers to its data blocks. Need index table Random access Dynamic access without external fragmentation, but have overhead of index block Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 47 / 57
  • 114. Indexed Allocation (2/2) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 48 / 57
  • 115. Indexed Allocation Problems Wasted space: overhead of the index blocks. For example, even with a file of only one or two blocks, we need an an entire index block. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 49 / 57
  • 116. Index Block Size How large the index block should be? Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 50 / 57
  • 117. Index Block Size How large the index block should be? Keep the index block as small as possible. • We need a mechanism to hold pointers for large files. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 50 / 57
  • 118. Index Block Size How large the index block should be? Keep the index block as small as possible. • We need a mechanism to hold pointers for large files. Mechanisms for this purpose include the following: • Linked scheme • Multi-level index • Combined scheme Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 50 / 57
  • 119. Linked Scheme Linked scheme: link blocks of index table (no limit on size) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 51 / 57
  • 120. Linked Scheme Linked scheme: link blocks of index table (no limit on size) For example, an index block might contain a small header giving the name of the file and a set of the first 100 disk-block addresses. The next address is null or is a pointer to another index block. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 51 / 57
  • 121. Multi-Level Index Two-level index A first-level index block to point to a set of second-level index blocks, which in turn point to the file blocks. Could be continued to a third or fourth level. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 52 / 57
  • 122. Combined Scheme Combine scheme: used in Unix/Linux FS The first 12 pointers point to direct blocks • The data for small files do not need a separate index block. The next 3 pointers point to indirect blocks. • Single indirect • Double indirect • Triple indirect Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 53 / 57
  • 123. Performance Best method depends on file access type. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
  • 124. Performance Best method depends on file access type. Contiguous is great for sequential and random. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
  • 125. Performance Best method depends on file access type. Contiguous is great for sequential and random. Linked is good for sequential, not random. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
  • 126. Performance Best method depends on file access type. Contiguous is great for sequential and random. Linked is good for sequential, not random. Indexed is more complex • Single block access could require 2 index block reads then data block read • Clustering can help improve throughput, reduce CPU overhead Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 54 / 57
  • 127. Summary Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 55 / 57
  • 128. Summary FS layers: device, I/O control, basic FS, file-organization, logical FS, application Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
  • 129. Summary FS layers: device, I/O control, basic FS, file-organization, logical FS, application FS implementation: • On-disk structures: boot control block, volume control block, directory structure, and file control block • In-memory structures: mount table, directory structure, open-file tables, and buffers Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
  • 130. Summary FS layers: device, I/O control, basic FS, file-organization, logical FS, application FS implementation: • On-disk structures: boot control block, volume control block, directory structure, and file control block • In-memory structures: mount table, directory structure, open-file tables, and buffers Virtual file system (VFS) Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
  • 131. Summary FS layers: device, I/O control, basic FS, file-organization, logical FS, application FS implementation: • On-disk structures: boot control block, volume control block, directory structure, and file control block • In-memory structures: mount table, directory structure, open-file tables, and buffers Virtual file system (VFS) Directory implementation: linear list, and hash table Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
  • 132. Summary FS layers: device, I/O control, basic FS, file-organization, logical FS, application FS implementation: • On-disk structures: boot control block, volume control block, directory structure, and file control block • In-memory structures: mount table, directory structure, open-file tables, and buffers Virtual file system (VFS) Directory implementation: linear list, and hash table Allocation methods: contiguous allocation, linked allocation, and indexed allocation Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 56 / 57
  • 133. Questions? Acknowledgements Some slides were derived from Avi Silberschatz slides. Amir H. Payberah (Tehran Polytechnic) File System Implementation 1393/9/8 57 / 57