4 3 Network File System NFS 202212 1

  • Slides: 32
Download presentation
4. 3 Network File System (NFS) 2022/1/2 1

4. 3 Network File System (NFS) 2022/1/2 1

NFS architecture vnodes 2022/1/2 2

NFS architecture vnodes 2022/1/2 2

Vnode n Data fields (struct vnode) v_flag v_data vfsp v_op v_count v_type v_vfsmountedhere …

Vnode n Data fields (struct vnode) v_flag v_data vfsp v_op v_count v_type v_vfsmountedhere … n inode/rnode Methods (struct vnodeops) vop_open vop_lookup vop_read vop_mkdir vop_getaddr … FS-dependent implementation of vnodeops FS-independent part 2022/1/2 3

vnode/vfs framework Client application System call interface vnode nsf_vnodeops NFS client code 2022/1/2 v_data

vnode/vfs framework Client application System call interface vnode nsf_vnodeops NFS client code 2022/1/2 v_data v_ops r-node (contains file handle) RPC call RPC client RPC reply interface 4

NFS server implementation (ufs server) vnode ufs-inode v_data v_ops NFS server code ufs_vnodeops ufs

NFS server implementation (ufs server) vnode ufs-inode v_data v_ops NFS server code ufs_vnodeops ufs code RPC call RPC reply server interface 2022/1/2 local disk 5

VFS layer FS ID 2022/1/2 inode # inode generation # 6

VFS layer FS ID 2022/1/2 inode # inode generation # 6

Server interface (text Fig. 8. 9) n lookup(dirfh, path-name) fh, attr u n attr=

Server interface (text Fig. 8. 9) n lookup(dirfh, path-name) fh, attr u n attr= mode (e. g. , read-only), user_id, group_id, size, access time, file system ID, etc. create(dirfh, name, attr) fh, attr u Argument and return attr are different sets n remove(dirfh, name) status read(fh, offset, count) attr, data write(fh, offset, count, data) attr rename(dirfh, name, 2 dirfh, 2 name) status setattr(fh, attr) attr n New in V 4 n n 2022/1/2 7

NFS daemons Client write( ) 2 1 nfsiod Server User Kernel nfsd 3 4

NFS daemons Client write( ) 2 1 nfsiod Server User Kernel nfsd 3 4 5 • Asynchronous writes (1, 2) at client User Kernel Disk • Write (3) on close, synch, and every 30 sec • Server either (a) puts it in cache, or (b) writes-through. • Write-through (synchronous writes) (3, 4, 5) on commit (=close) 2022/1/2 8

Read-ahead and delayed write 2022/1/2 9

Read-ahead and delayed write 2022/1/2 9

Cache consistency 2022/1/2 10

Cache consistency 2022/1/2 10

TTL (Time-to-Live) and validation file directory 2022/1/2 TTL=3 sec delayed write (< 30 s

TTL (Time-to-Live) and validation file directory 2022/1/2 TTL=3 sec delayed write (< 30 s ec) 0 sec 3 = L T T hru write-t Server 11

Stateless server (V 3) 2022/1/2 12

Stateless server (V 3) 2022/1/2 12

Pathname lookup in V 3 2022/1/2 13

Pathname lookup in V 3 2022/1/2 13

Review: Mounting in vfs/vnode architecture vfs Root file system rootvfs ROOT / vnode belongs

Review: Mounting in vfs/vnode architecture vfs Root file system rootvfs ROOT / vnode belongs to covers vfs Mounted file system mounted ROOT / /usr here vnode Vnodes for mounted-on directories and mounted roots nov 16 are kept in MM. 2022/1/2 14

Mounting example Server 1 2022/1/2 Server 2 15

Mounting example Server 1 2022/1/2 Server 2 15

Mounting on top of imported directory Server 1 (S 1) Importing from S 1

Mounting on top of imported directory Server 1 (S 1) Importing from S 1 2022/1/2 Server 2 (S 2) Importing from S 2 16

Two file systems at the same server Server 1 disk 0 / usr u

Two file systems at the same server Server 1 disk 0 / usr u 1 f 2 f 1 Similarly for importing. / disk 1 f 3 2022/1/2 local Server 1 exports /usr and /usr/local (Exporting /usr doesn’t automatically export /usr/local). f 4 In V 3, readdir on fh for local returns its original contents 17

continued … f 3 != f 3 Lookup for /usr/local/f 3 Cannot pass entire

continued … f 3 != f 3 Lookup for /usr/local/f 3 Cannot pass entire path to Server 1. / usr u 1 f 1 2022/1/2 local f 2 f 3 mount –t nfs Server 1: /usr mount –t nfs Server 2: /local /usr/local 18

Mount permission 2022/1/2 19

Mount permission 2022/1/2 19

Automount 2022/1/2 20

Automount 2022/1/2 20

Automount example n n n /etc/auto_home contains u tiko server 1: /export/home/tiko u john

Automount example n n n /etc/auto_home contains u tiko server 1: /export/home/tiko u john server 2: /export/home/john When /home/tiko is accessed for the first time on any machine (at log-in time), server 1: /export/home/tiko is mounted on local /home/tiko This way, I can log on to any machine and have the same /home/tiko environment. 2022/1/2 21

Important NFS V 3 properties 2022/1/2 22

Important NFS V 3 properties 2022/1/2 22

Version 4 2022/1/2 23

Version 4 2022/1/2 23

Version 4 pathname lookup orange: /export/vol 1 n Request putrootfh lookup “export/vol 1” getfh

Version 4 pathname lookup orange: /export/vol 1 n Request putrootfh lookup “export/vol 1” getfh Get fh for /export/vol 1 getattr n Response putrootfh OK CURFH lookup OK CURFH getfh OK getattr OK n Returned FH for orange: /export/vol 1 can be cached at client’s machine. n 2022/1/2 24

Reading orange: /export/vol 1/home/data putfh fh fh is file handle for /export/vol 1 open

Reading orange: /export/vol 1/home/data putfh fh fh is file handle for /export/vol 1 open “home/data” read at 0 for 1024 putfh OK CURFH open OK CURFH read OK (1024 bytes) n NFS V 4 itself has no concept of mounting. 2022/1/2 25

Pathname lookup failure n n ls /export/home/fake putrootfh lookup “export” “home” “fake” getfh getattr

Pathname lookup failure n n ls /export/home/fake putrootfh lookup “export” “home” “fake” getfh getattr If fake doesn’t exist, response would be putfh OK CURFH lookup FAILED 2022/1/2 26

Component-wise pathname lookup n Client can then resort to component-bycomponent resolution putrootfh lookup “export”

Component-wise pathname lookup n Client can then resort to component-bycomponent resolution putrootfh lookup “export” getfh getattr lookup “home” getfh getattr lookup “fake” getfh getattr 2022/1/2 n Response from server putrootfh OK CURFH lookup OK CURFH getfh OK getattr OK lookup FAILED 27

Component-wise lookup 2022/1/2 28

Component-wise lookup 2022/1/2 28

Compound procedure 2022/1/2 29

Compound procedure 2022/1/2 29

V 4 file locking n n lock: lockt: locku: renew: 2022/1/2 30

V 4 file locking n n lock: lockt: locku: renew: 2022/1/2 30

V 4 server crash recovery 2022/1/2 31

V 4 server crash recovery 2022/1/2 31

Duplicates elimination upon RPC failures n a) b) c) 2022/1/2 Three situations for handling

Duplicates elimination upon RPC failures n a) b) c) 2022/1/2 Three situations for handling retransmissions. The request is still in progress The reply has just been returned The reply had been sent some time ago, but was lost. 32