资源预览内容
第1页 / 共72页
第2页 / 共72页
第3页 / 共72页
第4页 / 共72页
第5页 / 共72页
第6页 / 共72页
第7页 / 共72页
第8页 / 共72页
第9页 / 共72页
第10页 / 共72页
亲,该文档总共72页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
Operating Systems,Department of Computer Science & Technology Tsinghua University,Lecture 16: File System,Outline,Basic Concepts File System & File File Descriptor Directory File Aliasing Types of File System Virtual File System Data Block Caching Data Structures for Open Files File Allocation Free-Space List Management of Multiple Disks RAID,File System and File,File system: an OS abstraction for using persistent storage Organizing, manipulating, navigating, accessing, and retrieving data on the persistent storage Most computer systems have file systems PCs, servers, laptops iPod, Tivo/set-top-box, cellphones/PDAs Google is made possible by a file system File: an OS abstraction for a unit of related data in the file system,File System Functionality,Allocate disk storage to files Managing file blocks (which blocks belong to which file) Managing free space (which blocks are free) Allocation algorithms (policies) Manage the collection of files Locate files and their contents Naming: interface to find files by name Most common: hierarchical file system(分层的文件系统) File system type (different ways to organize files) Provide convenience and features Protection: layers to keep data secure Reliability/Durability: Keeping of files durable despite crashes, media failures, attacks, etc(可靠,持久),File and Blocks,File attributes Name, type, location, size, protection, creator, creation time, last-modified-time, File header On-storage metadata(元数据) storing information on each file Storing the file attributes Tracking which blocks of the storage belong at which offsets within the logical file structure,Outline,Basic Concepts File System & File File Descriptor Directory File Aliasing Types of File System Virtual File System Data Block Caching Data Structures for Open Files File Allocation Free-Space List Management of Multiple Disks RAID,Open File and File Descriptor,File use model User program must “open” a file before use f = open(name, flag); = read(f, ); close(f); Kernel keeps track of open files for each process OS maintains an open file table per process An open file descriptor is an index into this table,open file table,file descriptor,File Descriptor,Several pieces of data are needed to manage open files: File pointer: pointer to last read/write location, per process that has the file open File-open count: counter of number of times a file is open to allow removal of data from open-file table when last processes closes it Disk location of the file: cache of data access information(作为文件的一个属性) Access rights: per-process access mode information,User vs System View of a File,Users view: Durable data structures At system call interface Collection of bytes (UNIX) Doesnt matter to system what kind of data structures you want to store on disk! OSs internal view Collection of blocks (a block is a logical transfer unit, while a sector is the physical transfer unit) Block size sector size; in UNIX, block size is 4KB,Translating from User to System View,What happens if user says: give me bytes 212? Fetch block corresponding to those bytes Return just the correct portion of the block What about: write bytes 212? Fetch block Modify portion Write out Block Everything inside File System is in whole size blocks For example, getc(), putc() buffers something like 4096 bytes, even if interface is one byte at a time,Access Patterns,How do users access files? Need to know type of access patterns user is likely to throw at system Sequential access: bytes read in order Almost all file access are of this flavor(eg.系统备份,查病毒) Random Access: read/write element out of middle Less frequent, but still important. For example, virtual memory backing file: page of memory stored in file Want this to be fast dont want to have to read all bytes to get to the middle of the file Content-based Access: by characteristics(比如在系统文件中找特定文件) Many systems dont provide this; instead, databases are built on top of disk access to index content (requires efficient random access),Example of Index and Relative Files,File Internal Structure,No structure Sequence of words, bytes Simple record structure Lines Fixed length Variable length Complex structures Formatted document (e.g., MS Word, PDF) Executable file ,File Sharing and Access Control,Sharing of files on multi-user systems is desirable Access control Who can have what type accesses to what files Types of access: read, write, execute, delete, list, etc. Per-file access control list (ACL) Unix model User IDs identify users, allowing permissions and protections to be per-user Group IDs allow users to be in groups, permitting group access rights,Consistency Semantics,Specify how multiple users/clients are to access a shared file simultaneously Similar to process synchronization algorithms Less complex due to disk I/O and network latency Unix file system (UFS) semantics Writes to an open file are visible immediately to other users of the same open file Sharing file pointer to allow multi
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号