SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
Mass storage device
Mass storage deviceMass storage device
Mass storage device
Raza Umer
 
B tree file system
B tree file systemB tree file system
B tree file system
Dinesh Gupta
 
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
 

Was ist angesagt? (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
 

Andere mochten auch

EYE Reporter Issue 1 2011
EYE Reporter Issue 1 2011EYE Reporter Issue 1 2011
EYE Reporter Issue 1 2011
Steve @ insider
 
цахим судалгаа
цахим судалгаа цахим судалгаа
цахим судалгаа
solongobaga
 
Saigon luxury apartment ms.duyên
Saigon luxury apartment   ms.duyênSaigon luxury apartment   ms.duyên
Saigon luxury apartment ms.duyên
tranduyen76
 
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
РИФ+КИБ 2013 // Как создать персонализированный маркетинг? // OZON.ru (Кира Ж...
Kira Zhestkova
 
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
 
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 maquetat
Josep Miquel
 
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
 

Andere mochten auch (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
 

Ähnlich wie Lect09

Btrfs by Chris Mason
Btrfs by Chris MasonBtrfs by Chris Mason
Btrfs by Chris Mason
Terry Wang
 
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
 
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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Kürzlich hochgeladen (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

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