CS510 Operating System Foundations. Jonathan Walpole

Similar documents
Chapter 11: File System Implementation. Objectives

CS510 Operating System Foundations. Jonathan Walpole

Operating Systems. Operating Systems Professor Sina Meraji U of T

CS3600 SYSTEMS AND NETWORKS

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

The Berkeley File System. The Original File System. Background. Why is the bandwidth low?

Operating Systems. File Systems. Thomas Ropars.

Physical Representation of Files

Chapter 10: Case Studies. So what happens in a real operating system?

What is a file system

Lecture 21: Reliable, High Performance Storage. CSC 469H1F Fall 2006 Angela Demke Brown

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

ICS Principles of Operating Systems

Question Points Score Total 100

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

UNIX File System. UNIX File System. The UNIX file system has a hierarchical tree structure with the top in root.

File System: Interface and Implmentation

Lecture 19: File System Implementation. Mythili Vutukuru IIT Bombay

Lecture S3: File system data layout, naming

CS 537 Fall 2017 Review Session

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

Long-term Information Storage Must store large amounts of data Information stored must survive the termination of the process using it Multiple proces

Implementation should be efficient. Provide an abstraction to the user. Abstraction should be useful. Ownership and permissions.

File Systems Ch 4. 1 CS 422 T W Bennet Mississippi College

File Systems Management and Examples

Review: FFS [McKusic] basics. Review: FFS background. Basic FFS data structures. FFS disk layout. FFS superblock. Cylinder groups

File Systems. ECE 650 Systems Programming & Engineering Duke University, Spring 2018

Chapter 6. File Systems

csci 3411: Operating Systems

Review: FFS background

Chapter 14: File-System Implementation

ECE 650 Systems Programming & Engineering. Spring 2018

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

Topics. File Buffer Cache for Performance. What to Cache? COS 318: Operating Systems. File Performance and Reliability

SCSI overview. SCSI domain consists of devices and an SDS

CS5460: Operating Systems Lecture 20: File System Reliability

NTFS Recoverability. CS 537 Lecture 17 NTFS internals. NTFS On-Disk Structure

CSE 120 Principles of Operating Systems

File Systems: FFS and LFS

OPERATING SYSTEM. Chapter 12: File System Implementation

File Systems. Information Server 1. Content. Motivation. Motivation. File Systems. File Systems. Files

File Systems: Consistency Issues

C13: Files and Directories: System s Perspective

CS 333 Introduction to Operating Systems. Class 11 Virtual Memory (1) Jonathan Walpole Computer Science Portland State University

CS720 - Operating Systems

Chapter 11: Implementing File Systems

Chapter 12: File System Implementation

Chapter 11: Implementing File-Systems

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

CS 318 Principles of Operating Systems

Chapter 10: File System Implementation

CS 318 Principles of Operating Systems

Local File Stores. Job of a File Store. Physical Disk Layout CIS657

Advanced File Systems. CS 140 Feb. 25, 2015 Ali Jose Mashtizadeh

Locality and The Fast File System. Dongkun Shin, SKKU

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

File System Implementations

OPERATING SYSTEMS CS136

Final Review. Geoffrey M. Voelker. Final mechanics Memory management Paging Page replacement Disk I/O File systems Advanced topics

File System Internals. Jo, Heeseung

we are here I/O & Storage Layers Recall: C Low level I/O Recall: C Low Level Operations CS162 Operating Systems and Systems Programming Lecture 18

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Chapter 11: Implementing File

Chapter 12 File-System Implementation

File System Implementation

ECE 598 Advanced Operating Systems Lecture 10

Modeling Page Replacement: Stack Algorithms. Design Issues for Paging Systems

Advanced file systems: LFS and Soft Updates. Ken Birman (based on slides by Ben Atkin)

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

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

PERSISTENCE: FSCK, JOURNALING. Shivaram Venkataraman CS 537, Spring 2019

Disks, Memories & Buffer Management

Computer Systems Laboratory Sungkyunkwan University

I/O and file systems. Dealing with device heterogeneity

CSE380 - Operating Systems

CS307: Operating Systems

we are here Page 1 Recall: How do we Hide I/O Latency? I/O & Storage Layers Recall: C Low level I/O

-Device. -Physical or virtual thing that does something -Software + hardware to operate a device (Controller runs port, Bus, device)

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

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

CSE 120: Principles of Operating Systems. Lecture 10. File Systems. November 6, Prof. Joe Pasquale

Chapter 11: Implementing File Systems

Chapter 12: File System Implementation

Virtual Memory Management

Final Exam Preparation Questions

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

CS 318 Principles of Operating Systems

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 18: Naming, Directories, and File Caching

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

CS 4284 Systems Capstone

CPSC 421 Database Management Systems. Lecture 11: Storage and File Organization

