filesystem reliability sockets intro
play

Filesystem Reliability + Sockets Intro 1 last time extents - PowerPoint PPT Presentation

Filesystem Reliability + Sockets Intro 1 last time extents non-binary trees on disk extra copies of data two or more FATs, two or more superblocks mirroring erasure coding : redundancy without full copies examples of RAID 4/5 careful


  1. promise: will perform logged updates redo logging: fjle creation no partial operation to real data recovery reclaim space in log inode twice already done? — okay, setting “commit” redo any operation with “commit” ignore any operation with no read log and… (after system reboots/recovers) fjle created crash after commit ? fjle not created write to log transaction steps: crash before commit ? “garbage collection” reclaim space in log update directory inode update fjle inode update directory entry update fjle data blocks in any order: write to log “commit transaction” normal operation update directory inode (size, time) direcotry entry, inode to write data blocks to create 15

  2. promise: will perform logged updates redo logging: fjle creation no partial operation to real data recovery reclaim space in log inode twice already done? — okay, setting “commit” redo any operation with “commit” ignore any operation with no read log and… (after system reboots/recovers) fjle created crash after commit ? fjle not created write to log transaction steps: crash before commit ? “garbage collection” reclaim space in log update directory inode update fjle inode update directory entry update fjle data blocks in any order: write to log “commit transaction” normal operation update directory inode (size, time) direcotry entry, inode to write data blocks to create 15

  3. redo logging: fjle creation write to log transaction steps: recovery reclaim space in log inode twice already done? — okay, setting “commit” redo any operation with “commit” ignore any operation with no read log and… (after system reboots/recovers) fjle created crash after commit ? no partial operation to real data fjle not created crash before commit ? “garbage collection” reclaim space in log update directory inode update fjle inode update directory entry update fjle data blocks in any order: write to log “commit transaction” normal operation update directory inode (size, time) direcotry entry, inode to write data blocks to create 15 promise: will perform logged updates

  4. promise: will perform logged updates redo logging: fjle creation no partial operation to real data recovery reclaim space in log inode twice already done? — okay, setting “commit” redo any operation with “commit” ignore any operation with no read log and… (after system reboots/recovers) fjle created crash after commit ? fjle not created write to log transaction steps: crash before commit ? “garbage collection” reclaim space in log update directory inode update fjle inode update directory entry update fjle data blocks in any order: write to log “commit transaction” normal operation update directory inode (size, time) direcotry entry, inode to write data blocks to create 15

  5. promise: will perform logged updates redo logging: fjle creation no partial operation to real data recovery reclaim space in log inode twice already done? — okay, setting “commit” redo any operation with “commit” ignore any operation with no read log and… (after system reboots/recovers) fjle created crash after commit ? fjle not created write to log transaction steps: crash before commit ? “garbage collection” reclaim space in log update directory inode update fjle inode update directory entry update fjle data blocks in any order: write to log “commit transaction” normal operation update directory inode (size, time) direcotry entry, inode to write data blocks to create 15

  6. idempotency logged operations should be okay to do twice = idempotent bad example: increment inode link count good example: overwrite inode with new inode value as long as last committed inode value in log is right… good example: overwrite data block with new value 16 good example: set inode link count to 4

  7. redo logging summary write intended operation to the log before ever touching ‘real’ data in format that’s safe to do twice write marker to commit to the log if exists, the operation will be done eventually actually update the real data 17

  8. redo logging and fjlesystems fjlesystems that do redo logging are called journalling fjlesystems 18

  9. the xv6 journal transaction ready for next transaction 4 clear log header ) (if number of blocks redone on recovery 3 write data (commits transaction) 2 write log header 1 write changed blocks start: num blocks = 0 no transaction otherwise: not committed or non- 0 : committed data of number of blocks (one sector) log header xv6 log (one transaction) … non-log block non-log block … … second block (log copy) fjrst block (log copy) … location for second block location for fjrst block 19

  10. the xv6 journal transaction ready for next transaction 4 clear log header ) (if number of blocks redone on recovery 3 write data (commits transaction) 2 write log header 1 write changed blocks start: num blocks = 0 no transaction otherwise: not committed or non- 0 : committed data of number of blocks (one sector) log header xv6 log (one transaction) … non-log block non-log block … … second block (log copy) fjrst block (log copy) … location for second block location for fjrst block 19

  11. the xv6 journal transaction ready for next transaction 4 clear log header ) (if number of blocks redone on recovery 3 write data (commits transaction) 2 write log header 1 write changed blocks start: num blocks = 0 no transaction otherwise: not committed or non- 0 : committed data of number of blocks = 0 (one sector) log header xv6 log (one transaction) … non-log block non-log block … … second block (log copy) fjrst block (log copy) … location for second block location for fjrst block 19

  12. the xv6 journal transaction ready for next transaction 4 clear log header ) (if number of blocks redone on recovery 3 write data (commits transaction) 2 write log header 1 write changed blocks start: num blocks = 0 no transaction otherwise: not committed or non- 0 : committed data of number of blocks = 0 (one sector) log header xv6 log (one transaction) … non-log block non-log block … … second block (log copy) fjrst block (log copy) … location for second block location for fjrst block 19

  13. the xv6 journal transaction ready for next transaction 4 clear log header ) (if number of blocks redone on recovery 3 write data (commits transaction) 2 write log header 1 write changed blocks start: num blocks = 0 no transaction otherwise: not committed or non- 0 : committed data of (one sector) log header xv6 log (one transaction) … non-log block non-log block … … second block (log copy) fjrst block (log copy) … location for second block location for fjrst block 19 number of blocks = N

  14. the xv6 journal transaction ready for next transaction 4 clear log header redone on recovery 3 write data (commits transaction) 2 write log header 1 write changed blocks start: num blocks = 0 no transaction otherwise: not committed or non- 0 : committed data of (one sector) log header xv6 log (one transaction) … non-log block non-log block … … second block (log copy) fjrst block (log copy) … location for second block location for fjrst block 19 number of blocks = N (if number of blocks � = 0 )

  15. the xv6 journal transaction ready for next transaction 4 clear log header redone on recovery 3 write data (commits transaction) 2 write log header 1 write changed blocks start: num blocks = 0 no transaction otherwise: not committed or non- 0 : committed data of (one sector) log header xv6 log (one transaction) … non-log block non-log block … … second block (log copy) fjrst block (log copy) … location for second block location for fjrst block 19 number of blocks = N = 0 (if number of blocks � = 0 )

  16. what is a transaction? so far: each fjle update? faster to do batch of updates together one log write fjnishes lots of things don’t wait to write xv6 solution: combine lots of updates into one transaction only commit when… no active fjle operation, or not enough room left in log for more operations 20

  17. what is a transaction? so far: each fjle update? one log write fjnishes lots of things don’t wait to write xv6 solution: combine lots of updates into one transaction only commit when… no active fjle operation, or not enough room left in log for more operations 20 faster to do batch of updates together

  18. redo logging problems doesn’t the log get infjnitely big? writing everything twice? 21

  19. redo logging problems doesn’t the log get infjnitely big? writing everything twice? 22

  20. limiting log size once transaction is written to real data, can discard sometimes called “garbage collecting” the log may sometimes need to block to free up log space perform logged updates before adding more to log hope: usually log cleanup happens “in the background” 23

  21. redo logging problems doesn’t the log get infjnitely big? writing everything twice? 24

  22. lots of writing? entire log can be written sequentially ideal for hard disk performance also pretty good for SSDs multiple updates can be done in any order can reorder to minimize seek time/rotational latency/etc. can interleave updates that make up multiple transactions no waiting for ‘real’ updates application can proceed while updates are happening fjles will be updated even if system crashes often better for performance! 25

  23. lots of writing? updating 1000 fjles? with redo logging — 2 big seeks write all updates to log in order write all updates to fjle/inode/directory data in order careful ordering — lots of seeks? write to free block map seek + write to inode seek + write to directory entry repeat 1000x maybe could combine fjle updates with careful ordering?? but sure starts to get complicated to track order requirements redo logging is probably simpler 26

  24. lots of writing? updating 1000 fjles? with redo logging — 2 big seeks write all updates to log in order write all updates to fjle/inode/directory data in order careful ordering — lots of seeks? write to free block map seek + write to inode seek + write to directory entry repeat 1000x maybe could combine fjle updates with careful ordering?? but sure starts to get complicated to track order requirements redo logging is probably simpler 26

  25. degrees of durability not all journalling fjlesystem use redo logging for everything some use it only for metadata operations some use it for both metadata and user data only metadata: avoids lots of duplicate writing metadata+user data: integrity of user data guaranteed 27

  26. snapshots fjlesystem snapshots idea: fjlesystem keeps old versions of fjles around accidental deletion? old version stil there eventually discard some old versions can access snapshot of fjles at prior time mechanism: copy-on-write changing fjle makes new copy of fjlesystem common parts shared between versions 28

  27. snapshots fjlesystem snapshots idea: fjlesystem keeps old versions of fjles around accidental deletion? old version stil there eventually discard some old versions can access snapshot of fjles at prior time changing fjle makes new copy of fjlesystem common parts shared between versions 28 mechanism: copy-on-write

  28. inode and copy-on-write + new inode of entire inode array don’t want to write new copy has big array of inodes challenge: FFS/xv6/ext2 design unchanged parts of fjle shared both old+new inode valid + new indirect blocks inode update: new data blocks new inode … fjle data … … indirect blocks 29

  29. inode and copy-on-write + new indirect blocks of entire inode array don’t want to write new copy has big array of inodes challenge: FFS/xv6/ext2 design unchanged parts of fjle shared both old+new inode valid + new inode update: new data blocks old new inode … fjle data … … indirect blocks inode 29

  30. inode and copy-on-write + new indirect blocks of entire inode array don’t want to write new copy has big array of inodes challenge: FFS/xv6/ext2 design unchanged parts of fjle shared both old+new inode valid + new inode update: new data blocks old new inode … fjle data … … indirect blocks inode 29

  31. inode and copy-on-write + new indirect blocks of entire inode array don’t want to write new copy has big array of inodes challenge: FFS/xv6/ext2 design unchanged parts of fjle shared both old+new inode valid + new inode update: new data blocks old new inode … fjle data … … indirect blocks inode 29

  32. extra indirection for inode array create new root inode array of root inodes multiple snapshots? shared between versions inode array unchanged parts of + pointers update one inode? root inode inode old … split into pieces arrays of inodes … indirect blocks 30

  33. extra indirection for inode array create new root inode array of root inodes multiple snapshots? shared between versions inode array unchanged parts of + pointers update one inode? root inode inode old … split into pieces arrays of inodes … indirect blocks 30

  34. extra indirection for inode array create new root inode array of root inodes multiple snapshots? shared between versions inode array unchanged parts of + pointers update one inode? root inode inode old … split into pieces arrays of inodes … indirect blocks 30

  35. extra indirection for inode array create new root inode array of root inodes multiple snapshots? shared between versions inode array unchanged parts of + pointers update one inode? root inode inode old … split into pieces arrays of inodes … indirect blocks 30

  36. extra indirection for inode array create new root inode array of root inodes multiple snapshots? shared between versions inode array unchanged parts of + pointers update one inode? root inode inode old … split into pieces arrays of inodes … indirect blocks 30

  37. copy-on-write indirection fjle update = replace with new version only copy modifjed parts keep reference counts, like for paging assignment lots of pointers — only change pointers where modifjcations happen 31 array of versions of entire fjlesystem

  38. snapshots in practice ZFS (used on department machines) implements this example: .zfs/snapshots/11.11.18-06 pseudo-directory contains contents of fjles at 11 November 2018 6AM 32

  39. mounting fjlesystems Unix-like system root fjlesystem appears as / other fjlesystems appear as directory e.g. lab machines: my home dir is in fjlesystem at /net/zf15 directories that are fjlesystems look like normal directories /net/zf15/.. is /net (even though in difgerent fjlesystems) 33

  40. mounts on a dept. machine noacl,sloppy,addr=128.143.136.9) ... noacl,sloppy,addr=128.143.67.236) zfs3:/zf14 on /net/zf14 type nfs (rw,hard,intr,proto=udp,nfsvers=3, noacl,sloppy,addr=128.143.136.9) zfs4:/sw on /net/sw type nfs (rw,hard,intr,proto=udp,nfsvers=3, noacl,sloppy,addr=128.143.67.236) zfs3:/zf19 on /net/zf19 type nfs (rw,hard,intr,proto=udp,nfsvers=3, zfs1:/zf2 on /net/zf2 type nfs (rw,hard,intr,proto=udp,nfsvers=3, ... /dev/sda3 on /localtmp type ext4 (rw) ... tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) udev on /dev type devtmpfs (rw,mode=0755) ... proc on /proc type proc (rw,noexec,nosuid,nodev) 34 /dev/sda1 on / type ext4 (rw,errors=remount − ro)

  41. kernel FS abstractions Linux: virtual fjle system API object-oriented, based on FFS-style fjlesystem to implement a fjlesystem, create object types for: superblock (represents “header”) inode (represents fjle) dentry (represents cached directory entry) fjle (represents open fjle ) common code handles directory traversal and caches directory traversals common code handles fjle descriptors, etc. 35

  42. linux VFS operations superblock: write_inodez, sync_fs, … inode: create, link, unlink, mkdir, open … most just for inodes which are directories dentry: compare, delete … more commonly argument to inode operation can be created for non-yet-existing fjles fjle: read, write, … 36

  43. linux VFS operations example struct inode_operations { } .. umode_t create_mode); ... 37 ... struct dentry * (*lookup) ( struct inode *, struct dentry *, unsigned int ); int (*create) ( struct inode *, struct dentry *, umode_t, bool ); int (*link) ( struct dentry *, struct inode *, struct dentry *); int (*unlink) ( struct inode *, struct dentry *); int (*symlink) ( struct inode *, struct dentry *, const char *); int (*mkdir) ( struct inode *, struct dentry *,umode_t); int (*rmdir) ( struct inode *, struct dentry *); int (*mknod) ( struct inode *, struct dentry *,umode_t,dev_t); int (*rename) ( struct inode *, struct dentry *, struct inode *, struct dentry *, unsigned int ); int (*update_time)( struct inode *, struct timespec64 *, int ); int (*atomic_open)( struct inode *, struct dentry *, struct file *, unsigned open_flag,

  44. FS abstractions and awkward FSes example: inode object for FAT? fake it: point to directory entry? 38

  45. distributed systems multiple machines working together to perform a single task 39 called a distributed system

  46. some distibuted systems models 2 peer-to-peer 7 node 6 node 5 node 4 node 3 node node client/server 1 node … N client N-1 client 2 client 1 client server 40

  47. client/server model server client GET /index.html index.html’s contents are … client: “sometimes on” sends requests to server needs to know how to contact server server: “always on” responds to client requests never initiaties contact with a client 41

  48. client/server model server client GET /index.html index.html’s contents are … client: “sometimes on” sends requests to server needs to know how to contact server server: “always on” responds to client requests never initiaties contact with a client 41

  49. client/server model server client GET /index.html index.html’s contents are … client: “sometimes on” sends requests to server needs to know how to contact server server: “always on” responds to client requests never initiaties contact with a client 41

  50. peer-to-peer no always-on server everyone knows about hopefully, no one bottleneck — “scalability” any machine can contact any other machine every machine plays an approx. equal role? set of machines may change over time 42

  51. easier to add incrementally redundancy — one machine can fail and others still work? distributed system reasons functional reasons: “the cloud” performance/reliability/cost reasons: combine many cheap machines to replace expensive machine 43 multiple people collaborating delegating responsiblities to another person/company

  52. distributed system reasons functional reasons: “the cloud” performance/reliability/cost reasons: combine many cheap machines to replace expensive machine easier to add incrementally redundancy — one machine can fail and others still work? 43 multiple people collaborating delegating responsiblities to another person/company

  53. transparency goal common goal of distributed systems is transparency normal user doesn’t notice that it’s distributed except because of the extra features that provides hopefully acts like better single-node system hope: user can rely on system to fjgure out which machines to use handle failures … 44

  54. transparency goal common goal of distributed systems is transparency normal user doesn’t notice that it’s distributed except because of the extra features that provides hopefully acts like better single-node system hope: user can rely on system to fjgure out which machines to use handle failures … 44

  55. mailbox model Recv() = “Hello” receiving program not yet received by queue of messages waiting to be sent from sending program queue of messages network knows how to get message to B B: “Hello” mailbox abstraction: send/receive messages Send(B, “Hello”) B: “Hello” B machine the network A machine 45

  56. mailbox model Recv() = “Hello” receiving program not yet received by queue of messages waiting to be sent from sending program queue of messages network knows how to get message to B B: “Hello” mailbox abstraction: send/receive messages Send(B, “Hello”) B: “Hello” B machine the network A machine 45

  57. mailbox model Recv() = “Hello” receiving program not yet received by queue of messages waiting to be sent from sending program queue of messages network knows how to get message to B B: “Hello” mailbox abstraction: send/receive messages Send(B, “Hello”) B: “Hello” B machine the network A machine 45

  58. mailbox model Recv() = “Hello” receiving program not yet received by queue of messages waiting to be sent from sending program queue of messages network knows how to get message to B B: “Hello” mailbox abstraction: send/receive messages Send(B, “Hello”) B: “Hello” B machine the network A machine 45

  59. what about servers? client/server model: server wants to reply to clients might want to send/receive multiple messages can build this with mailbox idea send a ‘return address’ need to track related messages common abstraction that does this: the connection 46

  60. what about servers? client/server model: server wants to reply to clients might want to send/receive multiple messages can build this with mailbox idea send a ‘return address’ need to track related messages common abstraction that does this: the connection 46

  61. extension: conections Conn = Accept() “4” = Recv(Conn) Send(Conn, “4”) A: (B, “4”) “2 + 2 = ?” = Recv(Conn) Send(Conn, “2 + 2 = ?”) B: (A, “2 + 2 = ?”) A: connection to B OK! connections : two-way channel for messages Conn = Connect(B) B: open connection to A? B machine A machine extra operations: connect, accept 47

  62. connections over mailboxes real Internet: mailbox-style communication connections implemented on top this including handling errors, transmitting more data than fjts in message, … full details: take networking 48

  63. connections versus pipes connections look kinda like two-direction pipes in fact, in POSIX will have the same API: each end gets fjle descriptor representing connection can use read() and write() 49

  64. connection missing pieces? how to specify the machine? multiple programs on one machine? who gets the message? 51

  65. names and addresses IPv6 address 2607:f8b0:4004:80b::2005 port number 443 service name https memory address 0x7FFF9430 variable counter and device 0x2eh / 0x46d inode# 120800873 fjlename /home/cr4bd/NOTES.txt hostname mail.google.com name IPv4 address 216.58.217.69 hostname mail.google.com IPv4 address 128.143.22.36 hostname www.virginia.edu location/how to locate logical identifjer address 52

  66. hostnames typically use domain name system (DNS) to fjnd machine names maps logical names like www.virginia.edu chosen for humans hierarchy of names …to addresses the network can use to move messages numbers ranges of numbers assigned to difgerent parts of the network network routers knows “send this range of numbers goes this way” 53

  67. DNS: distributed database cs.virginia.edu check for updated version once in a while optimization: cache its address .edu server doesn’t change much try .edu server at … www.cs.virginia.edu? 128.143.67.11 www.cs.virginia.edu = www.cs.virginia.edu? address for DNS server DNS server my virginia.edu DNS server .edu DNS server root when it connected to network address sent to my machine DNS server ISP’s machine 54

  68. DNS: distributed database cs.virginia.edu check for updated version once in a while optimization: cache its address .edu server doesn’t change much try .edu server at … www.cs.virginia.edu? 128.143.67.11 www.cs.virginia.edu = www.cs.virginia.edu? address for DNS server DNS server my virginia.edu DNS server .edu DNS server root when it connected to network address sent to my machine DNS server ISP’s machine 54

  69. DNS: distributed database cs.virginia.edu check for updated version once in a while optimization: cache its address .edu server doesn’t change much try .edu server at … www.cs.virginia.edu? 128.143.67.11 www.cs.virginia.edu = www.cs.virginia.edu? address for DNS server DNS server my virginia.edu DNS server .edu DNS server root when it connected to network address sent to my machine DNS server ISP’s machine 54

  70. DNS: distributed database cs.virginia.edu check for updated version once in a while optimization: cache its address .edu server doesn’t change much try .edu server at … www.cs.virginia.edu? 128.143.67.11 www.cs.virginia.edu = www.cs.virginia.edu? address for DNS server DNS server my virginia.edu DNS server .edu DNS server root when it connected to network address sent to my machine DNS server ISP’s machine 54

  71. DNS: distributed database cs.virginia.edu check for updated version once in a while optimization: cache its address .edu server doesn’t change much try .edu server at … www.cs.virginia.edu? 128.143.67.11 www.cs.virginia.edu = www.cs.virginia.edu? address for DNS server DNS server my virginia.edu DNS server .edu DNS server root when it connected to network address sent to my machine DNS server ISP’s machine 54

  72. IPv4 addresses 32-bit numbers typically written like 128.143.67.11 four 8-bit decimal values separated by dots fjrst part is most signifjcant organizations get blocks of IPs e.g. UVa has 128.143.0.0–128.143.255.255 e.g. Google has 216.58.192.0–216.58.223.255 and 74.125.0.0–74.125.255.255 and 35.192.0.0–35.207.255.255 55 same as 128 · 256 3 + 143 · 256 2 + 67 · 256 + 11 = 2 156 782 459

  73. IPv4 addresses and routing tables … network 3 anything else … … network 2 64.8.0.0–64.15.255.255 network 2 4.0.0.0–7.255.255.255 … router network 1 192.107.102.0–192.107.102.255 network 1 128.143.0.0—128.143.255.255 send it to… if I receive data for… network 3 network 2 network 1 56

  74. selected special IPv4 addresses 127.0.0.0 — 127.255.255.255 — localhost AKA loopback the machine we’re on typically only 127.0.0.1 is used 192.168.0.0–192.168.255.255 and 10.0.0.0–10.255.255.255 and 172.16.0.0–172.31.255.255 “private” IP addresses not used on the Internet also 100.64.0.0–100.127.255.255 (but with restrictions) 169.254.0.0-169.254.255.255 link-local addresses — ‘never’ forwarded by routers 57 commonly connected to Internet with network address translation

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend