Advanced Operating Systems

Slides:



Advertisements
Similar presentations
Advanced Operating Systems
Advertisements

Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 12: File System Implementation
File Management.
Session 8: Virtual Memory management
8. Virtual Memory 8.1 Principles of Virtual Memory
Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 6: File Systems.
Operating Systems1 10. File Systems 10.1 Basic Functions of File Management 10.2 Hierarchical Model of a File System 10.3 User’s View of Files –Logical.
Chapter 4 : File Systems What is a file system?
File Systems.
Chapter 11: File System Implementation
Operating Systems File Systems CNS 3060.
1 Pertemuan 21 Sistem File Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File System Implementation: beyond the user’s view A possible file system layout on a disk.
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
File Systems Topics –File –Directory –File System Implementation Reference: Chapter 5: File Systems Operating Systems Design and Implementation (Second.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
Chapter 6 File Systems 6.1 Files 6.2 Directories
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
CS 333 Introduction to Operating Systems Class 17 - File Systems Jonathan Walpole Computer Science Portland State University.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
Chapter 4 File Systems Files Directories Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved
MODERN OPERATING SYSTEMS Third Edition ANDREW S. TANENBAUM Chapter 4 File Systems Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File Systems (1). Readings r Silbershatz et al: 10.1,10.2,
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File Systems Long-term Information Storage Store large amounts of information Information must survive the termination of the process using it Multiple.
Operating Systems Mehdi Naghavi Spring 1386.
NETW3005 File System Interface. Reading For this lecture, you should have read Chapter 10 (Sections 1-5) and Chapter 11 (Sections 1-4). NETW3005 (Operating.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
CSC 322 Operating Systems Concepts Lecture - 19: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
CSC 322 Operating Systems Concepts Lecture - 20: by Ahmed Mumtaz Mustehsan Special Thanks To: Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall,
1 File systems Files Directories & naming File system implementation Example file systems.
CS333 Intro to Operating Systems Jonathan Walpole.
File Storage Organization The majority of space on a device is reserved for the storage of files. When files are created and modified physical blocks are.
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.
Some basic concepts and information on file systems Portions taken and modified from books by ANDREW S. TANENBAUM.
CS450/550 FileSystems.1 Adapted from MOS2E UC. Colorado Springs CS450/550 Operating Systems Lecture 6 File Systems Palden Lama Department of Computer.
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.
Why Do We Need Files? Must store large amounts of data. Information stored must survive the termination of the process using it - that is, be persistent.
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.
CS 333 Introduction to Operating Systems Class 17 - File Systems Jonathan Walpole Computer Science Portland State University.
Annotated by B. Hirsbrunner File Systems Chapter Files 5.2 Directories 5.3 File System Implementation 5.4 Security 5.5 Protection Mechanism 5.6 Overview.
Chapter 6 File Systems. Essential requirements 1. Store very large amount of information 2. Must survive the termination of processes persistent 3. Concurrent.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
操作系统原理 OPERATING SYSTEMS Chapter 4 File Systems 文件系统.
F ILE M ANAGEMENT Prepared By: Dr. Vipul Vekariya.
W4118 Operating Systems Instructor: Junfeng Yang.
Fall 2011 Nassau Community College ITE153 – Operating Systems 1 Session 5 Files.
File-System Management
MODERN OPERATING SYSTEMS Third Edition ANDREW S
FileSystems.
Chapter 11: File System Implementation
Operating Systems (CS 340 D)
Filesystems.
Chapter 11: File System Implementation
CS510 Operating System Foundations
File Systems Implementation
Chapter 11: File System Implementation
Chapter 14: File-System Implementation
Chapter 11: File System Implementation
Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

Advanced Operating Systems File Systems-I Prof. Muhammad Saeed

Advanced Operating Systems File Systems Files Directories & naming File system implementation Example file systems Advanced Operating Systems

Advanced Operating Systems Long-Term Information Storage Must store large amounts of data Gigabytes -> terabytes -> petabytes Stored information must survive the termination of the process using it (persistence) Lifetime can be seconds to years Must have some way of finding it! Multiple processes must be able to access the information concurrently Advanced Operating Systems

Advanced Operating Systems Naming files Important to be able to find files after they’re created Every file has at least one name Name can be Human-accessible: “solve.c”, “my drawing”, “Air Routes!”, “Speech Final Draft” Machine-usable: 4502, 33481 Case may or may not matter Depends on the file system Name may include information about the file’s contents Certainly does for the user (the name should make it easy to figure out what’s in it!) Computer may use part of the name to determine the file type Advanced Operating Systems

Typical file extensions Advanced Operating Systems

Advanced Operating Systems File structures Sequence of bytes Sequence of records 1 byte 1 record 12A 101 111 sab wm cm avg ejw elm br S02 F01 W02 Tree Advanced Operating Systems

Advanced Operating Systems File types Executable file Archive Advanced Operating Systems

Advanced Operating Systems Accessing a file Sequential access Read all bytes/records from the beginning Cannot jump around May rewind or back up, however Convenient when medium was magnetic tape Often useful when whole file is needed Random access Bytes (or records) read in any order Essential for database systems Read can be … Move file marker (seek), then read or … Read and then move file marker Advanced Operating Systems

Advanced Operating Systems File attributes Advanced Operating Systems

Advanced Operating Systems File operations Create: make a new file Delete: remove an existing file Open: prepare a file to be accessed Close: indicate that a file is no longer being accessed Read: get data from a file Write: put data to a file Append: like write, but only at the end of the file Seek: move the “current” pointer elsewhere in the file Get attributes: retrieve attribute information Set attributes: modify attribute information Rename: change a file’s name Advanced Operating Systems

Using file system calls Advanced Operating Systems

Using file system calls, continued Advanced Operating Systems

Advanced Operating Systems Memory-mapped files Program text Data Before mapping After mapping abc xyz Segmented process before mapping files into its address space Process after mapping Existing file abc into one segment Creating new segment for xyz Advanced Operating Systems

More on memory-mapped files Memory-mapped files are a convenient abstraction Example: string search in a large file can be done just as with memory! Let the OS do the buffering (reads & writes) in the virtual memory system Some issues come up… How long is the file? Easy if read-only Difficult if writes allowed: what if a write is past the end of file? What happens if the file is shared: when do changes appear to other processes? When are writes flushed out to disk? Clearly, easier to memory map read-only files… Advanced Operating Systems

Advanced Operating Systems Virtual File System Advanced Operating Systems

Advanced Operating Systems Directories Naming is nice, but limited Humans like to group things together for convenience File systems allow this to be done with directories (sometimes called folders) Grouping makes it easier to Find files in the first place: remember the enclosing directories for the file Locate related files (or just determine which files are related) Advanced Operating Systems

Single-level directory systems Root directory A abc A def B ghi C jkl One directory in the file system Example directory Contains 4 files (abc, def, ghi, jkl) owned by 3 different people: A, B, and C (owners shown in red) Problem: what if user B wants to create a file called abc? Advanced Operating Systems

Two-level directory system Root directory A foo A bar B foo B baz A B C C bar C foo C blah Solves naming problem: each user has her own directory Multiple users can use the same file name By default, users access files in their own directories Extension: allow users to access files in others’ directories Advanced Operating Systems

Hierarchical directory system Root directory A foo A Mom B foo B foo.tex A B C C bar C foo C blah Papers Photos Family A sunset A os.tex A kids B foo.ps Advanced Operating Systems

Advanced Operating Systems Unix directory tree Advanced Operating Systems

Operations on directories Create: make a new directory Delete: remove a directory (usually must be empty) Opendir: open a directory to allow searching it Closedir: close a directory (done searching) Readdir: read a directory entry Rename: change the name of a directory Similar to renaming a file Link: create a new entry in a directory to link to an existing file Unlink: remove an entry in a directory Remove the file if this is the last link to this file Advanced Operating Systems

File system implementation issues How are disks divided up into file systems? How does the file system allocate blocks to files? How does the file system manage free space? How are directories handled? How can the file system improve… Performance? Reliability? Advanced Operating Systems

Advanced Operating Systems Carving up the disk Master boot record Partition table Partition 1 Partition 2 Partition 3 Partition 4 Entire disk Boot block Super block Free space management Index nodes Files & directories Advanced Operating Systems

Contiguous allocation for file blocks D E F Free Contiguous allocation requires all blocks of a file to be consecutive on disk Problem: deleting files leaves “holes” Similar to memory allocation issues Compacting the disk can be a very slow procedure… Advanced Operating Systems

Contiguous allocation Data in each file is stored in consecutive blocks on disk Simple & efficient indexing Starting location (block #) on disk (start) Length of the file in blocks (length) Random access well-supported Difficult to grow files Must pre-allocate all needed space Wasteful of storage if file isn’t using all of the space Logical to physical mapping is easy blocknum = (pos / 1024) + start; offset_in_block = pos % 1024; Start=5 Length=2902 1 2 3 4 5 6 7 8 9 10 11 Advanced Operating Systems

Advanced Operating Systems Linked allocation 1 2 3 4 5 6 7 8 9 10 11 Start=9 End=4 Length=2902 Start=3 End=6 Length=1500 x File is a linked list of disk blocks Blocks may be scattered around the disk drive Block contains both pointer to next block and data Files may be as long as needed New blocks are allocated as needed Linked into list of blocks in file Removed from list (bitmap) of free blocks Advanced Operating Systems

Finding blocks with linked allocation Directory structure is simple Starting address looked up from directory Directory only keeps track of first block (not others) No wasted space - all blocks can be used Random access is difficult: must always start at first block! Logical to physical mapping is done by block = start; offset_in_block = pos % 1024; for (j = 0; j < pos / 1024; j++) { block = block->next; } Assumes that next pointer is stored at end of block May require a long time for seek to random location in file Advanced Operating Systems

Linked allocation using a RAM-based table A B 4 1 2 -2 3 5 6 -1 7 8 9 10 11 12 13 14 15 Links on disk are slow Keep linked list in memory Advantage: faster Disadvantages Have to copy it to disk at some point Have to keep in-memory and on-disk copy consistent Advanced Operating Systems

Advanced Operating Systems Using a block index for allocation 1 2 3 4 5 6 7 8 9 10 11 grades 4 4802 Name index size Store file block addresses in an array Array itself is stored in a disk block Directory has a pointer to this disk block Non-existent blocks indicated by -1 Random access easy Limit on file size? Advanced Operating Systems

Finding blocks with indexed allocation Need location of index table: look up in directory Random & sequential access both well-supported: look up block number in index table Space utilization is good No wasted disk blocks (allocate individually) Files can grow and shrink easily Overhead of a single disk block per file Logical to physical mapping is done by block = index[block % 1024]; offset_in_block = pos % 1024; Limited file size: 256 pointers per index block, 1 KB per file block -> 256 KB per file limit Advanced Operating Systems

Larger files with indexed allocation How can indexed allocation allow files larger than a single index block? Linked index blocks: similar to linked file blocks, but using index blocks instead Logical to physical mapping is done by index = start; blocknum = pos / 1024; for (j = 0; j < blocknum /255); j++) { index = index->next; } block = index[blocknum % 255]; offset_in_block = pos % 1024; File size is now unlimited Random access slow, but only for very large files Advanced Operating Systems

Two-level indexed allocation Allow larger files by creating an index of index blocks File size still limited, but much larger Limit for 1 KB blocks = 1 KB * 256 * 256 = 226 bytes = 64 MB Logical to physical mapping is done by blocknum = pos / 1024; index = start[blocknum / 256)]; block = index[blocknum % 256] offset_in_block = pos % 1024; Start is the only pointer kept in the directory Overhead is now at least two blocks per file This can be extended to more than two levels if larger files are needed... Advanced Operating Systems

Block allocation with extents Reduce space consumed by index pointers Often, consecutive blocks in file are sequential on disk Store <block,count> instead of just <block> in index At each level, keep total count for the index for efficiency Lookup procedure is: Find correct index block by checking the starting file offset for each index block Find correct <block,count> entry by running through index block, keeping track of how far into file the entry is Find correct block in <block,count> pair More efficient if file blocks tend to be consecutive on disk Allocating blocks like this allows faster reads & writes Lookup is somewhat more complex Advanced Operating Systems

Advanced Operating Systems Extents Extents replace the traditional block mapping scheme used by ext2/3 filesystems. An extent is a range of contiguous physical blocks, improving large file performance and reducing fragmentation. A single extent in ext4 can map up to 128 MiB of contiguous space with a 4 KiB block size.1 There can be 4 extents stored in the inode. When there are more than 4 extents to a file, the rest of the extents are indexed in an Htree. The ext4 filesystem can support volumes with sizes up to 1 exbibyte (EiB) and files with sizes up to 16 tebibytes (TiB). Stable system in 2008. Advanced Operating Systems

Advanced Operating Systems The Relationships Among Segments, Extents, and Data Blocks as implemented by Oracle Advanced Operating Systems

Advanced Operating Systems FS Name Year Introduced Original OS Max File Size Max FS Size Journaling FAT16 1983 MSDOS V2 4GB 16MB to 8GB N FAT32 1997 Windows 95 8GB to 2TB HPFS 1988 OS/2 2TB NTFS 1993 Windows NT 16EB Y HFS+ 1998 Mac OS 8EB ? UFS2 2002 FreeBSD 512GB to 32PB 1YB ext2 Linux 16GB to 2TB4 2TB to 32TB ext3 1999 ReiserFS3 2001 8TB8 16TB ReiserFS4 2005 XFS 1994 IRIX 9EB JFS AIX 512TB to 4PB VxFS 1991 SVR4.0 ZFS 2004 Solaris 10 Advanced Operating Systems

Advanced Operating Systems END Courtesy of University of PITTSBURGH Advanced Operating Systems