SlideShare a Scribd company logo
File system internals
    Tanenbaum, Chapter 4



   COMP3231
Operating Systems
Architecture of the OS storage stack
                              Application

File system:                   FD table
                               OF table
• Hides physical location
  of data on the disk            VFS
                                  FS
• Exposes: directory          Buffer cache
  hierarchy, symbolic file
                             Disk scheduler
  names, random-access
  files, protection          Device driver




                                              2
Some popular file systems
   • FAT16                         • HFS+
   • FAT32                         • UFS2
   • NTFS                          • ZFS
   • Ext2                          • JFS
   • Ext3                          • OCFS
   • Ext4                          • Btrfs
   • ReiserFS                      • JFFS2
   • XFS                           • ExFAT
   • ISO9660                       • UBIFS

Question: why are there so many?
                                             3
Why are there so many?
• Different physical nature of storage devices
   – Ext3 is optimised for magnetic disks
   – JFFS2 is optimised for flash memory devices
   – ISO9660 is optimised for CDROM
• Different storage capacities
   – FAT16 does not support drives >2GB
   – FAT32 becomes inefficient on drives >32GB
   – Btrfs is designed to scale to multi-TB disk arrays
• Different CPU and memory requirements
   – FAT16 is not suitable for modern PCs but is a good fit for
     many embedded devices
• Proprietary standards
   – NTFS may be a nice FS, but its specification is closed
                                                                  4
Assumptions

• In this lecture we focus on file systems for magnetic
  disks
   – Rotational delay
      • 8ms worst case for 7200rpm drive
   – Seek time
      • ~15ms worst case
   – For comparison, disk-to-buffer transfer speed of a modern
     drive is ~10µs per 4K block.
• Conclusion: keep blocks that are likely to be accessed
  together close to each other


                                                            5
Implementing a file system
• The FS must map symbolic file
  names into block addresses
• The FS must keep track of
   – which blocks belong to which files.
   – in what order the blocks form the
     file
   – which blocks are free for allocation
• Given a logical region of a file, the
  FS must track the corresponding                           File system
  block(s) on disk.
                                                4                             7
   – Stored in file system metadata
                                                            8    2
                                            5           1
                                                    6                3
                                                                          6
Allocation strategies

• Contiguous allocation
 ✔
     Easy bookkeeping (need to keep track of the starting block
     and length of the file)
 ✔
     Increases performance for sequential operations
 ✗
     Need the maximum size for the file at the time of creation
 ✗
     As files are deleted, free space becomes divided into many
     small chunks (external fragmentation)
Example: ISO 9660 (CDROM FS)

                         1 2 3 4 5 6 7 8
            metadata

                                                                  7
Allocation strategies
• Dynamic allocation
   – Disk space allocated in portions as needed
   – Allocation occurs in fixed-size blocks
   ✔
       No external fragmentation
   ✔
       Does not require pre-allocating disk space
   ✗
       Partially filled blocks (internal fragmentation)
   ✗
       File blocks are scattered across the disk
   ✗
       Complex metadata management (maintain the list of blocks for each
       file)
                   1
                   2
                   3
                   4
                   5
                   6
                   7
                   8
                                                                    8
External and internal fragmentation

• External fragmentation
   – The space wasted external to the allocated memory
     regions
   – Memory space exists to satisfy a request but it is unusable
     as it is not contiguous
• Internal fragmentation
   – The space wasted internal to the allocated memory
     regions
   – Allocated memory may be slightly larger than requested
     memory; this size difference is wasted memory internal to
     a partition


                                                              9
Linked list allocation

• Each block contains a pointer to the next block in the
  chain. Free blocks are also linked in a chain.
   ✔
       Only single metadata entry per file
   ✔
       Best for sequential files




             1      4              2         3



Question: What are the downsides?
                                                           10
Linked list allocation

• Each block contains a pointer to the next block in the
  chain. Free blocks are also linked in a chain.
   ✔
       Only single metadata entry per file
   ✔
       Best for sequential files




             1      4              2          3

   ✗
       Poor for random access
   ✗
       Blocks end up scattered across the disk due to free list
       eventually being randomised                                11
File allocation table
• Keep a map of the entire FS in a separate table
   – A table entry contains the number of the next block of the file
   – The last block in a file and empty blocks are marked using
     reserved values
• The table is stored on the disk and is replicated in memory
• Random access is fast (following the in-memory list)




            1      4            2             3

                Question: any issues with this design?         12
File allocation table
• Issues
  – Requires a lot of memory for large disks
     • 200GB = 200*10^6 * 1K-blocks ==>
       200*10^6 FAT entries = 800MB
  – Free block lookup is slow




           1     4              2          3

                                               13
File allocation table

• Examples
  – FAT12, FAT16, FAT32




 reserved   FAT1   FAT2           data blocks




                                                14
inode-based FS structure

• Idea: separate table (index-node or i-node) for each file.
   – Only keep table for open files in memory
   – Fast random access
• The most popular FS structure today




           1      4           2            3

                                                          15
i-node implementation issues

• i-nodes occupy one or several disk areas



          i-nodes               data blocks

• i-nodes are allocated dynamically, hence free-space
  management is required for i-nodes
   – Use fixed-size i-nodes to simplify dynamic allocation
   – Reserve the last i-node entry for a pointer to an extension
     i-node



                                                              16
i-node implementation issues




                               17
i-node implementation issues
• Free-space management
  – Approach 1: linked list of free blocks
  – Approach 2: keep bitmaps of free blocks and free i-nodes




                                                          18
Free block list
• List of all unallocated blocks
• Background jobs can re-order list for better contiguity
• Store in free blocks themselves
   – Does not reduce disk capacity
• Only one block of pointers need be kept in the main
  memory




                                                            19
Free block list




(a) Almost-full block of pointers to free disk blocks in RAM
   ●   three blocks of pointers on disk
(b) Result of freeing a 3-block file
(c) Alternative strategy for handling 3 free blocks
   ●   shaded entries are pointers to free disk blocks

                                                               20
Bit tables
• Individual bits in a bit vector flags used/free blocks
• 16GB disk with 512-byte blocks --> 4MB table
• May be too large to hold in main memory
• Expensive to search
   – But may use a two level table
• Concentrating (de)allocations in a portion of the bitmap
  has desirable effect of concentrating access
• Simple to find contiguous free space




                                                           21
Implementing directories

• Directories are stored like normal files
   – directory entries are contained inside data blocks
• The FS assigns special meaning to the content of these
  files
   – a directory file is a list of directory entries
   – a directory entry contains file name, attributes, and the file
     i-node number
       • maps human-oriented file name to a system-oriented
         name




                                                               22
Fixed-size vs variable-size directory entries

• Fixed-size directory entries
   – Either too small
      • Example: DOS 8+3 characters
   – Or waste too much space
      • Example: 255 characters per file name
• Variable-size directory entries
   – Freeing variable length entries can create external
     fragmentation in directory blocks
       • Can compact when block is in RAM



                                                           23
Directory listing

