CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Similar documents
CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Frequently asked questions from the previous class survey

Frequently asked questions from the previous class survey

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

CS370 Operating Systems

Frequently asked questions from the previous class survey

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Fall 2018] Dept. Of Computer Science, Colorado State University

Frequently asked questions from the previous class survey

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

File System Internals. Jo, Heeseung

Chapter 12: File System Implementation

Chapter 11: File System Implementation. Objectives

Chapter 11: Implementing File

Chapter 11: Implementing File Systems. Operating System Concepts 9 9h Edition

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

CS3600 SYSTEMS AND NETWORKS

e-pg Pathshala Subject: Computer Science Paper: Operating Systems Module 35: File Allocation Methods Module No: CS/OS/35 Quadrant 1 e-text

Frequently asked questions from the previous class survey

Computer Systems Laboratory Sungkyunkwan University

CSE 4/521 Introduction to Operating Systems. Lecture 23 File System Implementation II (Allocation Methods, Free-Space Management) Summer 2018

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CHAPTER 11: IMPLEMENTING FILE SYSTEMS (COMPACT) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Da-Wei Chang CSIE.NCKU. Professor Hao-Ren Ke, National Chiao Tung University Professor Hsung-Pin Chang, National Chung Hsing University

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Chapter 10: File System Implementation

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Outlook. File-System Interface Allocation-Methods Free Space Management

Chapter 14: File-System Implementation

Introduction to OS. File Management. MOS Ch. 4. Mahmoud El-Gayyar. Mahmoud El-Gayyar / Introduction to OS 1

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

V. File System. SGG9: chapter 11. Files, directories, sharing FS layers, partitions, allocations, free space. TDIU11: Operating Systems

Chapter 11: Implementing File Systems

UNIX File Systems. How UNIX Organizes and Accesses Files on Disk

Chapter 12: File System Implementation. Operating System Concepts 9 th Edition

CS370 Operating Systems

OPERATING SYSTEM. Chapter 12: File System Implementation

Chapter 11: Implementing File Systems. Operating System Concepts 8 th Edition,

Chapter 12: File System Implementation

File System Internals. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

File System Implementation

Chapter 11: Implementing File Systems

File System: Interface and Implmentation

File Systems. Kartik Gopalan. Chapter 4 From Tanenbaum s Modern Operating System

Operating Systems. Operating Systems Professor Sina Meraji U of T

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

Operating Systems. File Systems. Thomas Ropars.

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Frequently asked questions from the previous class survey

Week 12: File System Implementation

Dept. Of Computer Science, Colorado State University

Operating System Concepts Ch. 11: File System Implementation

CS 550 Operating Systems Spring File System

CS370: Operating Systems [Spring 2017] Dept. Of Computer Science, Colorado State University

Chapter 12: File System Implementation

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Frequently asked questions from the previous class survey

ICS Principles of Operating Systems

CS370 Operating Systems

File System CS170 Discussion Week 9. *Some slides taken from TextBook Author s Presentation

File Systems. CS 4410 Operating Systems. [R. Agarwal, L. Alvisi, A. Bracy, M. George, E. Sirer, R. Van Renesse]

Chapter 7: File-System

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

File Layout and Directories

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission 1

OPERATING SYSTEMS II DPL. ING. CIPRIAN PUNGILĂ, PHD.

CS 318 Principles of Operating Systems

Frequently asked questions from the previous class survey

CS307: Operating Systems

I/O and file systems. Dealing with device heterogeneity

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

File-System Structure. Allocation Methods. Free-Space Management. Directory Implementation. Efficiency and Performance. Recovery

Frequently asked questions from the previous class survey

File Systems. File system interface (logical view) File system implementation (physical view)

File Systems: Interface and Implementation

CS 318 Principles of Operating Systems

CSE 153 Design of Operating Systems

Page 1. Review: Storage Performance" SSD Firmware Challenges" SSD Issues" CS162 Operating Systems and Systems Programming Lecture 14

Chapter 12: File System Implementation

CS370: System Architecture & Software [Fall 2014] Dept. Of Computer Science, Colorado State University

Filesystem. Disclaimer: some slides are adopted from book authors slides with permission

The UNIX Time- Sharing System

CS 4284 Systems Capstone

Chapter 4 File Systems. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

FILE SYSTEM IMPLEMENTATION. Sunu Wibirama

Principles of Operating Systems

Frequently asked questions from the previous class survey

CS370: Operating Systems [Spring 2016] Dept. Of Computer Science, Colorado State University

Introduction. Secondary Storage. File concept. File attributes

File Systems. CS170 Fall 2018

CS 111. Operating Systems Peter Reiher

W4118 Operating Systems. Instructor: Junfeng Yang

