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
11 MANAGING DISKS AND FILE SYSTEMS Chapter 3. Chapter 3: Managing Disks and File Systems2 OVERVIEW Monitor and configure disks Monitor, configure, and.
File Management.
Session 8: Virtual Memory management
More on File Management
Chapter 6 File Systems 6.1 Files 6.2 Directories
Chapter 6: File Systems.
File Systems 1Dennis Kafura – CS5204 – Operating Systems.
1 CMPT 300 Introduction to Operating Systems File Systems Sample Questions.
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.
File Systems Examples.
Chapter 11: File System Implementation
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
File System Implementation
File System Implementation CSCI 444/544 Operating Systems Fall 2008.
File Systems Implementation
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
Ceng Operating Systems
File System Structure §File structure l Logical storage unit l Collection of related information §File system resides on secondary storage (disks). §File.
Chapter 12: File System Implementation
File Systems. Main Points File layout Directory layout.
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.
1 File Systems Chapter Files 6.2 Directories 6.3 File system implementation 6.4 Example file systems.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Operating Systems Mehdi Naghavi Spring 1386.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
OSes: 11. FS Impl. 1 Operating Systems v Objectives –discuss file storage and access on secondary storage (a hard disk) Certificate Program in Software.
1 File systems Files Directories & naming File system implementation Example file systems.
ReiserFS Hans Reiser
Free Space Management.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 12: File System Implementation File System Structure File System Implementation.
File System Implementation
Module 4.0: File Systems File is a contiguous logical address space.
File Systems Security File Systems Implementation.
12.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Chapter 12: File System Implementation Chapter 12: File System Implementation.
Disk & File System Management Disk Allocation Free Space Management Directory Structure Naming Disk Scheduling Protection CSE 331 Operating Systems Design.
Page 112/7/2015 CSE 30341: Operating Systems Principles Chapter 11: File System Implementation  Overview  File system structure – layered, block based.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File System Implementation.
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.
Lecture 10 Page 1 CS 111 Summer 2013 File Systems Control Structures A file is a named collection of information Primary roles of file system: – To store.
1 Pertemuan 22 Implementasi Sistem File Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
Operating Systems 1 K. Salah Module 4.0: File Systems  File is a contiguous logical address space (of related records)  Access Methods  Directory Structure.
11.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles 11.5 Free-Space Management Bit vector (n blocks) … 012n-1 bit[i] =  1  block[i]
Operating Systems Files, Directory and File Systems Operating Systems Files, Directory and File Systems.
W4118 Operating Systems Instructor: Junfeng Yang.
Fall 2011 Nassau Community College ITE153 – Operating Systems 1 Session 5 Files.
File-System Management
File System Implementation
Jonathan Walpole Computer Science Portland State University
File-System Implementation
Chapter 11: File System Implementation
FileSystems.
File System Structure How do I organize a disk into a file system?
Chapter 11: File System Implementation
Filesystems.
Chapter 11: File System Implementation
CS510 Operating System Foundations
Chapter 11: File System Implementation
Directory Structure A collection of nodes containing information about all files Directory Files F 1 F 2 F 3 F 4 F n Both the directory structure and the.
Overview: File system implementation (cont)
File-System Structure
Chapter 14: File-System Implementation
Chapter 11: File System Implementation
Chapter 6 File Systems 6.1 Files 6.2 Directories
Presentation transcript:

Advanced Operating Systems File Systems-II Prof. Muhammad Saeed

Managing free space: bit vector Keep a bit vector, with one entry per file block Number bits from 0 through n-1, where n is the number of file blocks on the disk If bit[j] == 0, block j is free If bit[j] == 1, block j is in use by a file (for data or index) If words are 32 bits long, calculate appropriate bit by: wordnum = block / 32; bitnum = block % 32; Search for free blocks by looking for words with bits unset (words != 0xffffffff) Easy to find consecutive blocks for a single file Bit map must be stored on disk, and consumes space Assume 4 KB blocks, 8 GB disk => 2M blocks 2M bits = 221 bits = 218 bytes = 256KB overhead Advanced Operating Systems

Managing free space: linked list Use a linked list to manage free blocks Similar to linked list for file allocation No wasted space for bitmap No need for random access unless we want to find consecutive blocks for a single file Difficult to know how many blocks are free unless it’s tracked elsewhere in the file system Difficult to group nearby blocks together if they’re freed at different times Less efficient allocation of blocks to files Files read & written more because consecutive blocks not nearby Advanced Operating Systems

Issues with free space management OS must protect data structures used for free space management OS must keep in-memory and on-disk structures consistent Update free list when block is removed: change a pointer in the previous block in the free list Update bit map when block is allocated Caution: on-disk map must never indicate that a block is free when it’s part of a file Solution: set bit[j] in free map to 1 on disk before using block[j] in a file and setting bit[j] to 1 in memory New problem: OS crash may leave bit[j] == 1 when block isn’t actually used in a file New solution: OS checks the file system when it boots up… Managing free space is a big source of slowdown in file systems Advanced Operating Systems

What’s in a directory? Two types of information File names File metadata (size, timestamps, etc.) Basic choices for directory information Store all information in directory Fixed size entries Disk addresses and attributes in directory entry Store names & pointers to index nodes (i-nodes) games attributes mail news research Storing all information in the directory Using pointers to index nodes Advanced Operating Systems

Advanced Operating Systems Directory structure Structure Linear list of files (often itself stored in a file) Simple to program Slow to run Increase speed by keeping it sorted (insertions are slower!) Hash table: name hashed and looked up in file Decreases search time: no linear searches! May be difficult to expand Can result in collisions (two files hash to same location) Tree Fast for searching Easy to expand Difficult to do in on-disk directory Name length Fixed: easy to program Variable: more flexible, better for users Advanced Operating Systems

