File Systems Review of File Systems and Disk Management.

Slides:



Advertisements
Similar presentations
File Management.
Advertisements

More on File Management
File Systems.
Allocation Methods - Contiguous
Chapter 11: File System Implementation
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
File System Implementation
File System Implementation
The design and implementation of a log-structured file system The design and implementation of a log-structured file system M. Rosenblum and J.K. Ousterhout.
Lecture 17 I/O Optimization. Disk Organization Tracks: concentric rings around disk surface Sectors: arc of track, minimum unit of transfer Cylinder:
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (4) File Management & Input/Out Systems 10/14/2008 Yang Song (Prepared.
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
CMPT 300: Final Review Chapters 8 – Memory Management: Ch. 8, 9 Address spaces Logical (virtual): generated by the CPU Physical: seen by the memory.
1 Outline File Systems Implementation How disks work How to organize data (files) on disks Data structures Placement of files on disk.
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
12: IO Systems1 I/O SYSTEMS This Chapter is About Processor I/O Interfaces: Connections exist between processors, memory, and IO devices. The OS must manage.
File System Implementation
Secondary Storage Management Hank Levy. 8/7/20152 Secondary Storage • Secondary Storage is usually: –anything outside of “primary memory” –storage that.
Disk and I/O Management
Chapter 5 Part 2 Secondary Storage Mgt. File Mgt. in Popular OSs
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
File Implementation. File System Abstraction How to Organize Files on Disk Goals: –Maximize sequential performance –Easy random access to file –Easy.
Operating Systems CMPSC 473 I/O Management (4) December 09, Lecture 25 Instructor: Bhuvan Urgaonkar.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Disk Structure Disk drives are addressed as large one- dimensional arrays of logical blocks, where the logical block is the smallest unit of transfer.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
CE Operating Systems Lecture 20 Disk I/O. Overview of lecture In this lecture we will look at: Disk Structure Disk Scheduling Disk Management Swap-Space.
I/O Management and Disk Structure Introduction to Operating Systems: Module 14.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
CSCI-375 Operating Systems Lecture Note: Many slides and/or pictures in the following are adapted from: slides ©2005 Silberschatz, Galvin, and Gagne Some.
File Management Chapter 12. File Management File management system is considered part of the operating system Input to applications is by means of a file.
CS 153 Design of Operating Systems Spring 2015 Lecture 22: File system optimizations.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
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.
CS 153 Design of Operating Systems Spring 2015 Lecture 21: File Systems.
File Structures. 2 Chapter - Objectives Disk Storage Devices Files of Records Operations on Files Unordered Files Ordered Files Hashed Files Dynamic and.
Chapter 11: File System Implementation Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 11: File System Implementation Chapter.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
CE Operating Systems Lecture 17 File systems – interface and implementation.
Fast File System 2/17/2006. Introduction Paper talked about changes to old BSD 4.2 File System (FS) Motivation - Applications require greater throughput.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
CS333 Intro to Operating Systems Jonathan Walpole.
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.
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
CS533 - Concepts of Operating Systems 1 A Fast File System for UNIX Marshall Kirk McKusick, William N. Joy, Samuel J. Leffler and Robert S. Fabry University.
Lecture Topics: 12/1 File System Implementation –Space allocation –Free Space –Directory implementation –Caching Disk Scheduling File System/Disk Interaction.
A Fast File System for UNIX By Marshall Kirk McKusick, William N. Joy, Samuel J. Leffler, Robert S. Fabry Presented by Agnimitra Roy.
FILE SYSTEM IMPLEMENTATION 1. 2 File-System Structure File structure Logical storage unit Collection of related information File system resides on secondary.
Lecture Topics: 11/22 HW 7 File systems –block allocation Unix and NT –disk scheduling –file caches –RAID.
W4118 Operating Systems Instructor: Junfeng Yang.
Jonathan Walpole Computer Science Portland State University
File-System Implementation
Chapter 11: File System Implementation
Chapter 11: File System Implementation
CS703 - Advanced Operating Systems
Operating Systems (CS 340 D)
Operating System I/O System Monday, August 11, 2008.
Lecture 45 Syed Mansoor Sarwar
Chapter 11: File System Implementation
Chapter 11: File System Implementation
Overview Continuation from Monday (File system implementation)
Secondary Storage Management Brian Bershad
File-System Structure
Secondary Storage Management Hank Levy
Chapter 11: File System Implementation
Disk Scheduling The operating system is responsible for using hardware efficiently — for the disk drives, this means having a fast access time and disk.
Presentation transcript:

File Systems Review of File Systems and Disk Management

File System Functions Disk Management: allocate disk blocks to files Naming (device independence): how to map user file names into physical addresses Protection: security and sharing of files, as needed Reliability: protection against crashes disk crash loses permanent info on disk; system crash can lose info in kernel buffers that hasn't been written to disk yet. Performance/Efficiency: try to reduce amount of time spent in I/O

Files and (Magnetic) Disks The disk is composed of sectors, tracks, surfaces, cylinders – this is the physical view of secondary storage The OS maintains a file system to hide messy disk details from applications. The file system provides an abstract view of the disk as a collection of logical blocks instead of sectors.

from Operating Sytems, by William Stallings, Prentice Hall

Files and Disks A sector is the physical unit of data transfer between memory and disk; a block is the logical unit of data transfer, as managed by the file system. A block is a sector multiple. (UNIX block size = 4-8KB, usually) The user views a file as a sequential stream of bytes (in UNIX and similar systems) or as a collection of fields/records (in database systems). When the user program reads or writes data the file system will fetch/write the block that contains those bytes.

Common Access Methods Sequential access: get_next Most file systems support this. For example, a C++ program will always maintain a pointer to the next byte to be read (or written) in an open file Random or direct access: seek to a particular location in the file – may be identified by byte or record number or some field value (in indexed files).

Performance Efficiency Caching and buffering Minimize storage fragmentation – small, unusable blocks of free disk space Minimize file fragmentation, splitting a file into multiple blocks so that a seek may occur between any two blocks –Objective: optimize locality – store related information close together

File System Caching The disk cache is a set of blocks (buffers) that are set aside in kernel space. Copies of recently accessed file blocks are kept here to reduce the number of disk accesses Same concept as cache memory, which reduces the number of main memory references. Blocks in the disk cache may be file data, or file system metadata (i-nodes, directory blocks, etc.)

Disk Storage Main Memory Various levels of hardware caches Disk Cache The memory hierarchy

Buffering in the File System Buffers are temporary storage located between a process and the disk. Buffered input: Read one or more blocks from disk to memory – return to user as requested. For sequential reading, buffering can (ideally) keep ahead of the user process, reducing the number of delays to wait for input. Buffered output: Save writes until a full block has been written, then dump to disk.

Caching and Buffering Buffering and caching have somewhat different purposes, but both reduce disk accesses, improve execution performance. The same kernel memory locations can serve both purposes (buffers or caches).

File System Data Structures Free-space list: represents the free disk blocks. May be stored as a bit map. File mapping structure used to associate file blocks with disk blocks (where is the file stored?) –File Allocation Tables (FAT) –indexed structures (e.g. UNIX inodes)

Disk Allocation Techniques Contiguous Linked Indexed

Contiguous Allocation Allocate disk space as a set of contiguous blocks (sequential) File map structure has address of first block, number of blocks Advantage: fast access (both sequential and random) Disadvantages: fragmented disk space; problems when file grows

Linked Allocation Allocated disk blocks may be anywhere on disk. File map contains address of first block; subsequent links stored directly in the blocks (block 0 contains the address of block 1, block 1 contains address of block 2, etc.) Advantages: –file can grow dynamically so no disk fragmentation; –sequential access is reasonable (requires a seek between blocks which isn’t needed in contiguous) but not as good as for contiguous allocation. Disadvantages: random access is impractical -

Indexed Allocation is similar to linked methods: –Allocate space as file grows, in some fixed block size –Allocation unit = one or more sectors Each process has its own file map (or index): a block of pointers to the individual blocks of the file – similar to a page table. Sequential and random access take roughly the same amount of time.

Indexed – Evaluation Disk utilization is good, no fragmentation May require a separate seek for each block, so access times are slower than for sequential allocation (but faster than for linked allocation). Usual approach: try to store file blocks sequentially if possible, but use index for access. The UNIX inode structure is an example of a multilevel index.

Disk Access A disk access has three components: –Seek: locates the cylinder (track) –Rotational delay: locates the sector –Transfer: transfer data btw. memory and disk Seek: most time-consuming factor –data transfer times are less significant. Moving large amounts of data in a single operation reduces the seek overhead.

Disk Scheduling Disk scheduling algorithms optimize throughput by reducing the total seek time needed to satisfy a set of requests. Useful primarily in server systems or other environments where request queues develop –SSTF: shortest seek time first. –SCAN: similar to SSTF, but works on the principle of an elevator: head moves in one direction only. Otherwise, FIFO is sufficient

File System Case Study UNIX FFS Read Sections 1, 2, 3 Skim 3.1, 3.2, 3.3

References UNIX Internals, the New Frontiers, Uresh Vahalia, Prentice Hall, "A Fast File System for UNIX," Marshall Kirk McKusick, William N. Joy, Samuel J. Leffler, Robert S. Fabry, ACM Transactions on Computer Systems, vol. 2, (Aug. 1984).

Outline UNIX file system – versions Characteristics of UNIX-like systems Evolution of UFS –Early ufs – problems –Berkeley Fast File System (FFS or BSD/FFS)

UNIX-like File Systems There are two main versions of the UNIX file system: s5fs [system V file system) and UFS [UNIX file system]. UFS is sometimes called FFS (Berkley Fast File System) because it was developed there originally. File systems for FreeBSD, Solaris, OpenBSD, etc. are UFS/FFS derivatives. Linux file system is modeled after UFS.

Characteristics of UNIX-like File Systems File Storage/inodes File Sharing/locking File I/O

UNIX File Storage UNIX files are stored non-contiguously. Each file is represented by an inode, a data structure which resides on disk. An inode table holds a block of inodes File system directory stores file names; resolve to inode numbers which are pointers into the table. –Resolution may be done via hashing File metadata is stored in the inode.

Source: Operating Systems by William Stallings

UNIX File Sharing UNIX permits users to share a file. Multiple concurrent accesses are possible. If two I/O operations start at about the same time, serial access is enforced to make sure data is consistent. That is, one operation is performed in its entirety before the next one begins. However, a read from user 1, followed by a write from user 2, followed by a read from user 1 means that user 1 is reading two different versions of the file. UNIX provides various file locking mechanisms to be used if this is a problem (advisory, mandatory, …)

File Locks, in UNIX No standard locking scheme. Most systems provide advisory locks: –Cooperating processes can agree to use the locks, but if one process breaks the agreement, there’s no penalty Mandatory locks are provided by some UNIX systems, but advisory is the default. Locks can be shared or exclusive (read or write), and may be applied to the whole file or a segment of it.

File I/O - Read For reads, if the data is already in memory (in a buffer) it is transferred to the user's space. The user is not blocked. If not, the reader blocks (sleeps) until the data is available. The read operation is said to be synchronous.

File I/O - Write Writes go to memory buffers and are transferred to disk later. Considered synchronous, but aren’t. –output operations can be scheduled according to some performance heuristic. –A write may change the size of a file. Before data is written to disk, the file system may need to allocate new blocks. If a write changes part of a block, the system must read in the entire block, make the changes, write entire block back to disk.

Evolution of UNIX File System Early versions –Disk layout –Limitations Berkeley FFS

Berkeley Fast File System Improved performance and added features, compared to earlier versions of the UNIX file system. Improvements –Reliability –Performance enhancement (faster) –Usability features

Disk Format in Early UFS The superblock contains metadata about the system: size, # of tracks, location of inodes, free block list, etc. Corruption of this area compromises the entire system. Reliability is a problem. UNIX disk structure/early versions Boot Block Super block inodes Data blocks

Performance Limitations inodes were located in one area of the disk, data blocks elsewhere. This means a lot of time spent seeking: –read inode, seek to appropriate data block. Originally, disk blocks are put on the free-space list in order, but as files are changed or deleted blocks are returned to the list in a random order. No attempt is made to allocate blocks contiguously; just get them directly off free list. Eventually blocks are allocated to files randomly. This adversely affects sequential processing.

Summary:Limitations of Early UNIX File Systems Performance Limitations –Separation of inodes from data blocks –Files not stored contiguously –Small block size Reliability –Corruption of superblock Useabilitiy –Short file names

Berkeley FFS Enhancements Cylinder groups Increased block size Other features

FFS Enhancements Two of the changes were designed to make file operations more efficient either by reducing the number or length of seeks. –Large block size –Cylinder groups Another change - Long File Names - improved usability Replication of superblock improved reliability.

Other functional enhancements Introduced –Locking mechanisms (advisory) –Symbolic links: support file sharing between different physical file systems. A special file that contains a pathname which names another file

Cylinder Groups Consist of a set of consecutive cylinders. For reliability, each cylinder group has a copy of the superblock. The superblock is stored in a different position on each cylinder group, so damage to one surface won’t ruin all copies of the superblock. For performance, the cylinder group contains related information (e.g., inodes and the data blocks they reference) to reduce seek times.

Increased Block Size Allowed more data to be moved in a single operation. Block sizes ranged from 4K to 8K. Using a block size of 4K, files up to 2 32 bytes can be addressed with only two levels of indirection. Today, the default block size for a freeBSD file is 16K

Storage Allocation To accommodate small files and avoid wasted space, large disk blocks can be divided into fragments, which are allocated separately. Fragment size can be any power-of-two fraction of total block size (down to 512 bytes). A fragmented block can store the last portions (partial blocks) of several files.

Disk Space Allocation Done in response to a write system call. There are three possibilities: If the current file does not fill the last block or fragment, and there is enough room to write new data in the existing space no additional space is allocated. If the last block doesn't contain enough space for the new data, look for one or more contiguous fragments. –If the amount to be written is a block or more, allocate one or more new blocks as needed. If the file has fragments, and the fragments plus the new data will fill a block, then copy fragments plus new data into a newly allocated block.

Placement Issues Placement considerations (most are designed to take advantage of locality): –Try to place all inodes for the files in a single directory in the same cylinder group. –Try to place data blocks in the same cylinder group with their inode –Try to place all blocks in a file close together to support sequential reads. Consider rotational characteristics of the disk.

Performance Studies showed that FFS performed substantially better than s5fs, particularly on read operations.

Questions How do file systems take advantage of the principle of locality? How do fragmentation issues compare in main memory management and disk memory management? Can you see comparisons between paged virtual memory management and indexed disk allocation policies?

Files and Disks Standard sector size has been 512 bytes, although some disks had larger sectors. –4K byte sectors became a standard in Traditionally, every sector has had the same # of bits, even though the physical sector side gets larger as you move from center to edge. Zoned recording divides disk into groups of adjacent tracks and stores more data in large zones than in small ones.