Page 111/15/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation  Overview  Allocation methods: Contiguous, Linked, Indexed,

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

Chapter 11: File System Implementation
File System Implementation
File System Implementation
Chapter 11: File System Implementation. File-System Structure File-System Implementation Directory Implementation Allocation Methods Free-Space Management.
Chapter 12: File System Implementation
1 Operating Systems Chapter 7-File-System File Concept Access Methods Directory Structure Protection File-System Structure Allocation Methods Free-Space.
Chapter 11: File System Implementation. 2 File System Implementation File System Implementation File-System Structure File-System Implementation Directory.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
Chapter 12: File System Implementation
04/05/2004CSCI 315 Operating Systems Design1 File System Implementation.
File System Implementation
04/07/2010CSCI 315 Operating Systems Design1 File System Implementation.
File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.
Contiguous Allocation of Disk Space. Linked Allocation.
Dr. Kalpakis CMSC 421, Operating Systems File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 11: File System Implementation Chapter 11: File System.
Operating Systems CMPSC 473 I/O Management (4) December 09, Lecture 25 Instructor: Bhuvan Urgaonkar.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 File-System Structure.
Dr. T. Doom 11.1 CEG 433/633 - Operating Systems I Chapter 11: File-System Implementation File structure –Logical storage unit –Collection of related information.
Free Space Management.
Silberschatz and Galvin  Operating System Concepts File-System Implementation File-System Structure Allocation Methods Free-Space Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
XE33OSA Chapter 11: File System Implementation. 11.2XE33OSA Silberschatz, Galvin and Gagne ©2005 Chapter 11: File System Implementation Chapter 11: File.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
12.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 12: File System Implementation Chapter 12: File System Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 11: File-System Interface File Concept Access Methods Directory Structure.
Ridge Xu 12.1 Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation Directory Implementation.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 11-2: File System Implementation Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Chapter 11: Implementing File Systems Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 11: Implementing File Systems Chapter.
12.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 12: File System Implementation Chapter 12: File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 11: File System Implementation Chapter.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 11: File System Implementation Chapter.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
10.1 CSE Department MAITSandeep Tayal 10 :File-System Implementation File-System Structure Allocation Methods Free-Space Management Directory Implementation.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 11 File-System Implementation Slide 1 Chapter 11: File-System Implementation.
Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation  Overview  File system structure – layered, block based.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 File-System Structure.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 11: File System Implementation Chapter.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 11-1: File Systems Implementation Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 12: File System Implementation.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 Chapter 11: File.
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
Allocation Methods An allocation method refers to how disk blocks are allocated for files: Contiguous allocation Linked allocation Indexed allocation.
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 12: File System Implementation.
Chapter 12: File System Implementation
File-System Implementation
Chapter 11: File System Implementation
Chapter 11: File System Implementation
Chapter 11: File System Implementation
Chapter 11: File System Implementation
Overview Continuation from Monday (File system implementation)
Outline Allocation Free space management Memory mapped files
Chapter 11: File System Implementation
Overview: File system implementation (cont)
File-System Structure
Chapter 14: File-System Implementation
Chapter 11: File System Implementation
File System Implementation
Presentation transcript:

page 111/15/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation  Overview  Allocation methods: Contiguous, Linked, Indexed, FAT  Free-space management: Bit vector, Linked list  Efficiency and performance  Memory mapped files

