CSE380 - Operating Systems

Similar documents
Typical File Extensions File Structure

CSE380 - Operating Systems. Communicating with Devices

CSE 380 Computer Operating Systems

File Systems Management and Examples

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

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

Chapter 11: File System Implementation. Objectives

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

File Systems. What do we need to know?

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

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

Computer Systems Laboratory Sungkyunkwan University

C13: Files and Directories: System s Perspective

Chapter 6: File Systems

V. Mass Storage Systems

Chapter 6. File Systems

File System: Interface and Implmentation

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

OPERATING SYSTEMS CS136

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

CS3600 SYSTEMS AND NETWORKS

Introduction. Secondary Storage. File concept. File attributes

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

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

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

Operating Systems. Lecture File system implementation. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

CS 4284 Systems Capstone

Chapter 5 Input/Output

File Management. Chapter 12

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

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

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

ICS Principles of Operating Systems

Chapter 4 File Systems

Operating System Concepts Ch. 11: File System Implementation

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

ECE 598 Advanced Operating Systems Lecture 14

Operating Systems, Fall

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

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

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

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

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

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

Operating Systems. Operating Systems Professor Sina Meraji U of T

File System Internals. Jo, Heeseung

CS 537 Fall 2017 Review Session

Chapter 10: Mass-Storage Systems

Advanced Operating Systems

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

CS510 Operating System Foundations. Jonathan Walpole

SMD149 - Operating Systems - File systems

Secondary Storage (Chp. 5.4 disk hardware, Chp. 6 File Systems, Tanenbaum)

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

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

I/O Hardwares. Some typical device, network, and data base rates

OPERATING SYSTEM. Chapter 12: File System Implementation

File systems: management 1

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

CS 550 Operating Systems Spring File System

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

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

Classifying Physical Storage Media. Chapter 11: Storage and File Structure. Storage Hierarchy (Cont.) Storage Hierarchy. Magnetic Hard Disk Mechanism

Classifying Physical Storage Media. Chapter 11: Storage and File Structure. Storage Hierarchy. Storage Hierarchy (Cont.) Speed

CS3600 SYSTEMS AND NETWORKS

CISC 7310X. C11: Mass Storage. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/19/2018 CUNY Brooklyn College

Chapter 11: Implementing File Systems

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

File Systems: Allocation Issues, Naming, and Performance CS 111. Operating Systems Peter Reiher

Operating Systems CMPSC 473 File System Implementation April 10, Lecture 21 Instructor: Trent Jaeger

Chapter 11: Implementing File

Storage and File Structure

File Layout and Directories

Wednesday, May 3, Several RAID "levels" have been defined. Some are more commercially viable than others.

Chapter 13: Mass-Storage Systems. Disk Scheduling. Disk Scheduling (Cont.) Disk Structure FCFS. Moving-Head Disk Mechanism

Chapter 13: Mass-Storage Systems. Disk Structure

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

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

CSE325 Principles of Operating Systems. Mass-Storage Systems. David P. Duggan. April 19, 2011

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

File Systems: Interface and Implementation

File systems. Chapter 6: File Systems. Naming files. Long-term information storage. Typical file extensions. File structures

Outline. Operating Systems. File Systems. File System Concepts. Example: Unix open() Files: The User s Point of View

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

File system internals Tanenbaum, Chapter 4. COMP3231 Operating Systems

Final Exam Preparation Questions

Chapter 11: Implementing File Systems

File Management. Ezio Bartocci.

I/O CANNOT BE IGNORED

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

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

ECE 598 Advanced Operating Systems Lecture 18

File Systems. CS 4410 Operating Systems

Motivation. Operating Systems. File Systems. Outline. Files: The User s Point of View. File System Concepts. Solution? Files!

Problem Overhead File containing the path must be read, and then the path must be parsed and followed to find the actual I-node. o Might require many

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

File Systems. CS170 Fall 2018

Chapter 12: File System Implementation

I/O CANNOT BE IGNORED

Transcription:

CSE380 - Operating Systems Notes for Lecture 17-11/10/05 Matt Blaze, Micah Sherr (some examples by Insup Lee)

Implementing File Systems We ve looked at the user view of file systems names, directory structure, attributes, operations on files We ve looked at some of the internal data structures directories, lined lists, FATs, i-nodes Now we ll look at file system algorithms, performance and tools