CSE 4/521 Introduction to Operating Systems. Lecture 14 Main Memory III (Paging, Structure of Page Table) Summer 2018

Segmentation with Paging. Review. Segmentation with Page (MULTICS) Segmentation with Page (MULTICS) Segmentation with Page (MULTICS)

Chapter 11: Implementing File-Systems

Transcription:

Frequently asked questions from the previous class survey CS 370: SYSTEM ARCHITECTURE & SOFTWARE [FILE SYSTEMS] Interpretation of metdata from different file systems Error Correction on hard disks? Shrideep Pallickara Computer Science Colorado State University L8. L8. Best Poster Competition: Judging Criteria 3 rd Floor Lobby of the CS Building Topics covered in this lecture Visual Appeal Technical Content Interview 3 pts 4 pts 3 pts Note: These points are just for the poster competition. The poster just accounts for % towards your final course grade. Block Allocations Linked allocations Indexed allocations n inodes Free space management Memory mapped files Final Exam Instructor: SHRIDEEP PALLICKARA L8.3 Instructor: SHRIDEEP PALLICKARA L8.4 Linked Allocation: Each file is a linked list of disk blocks Pointer to next block File A Physical block 0 4 7 3 0 4 LINKED ALLOCATIONS Physical block L8.5 0 6 3 File B 3 4 L8.6 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.

Linked List Allocations: Advantages Every disk block can be used No space is lost in external fragmentation Sufficient for directory entry to merely store disk address of first block Rest can be found starting there Linked List Allocation: Disadvantages Used effectively only for sequential accesses Extremely slow random access Space in each block set aside for pointers Each file requires slightly more space Reliability What if a pointer is lost or damaged? L8.7 L8.8 Linked List Allocations: Reading and writing files is much less efficient Amount of data storage in block is no longer a power of two Pointer takes up some space Peculiar size is less efficient Programs read/write in blocks that is a power of two Linked list allocation: Take pointers from disk block and put in table L8.9 0 3 4 5 6 7 8 9 0 3 0 7 3 4 EOF 0 4 7 3 0 Table tracks EVERY disk block in the system 4 L8.0 Linked list allocation using an index Entire disk block is available for data Random access is much easier Chain must still be followed n But this chain could be cached in memory Linked list allocation using an index: Disadvantages Table must be cached in memory for efficient access A large disk will have a large number of data blocks Table consumes a large amount of physical memory MS-DOS and OS/ operating systems Use such a file allocation table (FAT) L8. L8. SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.

Indexed allocations Bring all pointers together into one location index block Each file has its own index block i th entry points to i th block of the file Directory contains address of the index block INDEXED ALLOCATIONS L8.3 L8.4 Indexed allocation supports direct access without external fragmentation Every disk block can be utilized No external fragmentation Space wasted by pointers is generally higher than linked listed allocations Example: File has two blocks n Linked listed allocations: pointers are utilized n Indexed allocations: Entire index block must be allocated inodes Instructor: SHRIDEEP PALLICKARA L8.5 L8.6 inode inode Fixed-length data structure One per file Contains information about File attributes n Size, owner, creation/modification time etc. Disk addresses n File blocks that comprise file The inode is used to encapsulate information about a large number of file blocks. For e.g. Block size = 8 KB, and file size = 8 GB There would be a million file-blocks n inode will store info about the pointers to these blocks inode allows us to access info for all these blocks n Storing pointers to these file blocks also takes up storage L8.7 L8.8 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.3

Managing information about data blocks in the inode Schematic structure of the inode First few data blocks of the file stored in inode If the file is large: Indirect pointer To a block of pointers that point to additional data blocks If the file is larger: Double indirect pointer Pointer to a block of indirect pointers If the file is huge: Triple indirect pointer Pointer to a block of double-indirect pointers Address of disk block File Attributes: Size (bytes) Owner UID/GID Relevant times Link and Block counts Permissions Direct pointers to first few file blocks Single indirect pointer Double indirect pointer Pointers to next file blocks Triple indirect pointer L8.9 L8.0 i-node: How the pointers to the file blocks are organized i-node Attributes Single indirect block Double indirect block Disk Layout in traditional UNIX systems Boot Block Super Block i-nodes Data Blocks... An integral number of inodes fit in a single data block Triple indirect block L8. Instructor: SHRIDEEP PALLICKARA L8. Super Block describes the state of the file system Total size of partition Block size and number of disk blocks Number of inodes List of free blocks inode number of the root directory A linear array of inodes follows the data block inodes are numbered from to some max Each inode is identified by its inode number inode number contains info needed to locate inode on the disk Users think of files as filenames UNIX thinks of files in terms of inodes Destruction of super block? Will render file system unreadable L8.3 L8.4 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.4

