Files and File Systems 1 CS502 Spring 2006 Files and File Systems CS502 – Operating Systems Spring 2006.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

Chapter 4 : File Systems What is a file system?
File Systems.
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.
Chapter 10: File-System Interface
File Management Chapter 12. File Management A file is a named entity used to save results from a program or provide data to a program. Access control.
File System Interface CSCI 444/544 Operating Systems Fall 2008.
Long-term Information Storage
Dr. Kalpakis CMSC 421, Operating Systems. Fall File-System Interface.
File SystemsCS-502 Fall File Systems CS-502 Operating Systems Fall 2006 (Slides include materials from Operating System Concepts, 7 th ed., by Silbershatz,
Operating Systems File Systems CNS 3060.
CS-3013 & CS-502, Summer 2006 File Systems1 Review – I/O subsystems OS responsibilities to device drivers Device API, buffering, naming, interrupt handling.
FilesCS-4513, D-Term Introduction to File Systems CS-4513 Distributed Computing Systems (Slides include materials from Operating System Concepts,
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File Systems Topics –File –Directory –File System Implementation Reference: Chapter 5: File Systems Operating Systems Design and Implementation (Second.
CS 104 Introduction to Computer Science and Graphics Problems Operating Systems (4) File Management & Input/Out Systems 10/14/2008 Yang Song (Prepared.
1 Operating Systems Chapter 7-File-System File Concept Access Methods Directory Structure Protection File-System Structure Allocation Methods Free-Space.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
Ceng Operating Systems
6/24/2015B.RamamurthyPage 1 File System B. Ramamurthy.
CS 333 Introduction to Operating Systems Class 17 - File Systems Jonathan Walpole Computer Science Portland State University.
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
10.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 10: File-System Objectives To discuss file-system design tradeoffs, including.
1 Friday, July 07, 2006 “Vision without action is a daydream, Action without a vision is a nightmare.” - Japanese Proverb.
File Management.
1 Course Outline Processes & Threads CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Networks, Protection and Security.
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
File Concept §Contiguous logical address space §Types: l Data: Numeric Character Binary l Program.
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,
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
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.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 10-1: File Systems Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
File System Implementations CS-502 Fall File System Implementations CS-502, Operating Systems Fall 2007 (Slides include materials from Operating.
Introduction to FilesCS-502 Fall Introduction to File Systems CS-502 Operating Systems Fall 2007 (Slides include materials from Operating System.
File Systems CSCI What is a file? A file is information that is stored on disks or other external media.
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
CS333 Intro to Operating Systems Jonathan Walpole.
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.
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.
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.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
CS 346 – Chapter 11 File system –Files –Access –Directories –Mounting –Sharing –Protection.
CE Operating Systems Lecture 17 File systems – interface and implementation.
File System Implementations CS-502 (EMC) Fall File System Implementations CS-502, Operating Systems Fall 2009 (EMC) (Slides include materials from.
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).
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.
File Systems cs550 Operating Systems David Monismith.
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.
Lecture Topics: 11/29 File System Interface –Files and Directories –Access Methods –Protection –Consistency.
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
W4118 Operating Systems Instructor: Junfeng Yang.
SVBIT SUBJECT:- Operating System TOPICS:- File Management
File-System Management
Chapter 11: File System Implementation
Filesystems.
Chapter 11: File System Implementation
CS510 Operating System Foundations
Implementation of File Systems
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
File System Implementations
Introduction to File Systems
Lecture 4: File-System Interface
Lecture Topics: 11/20 HW 7 What happens on a memory reference Traps
Chapter 5 File Systems -Compiled for MCA, PU
Presentation transcript:

Files and File Systems 1 CS502 Spring 2006 Files and File Systems CS502 – Operating Systems Spring 2006

Files and File Systems 2 CS502 Spring 2006 File – an abstraction A (potentially) large amount of information or data that lives a (potentially) very long time Often much larger than the memory of the computer Often much longer than any computation (Usually) organized as a linear array of bytes or blocks Internal structure is imposed by application (Occasionally) blocks may be variable length (Often) requiring concurrent access by multiple processes Even by processes on different machines!

Files and File Systems 3 CS502 Spring 2006 File Systems and Disks User view –File is a named persistent collection of data OS & file system view –File is collection of disk blocks –File System maps file names and offsets to disk blocks Outline for this section –Files –Directories –Implementation of Files –Implementation of Directories

Files and File Systems 4 CS502 Spring 2006 Fundamental ambiguity Is the file the “container of the information” or the “information” itself? Almost all systems confuse the two. Almost all people confuse the two.

Files and File Systems 5 CS502 Spring 2006 Example – Suppose that you me a document Later, how do either of us know that we are using the same version of the document? Windows/Outlook/Exchange: Time-stamp is a pretty good indication that they are Time-stamps preserved on copy, drag and drop, transmission via , etc. Unix By default, time-stamps not preserved on copy, ftp, , etc. Time-stamp associated with container, not with information

Files and File Systems 6 CS502 Spring 2006 Rule of Thumb Almost always, application (and user) thinks in terms of the information Most systems think in terms of containers Professional Guidance: Be aware of the distinction, even when the system is not

Files and File Systems 7 CS502 Spring 2006 Attributes of Files Name: –Although the name may not be what you think it is! Type: –May be encoded in the name (e.g.,.cpp,.txt) Dates: –Creation, updated, last accessed, etc. –(Usually) associated with container Size: –Length in number of bytes; occasionally rounded up Protection: –Owner, group, etc. –Authority to read, update, extend, etc. Locks: –For managing concurrent access …

Files and File Systems 8 CS502 Spring 2006 File Metadata Attributes of the file maintained by the file system –Separate from file itself –Possibly attached to the file –Used by OS in variety of ways

Files and File Systems 9 CS502 Spring 2006 File Types

Files and File Systems 10 CS502 Spring 2006 Non-attribute of files – Location Example 1: mv ~lauer/project1.doc ~cs502/public_html/S06 Example 2: –System moves file from disk block 10,000 to disk block 20,000 –System restores a file from backup

Files and File Systems 11 CS502 Spring 2006 Attribute anomaly – Unix File Naming ln ~lauer/project1.doc ~cs502/public_html/S06 ln ~lauer/project1.doc NewProject1.doc Unix hard links allow one file to have more than one name and/or location –The real name of a Unix file is its i-node – an internal name known only to the OS Hard links are rarely used in modern Unix practice –Usually safe to regard last element of path as name

Files and File Systems 12 CS502 Spring 2006 Operations on Files Open, Close Gain or relinquish access to a file OS returns a file handle – an internal data structure letting it cache internal information needed for efficient file access Read, Write, Truncate Read: return a sequence of n bytes from file Write: replace n bytes in file, and/or append to end Truncate: throw away all but the first n bytes of file Seek, Tell Seek: reposition file pointer for subsequent reads and writes Tell: get current file pointer Create, Delete: Conjure up a new file; or blow away an existing one

Files and File Systems 13 CS502 Spring 2006 File – a very powerful abstraction Documents, code Databases Very large, possibly spanning multiple disks Streams Input, output, keyboard, display Pipes Virtual memory backing store …

Files and File Systems 14 CS502 Spring 2006 File Access Methods Sequential access –Read all bytes/records from the beginning –Cannot jump around, could possibly rewind or back up –Convenient when medium was magnetic tape Random access –Bytes/records read in any order –Essential for data base systems –Read can be … move file pointer (seek), then read or … read and then move file marker

Files and File Systems 15 CS502 Spring 2006 File Access Methods (continued) Keyed or indexed access – access items in file based on the contents of an (part of an) item in the file –Provided in older commercial operating systems (IBM ISAM) –(Today) usually handled separately by database applications in modern systems

Files and File Systems 16 CS502 Spring 2006 Directory – A Special Kind of File A tool for users & applications to organize and find files User-friendly names Names that are meaningful over long periods of time The data structure for OS to locate files (i.e., containers) on disk

Files and File Systems 17 CS502 Spring 2006 Directory structures Single level –One directory per system, one entry pointing to each file –Small, single-user or single-use systems PDA, cell phone, etc. Two-level –Single “master” directory per system –Each entry points to one single-level directory per user –Uncommon in modern operating systems Hierarchical –Any directory entry may point to Another directory Individual file –Used in most modern operating systems

Files and File Systems 18 CS502 Spring 2006 Directory Organization – Hierarchical

Files and File Systems 19 CS502 Spring 2006 Directory Considerations Efficiency – locating a file quickly. Naming – convenient to users. Separate users can use same name for separate files. The same file can have different names for different users. Names need only be unique within a directory Grouping – logical grouping of files by properties e.g., all Java programs, all games, …

Files and File Systems 20 CS502 Spring 2006 More on Hierarchical Directories Most systems support idea of current (working) directory –Absolute names – fully qualified from root of file system /usr/group/foo.c –Relative names – specified with respect to working directory foo.c –A special name – the working directory itself “.” Modified Hierarchical – Acyclic Graph (no loops) and General Graph –Allow directories and files to have multiple names –Links are file names (directory entries) that point to existing (source) files

Files and File Systems 21 CS502 Spring 2006 Links Hard links: bi-directional relationship between file names and file –A hard link is directory entry that points to a source file’s metadata –Metadata counts the number of hard links (including the source file) – link reference count –Link reference count is decremented when a hard link is deleted –File data is deleted and space freed when the link reference count is 0 Symbolic (soft) links: uni-directional relationship between a file name and the file –Directory entry points to new metadata –Metadata points to the source file –If the source file is deleted, the link pointer is invalid

Files and File Systems 22 CS502 Spring 2006 Path Name Translation Assume that I want to open “/home/lauer/foo.c” fd = open(“/home/lauer/foo.c”, O_RDWR); File system does the following –Opens directory “/” – the root directory is in a known place on disk –Search root directory for the directory home and get its location –Open home and search for the directory lauer and get its location –Open lauer and search for the file foo.c and get its location –Open the file foo.c –Note that the process needs the appropriate permissions Some file systems spend a lot of time walking down directory paths –This is why open calls are separate from other file operations –File System attempts to cache prefix lookups to speed up common searches

Files and File Systems 23 CS502 Spring 2006 Directory Operations Create: Make a new directory Add, Delete entry: Invoked by file create & destroy, directory create & destroy Find, List: Search or enumerate directory entries Rename: Change name of an entry without changing anything else about it Link, Unlink: Add or remove entry pointing to another entry elsewhere Introduces possibility of loops in directory graph Destroy: Removes directory; must be empty

Files and File Systems 24 CS502 Spring 2006 More on Directories Fundamental mechanism for interpreting file names in an operating system Orphan: a file not named in any directory Cannot be opened by any application (or even OS) (Often) does not even have name! Tools FSCK – check & repair file system, find orphans Delete_on_close – when number of links reaches zero Special directory entry: “..”  parent in hierarchy Essential for maintaining integrity of directory system Useful for relative naming

Files and File Systems 25 CS502 Spring 2006 Implementation of Files Map file abstraction to physical disk blocks Some goals –Efficient in time, space, use of disk resources –Fast enough for application requirements –Effective for a wide variety of file sizes Many small files (< 1 page) Huge files (100’s of gigabytes, terabytes, spanning disks) Everything in between

Files and File Systems 26 CS502 Spring 2006 File Allocation Schemes Contiguous –Blocks of file stored in consecutive disk sectors –Directory points to first entry, others derived by math Linked –Blocks of file scatter across disk, as linked list –Directory points to first entry, follow link to find others Indexed –Separate index block contains pointers to file blocks –Directory points to index block, lookup all blocks

Files and File Systems 27 CS502 Spring 2006 Contiguous Allocation Ideal for large, static files –Databases, fixed system structures, OS code –CD-ROM, DVD Simple address calculation –Block address  sector address Fast multi-block reads and writes –Minimize seeks between blocks Prone to fragmentation when … Files come and go Files change size –Similar to unpaged virtual memory

Files and File Systems 28 CS502 Spring 2006 Bad Block Management – Contiguous Allocation Bad blocks must be concealed Foul up the block-to-sector calculation Methods Spare sectors in each track, remapped by formatting Look-aside list of bad sectors –Check each sector request against hash table –If present, substitute a replacement sector behind the scene Handling Disk controller, invisible to OS Lower levels of OS file system, invisible to appl.

Files and File Systems 29 CS502 Spring 2006 Contiguous Allocation – Extents Extent: a contiguously allocated subset of a file Directory entry contains –(For file with one extent) the extent itself –(For file with multiple extents) pointer to an extent block describing multiple extents Advantages –Speed, ease of address calculation of contiguous file –Avoids (some of) the fragmentation issues –Can be extended to support files across multiple disks Disadvantages –Degenerates to indexed allocation in Unix-like systems

Files and File Systems 30 CS502 Spring 2006 Linked Allocation Blocks scattered across disk –Each block contains pointer to next block –Directory points to first and last blocks –Sector header block: Pointer to next block ID and block number of file

Files and File Systems 31 CS502 Spring 2006 Linked Allocation Advantages –No space fragmentation –Easy to create, extend files –Ideal for lots of small files Disadvantages –Lots of disk arm movement –Space taken up by links –Sequential access only!

Files and File Systems 32 CS502 Spring 2006 Variation on Linked Allocation – File Allocation Table Instead of a link on each block, put all links in one table –the FAT (File Allocation Table) –fixed place on disk One entry per physical block in disk –Directory points to first & last blocks of file –Each block points to next block (or EOF)

Files and File Systems 33 CS502 Spring 2006 FAT File Systems Advantages –Advantages of Linked File System –FAT can be cached in memory –Searchable at CPU speeds, pseudo-random access Disadvantages –Limited size, not suitable for very large disks –FAT cache describes entire disk, not just open files! –Not fast enough for large databases Used in MS-DOS, early Windows systems

Files and File Systems 34 CS502 Spring 2006 Disk Defragmentation Re-organize blocks in disk so that file is (mostly) contiguous Linked or FAT organization preserved Minimizes disk arm movement during sequential accesses

Files and File Systems 35 CS502 Spring 2006 Bad Block Management – Linked and FAT Systems In OS:– format all sectors of disk Don’t reserve any spare sectors Allocate bad blocks to a hidden file for the purpose If a block becomes bad, append to the hidden file Advantages Very simple No look-aside or sector remapping needed Totally transparent without any hidden mechanism

Files and File Systems 36 CS502 Spring 2006 Indexed Allocation i-node: –Part of file metadata –Data structure lists the sector address of each block of file Advantages –True random access –Only i-nodes of open files need to be cached –Supports small and large files

Files and File Systems 37 CS502 Spring 2006 Unix i-nodes – Part of File Metadata Direct blocks: –Pointers to first n sectors Single indirect table: –Extra block containing pointers to blocks n+1.. n+m Double indirect table: –Extra block containing single indirect blocks …

Files and File Systems 38 CS502 Spring 2006 Indexed Allocation Access to every block of file is via i-node Bad block management –Same as Linked/FAT systems Disadvantage –Not as fast a contiguous allocation for large databases

Files and File Systems 39 CS502 Spring 2006 Next time Implementing Directories Other “disk” systems –CD-ROM –RAID (Redundant Array of Inexpensive Disks) Stable Storage Log File Systems