intro to dfs assignment. announcements dfs (pa4) part 1 will be out over the weekend part 1 due...

33
Intro to DFS assignment

Upload: primrose-joseph

Post on 18-Jan-2018

222 views

Category:

Documents


0 download

DESCRIPTION

You build a DFS! 1. Lock server, at-most-once RPC semantics 2. Implement extent server; create/lookup/readdir FUSE ops 3. Implement read/write/open/setattr 4. Implement mkdir/unlink, integrate locks! (optional)

TRANSCRIPT

Page 1: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Intro to DFS assign-ment

Page 2: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Announcements• DFS (PA4) Part 1 will be out over the weekend• Part 1 Due 10/30 11:59 pm • Part 2 12/7 11:59 pm• Part 3 12/14 11:59 pm• Part 4 (optional extra credit) 12/23 11:59pm

Page 3: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

You build a DFS!1. Lock server, at-most-once RPC semantics2. Implement extent server; create/lookup/readdir FUSE ops3. Implement read/write/open/setattr4. Implement mkdir/unlink, integrate locks! (op-tional)

Page 4: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Programming Assignment: YFS• Yet-another File System. :)• Simpler version of what we just talked about: only

one extent server (you don’t have to implement Petal; single lock server)

Page 5: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Part 1: lock server• Implementing the lock server• Provide mutual exclusion to ‘lock resources’•Using pthread mutexes, condition variables!

• Implementing at-most-once RPC semantics

Page 6: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Providing mutualexclusion over the net• In the assignment: lock is a 64-bit number•Client might:• acquire(lock_a); do work; release(lock_a);•You must create the lock if it doesn’t yet exist on the server

Page 7: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Example tester% ./lock_tester 3772 simple lock client acquire a release a acquire a release a acquire a acquire b release b release a test2: client 0 acquire a release a test2: client 2 acquire a release a ...

Page 8: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

What’s provided• Simple RPC framework, skeleton for lockserver code•What it does: handles setting up sockets, mar-shalling/unmarshalling basic data types, sending over TCP (whew)•What it doesn’t: does not keep track of RPC re-quest state; duplicate RPCs are invoked twice! :(

Page 9: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Example RPC call

Page 10: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Your job for lock server

Page 11: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Lossy• RPC_LOSSY: drops, duplicates, delays.• Run lock_tester with RPC_LOSSY=0

• Now try running it with RPC_LOSSY=5• Simulates network failure• it should hang or error. FAIL!

Page 12: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Why?• No at-most-once RPC semantics• implemented...yet.

• If reply dropped, duplicate sent: acquire(a), acquire(a)..............................

Page 13: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Strawman•Remember every RPC call•Client sends a unique RPC identifier

•Remember every RPC reply•To avoid invoking the actual function

•What’s the problem with this ap-proach?

Page 14: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Sliding window RPCs• Assume the following sent by client:marshall m1 << clt nonce // client id << svr nonce // server id<< proc // procedure number (bind, acquire, etc).<< myxid // unique request id for this RPC<< xid_rep_window.front() // Last out-of-order RPC reply received<< req.str(); // Data• But we need some additional info from the client

Page 15: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

At the end% export RPC_LOSSY=5% ./lock_server 3772 &% ./lock_tester 3772...all tests passed% ./rpctestsimple_tests...all tests passed

Page 16: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Helper functions• Method_thread

Page 17: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Code reading

Page 18: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Part 2• Extent server• FUSE!• Semantics of filesystem calls

Page 19: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Programming Assignment: YFS• Part 1: lock server• Part 2: extent server

Page 20: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

The extent server•Don’t have to deal with storing data on disk: you will store contents in memory•map<inode, std::string>

•All yfs_client operations synchronize with same extent server

Page 21: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Getattr (given)

Page 22: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Your job• Extend extent_server to support• put(extentid, string, ...)• get(extentid, string&)• remove(extentid, ...)• See extent_protocol.h and extent_smain.cc• Later you will likely add more!• Must properly deal with ctime/atime/mtime

Page 23: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Data formats at extent server•Directories maintain a mapping of filenames to inode numbers• if root (inode 1) has two files “file1”, “file2”: get(1) might return• file1:3983293923• file2:3384927553

• You can choose how you store this information as a string

Page 24: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Metadata time mgmt• atime: access time• Updated whenever file contents accessed• Set to 0 on file creation

• mtime: modification time• Updated when file contents modified

• ctime: change time• Updated whenever metadata modified

Page 25: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

FUSE• http://fuse.sourceforge.net/

Page 26: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Mapping FUSE functions

Page 27: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Example• Fuse.cc• void• fuseserver_getattr(

Page 28: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

CREATE/MKNOD•Generate inode number (rand())• This is called on files: make sure inode has MSB set to 1• Directories have MSB set to 0

• Create the file at the extent server• Add the name to inode mapping to parent info at extent server

Page 29: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Lookup•Given: filename, parent inode• Look through parent directory list• Find inode that maps from filename• Getattr on that inode

• Fill in return structure (fuse_entry_param)

Page 30: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Readdir• Given: inode number for a directory• Get filename:inode mapping for that dir• For each filename:inode pair call dirbuf_add(...) function

provided

Page 31: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

• You will be able to create empty files in the root direc-tory and do an ls on the root• You’re not yet storing files...

Page 32: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Testing

• ./start.sh• ./test-lab-2.pl• ./stop.sh• test-lab-2.pl creates a bunch of files, tests whether the files the script created are there

Page 33: Intro to DFS assignment. Announcements DFS (PA4) Part 1 will be out over the weekend Part 1 Due 10/30 11:59 pm Part 2 12/7 11:59 pm Part 3 12/14 11:59

Parts 3 and 4• Part 3: You implement open, read, write, setattr• Part 4: You implement mkdir, unlink, and locking