Crash Consistency: FSCK and Journaling. Dongkun Shin, SKKU

Week 12: File System Implementation

Week 2: Tiina Niklander

b. How many bits are there in the physical address?

CSE 120: Principles of Operating Systems. Lecture 10. File Systems. February 22, Prof. Joe Pasquale

Virtual Memory. Reading. Sections 5.4, 5.5, 5.6, 5.8, 5.10 (2) Lecture notes from MKP and S. Yalamanchili

Chapter 11: File System Implementation

ESE 333 Real-Time Operating Systems 163 Review Deadlocks (Cont.) ffl Methods for handling deadlocks 3. Deadlock prevention Negating one of four condit

File systems CS 241. May 2, University of Illinois

Transcription:

CS510 Operating System Foundations Jonathan Walpole

File System Performance

File System Performance Memory mapped files - Avoid system call overhead Buffer cache - Avoid disk I/O overhead Careful data placement on disk - Avoid seek overhead Log structured file systems - Avoid seek overhead for disk writes (reads hit in buffer cache)

Memory-Mapped Files Conventional file I/O - Use system calls (e.g., open, read, write,...) to move data from disk to memory Observation - Data gets moved between disk and memory all the time without system calls - Pages moved to/from PAGEFILE by VM system - Do we really need to incur system call overhead for file I/ O?

Memory-Mapped Files Why not map files into the virtual address space - Place the file in the virtual address space - Each byte in a file has a virtual address To read the value of a byte in the file: - Just load that byte s virtual address - Calculated from the starting virtual address of the file and the offset of the byte in the file - Kernel will fault in pages from disk when needed To write values to the file: - Just store bytes to the right memory locations Open & Close syscalls Map & Unmap syscalls

Memory-Mapped Files Stack File on Disk Text & Data

Memory-Mapped Files Stack Map syscall is made Text & Data File on Disk

Memory-Mapped Files Stack Map syscall is made Text & Data File on Disk

Memory-Mapped Files Stack Map syscall is made Text & Data File on Disk

Memory-Mapped Files Stack Map syscall is made File on Disk Text & Data Demand Paging: Only read pages when needed

File System Performance How does memory mapping a file affect performance?

Buffer Cache Observations: - Once a block has been read into memory it can be used to service subsequent read/write requests without going to disk - Multiple file operations from one process may hit the same file block - File operations of multiple processes may hit the same file block Idea: maintain a block cache (or buffer cache) in memory - When a process tries to read a block check the cache first

Buffer Cache Cache organization: - Many blocks (e.g., 1000s) - Indexed on block number key device block#

Buffer Cache Cache organization: - Many blocks (e.g., 1000s) - Indexed on block number For efficiency, - Use a hash table key device block#

Buffer Cache!

Buffer Cache Need to write a block? - Modify the version in the block cache But when should we write it back to disk?

Buffer Cache Need to write a block? - Modify the version in the block cache But when should we write it back to disk? - Immediately? - Later?

Buffer Cache Need to write a block? - Modify the version in the block cache But when should we write it back to disk? - Immediately Write-through cache - Later The Unix sync syscall

Buffer Cache Need to write a block? - Modify the version in the block cache But when should we write it back to disk? - Immediately Write-through cache - Later The Unix sync syscall What if the system crashes? Can the file system become inconsistent?

Buffer Cache What if system crashes? Can the file system become inconsistent? - Write directory and i-node info immediately - Okay to delay writes to files - Background process to write dirty blocks

File System Performance How does a buffer cache improve file system performance?

Careful Data Placement Break disk into regions - Cylinder Groups Put blocks that are close together in the same cylinder group - Try to allocate i-node and blocks in the file within the same cylinder group

Old vs New Unix File Systems

File System Performance How does disk space allocation based on cylinder groups affect file system performance?

Log-Structured File Systems Observation - Buffer caches are getting larger - For a read Increasing probability the block is in the cache - The buffer cache effectively filters out most reads Conclusion: - Most disk I/O is write operations! How well do our file systems perform for a write-dominated workload? Is the strategy for data placement on disk appropriate?

Log-Structured File Systems Problem: - The need to update disk blocks in place forces writes to seek to the location of the block Idea: - Why not just write a new version of the block and modify the inode to point to that one instead - This way we can write the block wherever the read/write head happens to be located, and avoid a seek! But - Wouldn t we have to seek to update the inode? - Maybe we could make a new version of that too?

Log-Structured File Systems What is a log? - A record of all actions

Log-Structured File Systems What is a log? - A record of all actions The entire disk becomes a log of disk writes

Log-Structured File Systems What is a log? - A record of all actions The entire disk becomes a log of disk writes All writes are buffered in memory Periodically all dirty blocks are written... to the end of the log - The i-node is modified to point to the new position of the updated blocks