Links May need more than one name for a file maybe in a different directory Hard link - early binding pointer to i-node added to the directory entries link counter in the i-node linked to incremented i-node can only be deleted (data addresses cleared) if counter goes down to 0 (why?) then space can be reclaimed Soft link (symbolic) - late binding new special file created of type LINK, which contains just the path name new file also has its own i-node created

Linked files File system containing a linked file

Linked Files i-node (a) Prior to linking (b) After the link is created (c) After the original owner removes the file

Disk Space Management Some similarity between disk management and memory management keeping track of free blocks segmentation caching and paging Natural first question: how big should block size be? smaller block size leads to less waste within a block but larger block size yields better data transfer rate (block assess time is dominated by seek time and rotational delay) experiments lead to estimate of median file size at 2KB Unix systems commonly use 1KB or 4KB probably not optimal; choice was made a long time ago MS-Dos has a limit on number of blocks, making block size proportional to disk size

Block size Block size Dark line (left hand scale) gives data rate of a disk Dotted line (right hand scale) gives disk space efficiency In this experiment, all files are exactly 2KB

Managing Free Disk Space Familiar problem: keeping track of unallocated blocks Linked Lists a list of blocks containing addresses of free blocks e.g., each block address is 32 bits (4 Bytes) a 1KB block used can hold addresses of 255 free blocks and an address of the next block in the list for free space management note: list can be stored in free blocks themselves Bitmap method: an array of bits, one entry per block, indicating whether that block is free or not 16-GB disk has 16 million 1 KB blocks storing the bitmap requires 16 million bits, or 2048 blocks How do the two methods compare in terms of space requirements?

Free Blocks (a) linked list free list (b) bit map free list

File System Backup Disks aren t very reliable Backup purpose recover from (natural) disaster recover from error recover from attack Backup tools full dump incremental dump physical dump logical dump

Logical Dump File that has not changed A file system to be dumped squares are directories, circles are files shaded items, modified since last dump each directory & file labeled by i-node number

Logical Dump Bitmaps (a) all directories and modified files (b) all modified files, their parent directories and modified directories (c) all directories to be dumped (d) all files to be dumped

Reliability by Redundancy Mirroring (or Shadowing): duplicate disks Write writes every block to both of the disks Read can be performed from either disk this can be exploited to allow parallelism and speeding up of reads mainly for error correction: if first read fails, try the other Crash recovery: If one disk crashes, the other can restore data If failures are independent, this dramatically increases mean-time to failure Mirroring can be managed by device controller hardware (if it can handle multiple disks) or by the OS software Disadvantage: duplicate disks are expensive (twice the cost) and can be slow if not mirrored by hardware

RAID: Redundant Array of Independent Disks Basic idea: spread work over several physical disks RAID controller talks to OS just like a device driver and manages a suite of disks to improve reliability and performance Striping: Organize logically consecutive chunks of data across different disks to improve performance Striping can be at bit-level, byte-level, or sector-level Incoming request is split into all relevant disks by RAID controller, and their outputs are put together Redundancy through duplication: Multiple requests can be load-balanced Error recovery on faults

RAID Level 0 Array of disks with block-level striping Stripe = k sectors (for suitably chosen k) First k sectors are on first stripe of first disk, next k sectors are on first strip of second disk, and so on Advantages: A large request spanning multiple stripes can be parallelized easily Not much overhead Used in high-performance applications Disadvantages No redundancy Mean-time to failure is, in fact, less than standard disks (why?) No parallelism for small requests

RAID Level 0 0 4 1 5 2 6 3 7

RAID Level 1 Like mirroring, but with striping of level 0 Use same number of backup disks with same striping Same benefits/issues as in mirroring 0 4 1 5 2 6 3 7 0 4 1 5 2 6 3 7

RAID Level 2 Called memory-style error correcting code organization Uses bit-level striping Some of the bits used for parity or other error correction Sample: 4-bits of data encoded by additional 3-bits of ECC, and resulting 7 bits stored on 7 different disks CM-2 machine: 32-bits of data with 7-bits of ECC spanning over array of 39 disks Advantages Great parallelism for read as well as write Even if one disk crashes, all data can be recovered (due to ECC) Disadvantages Drives have to synchronized Overhead in putting together reads from different disks Crash recovery much slower (compared to RAID-1)

RAID Levels 3-5 Raid levels 3 through 5 Backup and parity drives are shaded

