Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

File System for Principle Computer Operating Systems - Slides | CSE 120, Study notes of Computer Science

Material Type: Notes; Professor: Voelker; Class: Princ/Computer Operating Systm; Subject: Computer Science & Engineering; University: University of California - San Diego; Term: Fall 2004;

Typology: Study notes

2009/2010

Uploaded on 03/28/2010

koofers-user-jkw
koofers-user-jkw 🇺🇸

10 documents

1 / 15

Toggle sidebar

Related documents


Partial preview of the text

Download File System for Principle Computer Operating Systems - Slides | CSE 120 and more Study notes Computer Science in PDF only on Docsity! 1 CSE 120 Principles of Operating Systems Fall 2004 Lecture 12: File Systems Geoffrey M. Voelker November 15, 2004 CSE 120 – Lecture 12 – File Systems 2 © 2004 Geoffrey M. Voelker File Systems First we’ll discuss properties of physical disks Structure Performance Scheduling Then we’ll discuss how we build file systems on them Files Directories Sharing Protection File System Layouts File Buffer Cache Read Ahead 2 November 15, 2004 CSE 120 – Lecture 12 – File Systems 3 © 2004 Geoffrey M. Voelker Disks and the OS Disks are messy physical devices: Errors, bad blocks, missed seeks, etc. The job of the OS is to hide this mess from higher level software Low-level device control (initiate a disk read, etc.) Higher-level abstractions (files, databases, etc.) The OS may provide different levels of disk access to different clients Physical disk (surface, cylinder, sector) Logical disk (disk block #) Logical file (file block, record, or byte #) November 15, 2004 CSE 120 – Lecture 12 – File Systems 4 © 2004 Geoffrey M. Voelker Physical Disk Structure Disk components Platters Surfaces Tracks Sectors Cylinders Arm Heads Arm Heads Track Platter Surface Cylinder Sector 5 November 15, 2004 CSE 120 – Lecture 12 – File Systems 9 © 2004 Geoffrey M. Voelker Disk Scheduling (2) In general, unless there are request queues, disk scheduling does not have much impact Important for servers, less so for PCs Modern disks often do the disk scheduling themselves Disks know their layout better than OS, can optimize better Ignores, undoes any scheduling done by OS November 15, 2004 CSE 120 – Lecture 12 – File Systems 10 © 2004 Geoffrey M. Voelker File Systems File systems Implement an abstraction (files) for secondary storage Organize files logically (directories) Permit sharing of data between processes, people, and machines Protect data from unwanted access (security) 6 November 15, 2004 CSE 120 – Lecture 12 – File Systems 11 © 2004 Geoffrey M. Voelker Files A file is data with some properties Contents, size, owner, last read/write time, protection, etc. A file can also have a type Understood by the file system » Block, character, device, portal, link, etc. Understood by other parts of the OS or runtime libraries » Executable, dll, souce, object, text, etc. A file’s type can be encoded in its name or contents Windows encodes type in name » .com, .exe, .bat, .dll, .jpg, etc. Unix encodes type in contents » Magic numbers, initial characters (e.g., #! for shell scripts) November 15, 2004 CSE 120 – Lecture 12 – File Systems 12 © 2004 Geoffrey M. Voelker Basic File Operations Unix creat(name) open(name, how) read(fd, buf, len) write(fd, buf, len) sync(fd) seek(fd, pos) close(fd) unlink(name) NT CreateFile(name, CREATE) CreateFile(name, OPEN) ReadFile(handle, …) WriteFile(handle, …) FlushFileBuffers(handle, …) SetFilePointer(handle, …) CloseHandle(handle, …) DeleteFile(name) CopyFile(name) MoveFile(name) 7 November 15, 2004 CSE 120 – Lecture 12 – File Systems 13 © 2004 Geoffrey M. Voelker File Access Methods Some file systems provide different access methods that specify different ways for accessing data in a file Sequential access – read bytes one at a time, in order Direct access – random access given block/byte number Record access – file is array of fixed- or variable-length records, read/written sequentially or randomly by record # Indexed access – file system contains an index to a particular field of each record in a file, reads specify a value for that field and the system finds the record via the index (DBs) What file access method does Unix, NT provide? Older systems provide more complicated methods November 15, 2004 CSE 120 – Lecture 12 – File Systems 14 © 2004 Geoffrey M. Voelker Directories Directories serve two purposes For users, they provide a structured way to organize files For the file system, they provide a convenient naming interface that allows the implementation to separate logical file organization from physical file placement on the disk Most file systems support multi-level directories Naming hierarchies (/, /usr, /usr/local/, …) Most file systems support the notion of a current directory Relative names specified with respect to current directory Absolute names start from the root of directory tree 10 November 15, 2004 CSE 120 – Lecture 12 – File Systems 19 © 2004 Geoffrey M. Voelker Protection File systems implement some kind of protection system Who can access a file How they can access it More generally… Objects are “what”, subjects are “who”, actions are “how” A protection system dictates whether a given action performed by a given subject on a given object should be allowed You can read and/or write your files, but others cannot You can read “/etc/motd”, but you cannot write it November 15, 2004 CSE 120 – Lecture 12 – File Systems 20 © 2004 Geoffrey M. Voelker Representing Protection Access Control Lists (ACL) For each object, maintain a list of subjects and their permitted actions Capabilities For each subject, maintain a list of objects and their permitted actions rwrwCharlie r-wBob rw-rwAlice /three/two/one Subjects Objects ACL Capability 11 November 15, 2004 CSE 120 – Lecture 12 – File Systems 21 © 2004 Geoffrey M. Voelker ACLs and Capabilities The approaches differ only in how the table is represented What approach does Unix use? Capabilities are easier to transfer They are like keys, can handoff, does not depend on subject In practice, ACLs are easier to manage Object-centric, easy to grant, revoke To revoke capabilities, have to keep track of all subjects that have the capability – a challenging problem ACLs have a problem when objects are heavily shared The ACLs become very large Use groups (e.g., Unix) November 15, 2004 CSE 120 – Lecture 12 – File Systems 22 © 2004 Geoffrey M. Voelker File System Layout How do file systems use the disk to store files? File systems define a block size (e.g., 4KB) Disk space is allocated in granularity of blocks A “Master Block” determines location of root directory Always at a well-known disk location Often replicated across disk for reliability A free map determines which blocks are free, allocated Usually a bitmap, one bit per block on the disk Also stored on disk, cached in memory for performance Remaining disk blocks used to store files (and dirs) There are many ways to do this 12 November 15, 2004 CSE 120 – Lecture 12 – File Systems 23 © 2004 Geoffrey M. Voelker Disk Layout Strategies Files span multiple disk blocks How do you find all of the blocks for a file? 1. Contiguous allocation » Like memory » Fast, simplifies directory access » Inflexible, causes fragmentation, needs compaction 2. Linked structure » Each block points to the next, directory points to the first » Good for sequential access, bad for all others 3. Indexed structure (indirection, hierarchy) » An “index block” contains pointers to many other blocks » Handles random better, still good for sequential » May need multiple index blocks (linked together) November 15, 2004 CSE 120 – Lecture 12 – File Systems 24 © 2004 Geoffrey M. Voelker Unix Inodes Unix inodes implement an indexed structure for files Also store metadata info (protection, timestamps, length, ref count…) Each inode contains 15 block pointers First 12 are direct blocks (e.g., 4 KB blocks) Then single, double, and triple indirect … 0 12 13 14 1 … … … (Metadata) (1) (2) (3)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved