CS 4284 Systems Capstone

Similar documents
STORING DATA: DISK AND FILES

I/O Handling. ECE 650 Systems Programming & Engineering Duke University, Spring Based on Operating Systems Concepts, Silberschatz Chapter 13

I/O Buffering and Streaming

Hard Disk Drives. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

EECS 482 Introduction to Operating Systems

File System Performance (and Abstractions) Kevin Webb Swarthmore College April 5, 2018

Disks, Memories & Buffer Management

Chapter 10: Mass-Storage Systems

I/O Device Controllers. I/O Systems. I/O Ports & Memory-Mapped I/O. Direct Memory Access (DMA) Operating Systems 10/20/2010. CSC 256/456 Fall

19 File Structure, Disk Scheduling

CS 4284 Systems Capstone

OPERATING SYSTEMS CS3502 Spring Input/Output System Chapter 9

Principles of Data Management. Lecture #2 (Storing Data: Disks and Files)

L9: Storage Manager Physical Data Organization

[537] I/O Devices/Disks. Tyler Harter

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective. Part I: Operating system overview: Disk and File System

Disks and Files. Storage Structures Introduction Chapter 8 (3 rd edition) Why Not Store Everything in Main Memory?

PROJECT 6: PINTOS FILE SYSTEM. CS124 Operating Systems Winter , Lecture 25

Disk scheduling Disk reliability Tertiary storage Swap space management Linux swap space management

I/O, Disks, and RAID Yi Shi Fall Xi an Jiaotong University

Principles of Operating Systems CS 446/646

Block Device Scheduling. Don Porter CSE 506

Block Device Scheduling

Chapter 12: Mass-Storage Systems. Operating System Concepts 8 th Edition,

CS 4284 Systems Capstone

Input/Output. Today. Next. Principles of I/O hardware & software I/O software layers Disks. Protection & Security

6.033 Computer System Engineering

CS370 Operating Systems

EECS 482 Introduction to Operating Systems

UNIT 4 Device Management

Chapter 8: Virtual Memory. Operating System Concepts

Hard Disk Drives (HDDs) Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

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

Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Database Management Systems need to:

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Anatomy of a disk. Stack of magnetic platters. Disk arm assembly

Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Chapter 7

STORAGE SYSTEMS. Operating Systems 2015 Spring by Euiseong Seo

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Hard Disk Drives (HDDs)

CSE506: Operating Systems CSE 506: Operating Systems

Storing Data: Disks and Files

Block Device Scheduling. Don Porter CSE 506

Disks and I/O Hakan Uraz - File Organization 1

Storing Data: Disks and Files

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. One OS function is to control devices

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

Operating Systems. V. Input / Output

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. (done)

Review 1-- Storing Data: Disks and Files

Database Systems. November 2, 2011 Lecture #7. topobo (mit)

22 File Structure, Disk Scheduling

CSE 153 Design of Operating Systems Fall 2018

EIDE, ATA, SATA, USB,

Chapter 10: Mass-Storage Systems

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

Operating Systems Comprehensive Exam. Spring Student ID # 3/16/2006

Disk Scheduling COMPSCI 386

ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

CS420: Operating Systems. Mass Storage Structure

Chapter 12: Secondary-Storage Structure. Operating System Concepts 8 th Edition,

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

CHAPTER 12: MASS-STORAGE SYSTEMS (A) By I-Chen Lin Textbook: Operating System Concepts 9th Ed.

Introduction. Operating Systems. Outline. Hardware. I/O Device Types. Device Controllers. One OS function is to control devices

Department of Computer applications. [Part I: Medium Answer Type Questions]

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Disk Scheduling. Based on the slides supporting the text

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

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

I/O Systems and Storage Devices