Handling long file names in a directory Advanced Operating Systems

Advanced Operating Systems Sharing files Root directory A foo ? ??? B foo A B C C bar C foo C blah Papers Photos Family A sunset A os.tex A kids B lake Advanced Operating Systems

Advanced Operating Systems Solution: use links A creates a file, and inserts into her directory B shares the file by creating a link to it A unlinks the file B still links to the file Owner is still A (unless B explicitly changes it) a.tex Owner: A Count: 1 Owner: A Count: 2 b.tex A B Advanced Operating Systems

Advanced Operating Systems Managing disk space Dark line (left hand scale) gives data rate of a disk Dotted line (right hand scale) gives disk space efficiency All files 2KB Advanced Operating Systems

Advanced Operating Systems Disk quotas Advanced Operating Systems

Advanced Operating Systems Hard and Soft Limits The hard block limit is the absolute maximum amount of disk space that a user or group can use. Once this limit is reached, no further disk space can be used. The soft block limit defines the maximum amount of disk space that can be used. However, unlike the hard limit, the soft limit can be exceeded for a certain amount of time. That time is known as the grace period. The grace period can be expressed in seconds, minutes, hours, days, weeks, or months. A warning is given if soft quota exceeds the limit. Advanced Operating Systems

Backing up a file system A file system to be dumped Squares are directories, circles are files Shaded items, modified since last dump Each directory & file labeled by i-node number Advanced Operating Systems

Bitmaps used in a file system dump Advanced Operating Systems

Checking the file system for consistency Consistent Missing (“lost”) block Duplicate block in free list Duplicate block in two files Advanced Operating Systems

Advanced Operating Systems File system cache Many files are used repeatedly Option: read it each time from disk Better: keep a copy in memory File system cache Set of recently used file blocks Keep blocks just referenced Throw out old, unused blocks Same kinds of algorithms as for virtual memory More effort per reference is OK: file references are a lot less frequent than memory references Goal: eliminate as many disk accesses as possible! Repeated reads & writes Files deleted before they’re ever written to disk Advanced Operating Systems

File block cache data structures Advanced Operating Systems

Advanced Operating Systems Grouping data on disk Advanced Operating Systems

Log-structured file systems The basic idea is to structure the entire disk as a log. All writes are initially buffered in memory, and periodically all the buffered writes are written to the disk in a single segment, at the end of the log. Opening a file now consists of using the map to locate the i-node for the file. Once the i-node has been located, the addresses of the blocks can be found from it. All of the blocks will themselves be in segments, somewhere in the log. Advanced Operating Systems

Log-structured file systems Trends in disk & memory Faster CPUs Larger memories Result More memory -> disk caches can also be larger Increasing number of read requests can come from cache Thus, most disk accesses will be writes LFS structures entire disk as a log All writes initially buffered in memory Periodically write these to the end of the disk log When file opened, locate i-node, then find blocks Issue: what happens when blocks are deleted? Advanced Operating Systems

Journaling file systems While log-structured file systems are an interesting idea, they are not widely used, in part due to their being highly incompatible with existing file systems. Nevertheless, one of the ideas inherent in them, robustness in the face of failure, can be easily applied to more conventional file systems. The basic idea in journaling file system is to keep a log of what the file system is going to do before it does it, so that if the system crashes before it can do its planned work, upon rebooting the system can look in the log to see what was going on at the time of the crash and finish the job. Such file systems, called journaling file systems, are actually in use. Microsoft's NTFS file system and the Linux ext3 and ReiserFS file systems use journaling. Advanced Operating Systems

Unix Fast File System indexing scheme • Direct pointers . inode data protection mode owner & group timestamps size block count single indirect double indirect triple indirect link count Advanced Operating Systems

Advanced Operating Systems More on Unix FFS First few block pointers kept in directory Small files have no extra overhead for index blocks Reading & writing small files is very fast! Indirect structures only allocated if needed For 4 KB file blocks (common in Unix), max file sizes are: 48 KB in directory (usually 12 direct blocks) 1024 * 4 KB = 4 MB of additional file data for single indirect 1024 * 1024 * 4 KB = 4 GB of additional file data for double indirect 1024 * 1024 * 1024 * 4 KB = 4 TB for triple indirect Maximum of 5 accesses for any file block on disk 1 access to read inode & 1 to read file block Maximum of 3 accesses to index blocks Usually much fewer (1-2) because inode in memory Advanced Operating Systems

Advanced Operating Systems Directories in FFS inode number record length name length name Directory Directories in FFS are just special files Same basic mechanisms Different internal structure Directory entries contain File name I-node number Other Unix file systems have more complex schemes Not always simple files… Advanced Operating Systems

Advanced Operating Systems CD-ROM file system Advanced Operating Systems

Directory entry in MS-DOS Advanced Operating Systems

MS-DOS File Allocation Table Block size FAT-12 FAT-16 FAT-32 0.5 KB 2 MB 1 KB 4 MB 2 KB 8 MB 128 MB 4 KB 16 MB 256 MB 1 TB 8 KB 512 MB 2 TB 16 KB 1024 MB 32 KB 2048 MB Advanced Operating Systems

Windows 98 directory entry & file name Bytes Checksum Advanced Operating Systems

Storing a long name in Windows 98 Long name stored in Windows 98 so that it’s backwards compatible with short names Short name in “real” directory entry Long name in “fake” directory entries: ignored by older systems OS designers will go to great lengths to make new systems work with older systems… Advanced Operating Systems

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