File System Consistency Disk I/O is buffered (delayed write) there may be a crash before modified blocks in memory are written back to the disk File system might become inconsistent fsck scandisk block consistency a block is either used (listed in i-node) by a file or is free (listed in free list) file consistency a file has the same number of directory entries (i.e. the same number of hard links) as the link count in its i-node

FS Consistency Check (a) consistent (b) missing block (c) duplicate block in free list (d) duplicate data block

Caching Since disk I/O is slow, a part of memory is reserved to hold disk blocks that are likely to be accessed repeatedly Basic data structure: Maintain a doubly linked list of blocks Use hashing so that a block can be quickly accessed from its address Efficient LRU implementation possible: every time a block is accessed move it to the back of the list (no special hardware needed)

Cache Writing Strategies If there is a crash, modified blocks in cache will be lost especially bad for blocks containing i-nodes or FAT and LRU guarantees loss of the exactly the worst blocks! MS-DOS: write-through cache every time a block is modified, a request to write it to disk is issued loop with putchar() generates busy disk I/O reads can still be fast Classify blocks and treat them separately (Unix) i-node blocks indirect blocks with addresses of file blocks free space management blocks data blocks of files Critical blocks (first 3 kinds) written upon modification data blocks just use standard LRU

Case Study: The CD-ROM ISO 9660 adopted in 1988 block size 2048 begins with 16 blocks whose functions are undefined can be used as boot blocks primary volume descriptor root and directories Directory filename 8+3 depth of nesting limited to 8

CD-ROM Directory Entry

And another: MS-DOS Originally intended as a method for storing data on floppy disks, first version has single directory Later used by MS-DOS with supports for a hierarchical directory structure, and fixed disks as well as floppy disks directory entries are fixed 32 bytes different versions support FAT-12, FAT-16 or FAT-32

Block Sizes and FAT Sizes Disk Size FAT-12 FAT-16 FAT-32 FAT entry Max # of blocks Block size 12 bits 4086 ~2 12 0.5KB to 4KB 16 bits 65526 ~2 16 2KB to 32KB 28 bits 2684354 56 ~2 28 4KB to 32KB FAT size 8KB 128KB 1GB

Block and Max Partition Sizes Internally sector sizes are 512 bytes Empty boxes represent invalid combinations

Windows 95 and 98 Long file names supported by Win95 V2 and Win98 In order to be backwards compatible to MS-DOS, each file has two names - an 8 character MS DOS name plus a long one Long names in Windows98

The Classic Unix File System Each disk partition has 4 Regions block 0: boot block block 1: super block. Contains the size of the disk and the boundaries of the other regions i-nodes: list of i-nodes, each is a 64-byte structure free storage blocks for the contents of files. Each i-node contains owner, protection bits, size, directory/file and 13 disk addresses. The first 10 of these addresses point directly at the first 10 blocks of a file. If a file is larger than 10 blocks (5,120 bytes), the 11th points at a block for secondary indexing (single indirect block)

Classic Unix File System (Cont) Second-level index block contains the addresses of the next 128 blocks of the file (70,656 bytes) Two levels of indirection:12th entry (double indirect block) points at up to 128 blocks, each pointing to 128 blocks of the file (8,459,264 bytes) Three levels of indirection: 13th address (triple indirect block) is for a three layered indexing of 1,082,201,087 bytes. A directory is accessed exactly as an ordinary file. It contains 16 byte entries consisting of a 14-byte name and an i-number (index or ID of an i-node). The root of the file system hierarchy is at a known i-number (2).

Unix i-node

Directory Entry: Unix V7 Each entry has file name and an I-node number I-node contains all the attributes Restriction: File name size is bounded (14 chars); newer versions use a heap to allow longer namers

Traversing Directory Structure Suppose we want to read the file /usr/ast/mbox Location of a i-node, given i-number, can be computed easily i-number of the root directory known (usually 2) Read in i-node 2 from the disk into memory Find out the location of the root directory file on disk, and read the directory block in memory If directory spans multiple blocks, then read blocks until usr found Find out the i-number of directory usr, which is 6 Read in i-node 6 from disk Find out the location of the directory file usr on disk, and read in the block containing this directory Find out the i-number of directory ast (26), and repeat

UNIX V7 Directory Lookup The steps in looking up /usr/ast/mbox