I/O & Storage. Jin-Soo Kim ( Computer Systems Laboratory Sungkyunkwan University

Chapter 10: Mass-Storage Systems

Storing Data: Disks and Files

OPERATING SYSTEM. Chapter 9: Virtual Memory

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

CS 140 Project 4 File Systems Review Session

ECE331: Hardware Organization and Design

CSE380 - Operating Systems. Communicating with Devices

To understand this, let's build a layered model from the bottom up. Layers include: device driver filesystem file

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING UNIT I

CSCI-GA Operating Systems. I/O : Disk Scheduling and RAID. Hubertus Franke

Chapter 14: Mass-Storage Systems. Disk Structure

V. Mass Storage Systems

CSC369 Lecture 9. Larry Zhang, November 16, 2015

QUESTION BANK UNIT I

Disks & Files. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

Operating Systems Peter Pietzuch

L7: Performance. Frans Kaashoek Spring 2013

I/O and file systems. Dealing with device heterogeneity

Module 13: Secondary-Storage Structure

I/O CANNOT BE IGNORED

ECE 571 Advanced Microprocessor-Based Design Lecture 13

Operating Systems Design Exam 2 Review: Spring 2011

I/O Management and Disk Scheduling. Chapter 11

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

Operating Systems 2010/2011

Transcription:

CS 4284 Systems Capstone Disks & File Systems Godmar Back

Disks & Filesystems

Disk Schematics Source: Micro House PC Hardware Library Volume I: Hard Drives 3

Tracks, Sectors, Cylinders 4

Hard Disk Example 2008 Seagate Barracuda 7200.11 See here for 2015 Drive 5

What s important about disks from OS perspective Disks are big & slow - compared to RAM Access to disk requires Seek (move arm to track + time to settle) to cross all tracks anywhere from 20-50ms, on average takes 1/3. Rotational delay (wait for sector to appear under track) 7,200rpm is 8.3ms per rotation, on average takes ½: 4.15ms rot delay Transfer time (fast: 512 bytes at 960 Mbit/s is about 4.26 s) Seek+Rot Delay dominates Random Access is expensive and unlikely to get better Consequence: avoid seeks seek to short distances amortize seeks by doing bulk transfers 6

Disk Scheduling Can use priority scheme (sometimes done) (absent priorities:) goal is to reduce average access time by sending requests to disk controller in certain order Or, more commonly, have disk controller itself reorder requests SSTF: shortest seek time first Like SJF in CPU scheduling, guarantees minimum avg seek time, but can lead to starvation SCAN: elevator algorithm Process requests with increasing track numbers until highest reached, then decreasing etc. repeat Variations: LOOK don t go all the way to the top without passengers C-SCAN: - only take passengers when going up 7

Accessing Disks Sector is the unit of atomic access Writes to sectors should always complete, even if power fails Consequence of sector granularity: Writing a single byte requires read-modifywrite void set_byte(off_t off, char b) { char buffer[512]; block_read(disk, off/disk_sector_size, buffer); buffer[off % DISK_SECTOR_SIZE] = b; block_write(disk, off/disk_sector_size, buffer); } 8

Disks & Filesystems Buffer Cache 9

Disk Caching Buffer Cache How much memory should be dedicated for it? In older systems (& Pintos), set aside a portion of physical memory In newer systems, integrated into virtual memory system: e.g., page cache in Linux How should eviction be handled? How should prefetching be done? How should concurrent access be mediated (multiple processes may be attempting to write/read to same sector)? How is consistency guaranteed? (All accesses must go through buffer cache!) What write-back strategy should be used? 10

Buffer Cache in Pintos Cache Block Descriptor - block_sector_id, if in use - dirty bit - valid bit - # of readers - # of writers - # of pending read/write requests - lock to protect above variables - signaling variables to signal availability changes - usage information for eviction policy - data (pointer or embedded) desc desc desc desc desc desc desc 512 bytes 512 bytes 512 bytes 512 bytes 512 bytes 512 bytes 512 bytes 64 11

A Buffer Cache Interface // cache.h struct cache_block; // opaque type // reserve a block in buffer cache dedicated to hold this sector // possibly evicting some other unused buffer // either grant exclusive or shared access struct cache_block * cache_get_block (disk_sector_t sector, bool exclusive); // release access to cache block void cache_put_block(struct cache_block *b); // read cache block from disk, returns pointer to data void *cache_read_block(struct cache_block *b); // fill cache block with zeros, returns pointer to data void *cache_zero_block(struct cache_block *b); // mark cache block dirty (must be written back) void cache_mark_block_dirty(struct cache_block *b); // not shown: initialization, readahead, shutdown 12

Block State Perspective EXCLUSIVE + VALID + DIRTY? ALLOCATED to disk block k VALID + DIRTY? cache_put_block() SHARED + VALID + DIRTY? cache_read_block()/cache_zero_block() + cache_mark_block_dirty()? FREE EXCLUSIVE access to disk block k writers == 1 SHARED access to disk block k readers > 0 Not subject to eviction; kernel code holds pointer cache_get_block (k, EXCL) ALLOCATED to disk block k INVALID cache_get_block (k, SHARED) Subject to eviction 13

Buffer Cache Sizing Simple approach Set aside part of physical memory for buffer cache/use rest for virtual memory pages as page cache evict buffer/page from same pool Disadvantage: can t use idle memory of other pool - usually use unified cache subject to shared eviction policy Windows allows user to limit buffer cache size ( Adjust for best performance of programs ) Problem: Bad prediction of buffer cache accesses can result in poor VM performance (and vice versa) Specifically, don t want large sequential file accesses to evict program pages 15

Buffer Cache Replacement Similar to VM Page Replacement, differences: Can do exact LRU (because client must call cache_get_block()!) But LRU hurts when long sequential accesses should use MRU (most recently used) instead. Example reference string: ABCDABCDABCD, can cache 3 blocks: LRU causes 12 misses, 0 hits, 9 evictions How many misses/hits/evictions would there be with (most-recently-used) MRU? Also: not all blocks are equally important, benefit from some hits more than from others 16

Buffer Cache Writeback Strategies Write-Through: Good for floppy drive, USB stick Poor performance every write causes disk access (Delayed) Write-Back: Makes individual writes faster just copy & set bit Absorbs multiple writes Allows write-back in batches Problem: what if system crashes before you ve written data back? Trade-off: performance in no-fault case vs. damage control in fault case If crash occurs, order of write-back can matter 17

Writeback Strategies (2) Must write-back on eviction (naturally) Periodically (every 30 seconds or so) When user demands: fsync(2) writes back all modified data belonging to one file database implementations use this sync(1) writes back entire cache Some systems guarantee write-back on file close But not all, since many files are used in open/write/close/open/read/close/delete sequence Some systems (databases) bypass OS buffer cache (O_SYNC flag) 18

Buffer Cache Prefetching Would like to bring next block to be accessed into cache before it s accessed Exploit Spatial locality Must be done in parallel use daemon thread and producer/consumer pattern Note: next(n) not always equal to n+1 although we try for it via clustering to minimize seek times Don t initiate read_ahead if next(n) is unknown or would require another disk access to find out b = cache_get_block(n, _); cache_read_block(b); cache_readahead(next(n)); queue q; cache_readahead(sector s) { q.lock(); q.add(request(s)); signal qcond; q.unlock(); } cache_readahead_daemon() { while (true) { q.lock(); while (q.empty()) qcond.wait(); s = q.pop(); q.unlock(); read sector(s); } } 19