• Locating a file in a directory
   – Linear scan
      • Use a directory cache to speed-up search
   – Hash lookup
   – B-tree (100's of thousands entries)




                                                   24
Storing file attributes




(a) disk addresses and attributes in directory entry
   – FAT
(b) directory in which each entry just refers to an i-node
   –   UNIX


                                                             25
Trade-off in FS block size
• File systems deal with 2 types of blocks
   – Disk blocks or sectors (usually 512 bytes)
   – File system blocks 512 * 2^N bytes
   – What is the optimal N?
• Larger blocks require less FS metadata
• Smaller blocks waste less disk space
• Sequential Access
   – The larger the block size, the fewer I/O operations required
• Random Access
   – The larger the block size, the more unrelated data loaded.
   – Spatial locality of access improves the situation
• Choosing an appropriate block size is a compromise
                                                                    26

More Related Content

What's hot

AOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocksAOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocks
Zubair Nabi
 
Coal presentationt
Coal presentationtCoal presentationt
Coal presentationt
fika sweety
 
Datastorage
DatastorageDatastorage
Datastorage
Anshumali Singh
 
Data Consistency Enhancement in Writeback mode of Journaling using Backpointers
Data Consistency Enhancement in Writeback mode of Journaling using BackpointersData Consistency Enhancement in Writeback mode of Journaling using Backpointers
Data Consistency Enhancement in Writeback mode of Journaling using Backpointers
Rohan Waghere
 
Disk structure
Disk structureDisk structure
Disk structure
Shareb Ismaeel
 
Mass Storage Devices
Mass Storage DevicesMass Storage Devices
Mass Storage Devices
Prabu U
 
Introduction to Disk Storage
Introduction to Disk StorageIntroduction to Disk Storage
Introduction to Disk Storage
Amir Villas
 
Storage memory
Storage memoryStorage memory
Storage memory
fika sweety
 
Mass storage device
Mass storage deviceMass storage device
Mass storage device
Raza Umer
 
Disk
DiskDisk
06 external memory
06 external memory06 external memory
06 external memory
Sher Shah Merkhel
 
external_memory
external_memoryexternal_memory
external_memory
limyamahgoub
 
Mass storage structurefinal
Mass storage structurefinalMass storage structurefinal
Mass storage structurefinal
marangburu42
 
B tree file system
B tree file systemB tree file system
B tree file system
Dinesh Gupta
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
Henry Osborne
 
Management file and directory in linux
Management file and directory in linuxManagement file and directory in linux
Management file and directory in linux
Zkre Saleh
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
Sher Shah Merkhel
 
Hard disks
Hard disksHard disks
Hard disks
English TVTC
 

What's hot (18)

AOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocksAOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocks
 
Coal presentationt
Coal presentationtCoal presentationt
Coal presentationt
 
Datastorage
DatastorageDatastorage
Datastorage
 
Data Consistency Enhancement in Writeback mode of Journaling using Backpointers
Data Consistency Enhancement in Writeback mode of Journaling using BackpointersData Consistency Enhancement in Writeback mode of Journaling using Backpointers
Data Consistency Enhancement in Writeback mode of Journaling using Backpointers
 
Disk structure
Disk structureDisk structure
Disk structure
 
Mass Storage Devices
Mass Storage DevicesMass Storage Devices
Mass Storage Devices
 
Introduction to Disk Storage
Introduction to Disk StorageIntroduction to Disk Storage
Introduction to Disk Storage
 
Storage memory
Storage memoryStorage memory
Storage memory
 
Mass storage device
Mass storage deviceMass storage device
Mass storage device
 
Disk
DiskDisk
Disk
 
06 external memory
06 external memory06 external memory
06 external memory
 
external_memory
external_memoryexternal_memory
external_memory
 
Mass storage structurefinal
Mass storage structurefinalMass storage structurefinal
Mass storage structurefinal
 
B tree file system
B tree file systemB tree file system
B tree file system
 
Disk and File System Management in Linux
Disk and File System Management in LinuxDisk and File System Management in Linux
Disk and File System Management in Linux
 
Management file and directory in linux
Management file and directory in linuxManagement file and directory in linux
Management file and directory in linux
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
Hard disks
Hard disksHard disks
Hard disks
 

Viewers also liked

Future of cities meda city congress november 2012
Future of cities   meda city congress november 2012Future of cities   meda city congress november 2012
Future of cities meda city congress november 2012
Alain Jordà
 
TEC CONTAINER - DELIVERED 2013 - 2016
TEC CONTAINER - DELIVERED 2013 - 2016TEC CONTAINER - DELIVERED 2013 - 2016
TEC CONTAINER - DELIVERED 2013 - 2016
teccontainer
 
EYE Reporter Issue 1 2011
EYE Reporter Issue 1 2011EYE Reporter Issue 1 2011
EYE Reporter Issue 1 2011
Steve @ insider
 
цахим судалгаа
цахим судалгаа цахим судалгаа
цахим судалгаа solongobaga
 
Learning resources in Education: Updates
Learning resources in Education: UpdatesLearning resources in Education: Updates
Learning resources in Education: Updates
wimdboer
 
Cpa network presentation_unisender_conf_prefinal
Cpa network presentation_unisender_conf_prefinalCpa network presentation_unisender_conf_prefinal
Cpa network presentation_unisender_conf_prefinal
Kira Zhestkova
 
Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012
Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012
Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012
onthewight
 
Saigon luxury apartment ms.duyên
Saigon luxury apartment   ms.duyênSaigon luxury apartment   ms.duyên
Saigon luxury apartment ms.duyêntranduyen76
 
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
Kira Zhestkova
 
Saigon luxury apartment
Saigon luxury apartment Saigon luxury apartment
Saigon luxury apartment
tranduyen76
 
49. upload lks 2015 web design (1)
49. upload lks 2015 web design (1)49. upload lks 2015 web design (1)
49. upload lks 2015 web design (1)
Smp Al-Hadi
 
সৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রম
সৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রমসৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রম
সৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রম
Abul Bashar
 
Breast Cancer Management
Breast Cancer ManagementBreast Cancer Management
Breast Cancer Management
Abdul Basit
 
Memoràndum 2013 maquetat
Memoràndum 2013 maquetatMemoràndum 2013 maquetat
Memoràndum 2013 maquetatJosep Miquel
 
Удержание пользователей (User Retention) // CPA Network Russia
Удержание пользователей (User Retention) // CPA Network RussiaУдержание пользователей (User Retention) // CPA Network Russia
Удержание пользователей (User Retention) // CPA Network Russia
Kira Zhestkova
 
Sacomreal hùng vương
Sacomreal hùng vươngSacomreal hùng vương
Sacomreal hùng vương
tranduyen76
 
dMT SPC Presentation Products-engl.
dMT SPC Presentation Products-engl.dMT SPC Presentation Products-engl.
dMT SPC Presentation Products-engl.
dmtgms
 
Commemoration of the Great War 1914-1918 by David Langford
Commemoration of the Great War 1914-1918 by David LangfordCommemoration of the Great War 1914-1918 by David Langford
Commemoration of the Great War 1914-1918 by David Langford
onthewight
 
Blackfreedom , terrific presentation
Blackfreedom , terrific presentationBlackfreedom , terrific presentation
Blackfreedom , terrific presentation
Jaseem Abid
 

Viewers also liked (20)

Future of cities meda city congress november 2012
Future of cities   meda city congress november 2012Future of cities   meda city congress november 2012
Future of cities meda city congress november 2012
 
TEC CONTAINER - DELIVERED 2013 - 2016
TEC CONTAINER - DELIVERED 2013 - 2016TEC CONTAINER - DELIVERED 2013 - 2016
TEC CONTAINER - DELIVERED 2013 - 2016
 
EYE Reporter Issue 1 2011
EYE Reporter Issue 1 2011EYE Reporter Issue 1 2011
EYE Reporter Issue 1 2011
 
цахим судалгаа
цахим судалгаа цахим судалгаа
цахим судалгаа
 
Learning resources in Education: Updates
Learning resources in Education: UpdatesLearning resources in Education: Updates
Learning resources in Education: Updates
 
Cpa network presentation_unisender_conf_prefinal
Cpa network presentation_unisender_conf_prefinalCpa network presentation_unisender_conf_prefinal
Cpa network presentation_unisender_conf_prefinal
 
Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012
Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012
Prof. Mark Hanson's Fat, Fate & Obesity talk to IW Cafe Scientifique sept 2012
 
Saigon luxury apartment ms.duyên
Saigon luxury apartment   ms.duyênSaigon luxury apartment   ms.duyên
Saigon luxury apartment ms.duyên
 
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
 
Saigon luxury apartment
Saigon luxury apartment Saigon luxury apartment
Saigon luxury apartment
 
JAXB
JAXBJAXB
JAXB
 
49. upload lks 2015 web design (1)
49. upload lks 2015 web design (1)49. upload lks 2015 web design (1)
49. upload lks 2015 web design (1)
 
সৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রম
সৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রমসৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রম
সৃজনশীল প্রশ্ন, শিক্ষক ও শ্রেণি কার্যক্রম
 
Breast Cancer Management
Breast Cancer ManagementBreast Cancer Management
Breast Cancer Management
 
Memoràndum 2013 maquetat
Memoràndum 2013 maquetatMemoràndum 2013 maquetat
Memoràndum 2013 maquetat
 
Удержание пользователей (User Retention) // CPA Network Russia
Удержание пользователей (User Retention) // CPA Network RussiaУдержание пользователей (User Retention) // CPA Network Russia
Удержание пользователей (User Retention) // CPA Network Russia
 
Sacomreal hùng vương
Sacomreal hùng vươngSacomreal hùng vương
Sacomreal hùng vương
 
dMT SPC Presentation Products-engl.
dMT SPC Presentation Products-engl.dMT SPC Presentation Products-engl.
dMT SPC Presentation Products-engl.
 
Commemoration of the Great War 1914-1918 by David Langford
Commemoration of the Great War 1914-1918 by David LangfordCommemoration of the Great War 1914-1918 by David Langford
Commemoration of the Great War 1914-1918 by David Langford
 
Blackfreedom , terrific presentation
Blackfreedom , terrific presentationBlackfreedom , terrific presentation
Blackfreedom , terrific presentation
 

Similar to Lect09

Extlect03
Extlect03Extlect03
Extlect03
Vin Voro
 
Btrfs by Chris Mason
Btrfs by Chris MasonBtrfs by Chris Mason
Btrfs by Chris Mason
Terry Wang
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
Cahaya Penyayang
 
The evolution of linux file system
The evolution of linux file systemThe evolution of linux file system
The evolution of linux file system
Gang He
 
Ext filesystem4
Ext filesystem4Ext filesystem4
Ext filesystem4
Neha Kulkarni
 
Os
OsOs
Ch11 file system implementation
Ch11   file system implementationCh11   file system implementation
Ch11 file system implementation
Welly Dian Astika
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
primeteacher32
 
storage techniques_overview-1.pptx
storage techniques_overview-1.pptxstorage techniques_overview-1.pptx
storage techniques_overview-1.pptx
20CS102RAMMPRASHATHK
 
Learn about log structured file system
Learn about log structured file systemLearn about log structured file system
Learn about log structured file system
Gang He
 
De-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory AnalysisDe-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory Analysis
Andrew Case
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
primeteacher32
 
Secondarystoragedevices1 130119040144-phpapp02
Secondarystoragedevices1 130119040144-phpapp02Secondarystoragedevices1 130119040144-phpapp02
Secondarystoragedevices1 130119040144-phpapp02
Seshu Chakravarthy
 
Computer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer ArchitectureComputer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer Architecture
Haris456
 
chapter5-file system implementation.ppt
chapter5-file system implementation.pptchapter5-file system implementation.ppt
chapter5-file system implementation.ppt
BUSHRASHAIKH804312
 
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
 
Unit 4 DBMS.ppt
Unit 4 DBMS.pptUnit 4 DBMS.ppt
Unit 4 DBMS.ppt
HARRSHITHAASCSE
 
19IS305_U4_LP10_LM10-22-23.pdf
19IS305_U4_LP10_LM10-22-23.pdf19IS305_U4_LP10_LM10-22-23.pdf
19IS305_U4_LP10_LM10-22-23.pdf
JESUNPK
 
Secondary storage devices
Secondary storage devices Secondary storage devices
Secondary storage devices
Slideshare
 
Windows file system
Windows file systemWindows file system
Windows file system
sumitjain2013
 

Similar to Lect09 (20)

Extlect03
Extlect03Extlect03
Extlect03
 
Btrfs by Chris Mason
Btrfs by Chris MasonBtrfs by Chris Mason
Btrfs by Chris Mason
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
The evolution of linux file system
The evolution of linux file systemThe evolution of linux file system
The evolution of linux file system
 
Ext filesystem4
Ext filesystem4Ext filesystem4
Ext filesystem4
 
Os
OsOs
Os
 
Ch11 file system implementation
Ch11   file system implementationCh11   file system implementation
Ch11 file system implementation
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
storage techniques_overview-1.pptx
storage techniques_overview-1.pptxstorage techniques_overview-1.pptx
storage techniques_overview-1.pptx
 
Learn about log structured file system
Learn about log structured file systemLearn about log structured file system
Learn about log structured file system
 
De-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory AnalysisDe-Anonymizing Live CDs through Physical Memory Analysis
De-Anonymizing Live CDs through Physical Memory Analysis
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Secondarystoragedevices1 130119040144-phpapp02
Secondarystoragedevices1 130119040144-phpapp02Secondarystoragedevices1 130119040144-phpapp02
Secondarystoragedevices1 130119040144-phpapp02
 
Computer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer ArchitectureComputer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer Architecture
 
chapter5-file system implementation.ppt
chapter5-file system implementation.pptchapter5-file system implementation.ppt
chapter5-file system implementation.ppt
 
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 4 DBMS.ppt
Unit 4 DBMS.pptUnit 4 DBMS.ppt
Unit 4 DBMS.ppt
 
19IS305_U4_LP10_LM10-22-23.pdf
19IS305_U4_LP10_LM10-22-23.pdf19IS305_U4_LP10_LM10-22-23.pdf
19IS305_U4_LP10_LM10-22-23.pdf
 
Secondary storage devices
Secondary storage devices Secondary storage devices
Secondary storage devices
 
Windows file system
Windows file systemWindows file system
Windows file system
 

More from Vin Voro

Tele3113 tut6
Tele3113 tut6Tele3113 tut6
Tele3113 tut6
Vin Voro
 
Tele3113 tut5
Tele3113 tut5Tele3113 tut5
Tele3113 tut5
Vin Voro
 
Tele3113 tut4
Tele3113 tut4Tele3113 tut4
Tele3113 tut4
Vin Voro
 
Tele3113 tut1
Tele3113 tut1Tele3113 tut1
Tele3113 tut1
Vin Voro
 
Tele3113 tut3
Tele3113 tut3Tele3113 tut3
Tele3113 tut3
Vin Voro
 
Tele3113 tut2
Tele3113 tut2Tele3113 tut2
Tele3113 tut2
Vin Voro
 
Tele3113 wk11tue
Tele3113 wk11tueTele3113 wk11tue
Tele3113 wk11tue
Vin Voro
 
Tele3113 wk10wed
Tele3113 wk10wedTele3113 wk10wed
Tele3113 wk10wed
Vin Voro
 
Tele3113 wk10tue
Tele3113 wk10tueTele3113 wk10tue
Tele3113 wk10tue
Vin Voro
 
Tele3113 wk11wed
Tele3113 wk11wedTele3113 wk11wed
Tele3113 wk11wed
Vin Voro
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
Vin Voro
 
Tele3113 wk9tue
Tele3113 wk9tueTele3113 wk9tue
Tele3113 wk9tue
Vin Voro
 
Tele3113 wk8wed
Tele3113 wk8wedTele3113 wk8wed
Tele3113 wk8wed
Vin Voro
 
Tele3113 wk9wed
Tele3113 wk9wedTele3113 wk9wed
Tele3113 wk9wed
Vin Voro
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
Vin Voro
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
Vin Voro
 
Tele3113 wk7tue
Tele3113 wk7tueTele3113 wk7tue
Tele3113 wk7tue
Vin Voro
 
Tele3113 wk6wed
Tele3113 wk6wedTele3113 wk6wed
Tele3113 wk6wed
Vin Voro
 
Tele3113 wk6tue
Tele3113 wk6tueTele3113 wk6tue
Tele3113 wk6tue
Vin Voro
 
Tele3113 wk5tue
Tele3113 wk5tueTele3113 wk5tue
Tele3113 wk5tue
Vin Voro
 

More from Vin Voro (20)

Tele3113 tut6
Tele3113 tut6Tele3113 tut6
Tele3113 tut6
 
Tele3113 tut5
Tele3113 tut5Tele3113 tut5
Tele3113 tut5
 
Tele3113 tut4
Tele3113 tut4Tele3113 tut4
Tele3113 tut4
 
Tele3113 tut1
Tele3113 tut1Tele3113 tut1
Tele3113 tut1
 
Tele3113 tut3
Tele3113 tut3Tele3113 tut3
Tele3113 tut3
 
Tele3113 tut2
Tele3113 tut2Tele3113 tut2
Tele3113 tut2
 
Tele3113 wk11tue
Tele3113 wk11tueTele3113 wk11tue
Tele3113 wk11tue
 
Tele3113 wk10wed
Tele3113 wk10wedTele3113 wk10wed
Tele3113 wk10wed
 
Tele3113 wk10tue
Tele3113 wk10tueTele3113 wk10tue
Tele3113 wk10tue
 
Tele3113 wk11wed
Tele3113 wk11wedTele3113 wk11wed
Tele3113 wk11wed
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
 
Tele3113 wk9tue
Tele3113 wk9tueTele3113 wk9tue
Tele3113 wk9tue
 
Tele3113 wk8wed
Tele3113 wk8wedTele3113 wk8wed
Tele3113 wk8wed
 
Tele3113 wk9wed
Tele3113 wk9wedTele3113 wk9wed
Tele3113 wk9wed
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
 
Tele3113 wk7wed
Tele3113 wk7wedTele3113 wk7wed
Tele3113 wk7wed
 
Tele3113 wk7tue
Tele3113 wk7tueTele3113 wk7tue
Tele3113 wk7tue
 
Tele3113 wk6wed
Tele3113 wk6wedTele3113 wk6wed
Tele3113 wk6wed
 
Tele3113 wk6tue
Tele3113 wk6tueTele3113 wk6tue
Tele3113 wk6tue
 
Tele3113 wk5tue
Tele3113 wk5tueTele3113 wk5tue
Tele3113 wk5tue
 

Recently uploaded

BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
nitinpv4ai
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
blueshagoo1
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
nitinpv4ai
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
Mohammad Al-Dhahabi
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 

Recently uploaded (20)

BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10Haunted Houses by H W Longfellow for class 10
Haunted Houses by H W Longfellow for class 10
 
CIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdfCIS 4200-02 Group 1 Final Project Report (1).pdf
CIS 4200-02 Group 1 Final Project Report (1).pdf
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)Oliver Asks for More by Charles Dickens (9)
Oliver Asks for More by Charles Dickens (9)
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)skeleton System.pdf (skeleton system wow)
skeleton System.pdf (skeleton system wow)
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 

