Comp111: Operating Systems
Classroom Exercise 17
Filesystem Structure
Fall 2017

group member 1: ____________________________ login: ______________
group member 2: ____________________________ login: ______________
group member 3: ____________________________ login: ______________
group member 4: ____________________________ login: ______________
group member 5: ____________________________ login: ______________
group member 6: ____________________________ login: ______________
group member 7: ____________________________ login: ______________
group member 8: ____________________________ login: ______________

  1. Suppose that you have an Ext2 disk (as described in lecture) organized as 8192-byte blocks. What kinds of blocks are read from and/or written to disk when one creates a text file containing just "hello\n"? Hint: you must update the inode table and containing directory, too! It's all just disk!









  2. In the previous question, suppose that the power fails without a disk page cache flush. How many states can the file be in as a result of the power-fail?









  3. (Advanced) Would writing to the filesystem be as efficient without the page cache in place? Why or why not?
  4. Suppose we have the multiple indirection scheme described in class, so that an inode contains the following fields:
     
    int first_thirteen[13]; 
    int *single_indirection; 
    int **double_indirection; 
    
    Please interpret each of these ints as a physical offset of a block on disk.
    1. Give an expression for the offset of the 5th block in the file (from block 0).





    2. Give an expression for the offset of the 15th block in the file (from block 0).





    3. Assuming that the blocks are 8192 bytes long, ints are four bytes long, and an indirection block contains 4096 ints, give an expression for the offset of the 5000th block in the file (from block 0). The length of ints is 2 bytes. I messed this up in the original handout.





    4. I claim that accessing the 5000th block is O(1). Why?





  5. (Advanced) To save power, some current disk drives use a built-in flash drive as a journal instead of a stripe on disk. The hard disk is spun up and the journal flushed only when the journal is nearly full. Otherwise the hard disk stays spun down. This saves power when writing files but not when reading files. Why?