Disks and Files Vivek Pai Princeton University. 2 Why Files Physical reality Block oriented Physical sector #s No protection among users of the system.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

Chapter 4 : File Systems What is a file system?
File Systems.
COS 318: Operating Systems File Layout and Directories
Chapter 10: File-System Interface
CS503: Operating Systems Spring 2014 General File Systems
File Systems Thomas Plagemann University of Oslo
Operating Systems File Systems (in a Day) Ch
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
Ceng Operating Systems
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
1 File Management in Representative Operating Systems.
1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data structures Placement of files on disk.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
Filesystems – Metadata, Paths, & Caching Vivek Pai Princeton University.
Disks and Files Vivek Pai Princeton University. 2 Gedankyou Imagine the following: A disk scheduling policy says “handle the request that is closest to.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
File Systems. Main Points File layout Directory layout.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
File Systems and Disk Management. File system Interface between applications and the mass storage/devices Provide abstraction for the mass storage and.
COSC 3407: Operating Systems Lecture 18: Disk Management and File System.
File Implementation. File System Abstraction How to Organize Files on Disk Goals: –Maximize sequential performance –Easy random access to file –Easy.
Files CS Spring Overview Example: FAT File System File Organization File System Organization –File Directories and File Sharing –Record Blocking.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
CSCI-375 Operating Systems Lecture Note: Many slides and/or pictures in the following are adapted from: slides ©2005 Silberschatz, Galvin, and Gagne Some.
1 File Systems: Consistency Issues. 2 File Systems: Consistency Issues File systems maintains many data structures  Free list/bit vector  Directories.
CS 153 Design of Operating Systems Spring 2015 Lecture 22: File system optimizations.
File System Implementation
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Module 4.0: File Systems File is a contiguous logical address space.
File Systems Security File Systems Implementation.
CS 153 Design of Operating Systems Spring 2015 Lecture 21: File Systems.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
File Systems. 2 What is a file? A repository for data Is long lasting (until explicitly deleted).
I MPLEMENTING FILES. Contiguous Allocation:  The simplest allocation scheme is to store each file as a contiguous run of disk blocks (a 50-KB file would.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Files and file allocation.
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems File systems.
CS 3204 Operating Systems Godmar Back Lecture 21.
File Systems Topics Design criteria History of file systems Berkeley Fast File System Effect of file systems on programs fs.ppt CS 105 “Tour of the Black.
14.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 10 & 11: File-System Interface and Implementation.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
Review CS File Systems - Partitions What is a hard disk partition?
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
1 Lecture 15: File System Interface  file system interface reasons for delegating storage management to OS file definition and operations on a file file.
Lecture Topics: 11/22 HW 7 File systems –block allocation Unix and NT –disk scheduling –file caches –RAID.
File System Department of Computer Science Southern Illinois University Edwardsville Spring, 2016 Dr. Hiroshi Fujinoki CS 314.
W4118 Operating Systems Instructor: Junfeng Yang.
COMP 3500 Introduction to Operating Systems Directory Structures Block Management Dr. Xiao Qin Auburn University
File Systems and Disk Management
File-System Management
Chapter 11: File System Implementation
File System Structure How do I organize a disk into a file system?
Filesystems.
File Systems and Disk Management
File Systems Implementation
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Introduction to Operating Systems
File Systems and Disk Management
File Systems and Disk Management
File Systems and Disk Management
File System Implementation
Chapter 16 File Management
File Systems and Disk Management
File Systems and Disk Management
File Systems and Disk Management
Department of Computer Science
File Systems CSE 2431: Introduction to Operating Systems
Presentation transcript:

Disks and Files Vivek Pai Princeton University

2 Why Files Physical reality Block oriented Physical sector #s No protection among users of the system Data might be corrupted if machine crashes Filesystem model Byte oriented Named files Users protected from each other Robust to machine failures

3 File Structures Byte sequence Read or write a number of bytes Unstructured or linear Record sequence Fixed or variable length Read or write a number of records Tree Records with keys Read, insert, delete a record (typically using B-tree)

4 File Structures Today Stream of bytes Simplest to implement in kernel Easy to manipulate in other forms Little performance loss More complicated structures Hardware assist fell out of favor Special-purpose hardware slower, costly

5 File Types ASCII – plain text A Unix executable file header: magic number, sizes, entry point, flags Text (code) Data relocation bits symbol table Devices Everything else in the system

6 So What Makes Filesystems Hard? Files grow and shrink in pieces Little a priori knowledge 6 orders of magnitude in file sizes Overcoming disk performance behavior Desire for efficiency Coping with failure

7 File System Components Disk management Arrange collection of disk blocks into files Naming User gives file name, not track or sector number, to locate data Security Keep information secure Reliability/durability When system crashes, lose stuff in memory, but want files to be durable User File Naming File access Disk management Disk drivers

8 Some Definitions File descriptor (fd) – an integer used to represent a file – easier than using names Metadata – data about data - bookkeeping data used to eventually access the “real” data Open file table – system-wide list of descriptors in use

9 Kinds of Metadata inode – index node, or a specific set of information kept about each file Two forms – on disk and in memory Directory – names and location information for files and subdirectories Note: stored in files in Unix Superblock – contains information to describe the file system, disk layout Information about free blocks/inodes on disk

10 Contents of an Inode Disk inode: File type, size, blocks on disk Owner, group, permissions (r/w/x) Reference count Times: creation, last access, last mod Inode generation number Padding & other stuff 128 bytes on classic Unix

11 Directories in Unix Stored like regular files Contents are file names and inode #s Names are nul-terminated strings Logic Separates file from location in tree File can appear in multiple places What are the drawbacks?

12 Effects of Corruption inode – file gets “damaged” Maybe some “free” block gets viewed Directory – “lose” files/directories Might get to read deleted files Superblock – can’t figure out anything This is why we replicate the superblock

13 Data Structures for A Typical File System Process control block Open file pointer array Open file table (systemwide) Memory Inode Disk inode

14 Opening A File File name lookup and authentication Copy the file metadata into the in-memory data structure, if it is not in yet Create an entry in the open file table (system wide) if there isn’t one Create an entry in PCB Link up the data structures Return a pointer to user PCB fd = open( FileName, access) Open file table Metadata Allocate & link up data structures File name lookup & authenticate File system on disk

15 Reading And Writing What happens when you… read 10 bytes from a file? write 10 bytes into an existing file? write 1024 bytes into a file? Disk works on blocks (sectors) Can have temporary (ephemeral) buffers Longer lasting buffers = disk cache

16 Reading A Block PCB Open file table Metadata read( fd, userBuf, size ) Logical  phyiscal read( device, phyBlock, size ) Get physical block to sysBuf copy to userBuf Disk device driver Buffer cache

17 A Disk Layout for A File System Superblock defines a file system size of the file system size of the file descriptor area free list pointer, or pointer to bitmap location of the file descriptor of the root directory other meta-data such as permission and various times For reliability, replicate the superblock Super block File metadata (i-node in Unix) File data blocks Boot block

18 File Usage Patterns How do users access files? Sequential: bytes read in order Random: read/write element out of middle of arrays Whole file or partial file How are files used? Most files are small Large files use up most of the disk space Large files account for most of the bytes transferred Bad news Need everything to be efficient

19 Data Structures for Disk Management A “header” for each file (part of the file meta-data) Disk sectors associated with each file A data structure to represent free space on disk Bit map 1 bit per block (sector) blocks numbered in cylinder-major order, why? Linked list Others? How much space does a bit map need for a 4G disk?

20 Linked Files (Alto) File header points to 1st block on disk Each block points to next Pros Can grow files dynamically Free list is similar to a file Cons random access: horrible unreliable: losing a block means losing the rest File header null...

21 Contiguous Allocation Request in advance for the size of the file Search bit map or linked list to locate a space File header first sector in file number of sectors Pros Fast sequential access Easy random access Cons External fragmentation Hard to grow files

22 Single-Level Indexed Files or Extent-based Filesystems A user declares max size A file header holds an array of pointers to point to disk blocks Pros Can grow up to a limit Random access is fast Cons Clumsy to grow beyond limit Periodic cleanup of new files Up-front declaration a real pain File header Disk blocks

File Allocation Table (FAT) Approach A section of disk for each partition is reserved One entry for each block A file is a linked list of blocks A directory entry points to the 1st block of the file Pros Simple Cons Always go to FAT Wasting space foo 217 EOF FAT

24 Multi-Level Indexed Files (Unix) 13 Pointers in a header 10 direct pointers 11: 1-level indirect 12: 2-level indirect 13: 3-level indirect Pros & Cons In favor of small files Can grow Limit is 16G and lots of seek What happens to reach block 23, 5, 340? 1 2 data data

25 Challenges Unix filesystem has great flexibility Extent-based filesystems have speed Seeks kill performance – locality Bitmaps show contiguous free space Linked lists easy to search How do you perform backup/restore?

26 Bigger, Faster, Stronger Making individual disks larger is hard Throw more disks at the problem Capacity increases Effective access speed may increase Probability of failure also increases Use some disks to provide redundancy Generally assume a fail-stop model Fail-stop versus Byzantine failures

27 RAID ( Redundant Array of Inexpensive Disks ) Main idea Store the error correcting codes on other disks General error correcting codes are too powerful Use XORs or single parity Upon any failure, one can recover the entire block from the spare disk (or any disk) using XORs Pros Reliability High bandwidth Cons The controller is complex RAID controller XOR

28 Synopsis of RAID Levels RAID Level 0: Non redundant (JBOD) RAID Level 1: Mirroring RAID Level 2: Byte-interleaved, ECC RAID Level 3: Byte-interleaved, parity RAID Level 4: Block-interleaved, parity RAID Level 5: Block-interleaved, distributed parity

29 Did RAID Work? Performance: yes Reliability: yes Cost: no Controller design complicated Fewer economies of scale High-reliability environments don’t care Now also software implementations