page 211/15/2015 CSE 30341: Operating Systems Principles Contiguous Allocation  Each file occupies a set of contiguous blocks on the disk  Simple – only starting location (block #) and length (number of blocks) are required  Random access  Wasteful of space (dynamic storage- allocation problem)  Files cannot grow

page 311/15/2015 CSE 30341: Operating Systems Principles Contiguous Allocation of Disk Space

page 411/15/2015 CSE 30341: Operating Systems Principles Extent-Based Systems  Many newer file systems (I.e. Veritas File System) use a modified contiguous allocation scheme  Extent-based file systems allocate disk blocks in extents  An extent is a contiguous block of disks  Extents are allocated for file allocation  A file consists of one or more extents.

page 511/15/2015 CSE 30341: Operating Systems Principles Linked Allocation  Each file is a linked list of disk blocks: blocks may be scattered anywhere on the disk.  Simple – need only starting address  Free-space management system – no waste of space  No random access pointer block =

page 611/15/2015 CSE 30341: Operating Systems Principles Linked Allocation

page 711/15/2015 CSE 30341: Operating Systems Principles File-Allocation Table (DOS FAT)

page 811/15/2015 CSE 30341: Operating Systems Principles Indexed Allocation  Brings all pointers together into the index block.  Logical view. index table

page 911/15/2015 CSE 30341: Operating Systems Principles Example of Indexed Allocation

page 1011/15/2015 CSE 30341: Operating Systems Principles Indexed Allocation (Cont.)  Need index table  Random access  Dynamic access without external fragmentation, but have overhead of index block.  Mapping from logical to physical in a file of maximum size of 256K words and block size of 512 words. We need only 1 block for index table.

page 1111/15/2015 CSE 30341: Operating Systems Principles Indexed Allocation – Mapping (Cont.)  outer-index index table file

page 1211/15/2015 CSE 30341: Operating Systems Principles Combined Scheme: UNIX (4K bytes per block)

page 1311/15/2015 CSE 30341: Operating Systems Principles … 012n-1 bit[i] =  0  block[i] free 1  block[i] occupied Free-Space Management  Bit vector (n blocks)  Block number calculation = (number of bits per word) * (number of 0-value words) + offset of first 1 bit

page 1411/15/2015 CSE 30341: Operating Systems Principles Free-Space Management (Cont.)  Bit map requires extra space  Example: block size = 2 12 bytes disk size = 2 38 bytes (256 Gigabyte) n = 2 38 /2 12 = 2 26 bits (or 8 Mbytes)  Easy to get contiguous files  Linked list (free list)  Cannot get contiguous space easily  No waste of space  Grouping  Counting

page 1511/15/2015 CSE 30341: Operating Systems Principles Linked Free Space List on Disk

page 1611/15/2015 CSE 30341: Operating Systems Principles Free-Space Management (Cont.)  Need to protect against inconsistency:  Pointer to free list  Bit map  Must be kept on disk  Copy in memory and disk may differ  Cannot allow for block[i] to have a situation where bit[i] = 1 in memory and bit[i] = 0 on disk  Solution:  Set bit[i] = 1 in disk  Allocate block[i]  Set bit[i] = 1 in memory

page 1711/15/2015 CSE 30341: Operating Systems Principles Efficiency and Performance  Efficiency dependent on:  disk allocation and directory algorithms  types of data kept in file’s directory entry  Performance  disk cache – separate section of main memory for frequently used blocks  free-behind and read-ahead – techniques to optimize sequential access  Compare these to LRU  improve PC performance by dedicating section of memory as virtual disk, or RAM disk  It was observed that temporary files were accessed frequently - hence make tmpfs using RAM memory

page 1811/15/2015 CSE 30341: Operating Systems Principles Memory-Mapped Files  Memory-mapped file I/O allows file I/O to be treated as routine memory access by mapping a disk block to a page in memory  A file is initially read using demand paging. A page- sized portion of the file is read from the file system into a physical page. Subsequent reads/writes to/from the file are treated as ordinary memory accesses.  Simplifies file access by treating file I/O through memory rather than read() write() system calls  Also allows several processes to map the same file allowing the pages in memory to be shared

page 1911/15/2015 CSE 30341: Operating Systems Principles Memory Mapped Files

page 2011/15/2015 CSE 30341: Operating Systems Principles Sample code using mmap #include main(int argc, char *argv[], char *envp[]) { int fd; char *ptr, *path = (argc == 2) ? argv[1] : "file"; /* Open a file and write some contents. If file already exists, delete old contents */ fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0660); write(fd, "hello", strlen("hello")); write(fd, " world", strlen(" world")); close(fd);

page 2111/15/2015 CSE 30341: Operating Systems Principles (continued) fd = open(path, O_RDWR); // mmap(addr, len, prot, flags, fildes, off); ptr = mmap(0, 4, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); ptr+=2; memcpy(ptr, "lp ", 3); munmap(ptr, 4); close(fd); }  Transform “hello world” into “help world”

page 2211/15/2015 CSE 30341: Operating Systems Principles Page Cache  A page cache caches pages rather than disk blocks using virtual memory techniques  Memory-mapped I/O uses a page cache  Routine I/O through the file system uses the buffer (disk) cache  This leads to the following figure

page 2311/15/2015 CSE 30341: Operating Systems Principles I/O Without a Unified Buffer Cache

page 2411/15/2015 CSE 30341: Operating Systems Principles Unified Buffer Cache  A unified buffer cache uses the same page cache to cache both memory-mapped pages and ordinary file system I/O

page 2511/15/2015 CSE 30341: Operating Systems Principles I/O Using a Unified Buffer Cache

page 2611/15/2015 CSE 30341: Operating Systems Principles Recovery  Consistency checking – compares data in directory structure with data blocks on disk, and tries to fix inconsistencies  scandisk in DOS, fsck in unix  Use system programs to back up data from disk to another storage device (floppy disk, magnetic tape, other magnetic disk, optical)  Recover lost file or disk by restoring data from backup

page 2711/15/2015 CSE 30341: Operating Systems Principles Log Structured File Systems  Log structured (or journaling) file systems record each update to the file system as a transaction  All transactions are written to a log  A transaction is considered committed once it is written to the log  However, the file system may not yet be updated  The transactions in the log are asynchronously written to the file system  When the file system is modified, the transaction is removed from the log  If the file system crashes, all remaining transactions in the log must still be performed