EECE.4810/EECE.5730 Operating Systems

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

File Management.
File Systems.
Allocation Methods - Contiguous
Chapter 10: File-System Interface
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Chapter 11: File System Implementation
File System Implementation
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
Chapter 12: File System Implementation
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
File System Design David E. Culler CS162 – Operating Systems and Systems Programming Lecture 24 October 24, 2014 Reading: A&D 13.3 HW 4 due 10/27 Proj.
File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.
File Systems. Main Points File layout Directory layout.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Chapter 11: File System Implementation Hung Q. Ngo KyungHee University Spring 2009
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials– 8 th Edition Chapter 10: File System Implementation.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 File-System Structure.
CSC 322 Operating Systems Concepts Lecture - 20: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
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.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 11: File-System Interface File Concept Access Methods Directory Structure.
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.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
CE Operating Systems Lecture 17 File systems – interface and implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
W4118 Operating Systems Instructor: Junfeng Yang.
Silberschatz, Galvin and Gagne ©2013 Operating System Concepts – 9 th Edition Chapter 12: File System Implementation.
Lecture : chapter 9 and 10 file system 1. File Concept A file is a collection of related information defined by its creator. Contiguous logical address.
File-System Management
File System Implementation
Chapter 11 & 12: File System Interface and Implementation
File System Interface CSSE 332 Operating Systems
Unit V File-System.
File-System Implementation
Chapter 11: File System Implementation
Chapter 11: Implementing File Systems
Chapter 11: File System Implementation
Filesystems.
EECE.4810/EECE.5730 Operating Systems
Subject Name: Operating Systems Subject Code:10CS53
Chapter 11: File System Implementation
File Systems Implementation
File Systems: Fundamentals.
Chapter 11: File System Implementation
EECE.4810/EECE.5730 Operating Systems
Directory Structure A collection of nodes containing information about all files Directory Files F 1 F 2 F 3 F 4 F n Both the directory structure and the.
Introduction to Operating Systems
File System Implementation
Chapter 10: File-System Interface
File-System Structure
Chapter 14: File System Implementation
Chapter 14: File-System Implementation
Chapter 11: File System Implementation
SE350: Operating Systems Lecture 12: File Systems.
Lecture 4: File-System Interface
EECE.4810/EECE.5730 Operating Systems
EECE.4810/EECE.5730 Operating Systems
Presentation transcript:

EECE.4810/EECE.5730 Operating Systems Instructor: Dr. Michael Geiger Spring 2018 Lecture 21: File systems (continued)

Operating Systems: Lecture 21 Lecture outline Announcements/reminders Program 3 now due 4/30 Point value now 150 points, not 100 Extra credit problem set to be posted; due Thursday 5/3 Today’s lecture Review: File details File operations Open files Directories More on file systems File system examples Space allocation Free space management 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 Review: File details File: unit of logical storage Abstract away low-level details of storage device Contiguous logical address space Structure of file defines types At a minimum, OS supports executable file Other types usually imposed by applications Text, source, etc. Extensions  more detailed file typing File system tracks file attributes (name, ID, type, file pointer, etc.) 11/13/2018 Operating Systems: Lecture 21

Review: File Operations Operations provide programmer interface to file system What operations should file system provide? Create Write – at write pointer location Read – at read pointer location Reposition within file - seek Delete Truncate – remove some data from file without deleting entire file Open(Fi) – search the directory structure on disk for entry Fi, and move the content of entry to memory Close (Fi) – move the content of entry Fi in memory to directory structure on disk 11/13/2018 Operating Systems: Lecture 21

Review: Working with open files Open-file table: tracks open files Per-process info File pointer: pointer to last read/write location Access rights: operations allowed by this process Centralized info File-open count: number of processes accessing file Table entry can be removed when count == 0 Disk location of the file: cache of data access information Accesses supported as sequential or direct (relative to start of file) 11/13/2018 Operating Systems: Lecture 21

Review: Directory structure Disk can be split into multiple partitions Partitions can be raw (no file system) or formatted Volume: formatted partition (e.g., C:\ on Windows) Each volume needs its own directory Effectively table of contents for volume Tracks information about all files on volume Imposes hierarchical structure in flat space 11/13/2018 Operating Systems: Lecture 21

Review: Tree-Structured Directories Absolute or relative path name Absolute name is full path Relative name—relative to current subdirectory or some other subdirectory Creating a new file is done in current directory Delete a file rm <file-name> Creating a new subdirectory is done in current directory mkdir <dir-name> Example: if in current directory /mail mkdir count Deleting “mail”  deleting the entire subtree rooted by “mail” 11/13/2018 Operating Systems: Lecture 21

Named Data in a File System 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 Directories Are Files 11/13/2018 Operating Systems: Lecture 21

Recursive Filename Lookup 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 Directory Layout Directory stored as a file Linear search to find filename (small directories) 11/13/2018 Operating Systems: Lecture 21

Large Directories: B Trees

Large Directories: Layout 11/13/2018 Operating Systems: Lecture 21

File system issues to be discussed How does the file system allocate space for a new file? How do different allocation schemes affect the way files are accessed? How does the file system store information about each file (metadata)? Includes time of last modification, access, etc. What are the different types of file systems and how do they differ? 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 Design Challenges Index structure How do we locate the blocks of a file? Index granularity What block size do we use? Free space How do we find unused blocks on disk? Locality How do we preserve spatial locality? Reliability What if machine crashes in middle of a file system op? 11/13/2018 Operating Systems: Lecture 21