Lect09

  • 1. File system internals Tanenbaum, Chapter 4 COMP3231 Operating Systems
  • 2. Architecture of the OS storage stack Application File system: FD table OF table • Hides physical location of data on the disk VFS FS • Exposes: directory Buffer cache hierarchy, symbolic file Disk scheduler names, random-access files, protection Device driver 2
  • 3. Some popular file systems • FAT16 • HFS+ • FAT32 • UFS2 • NTFS • ZFS • Ext2 • JFS • Ext3 • OCFS • Ext4 • Btrfs • ReiserFS • JFFS2 • XFS • ExFAT • ISO9660 • UBIFS Question: why are there so many? 3
  • 4. Why are there so many? • Different physical nature of storage devices – Ext3 is optimised for magnetic disks – JFFS2 is optimised for flash memory devices – ISO9660 is optimised for CDROM • Different storage capacities – FAT16 does not support drives >2GB – FAT32 becomes inefficient on drives >32GB – Btrfs is designed to scale to multi-TB disk arrays • Different CPU and memory requirements – FAT16 is not suitable for modern PCs but is a good fit for many embedded devices • Proprietary standards – NTFS may be a nice FS, but its specification is closed 4
  • 5. Assumptions • In this lecture we focus on file systems for magnetic disks – Rotational delay • 8ms worst case for 7200rpm drive – Seek time • ~15ms worst case – For comparison, disk-to-buffer transfer speed of a modern drive is ~10µs per 4K block. • Conclusion: keep blocks that are likely to be accessed together close to each other 5
  • 6. Implementing a file system • The FS must map symbolic file names into block addresses • The FS must keep track of – which blocks belong to which files. – in what order the blocks form the file – which blocks are free for allocation • Given a logical region of a file, the FS must track the corresponding File system block(s) on disk. 4 7 – Stored in file system metadata 8 2 5 1 6 3 6
  • 7. Allocation strategies • Contiguous allocation ✔ Easy bookkeeping (need to keep track of the starting block and length of the file) ✔ Increases performance for sequential operations ✗ Need the maximum size for the file at the time of creation ✗ As files are deleted, free space becomes divided into many small chunks (external fragmentation) Example: ISO 9660 (CDROM FS) 1 2 3 4 5 6 7 8 metadata 7
  • 8. Allocation strategies • Dynamic allocation – Disk space allocated in portions as needed – Allocation occurs in fixed-size blocks ✔ No external fragmentation ✔ Does not require pre-allocating disk space ✗ Partially filled blocks (internal fragmentation) ✗ File blocks are scattered across the disk ✗ Complex metadata management (maintain the list of blocks for each file) 1 2 3 4 5 6 7 8 8
  • 9. External and internal fragmentation • External fragmentation – The space wasted external to the allocated memory regions – Memory space exists to satisfy a request but it is unusable as it is not contiguous • Internal fragmentation – The space wasted internal to the allocated memory regions – Allocated memory may be slightly larger than requested memory; this size difference is wasted memory internal to a partition 9
  • 10. Linked list allocation • Each block contains a pointer to the next block in the chain. Free blocks are also linked in a chain. ✔ Only single metadata entry per file ✔ Best for sequential files 1 4 2 3 Question: What are the downsides? 10
  • 11. Linked list allocation • Each block contains a pointer to the next block in the chain. Free blocks are also linked in a chain. ✔ Only single metadata entry per file ✔ Best for sequential files 1 4 2 3 ✗ Poor for random access ✗ Blocks end up scattered across the disk due to free list eventually being randomised 11
  • 12. File allocation table • Keep a map of the entire FS in a separate table – A table entry contains the number of the next block of the file – The last block in a file and empty blocks are marked using reserved values • The table is stored on the disk and is replicated in memory • Random access is fast (following the in-memory list) 1 4 2 3 Question: any issues with this design? 12
  • 13. File allocation table • Issues – Requires a lot of memory for large disks • 200GB = 200*10^6 * 1K-blocks ==> 200*10^6 FAT entries = 800MB – Free block lookup is slow 1 4 2 3 13
  • 14. File allocation table • Examples – FAT12, FAT16, FAT32 reserved FAT1 FAT2 data blocks 14
  • 15. inode-based FS structure • Idea: separate table (index-node or i-node) for each file. – Only keep table for open files in memory – Fast random access • The most popular FS structure today 1 4 2 3 15
  • 16. i-node implementation issues • i-nodes occupy one or several disk areas i-nodes data blocks • i-nodes are allocated dynamically, hence free-space management is required for i-nodes – Use fixed-size i-nodes to simplify dynamic allocation – Reserve the last i-node entry for a pointer to an extension i-node 16
  • 18. i-node implementation issues • Free-space management – Approach 1: linked list of free blocks – Approach 2: keep bitmaps of free blocks and free i-nodes 18
  • 19. Free block list • List of all unallocated blocks • Background jobs can re-order list for better contiguity • Store in free blocks themselves – Does not reduce disk capacity • Only one block of pointers need be kept in the main memory 19
  • 20. Free block list (a) Almost-full block of pointers to free disk blocks in RAM ● three blocks of pointers on disk (b) Result of freeing a 3-block file (c) Alternative strategy for handling 3 free blocks ● shaded entries are pointers to free disk blocks 20
  • 21. Bit tables • Individual bits in a bit vector flags used/free blocks • 16GB disk with 512-byte blocks --> 4MB table • May be too large to hold in main memory • Expensive to search – But may use a two level table • Concentrating (de)allocations in a portion of the bitmap has desirable effect of concentrating access • Simple to find contiguous free space 21
  • 22. Implementing directories • Directories are stored like normal files – directory entries are contained inside data blocks • The FS assigns special meaning to the content of these files – a directory file is a list of directory entries – a directory entry contains file name, attributes, and the file i-node number • maps human-oriented file name to a system-oriented name 22
  • 23. Fixed-size vs variable-size directory entries • Fixed-size directory entries – Either too small • Example: DOS 8+3 characters – Or waste too much space • Example: 255 characters per file name • Variable-size directory entries – Freeing variable length entries can create external fragmentation in directory blocks • Can compact when block is in RAM 23
  • 24. Directory listing • Locating a file in a directory – Linear scan • Use a directory cache to speed-up search – Hash lookup – B-tree (100's of thousands entries) 24
  • 25. Storing file attributes (a) disk addresses and attributes in directory entry – FAT (b) directory in which each entry just refers to an i-node – UNIX 25
  • 26. Trade-off in FS block size • File systems deal with 2 types of blocks – Disk blocks or sectors (usually 512 bytes) – File system blocks 512 * 2^N bytes – What is the optimal N? • Larger blocks require less FS metadata • Smaller blocks waste less disk space • Sequential Access – The larger the block size, the fewer I/O operations required • Random Access – The larger the block size, the more unrelated data loaded. – Spatial locality of access improves the situation • Choosing an appropriate block size is a compromise 26