Presentation is loading. Please wait.

Presentation is loading. Please wait.

Project 6 Project 6 Supplemental Lecture Joe Mongeluzzi Jason Zhao Cornell CS 4411, November 30, 2012.

Similar presentations


Presentation on theme: "Project 6 Project 6 Supplemental Lecture Joe Mongeluzzi Jason Zhao Cornell CS 4411, November 30, 2012."— Presentation transcript:

1 Project 6 Project 6 Supplemental Lecture Joe Mongeluzzi Jason Zhao Cornell CS 4411, November 30, 2012

2 Project 6 Administrative Information  CS4410 MP4 is optional for 4411 students.  Project 6 due Friday, December 7th at 11:59 PM.  Office hours will be held this weekend and next week.  Unless otherwise noted on the website.  All regrade requests will get a response.

3 Project 6 General Notes  These slides generally reveal implementation hints.  You do not have to follow the implementation we describe here!  Consider following the hints only if you are stuck.  Focus on correctness first, then performance later.  mkfs and fsck should be minithread programs.  Compile them as separate programs.  Don’t make mkfs or fsck function calls in your minifile implementation.

4 Project 6 Getting started  They are set inside main(), before minithread_system_initialize() is called. int main(int argc, char** argv) { use_existing_disk=0; disk_name = “disk0”; disk_flags = DISK_READWRITE; disk_size = 1000; minithread_system_initialize(entrypoint, NULL); } void minithread_system_initialize(proc_t mainproc, arg_t arg) { disk_initialize(&disk); install_disk_handler(disk_handler); }

5 Project 6 On-disk data structures  One disk block for superblock.  May use one block per inode.  Packing more than one inode per block is more efficient and a little more difficult.  Concurrency-related structures should not be on disk.  Reference counters, locks etc.  “Pointers” on the disk refer to disk block number.  Or inode numbers if multiple per block.

6 Project 6 magic no. size of disk root inode first free inode first free data block type size direct ptr indirect ptr dir inode nameblock no. nameblock no. nameblock no. nameblock no. direct ptr indirect ptr direct ptr indirect ptr next free block next free block type size direct ptr indirect ptr data nameblock no. The Big Picture superblockfile datafile inodedir data free block

7 Project 6 magic no.: 4411 size of disk: 1000 blocks root inode: 1 first free inode free data block: 103 type: DIR_INODE size: 3 entries direct ptr: 100 0 0 block 1..1.1 abc.txt2 0 next free block: 104 next free Block: 105 Type: FILE_INODE size: 12 bytes direct ptr: 102 0 0 Hello world! 0 The Big Picture block 0block 102block 2block 100 block 103 0 … block 999

8 Project 6 magic number size of disk root inode first free inode first free data block superblock Superblock  Use disk block 0 for the superblock.  Root inode field contains the value 1.  Since that inode is located at disk block 1

9 Project 6  You can use the same structure for file and directory inodes.  Size: number of directory entries if inode is a directory.  Size: number of bytes of a file if inode is a file inode. inode type size direct ptr 1 direct ptr 2 direct ptr n inode indirect ptr Inodes

10 Project 6  This is just a table with 2 columns.  Directory data blocks are stored in the region of disk reserved for data blocks.  You can’t tell from this table if a certain entry is a file or a directory.  No indirect pointers in this block. directory data block nameinode ptr name inode ptr name inode ptr name inode ptr nameinode ptr name inode ptr Directory Data Blocks nameinode ptr

11 Project 6  Use the same data structure for free inodes and data blocks.  Just store an integer that points to the next free block.  If the next free block says 0, there are no more free blocks after this.  Returning new blocks to the list: Append or prepend? ptr to next free block free block Free Blocks

12 Project 6  Structs you may want:  Superblock  Inode  Directory data block  Free data block  File data block?  How big should each struct be? Data structures for blocks struct superblock { // members of superblock here }

13 Project 6 Data structures for blocks  Can apply trick we’ve seen before: struct superblock { union { struct { // Members of superblock here } data; char padding[DISK_BLOCK_SIZE]; } }

14 Project 6  You can cast the struct into a char* and directly use it in disk read and write operations.  The struct is of size DISK_BLOCK_SIZE, so you will read/write exactly one block.  No need to worry about padding. Benefits

15 Project 6 Variations  Remember: you don’t have to follow our suggestions.  As long as your file system is reasonable and concurrent.  Describe your implementation in the README file.  More than one inode per block.  Double/triple indirect pointers, similar to Linux.  Bitmap instead of a free list.  Different structures for blocks.

16 Project 6  Constricting free expansion for the number of directory entries or file size. However:  Directory and file sizes will not exceed 2 32 bytes (4Gb).  Storing names in inodes.  Storing directory data or indirect blocks in the inode- reserved section of the disk. Unacceptable variations

17 Project 6 Concurrency  Create some in-memory protection structures.  Must be dynamically allocated since disk_size is a variable.  Our suggestion: one ‘big lock’ for metadata accesses that can potentially span multiple inodes.  One lock per inode for file updates.  Lock this inode when performing reading/writing, but release it as soon as you can.  Some way to handle delete of an open directory/file

18 Project 6 Need more implementation hints?  The Design of the UNIX Operating System, Maurice J. Bach.  Lots of information available online.

19 Project 6 Parting Quote “Good design comes from experience. Experience comes from bad design.” -Theodore von Karman

20 Project 6 Questions? Questions


Download ppt "Project 6 Project 6 Supplemental Lecture Joe Mongeluzzi Jason Zhao Cornell CS 4411, November 30, 2012."

Similar presentations


Ads by Google