Some File System Design Options FAT FFS NTFS Index structure Linked list Tree (fixed, asym) (dynamic) granularity block extent free space allocation FAT array Bitmap (fixed location) (file) Locality defrag Block groups + reserve space Extents Best fit 11/13/2018 Operating Systems: Lecture 21

Named Data in a File System 11/13/2018 Operating Systems: Lecture 21

Microsoft File Allocation Table (FAT) Linked list index structure Simple, easy to implement Still widely used (e.g., thumb drives) File table: Linear map of all blocks on disk Each file a linked list of blocks 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FAT 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FAT Pros: Easy to find free block Easy to append to a file Easy to delete a file Cons: Small file access is slow Random access is very slow Fragmentation File blocks for a given file may be scattered Files in the same directory may be scattered Problem becomes worse as disk fills 11/13/2018 Operating Systems: Lecture 21

Berkeley UNIX FFS (Fast File System) inode table Analogous to FAT table inode Metadata File owner, access permissions, access times, … Set of 12 data pointers With 4KB blocks => max size of 48KB files 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FFS inode Metadata File owner, access permissions, access times, … Set of 12 data pointers With 4KB blocks => max size of 48KB files Indirect block pointer pointer to disk block of data pointers Indirect block: 1K data blocks => 4MB (+48KB) 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FFS inode Metadata File owner, access permissions, access times, … Set of 12 data pointers With 4KB blocks => max size of 48KB Indirect block pointer pointer to disk block of data pointers 4KB block size => 1K data blocks => 4MB Doubly indirect block pointer Doubly indirect block => 1K indirect blocks 4GB (+ 4MB + 48KB) 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FFS inode Metadata File owner, access permissions, access times, … Set of 12 data pointers With 4KB blocks => max size of 48KB Indirect block pointer pointer to disk block of data pointers 4KB block size => 1K data blocks => 4MB Doubly indirect block pointer Doubly indirect block => 1K indirect blocks 4GB (+ 4MB + 48KB) Triply indirect block pointer Triply indirect block => 1K doubly indirect blocks 4TB (+ 4GB + 4MB + 48KB) 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FFS Asymmetric Tree Small files: shallow tree Efficient storage for small files Large files: deep tree Efficient lookup for random access in large files Sparse files: only fill pointers if needed 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FFS Locality Block group allocation Block group is a set of nearby cylinders Files in same directory located in same group Subdirectories located in different block groups inode table spread throughout disk inodes, bitmap near file blocks First fit allocation Small files fragmented, large files contiguous 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 11/13/2018 Operating Systems: Lecture 21

FFS First Fit Block Allocation 11/13/2018 Operating Systems: Lecture 21

FFS First Fit Block Allocation 11/13/2018 Operating Systems: Lecture 21

FFS First Fit Block Allocation 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 FFS Pros Efficient storage for both small and large files Locality for both small and large files Locality for metadata and data Cons Inefficient for tiny files (a 1 byte file requires both an inode and a data block) Inefficient encoding when file is mostly contiguous on disk (no equivalent to superpages) Need to reserve 10-20% of free space to prevent fragmentation 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 NTFS Master File Table Flexible 1KB storage for metadata and data Extents Block pointers cover runs of blocks Similar approach in linux (ext4) File create can provide hint as to size of file Journalling for reliability Will cover later this week/early next week 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 NTFS Small File 11/13/2018 Operating Systems: Lecture 21

NTFS Medium-Sized File 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 NTFS Indirect Block 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 11/13/2018 Operating Systems: Lecture 21

Free-Space Management File system maintains free-space list to track available blocks/clusters (Using term “block” for simplicity) Bit vector or bit map (n blocks) … 1 2 n-1 bit[i] =  1  block[i] free 0  block[i] occupied Block number calculation (number of bits per word) * (number of 0-value words) + offset of first 1 bit CPUs have instructions to return offset within word of first “1” bit 11/13/2018 Operating Systems: Lecture 21

Free-Space Management (Cont.) Bit map requires extra space Example: block size = 4KB = 212 bytes disk size = 240 bytes (1 terabyte) n = 240/212 = 228 bits (or 32MB) if clusters of 4 blocks -> 8MB of memory Easy to get contiguous files 11/13/2018 Operating Systems: Lecture 21

Linked Free Space List on Disk Linked list (free list) Cannot get contiguous space easily No waste of space No need to traverse the entire list (if # free blocks recorded) 11/13/2018 Operating Systems: Lecture 21

Free-Space Management (Cont.) Grouping Modify linked list to store address of next n-1 free blocks in first free block, plus a pointer to next block that contains free-block-pointers (like this one) Counting Because space is frequently contiguously used and freed, with contiguous-allocation allocation, extents, or clustering Keep address of first free block and count of following free blocks Free space list then has entries containing addresses and counts 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 Final notes Next time Finish file system discussion Reminders: Program 3 now due 4/30 Point value now 150 points, not 100 Extra credit problem set to be posted; due Thursday 5/3 11/13/2018 Operating Systems: Lecture 21

Operating Systems: Lecture 21 Acknowledgements These slides are adapted from the following sources: Silberschatz, Galvin, & Gagne, Operating Systems Concepts, 9th edition Anderson & Dahlin, Operating Systems: Principles and Practice, 2nd edition Chen & Madhyastha, EECS 482 lecture notes, University of Michigan, Fall 2016 11/13/2018 Operating Systems: Lecture 21