1 / 40

CS450/550 Operating Systems Lecture 6 File Systems

CS450/550 Operating Systems Lecture 6 File Systems. Palden Lama Department of Computer Science. Review: Summary of Chapter 5. OS responsibilities in I/O operations Protection and Scheduling CPU communicates with I/O devices I/O devices notify OS/CPU I/O software hierarchy

Télécharger la présentation

CS450/550 Operating Systems Lecture 6 File Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS450/550Operating SystemsLecture 6 File Systems Palden Lama Department of Computer Science

  2. Review: Summary of Chapter 5 • OS responsibilities in I/O operations • Protection and Scheduling • CPU communicates with I/O devices • I/O devices notify OS/CPU • I/O software hierarchy • Interrupt handlers • Device drivers • Buffering • Storage Systems • Disk head scheduling algorithms • Power Management • More reading: textbook 5.1 - 5.11

  3. 6.1 Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems Chapter 6: File Systems

  4. Long-term Information Storage Three essential requirements for long-term information storage • Must store large amounts of data • Information stored must survive the termination of the process using it • Multiple processes must be able to access the information concurrently What are users’ concerns of the file system? What are implementors’ concerns of the file system?

  5. File Naming • Files are an abstraction mechanism • two-part file names Typical file extensions.

  6. File Structures What files look like from programmers’ viewpoint? • Three kinds of file structures • Unstructured byte sequence (Unix and WinOS view) • Record sequence (early machines’ view) • Tree (mainframe view)

  7. File Types • Regular files • ASCII files or binary files • Directories • Character special files • Block special files

  8. File Access • Sequential access • read all bytes/records from the beginning • cannot jump around, could rewind or back up • convenient when medium was mag tape • Random access • bytes/records read in any order • essential for data base systems • read can be … • move file marker (seek), then read or … • read and then move file marker

  9. File Attributes Possible file attributes

  10. Create Delete Open Close Read Write Append Seek Get attributes Set Attributes Rename File Operations

  11. An Example Program Using File System Calls

  12. An Example Program Using File System Calls (cont.)

  13. Memory-Mapped Files • OS provide a way to map files into the address space of a running process; map() and unmap() • No read or write system calls are needed thereafter (a) Segmented process before mapping files into its address space (b) Process after mapping existing file abc into one segment creating new segment for xyz

  14. Directories: Single-Level Directory Systems • A single-level directory system is simple for implementation • contains 4 files • owned by 3 different people, A, B, and C What is the key problem with the single-level directory systems? Different users may use the same names for their files

  15. Two-level Directory Systems Letters indicate owners of the directories and files What additional operation required, compared with single-level directory systems? Login procedure What if a user has many files and wants to group them in logical way?

  16. Hierarchical Directory Systems A hierarchical directory system

  17. Path Names • Absolute path name • Relative path name A UNIX directory tree

  18. Create Delete Opendir Closedir Readdir Rename Link Unlink Directory Operations What are file system implementors’ concerns? How files & directories stored? How disk space is managed? How to make everything work efficiently and reliably?

  19. File System Implementation • File system layout • Most disks can be divided into one or more partitions • BIOS MBR (Master Boot Record) A possible file system layout How to keep track of which disk blocks go with which file?

  20. Implementing Files (1) – Contiguous Allocation • Pros: simple addressing and one-seek only reading • Cons: disk fragmentation (like Swapping) fit CD-ROM (a) Contiguous block allocation of disk space for 7 files (b) State of the disk after files D and E have been dynamically removed

  21. Implementing Files (2) – Linked List Allocation • Keep each file as a linked list of disk blocks • Pros: no space is lost due to disk fragmentation • Cons: how about random access? Storing a file as a linked list of disk blocks

  22. Implementing Files (3) – FAT (File Allocation Table) • FAT: a table in memory with the pointer word of each disk block • High utilization + easy random access, but too “FAT” maybe? Linked list allocation using a file allocation table in RAM Consider: A 20 GB disk 1 KB block size Each entry 3 B How much space for a FAT? How about paging it?

  23. Implementing Files (4) – I-nodes • i-node: a data structure listing the attributes and disk addresses of the file’s blocks; in memory when the corresponding file is open An example i-node Why i-node scheme requires much less space than FAT?

  24. Implementing Files (5) – Summary • How to find the disk blocks of a file? • Contiguous allocation: the disk address of the entire file • Linked list & FAT: the number of the first block • i-node: the number of the i-node • Who provides the information above? • The directory entry (based on the path name)

  25. Implementing Directories (1) • The directory entry, based on the path name, provides the information to find the disk blocks (a) A simple directory (MS-DOS/Windows) Fixed-size entries File names, attributes, and disk addresses in directory entry (b) Directory (UNIX); each entry just refers to an i-node, i-number returned …… What to do for few but long and variable-length file names?

  26. Implementing Directories (2) • Two ways of handling long and variable-length file names in directory (a) In-line: compaction and page fault. (b) In a heap: page fault

  27. Shared Files • How to let multiple users share files? File system containing a shared file What if directories contain the disk addresses?

  28. Shared Files in UNIX • UNIX utilizes i-node’ data structure • What if a file is removed by the owner? (a) Situation prior to linking; (b) After the link is created (c) After the original owner removes the file

  29. Shared Files – Symbolic Linking • A new file, created with type LINK, enters B’s directory • The file contains just the path name of the linked file • Con: extra overhead with each file access, parsing • Pro 1: Only when the owner removes the file, it is destroyed • Removing a symbolic link does not affect the file • Pro 2: networked file systems

  30. Block size Disk Space Management – Block Size • All file systems chop files to fixed-size non-adjacent blocks • Block size is a trade-off of space utilization and data rate • Three-step disk access • Dark line (left hand scale) gives data rate of a disk • Dotted line (right hand scale) gives disk space efficiency • All files 2KB

  31. Disk Space Management – Tracking Free Blocks • How to keep track of free blocks? (a) Storing the free list on a linked list. (b) A bit map

  32. Example of Tracking Free Blocks • Consider a 16-GB disk, 1-KB block size, 32-bit disk block number • if all blocks are empty, how many blocks in the free list and in the bit map, respectively? Which one uses less space? But what if the disk is nearly full? How much information should be stored in the memory for each scheme?

  33. Disk Space Management – Disk Quotas • An open file table in memory has attributes telling who the owner of an opened file is; and a per-user table contains the quota Quotas for keeping track of each user’s disk use

  34. File System Reliability • Physical dumping: starts at block 0, writes al the disk blocks onto the output tape in order • Logical dumping: starts one or more specified directories and recursively dumps all files and directories found there that have changed sine some given based date (e.g., the last backup from an incremental dump or system installation for a full dump)

  35. File System Consistency • File system states (a) consistent (b) missing block (c) duplicate block in free list (d) duplicate data block

  36. File System Performance - Caching • Cache: a collection of blocks that logically belong on the disk but are being kept in memory for performance reasons • Hash the device and disk address and look up the result in a hash table with collision chains • Cache references are relatively infrequent The block cache data structures with a bi-directional usage list Why LRU is undesirable when consistency is an issue if the system crashes?

  37. File System Performance – Caching II • Cache & Consistency • UNIX system call sync() every 30s • MS-DOS strategy write-through

  38. File System Performance – Block Read Ahead • Block Read Ahead works well for files that are being read sequentially • Spatial locality

  39. Bytes The Windows 98 File System (1) The extended MOS-DOS directory entry used in Windows 98

  40. Summary • Files and directories • File system implementation • Contiguous files • Linked lists • FAT • i-nodes • Disk space management • File system performance and consistency • More reading: textbook 6.1 - 6.6

More Related