Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 11: File System Implementation Joe McCarthy CSS 430: Operating Systems - File System Implementation1.

Similar presentations


Presentation on theme: "Chapter 11: File System Implementation Joe McCarthy CSS 430: Operating Systems - File System Implementation1."— Presentation transcript:

1 Chapter 11: File System Implementation Joe McCarthy CSS 430: Operating Systems - File System Implementation1

2 File System Implementation File-System Structure File-System Implementation Directory Implementation Allocation Methods Free-Space Management Efficiency and Performance Recovery NFS Example: WAFL File System CSS 430: Operating Systems - File System Implementation2 Material derived, in part, from Operating Systems Concepts with Java, 8 th Ed. © 2009 Silberschatz, Galvin & Gagne

3 File-System Structure CSS 430: Operating Systems - File System Implementation3 File system interface provides applications with various system calls and commands such as open, write, read, seek, etc.. File system maintains disk space in blocks and allocates available blocks to each stream-oriented file. Basic file system (BIOS) maintains data in physical blocks Device driver reads / writes disk blocks which consists of one (or more) sector(s). Disk maintains physical block locations indexed by drive#, cylinder#, track# and sector# track sector cylinder

4 Layered File System 4CSS 430: Operating Systems - File System Implementation

5 File-System Implementation Boot control block contains info needed by system to boot OS from that volume Volume control block contains volume details – # blocks, block size, free block count/pointers Directory structure organizes the files Per-file File Control Block (FCB) contains many details about the file CSS 430: Operating Systems - File System Implementation5

6 In-Memory File System Structures CSS 430: Operating Systems - File System Implementation6

7 Allocation Methods An allocation method refers to how disk blocks are allocated for files: – Contiguous allocation – Linked allocation – Indexed allocation 7CSS 430: Operating Systems - File System Implementation

8 Contiguous Allocation CSS 430: Operating Systems - File System Implementation8 Each file occupies a set of contiguous blocks on the disk Advantage(s): Disadvantage(s):

9 Contiguous Allocation CSS 430: Operating Systems - File System Implementation9 Each file occupies a set of contiguous blocks on the disk Advantage(s): Simple: start, length Fast Supports direct access Disadvantage(s): External fragmentation What if file grows?

10 Extent-Based Systems Some file systems use a modified contiguous allocation scheme Extent-based file systems allocate disk blocks in extents – Contiguous sequence of blocks – Allows more space for files to grow CSS 430: Operating Systems - File System Implementation10

11 Linked Allocation Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. Advantage(s): Disadvantage(s): CSS 430: Operating Systems - File System Implementation11 pointer Block =

12 Linked Allocation Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk. Advantage(s): – Simple: start, end – No external fragmentation Disadvantage(s): – No direct access – Slow – Reliability CSS 430: Operating Systems - File System Implementation12 pointer Block =

13 File-Allocation Table FAT has an entry for each disk block. FAT entries rather than blocks themselves are linked. Example: – MS-DOS and OS/2 Advantage(s): Disadvantage(s): CSS 430: Operating Systems - File System Implementation13

14 File-Allocation Table FAT has an entry for each disk block. FAT entries rather than blocks themselves are linked. Example: – MS-DOS and OS/2 Advantage(s): – Save disk block space – Faster direct access Disadvantage(s): – A significant number of disk head seeks CSS 430: Operating Systems - File System Implementation14

15 Indexed Allocation CSS 430: Operating Systems - File System Implementation15 Index block Need index table Advantage(s): Disadvantage(s):

16 Indexed Allocation CSS 430: Operating Systems - File System Implementation16 Index block Need index table Advantage(s): – Direct access – No external fragmentation Disadvantage(s): – Internal fragmentation – Determining optimal index block size Too small: can’t fit a file Too large: wasted space

17 Indexed Allocation CSS 430: Operating Systems - File System Implementation17  outer-index index table file

18 Combined Scheme: UNIX UFS CSS 430: Operating Systems - File System Implementation18 4K bytes per block

19 Free Space Management CSS 430: Operating Systems - File System Implementation19 Bit vector (n blocks) … 012n-1 bit[i] =  0  block[i] free 1  block[i] occupied Linked free space list

20 Free Space Management CSS 430: Operating Systems - File System Implementation20 Bit vector (n blocks) … 012n-1 bit[i] =  0  block[i] free 1  block[i] occupied Linked free space list

21 css430 file-system implementation21 ThreadOS Superblock & Inodes Superblock int totalBlocks; int totalInodes; int freeList; Inode #032bytes Inode #1 Inode #15 Inode #inodeBlocks -1 Block #0 Block #1 Block #2 Block #(totalBlocks – 1) Free Block #x Free Block #y Free Block #z / root directory

22 css430 file-system implementation22 ThreadOS Root Directory (“/”) Directory() – Initialize “/” directory bytes2directory( byte data[]) – Initialize directory with byte[] which have been retrieved from disk directory2bytes() – Converts directory information into byte[] ialloc( String filename ) – Allocate an iNumber for filename ifree( short iNumber ) – Deallocate the iNumber namei( String filename ) – Return filename’s iNumber Entry[] fsizes fnames (iNumber) 0 1 2 3 4 5 6 7 8 9 10 inodeBlock-1 14444556696651444455669665 / init fsck clri motd mount mknod passwd umount checklist fsdblb config getty

23 css430 file-system implementation23 CSS430 ThreadOS File System int fd = SysLib.open(“fileA”, mode); SysLib.read(fd, …); stdin stdout stderr 0 1 2 3 31 User file Descriptor table TCB struct file: count 1 inode File Table Inode: length count 1 direct[11] indirect Inode Disk Thread A simplified structure of Unix file system


Download ppt "Chapter 11: File System Implementation Joe McCarthy CSS 430: Operating Systems - File System Implementation1."

Similar presentations


Ads by Google