Lab 4 File System CS140 February 27, 2015 Slides adapted from previous quarters
Logistics Lab 3 was due at noon today Lab 4 is due Friday, March 13
Overview Motivation Suggested Order of Implementation Buffer Cache Extensible Files Subdirectories System Calls
Motivation Limitations of the default Pintos file systems File sizes are specified and fixed at creation Only one directory. No subdirectories No synchronization No caches. Slow Let s fix it!
Suggested Order of Implementation Buffer caches Previous tests should still pass Extensible files File growth tests should pass Subdirectories directory tests should pass The persistence tests will not pass until extensible files & subdirectories are both implemented
Buffer Cache The default file system uses bounce buffers Replace it with a cache Limited to a cache with 64-blocks of data The free map could be permanently cached in memory Eviction algorithm should be at least as good as clock Should also implement read-ahead
Buffer Cache Use the write back scheme to ensure the consistency of the file system Write to the disk at the following times: Only for the blocks which are dirty A dirty block is evicted from the cache filesys_done() is called (i.e. when Pintos exits) Periodically flush all dirty blocks to the disk Can create background threads with thread_create() Can use timer_sleep() in Lab 1 as the timer
Buffer Cache: Synchronization Operations on different blocks should not block Operations on the same block should block only when the eviction occurs and disk I/O is involved Read-ahead and periodical flush should not block the calling thread run as background threads Creating a new kernel thread for each read-ahead request would be too slow
Inode Use an index structure with direct, indirect, and doubly indirect blocks You are welcome to choose a different scheme Should support 8MB files
File Growth Files can be expanded on write Beyond the current EOF seeking is fine reading returns no bytes writing extends the file Fill the gap between previous EOF and the start of write with zeros Could allocate real blocks for these zero blocks Or use sparse files, do not allocate until they are written
Files: Synchronization Multiple reads should not block each other Multiple writes should not block each other except when extending a file Extending a file and writing data should be atomic i.e. A reads and B writes non-zero data beyond EOF at the same time. A is not allowed to see any zeros. Operations on different files should never block each other
Directories: Expansion The default file system only support 16 files in root directory Your implementation should support enough files to fill the disk with zero-length files Exploit the similarities between extensible files and extensible directories
Subdirectory The default file system has only one root directory Your implementation should Support arbitrary depth of subdirectories Support as many directories as can fit on the disk Support the lookup of absolute and relative paths Current working directory is needed Used for lookup by relative paths Inherits from the parent process at creation, but not shared
Paths Collapse multiple slashes a//b == a/b Support absolute and relative paths /a!= a except for root directory Support special directories. and.. a/b == a/../a/b Trailing slashes are only valid on directories a/ == a if a is a directory a/!= a if a is a file
Directories: Synchronization Operations on different directories should not block each other Operations on the same directory can be sequential
System Calls Create new system calls chdir changes current working directory mkdir creates a new directory readdir reads the next entry in the directory isdir returns whether this FD is a directory inumber returns the inode number of a FD
System Calls Update some existing system calls open needs to be able to open directories close needs to be able to close directories remove needs to be able to remove directories Can only remove empty directories You may decide whether to allow the deletion of an open directory If it s allowed, no files can be opened or created in the deleted dir All system calls that support paths must support both absolute and relative paths