UNIX directory structure Contains only file names and the corresponding inode numbers Directory entry, inode and data block for a simple file i-node Number 345 File name name i-node Number File name Use ls i to retrieve inode numbers of the files in the directory inode 345 3567 Block 3567 Fragment of the text in the file L8.5 L8.6 Looking up path names in UNIX Example: /usr/tom/mbox Root directory. 4 bin 7 dev 4 lib 9 etc 6 usr 8 tmp Looking up usr yields i-node 6 i-node 6 is for /usr Mode, size attributes 3 i-node 6 says that /usr is in block 3 Block 3 is /usr directory 6. 9 dick 30 eve 5 jim 6 tom 45 zac /usr/tom is in i-node 6 i-node 6 is /usr/tom Mode, size attributes 406 i-node 6 says that /usr/tom is in block 406 Block 406 is /usr/tom dir 6. 6 64 grants 9 dev 60 mbox 8 docs 7 src /usr/tom/mbox is in i-node 60 Advantages of directory entries that have name and inode information Changing filename only requires changing the directory entry Only physical copy of file needs to be on disk File may have several names (or the same name) in different directories Directory entries are small Most file info is kept in the inode L8.7 L8.8 Two hard links to the same file Two hard links to the same file Directory entry in /dira i-node File name Directory entry in /dira i-node File name Directory entry in /dirb i-node File name 345 name 345 name 345 name Block 3567 3567 Fragment of the text in the file 3567 Block 3567 Fragment of the text in the file inode 345 inode 345 L8.9 L8.30 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.5

File with a symbolic link Directory entry Directory entry in /dira in /dirb i-node File name i-node File name 345 name 3579 name Maximum size of your hard disk (8 KB blocks and 3-bit pointers) 3-bit pointers can address 3 blocks At 8 KB per-block Hard disk can be 3 x 3 = 45 bytes (3 TB) 3567 inode 345 Block 3567 Fragment of the text in the file 53 /dira/name Block 53 inode 3579 L8.3 L8.3 The case for larger block sizes Larger partitions for a fixed pointer size Retrieval is more efficient Better system throughput Problem Internal fragmentation Limitations of a file system based on inodes File must fit in a single disk partition Partition size and number of files are fixed when system is set up L8.33 L8.34 inode preallocation and distribution inodes are preallocated on a volume Even on empty disks % of space lost to inodes Preallocating inodes and spreading them Improves performance Keep file s data block close to its inode Reduce seek times Checking up on the inodes: The df i command (disk free) inode statistics for a given set of file systems Total, free and used inodes L8.35 L8.36 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.6

FREE SPACE MANAGEMENT Free space management Disk space is limited Reuse space from deleted files Keep track of free disk space Maintain free-space list Record all free disk blocks Metadata I/O can impact performance L8.37 L8.38 Free space management using the free-space list Creating a new file Search free-space list for requisite space Allocate that to the file Deletion of a file Add file blocks of deleted file to the free-space list Using bit vectors to implement the freespace list Each file block is represented with a bit Block is free: bit is Block is allocated: bit is 0 A HDD with n blocks requires an n-bit vector Free 3 4 5 6 7 8 9 0 3 4 5 6 7 8 9 Bit Vector: 000000 L8.39 L8.40 Advantages of using the bit-vector Simplicity Efficiency in finding first free block Or n consecutive free blocks Most CPUs have bit manipulation operators Allows us to compute free blocks fairly fast Finding free blocks using the bit vector A 0 valued word represents allocated blocks First non-0 word is scanned for first -bit This is the location of the first free block Free Block number Bits Per-Word x Num 0-value words + Offset First -bit L8.4 L8.4 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.7

Problems with the bit vector approach For efficiency purposes, bit vector must be memoryresident Difficult for larger disks TB hard disk with 4 KB blocks n Bit Vector = 3 MB PB disk = 3 GB bit vector Linked list approach to free space management Link free-blocks Pointer to first free block Stored in a special location on disk Cached in memory Freeing GB of data on a TB disk Thousands of blocks of bit maps need to be updated n Blocks could be scattered all over disk L8.43 L8.44 Tracking free space using the linked list approach 0 3 4 5 6 7 8 9 0 3 4 5 Problems with this approach To traverse list we must read each block Substantial I/O Finding large number of free blocks is expensive 6 7 8 9 0 3 4 5 6 7 L8.45 L8.46 Grouping to augment the linked list approach Set aside one block for tracking portion of chain First n- entries are free blocks Last entry points to another set of free blocks If tracker-block has 5 entries After linked list block is loaded in memory n Next 50 blocks do not need I/O operations 5 th entry points to another tracker-block Free space management using Counting Several contiguous blocks are free or allocated simultaneously Keep address of first free block AND Number of contiguous blocks that follow it Free 3 4 5 6 7 8 9 0 {, 3} {8, 5} {7, }. 3 4 5 6 7 8 9 L8.47 L8.48 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.8