Log-Structured File Systems The disk is a giant log of file system operations What happens when the disk fills up?

Log-Structured File Systems How do we reclaim space for old versions of blocks? Won t the disk s free space become fragmented? - If it did, we would have to seek to a free block every time we wanted to write anything! How do we ensure that the disk always has large expanses of contiguous free blocks - If it does we can write out the log to contiguous blocks with no seek or rotational delay overhead - Optimal disk throughput for writes

Log-Structured File Systems A cleaner process - Reads blocks in from the beginning of the log - Most of them will be free at this point - Adds non-free blocks to the buffer cache - These get written out to the log later Log data is written in units of an entire track The cleaner process reads an entire track at a time for efficiency

File System Performance How do log structured file systems improve file system performance?

Backing Up a File System Incremental dumps - Once a month, back up the entire file system - Once a day, make a copy of all files that have changed Why? - Its faster than backing up everything To restore entire file system... 1. Restore from complete dump 2. Process each incremental dump in order

Backing Up Physical Dump - Start a block 0 on the disk - Copy each block, in order

Backing Up Physical Dump - Start a block 0 on the disk - Copy each block, in order Blocks on the free list? - Should avoid copying them

Backing Up Physical Dump - Start a block 0 on the disk - Copy each block, in order Blocks on the free list? - Should avoid copying them Bad sectors on disk? - Controller remaps bad sectors: - Backup utility need not do anything special! - OS handles bad sectors: - Backup utility must avoid copying them!

Backing Up Logical Dump - Dump files and directories (Most common form) Incremental dumping of files and directories - Copy only files that have been modified since last incremental backup. - Copy the directories containing any modified files

Incremental Backup of Files Determine which files have been modified / A B C i D j E F k l m n G H o p q r

Incremental Backup of Files Determine which files have been modified / A B C i D j E F k l m n G H o p q r

Incremental Backup of Files Which directories must be copied? / A B C i D j E F k l m n G H o p q r

Incremental Backup of Files Which directories must be copied? / A B C i D j E F k l m n G H o p q r

Incremental Backup of Files Which directories must be copied? / A B C i D j E F k l m n G H o p q r

Incremental Backup of Files Copy only these / A B C i D j E F k l m n G H o p q r

Incremental Backup of Files Copy only these / A B C i D j E F k l m n G H o p q r

Recycle Bins Goal: - Help the user to avoid losing data Common Problem: - User deletes a file and then regrets it Solution: - Move all deleted files to a garbage directory - User must empty the garbage explicitly This is only a partial solution - May still need recourse to backup tapes

File System Consistency Invariant: Each disk block must be in a file (or directory), or on the free list

File System Consistency Inconsistent States:

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block )

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block ) - Some block is on free list and is in some file

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block ) - Some block is on free list and is in some file - Some block is on the free list more than once

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block ) - Some block is on free list and is in some file - Some block is on the free list more than once - Some block is in more than one file

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block ) Add it to the free list. - Some block is on free list and is in some file - Some block is on the free list more than once - Some block is in more than one file

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block ) Add it to the free list. - Some block is on free list and is in some file Remove it from the free list. - Some block is on the free list more than once - Some block is in more than one file

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block ) Add it to the free list. - Some block is on free list and is in some file Remove it from the free list. - Some block is on the free list more than once (Can t happen when using a bitmap for free blocks.) Fix the free list so the block appears only once. - Some block is in more than one file

File System Consistency Inconsistent States: - Some block is not in a file or on free list ( missing block ) Add it to the free list. - Some block is on free list and is in some file Remove it from the free list. - Some block is on the free list more than once (Can t happen when using a bitmap for free blocks.) Fix the free list so the block appears only once. - Some block is in more than one file Allocate another block. Copy the block. Put each block in each file. Notify the user that one file may contain data from another file.

File System Consistency Invariant (for Unix): The reference count in each i-node must be equal to the number of hard links to the file. D1: D2: D3: A B C X Y F G C File

File System Consistency Problems: - Reference count is too large - Reference count is too small

File System Consistency Problems: - Reference count is too large - The rm command will delete a hard link - When the count becomes zero, the blocks are freed - Permanently allocated; blocks can never be reused - Reference count is too small

File System Consistency Problems: - Reference count is too large - The rm command will delete a hard link - When the count becomes zero, the blocks are freed - Permanently allocated; blocks can never be reused - Reference count is too small - When links are removed, the count will go to zero too soon! - The blocks will be added to the free list, even though the file is still in some directory!

File System Consistency Problems: - Reference count is too large - The rm command will delete a hard link - When the count becomes zero, the blocks are freed - Permanently allocated; blocks can never be reused - Reference count is too small - When links are removed, the count will go to zero too soon! Solution: - The blocks will be added to the free list, even though the file is still in some directory! - Correct the reference count!