120 likes | 311 Views
Week 9. March 4, 2004 Adrienne Noble. Important Dates. Homework 9 due Monday, March 8 Project 4 due Wednesday, March 10 Final Exam on Tuesday, March 16, 2:30-4:20pm. Questions?. Lecture Homework 9 Project 4. Review from last week. /foo/hello.c. The VFS.
E N D
Week 9 March 4, 2004 Adrienne Noble
Important Dates • Homework 9 due Monday, March 8 • Project 4 due Wednesday, March 10 • Final Exam on Tuesday, March 16, 2:30-4:20pm
Questions? • Lecture • Homework 9 • Project 4
Review from last week • /foo/hello.c
The VFS • Not written in C++, so we can’t use an abstract class • Defines structs for superblocks and inodes • File system must store all this information • Includes an extra field that the file system can use however it wants • Defines a struct with functions that the file system needs to implement • The file system can add additional helper functions
The Buffer Manager • Linux source is large, so these tools can help you find what you need • Cross Referencing Linux: http://lxr.linux.no/source/ • grep • Two pieces of the buffer manager • Data structures (struct buffer_head) • Actual data (pointed to by the b_data field in buffer_head)
For any given disk block, the buffer manager may be • Completely unaware of the block • Aware of the block’s information, but the block is not it memory • Have the block’s information and data in memory
Buffer Manager functions • bh = bread(dev, block, size) • Get the buffer_head for the given disk block, ensuring that the data is in memory and ready for use. Increments the ref count; always pair with a brelse. • bh = getblk(dev, block, size) • Get the buffer_head for the given disk block. Does not guarantee anything about the state of the actual data. Increments ref count; always pair with a brelse. • bh = get_hash_table(dev, block, size) • Find the buffer_head for the given block in the hash table. Does not guarantee anything about the state of the actual data. Increments ref count; always pair with a brelse.
More functions • ll_rw_block(rw, numbufs, bh[]) • Lock buffer, begin IO (either read of write), schedule a callback that will unlock buffer when IO finishes, and return (does not wait for IO completion – see wait_on_buffer). • wait_on_buffer(bh) • Wait for the buffer to be unlocked (e.g. read from disk to complete)
Still More… • mark_buffer_dirty(bh) • Mark the buffer modified • mark_buffer_uptodate(bh) • Indicate that the data pointed to be bh is valid • is_valid = buffer_uptodate(bh) • Return whether the bh points to valid data • brelse(bh) • “buffer release” - decrement the ref count of the given buffer
cse451fs functions • bh = cse451_bread(inode, block, create) • Similar to bread, but takes an inode and block number relative to the inode instead • bh = cse451_getblk(inode, block, create) • Similar to getblk, but takes an inode and block number • err = get_block(inode, block, &bh, create) • Fills in b_blocknr field in bh, allocating a new data block if necessary