Documente Academic
Documente Profesional
Documente Cultură
Lesson 13:
File Systems
Jesús Carretero Pérez
David Expósito Singh
José Daniel García Sánchez
Francisco Javier García Blas
Florin Isaila
Operating Systems 1
Goals
Operating Systems 2
Contents
Operating Systems 3
File systems and partitions
Operating Systems 4
File System and partitions
FAT
2 FAT Root Data and
Boot
copies directory directories
UNIX
Super Bit Data and
Boot i-nodes
block Maps directories
Operating Systems 5
File systems and partitions
Operating Systems 6
Partition types
Partition 4 Partition 5
Partition 1
Partition 2
Partition 3
Operating Systems 7
Blocks and clusters
Operating Systems 8
ISO-9660 file system
Operating Systems 9
FAT file system
Operating Systems 10
FAT12
Operating Systems 11
FAT16
Operating Systems 13
UNIX-like file systems
• Structure:
– Boot: Operating system boot info.
– Superblock: Descriptive information for file system
structure.
• Virtual superblock: Generic information.
• Specific superblock: OS dependent information.
– Block bitmaps: One bit per block to signal free/used.
– i-node bitmaps: One bit per i-node (in i-node) area to
signal free/used.
– i-nodes: As many i-nodes as number of files that can be
stored on the file system.
• Linux creates one i-node for every to data blocks.
– Data blocks.
Operating Systems 14
BSD-like file systems
Operating Systems 15
Contents
Operating Systems 16
File server
• Design problems:
– Define user view of I/O system including services, files,
directories, file systems, etc …
– Define algorithms and data structures to map the user
view to the secondary storage physical system.
Operating Systems 17
File system layers
Operating Systems 18
Virtual file system
• Services:
– Directory management.
– Name management.
– Security services.
– Generic services on files and directories.
Operating Systems 19
File management module
• Highlights:
– A file management module per supported file system (UNIX, AFS,
NTFS, EFS, …)
– Also files for pseudo files (e.g. files in /proc).
Operating Systems 20
Block server
• Optimizations:
– Block cache.
– May be integrated with virtual memory page manager.
• Operations translated into calls to drivers for each specific devices and
passed to lower level in file system.
• This layer hides device differences, using logical names.
– For example, /dev/hda3 is a hard disk (hd) device, whose main name is a and
working on partition 3.
Operating Systems 21
Block operations
Blocks
Operating Systems 22
Device drivers
Operating Systems 23
Dataflow in file system
read(fd,buffer,sz)
User view buffer
sz
417
499
Block server
315
211
Operating Systems 24
Contents
Operating Systems 25
Associated data structures
• v-nodes table:
– Single table with all v-nodes for all open files.
• i-node tables.
– Single table with i-nodes from all open files.
Operating Systems 26
V-nodes table
• In each entry:
– V-node information in disk.
– Additional in-memory information.
Operating Systems 27
Per-process open file table
Operating Systems 28
System-wide open file table
Operating Systems 29
Open i-nodes table
• In each entry:
– Information of i-node on disk.
– Additional only in-memory information.
Operating Systems 30
File system tables
Operating Systems 31
Contents
Operating Systems 32
Performance improvement
Operating Systems 33
Block cache
• Fundamentals:
– Disk access much slower that memory access.
– Locality:
• Spatial locality.
• Temporal locality.
– Two kinds of I/O flow:
• A block used only once.
• A block used repeatedly.
Operating Systems 34
Block cache
Process Process
Cache
Cache
– Prefetching.
Disk Disk
– Cache cleanup (sync)
• Main problem: File system reliability.
Operating Systems 35
Data flow with block cache
read(fd,buffer,sz)
User view
buffer
sz
Logical file (VFS) Logical file
417
499
Block server
Operating Systems 36
Replacement policies
• Algorithm:
– Check if block to be read is in cache.
• If not found, read from device and copy to cache.
• If cache is full, need to make room for new block replacing an existing one
(replacement policy).
• If block has been modified (dirty): write policy.
• Replacement policy: FIFO (First in First Out), second chance, MRU (Most
Recently Used), LRU (Least Recently Used), etc.
– Most commonly used is LRU.
– Replaces block with more time since last use, assuming it will not be used in
near future.
– Most used blocks tend to be always in cache. Could lead to reliability
problems on failure.
Operating Systems 37
Write politics
• Write on close: When file is closed, all blocks are dumped to disk
Operating Systems 38
OPERATING SYSTEMS:
Lesson 13:
File Systems
Jesús Carretero Pérez
David Expósito Singh
José Daniel García Sánchez
Francisco Javier García Blas
Florin Isaila
Operating Systems 39