Space Maps used in ZFS (Zettabyte File System) ZB = 70 bytes Controls size of I/O data structures Minimize I/O needed to manage them Metaslabs divide space on disk into chunks A volume has 00s of metaslabs A metaslab has a space-map Counting algorithm to store info on space maps ZFS free space management Does not write I/O metadata directly to disk Free-space list updated on disk using transactional techniques When space is (de)allocated from metaslab Corresponding space map is loaded into memory n B-Tree structure indexed by block offsets L8.49 L8.50 Memory mapped files open(), read(), write() Requires system calls and disk access Allow part of the virtual address space to be logically associated with the file Memory mapping MEMORY MAPPED FILES L8.5 L8.5 Memory-mapping maps a disk block to a page (or pages) in memory Manipulate files through memory Multiple processes may map file concurrently n Enables data sharing Since JVM.4, Java supports memory-mapped files n FileChannel Writes to files in memory are not necessarily immediate Memory mapped files: Things to watch for Make sure that two processes do not see inconsistent views of the same file File may be larger than the entire virtual address space! Map portions of the file L8.53 L8.54 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.9

Improving reads from the disk PERFORMANCE Disk controllers have onboard cache that can store multiple tracks When a seek is performed Track is read into the disk cache Starting at the sector under disk head n Reduces latency time Controller then transfers sectors to the OS L8.55 L8.56 Buffering data read from disks since they may be used again I/O without a unified buffer cache: Double caching Maintain a separate section of memory for the buffer cache Memory-mapped I/O I/O using read() and write() Cache file data using a page cache Use virtual memory techniques Cache as pages rather than file blocks Access interfaces with virtual memory n Not the file system Page cache Buffer cache Double Caching: Wastes memory and CPU cycles File system L8.57 L8.58 Unified buffer cache I/O using a unified buffer cache Memory mapping and read()/write() system calls use the same page cache Memory-mapped I/O I/O using read() and write() Allows virtual memory to manage the file system data Buffer cache File system L8.59 L8.60 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.0

Need to make a distinction between pages allocated to processes and page cache, else Processes performing I/O will use most of the memory set aside for caching pages Pages may be reclaimed from processes Solution: Fixed limit for process pages and the filesystem page cache Prevent one from forcing out the other Solaris 8 Synchronous writes Writes are not buffered Occurs in the order that the disk receives them Calling routine waits for data to reach disk Blocking call Metadata writes tend to be synchronous Databases use this for atomic transactions L8.6 L8.6 Asynchronous writes Data stored in the cache Control returns to the caller immediately Done majority of the time Page cache, disk drivers and asynchronous disk writes When data is written to disk Pages are buffered in the cache Disk driver sorts its output queue based on disk addresses Minimize disk head seeks Write at times optimized for disk rotations L8.63 L8.64 Page cache and page replacement algorithms Replacement algo depends on file access type File being read/written sequentially Pages should not be replaced in LRU order n Most recently used page may never be used again Free-behind Remove page from buffer when next one requested Read-ahead Requested page and subsequent pages are cached FINAL EXAM Instructor: SHRIDEEP PALLICKARA L8.65 L8.66 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.

Final exam December 5 th : In our regular classroom (Clark A-03) from 6:0-8:0 pm There will be NO MAKEUP exam Comprehensive exam Covers ALL topics that we have discussed in the course Duration: hours Breakdown Processes and IPC 5 Threads: 0 CPU Scheduling: 0 Process Synchronization & Atomic Transactions 5 Deadlocks 0 Memory Management 0 Virtual Memory 0 Virtualization 0 File Systems 5 Mass Storage & Disk Scheduling 5 L8.67 L8.68 The contents of this slide-set are based on the following references Avi Silberschatz, Peter Galvin, Greg Gagne. Operating Systems Concepts, 9 th edition. John Wiley & Sons, Inc. ISBN-3: 978-8063330. [Chapter ] Andrew S Tanenbaum. Modern Operating Systems. 4 th Edition, 04. Prentice Hall. ISBN: 033596X/ 978-0335960. [Chapter 4] Kay Robbins & Steve Robbins. Unix Systems Programming, nd edition, Prentice Hall ISBN-3: 978-0-3-044-. [Chapter 4] Instructor: SHRIDEEP PALLICKARA L8.69 SLIDES CREATED BY: SHRIDEEP PALLICKARA L8.