CS703 - Advanced Operating Systems

Slides:



Advertisements
Similar presentations
4/8/14CS161 Spring FFS Recovery: Soft Updates Learning Objectives Explain how to enforce write-ordering without synchronous writes. Identify and.
Advertisements

Chapter 12: File System Implementation
Garbage collection David Walker CS 320. Where are we? Last time: A survey of common garbage collection techniques –Manual memory management –Reference.
More on File Management
Concepts about the file system 2. The disk structure 3. Files in disk – The ext2 FS 4. The Virtual File System (c) 2013, Prof. Jordi Garcia.
Free Space and Allocation Issues
CS4432: Database Systems II Hash Indexing 1. Hash-Based Indexes Adaptation of main memory hash tables Support equality searches No range searches 2.
Garbage Collection  records not reachable  reclaim to allow reuse  performed by runtime system (support programs linked with the compiled code) (support.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
CPSC 388 – Compiler Design and Construction
CS 1114: Data Structures – Implementation: part 1 Prof. Graeme Bailey (notes modified from Noah Snavely, Spring 2009)
Lecture 18 ffs and fsck. File-System Case Studies Local FFS: Fast File System LFS: Log-Structured File System Network NFS: Network File System AFS: Andrew.
Jonathan Walpole Computer Science Portland State University
File Systems Implementation
Files. System Calls for File System Accessing files –Open, read, write, lseek, close Creating files –Create, mknod.
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
Ceng Operating Systems
Memory Allocation and Garbage Collection. Why Dynamic Memory? We cannot know memory requirements in advance when the program is written. We cannot know.
File Systems Implementation. 2 Recap What we have covered: –User-level view of FS –Storing files: contiguous, linked list, memory table, FAT, I-nodes.
Crash recovery All-or-nothing atomicity & logging.
Lecture 17 FS APIs and vsfs. File and File Name What is a File? Array of bytes. Ranges of bytes can be read/written. File system consists of many files,
CS 333 Introduction to Operating Systems Class 19 - File System Performance Jonathan Walpole Computer Science Portland State University.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
SIMULATED UNIX FILE SYSTEM Implementation in C Tarek Youssef Bipanjit Sihra.
File System Implementation Chapter 12. File system Organization Application programs Application programs Logical file system Logical file system manages.
Chapter 4. INTERNAL REPRESENTATION OF FILES
CS 149: Operating Systems April 9 Class Meeting Department of Computer Science San Jose State University Spring 2015 Instructor: Ron Mak
CS 4284 Systems Capstone Godmar Back Disks & File Systems.
1 File Systems: Consistency Issues. 2 File Systems: Consistency Issues File systems maintains many data structures  Free list/bit vector  Directories.
1 Shared Files Sharing files among team members A shared file appearing simultaneously in different directories Share file by link File system becomes.
Chapter 4. INTERNAL REPRESENTATION OF FILES
File Systems Operating Systems 1 Computer Science Dept Va Tech August 2007 ©2007 Back File Systems & Fault Tolerance Failure Model – Define acceptable.
1 Chapter 4. INTERNAL REPRESENTATION OF FILES THE DESIGN OF THE UNIX OPERATING SYSTEM Maurice J. bach Prentice Hall.
CS333 Intro to Operating Systems Jonathan Walpole.
Lecture 21 LFS. VSFS FFS fsck journaling SBDISBDISBDI Group 1Group 2Group N…Journal.
UNIX File System (UFS) Chapter Five.
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.
CS 3204 Operating Systems Godmar Back Lecture 21.
File Systems 2. 2 File 1 File 2 Disk Blocks File-Allocation Table (FAT)
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]
4P13 Week 9 Talking Points
Lecture 20 FSCK & Journaling. FFS Review A few contributions: hybrid block size groups smart allocation.
Distributed File Systems Questions answered in this lecture: Why are distributed file systems useful? What is difficult about distributed file systems?
Using Alcoa to Specify a UNIX File System Specification of some structures and operations in a File System.
File System Performance CSE451 Andrew Whitaker. Ways to Improve Performance Access the disk less  Caching! Be smarter about accessing the disk  Turn.
CS 3204 Operating Systems Godmar Back Lecture 25.
Memory Management CSCI 2720 Spring What is memory management? “the prudent utilization of this scarce resource (memory), whether by conservation,
CHAPTER 4-3 FILE SYSTEM CONSISTENCY AND EFFICIENCY.
CSC 533: Programming Languages Spring 2016
Jonathan Walpole Computer Science Portland State University
CSC 533: Programming Languages Spring 2015
File System Structure How do I organize a disk into a file system?
CS703 - Advanced Operating Systems
CS 5204 Operating Systems Disks & File Systems Godmar Back.
Concepts of programming languages
Linked Lists.
File Systems Kanwar Gill July 7, 2015.
Lecture 20 LFS.
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Printed on Monday, December 31, 2018 at 2:03 PM.
File System Implementation
CSE 451 Fall 2003 Section 11/20/2003.
CS703 - Advanced Operating Systems
CS703 - Advanced Operating Systems
File System Performance
Garbage collection Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
Internal Representation of Files
Linked Lists.
CSC 533: Programming Languages Spring 2019
The File Manager Implementation issues
Presentation transcript:

CS703 - Advanced Operating Systems By Mr. Farhan Zaidi

Lecture No. 32

Reactive: reconstruct freelist on crash How? Mark and sweep garbage collection! Start at root directory Recursively traverse all objects, removing from free list Good: is a fixable error. Also fixes case of allocated objects marked as free. Bad: Expensive. requires traversing all live objects and makes reboot slow.

Deleting a file Unlink(“foo”) 1: traverse current working directory looking for “foo” if not there, or wrong permissions, return error 2: clear directory entry 3: decrement inode’s reference count 4: if count is zero, free inode and all blocks it points to

Bogus reference count R=2 R=1 Reference count too high? inode and its blocks will not be reclaimed (2 gig file = big trouble) what if we decrement count before removing pointer? Reference count too low real danger: blocks will be marked free when still in use major security hole: password file stored in “freed” blocks. Proactive: Never decrement reference counter before removing pointer to object. Do synchronous writes Reactive: fix with mark & sweep R=2 R=1

Creating a new file Our rule: never (persistently) point to a resource before it has been initialized Implication: file create 2 or 3 synchronous writes! Write 1: Write out the modified free list to disk. Wait. Write 2: Write out 0s to initialize inode. Wait. Write 3: write out directory block containing pointer to inode.

Growing a file write(fd, &c, 1) translate current file position (byte offset) into location in inode (or indirect block, double indirect, …) if inode already points to a block, modify the block and write back otherwise: (1) allocate a free block, (2) write the modified free list to disk, wait (3) write the newly allocated block to disk, wait (4) write the pointer (inode) to the new block to disk, wait

Conservatively moving a file Rule: never reset old pointer to object before a new pointer has been set mv foo bar (assume foo -> inode # 41) lookup foo in current working directory if does not exist or wrong permissions, return error lookup bar in current working directory if wrong permissions return error 0: increment inode 41’s reference count. Write inode to disk, Wait. 1: insert (“bar”, inode 41). , write bar directory block to disk, Wait. 2: destroy (“foo”, inode 41). Write foo directory block to disk, Wait. 3: decrement inode 41’s reference count, write inode to disk, wait costly: 3 synchronous writes!

Summary: the two fixable cases Case 1: Free list holds pointer to allocated block cause: crash during allocation or deallocation rule: make free list conservative free: nullify pointer before putting on free list allocate: remove from free list before adding pointer Case 2: Wrong reference count too high = lost memory (but safe) too low = reuse object still in use (very unsafe) cause: crash while forming or removing a link rule: conservatively set reference count to be high unlink: nullify pointer before reference count decrement link: increment reference count before adding pointer Alternative: ignore rules and fix on reboot.

FSCK: Reconstructing File System # mark and sweep + fix reference counts worklist := { root directory } while e := pop(worklist) # sweep down from roots foreach pointer p in e # if we haven’t seen p and p contains pointers, add if p.type != dataBlock and !seen{p} push(worklist, p); refs{p} = p.refcnt; # p’s notion of pointers to it seen{p} += 1; # count references to p freelist[p] = ALLOCATED; # mark not free foreach e in refs # fix reference counts if(seen{e} != refs{e}) e.refcnt = seen{e}; e.dirty = true;

Write ordering C A B sol’n have buffer cache provide ordering support Synchronous writes expensive sol’n have buffer cache provide ordering support Whenever block “a” must be written before block “b” insert a dependency Before writing any block, check for dependencies (when deadlock?) To eliminate dependency, synchronously write out each block in chain until done. Block B & C can be written immediately Block A requires block B be synchronously written first. B A C