Docsity

Consistency Problem in Big File Systems: Solutions and Atomic Disk Operations, Slides of Advanced Operating Systems

Partial preview of the text

Download Consistency Problem in Big File Systems: Solutions and Atomic Disk Operations and more Slides Advanced Operating Systems in PDF only on Docsity!

Lecture No.

Consistency problem?

 The Big File System Promise: persistence

 it will hold your data until you explicitly delete it  (and sometimes even beyond that: backup/restore)

 What’s hard about this? Crashes

 If your data is in main memory, a crash destroys it.  Performance tension: need to cache everything. But if so, then crash = lose everything.  More fundamental: interesting ops = multiple block modifications, but can only atomically modify disk a sector at a time.

 For disk: construct a pair of operations:  put(blk, address) : writes data in blk on disk at address  get(address) -> blk : returns blk at given disk address  such that “put” appears to place data on disk in its entirety or not at all and “get” returns the latest version  what we have to guard against: a system crash during a call to “put”, which results in a partial write.

Arbitrary-sized atomic disk ops

void atomic-put(data) blk atomic-get() version++; # unique integer V1 := get(V1) put(version, V1); D1data := get(D1); put(data, D1); V2 := get(V2); put(version, V2); D2data := get(D2); put(data, D2); if(V1 == V2) return D1data; else return D2data;

SABRE atomic disk operations

 Once data written, the disk returns it correctly

 Disk is in a correct state when atomic-put starts

Two assumptions

cksum( blk ) 45148

45148

Recovery

void recover(void) { V1data = get(V1); # following 4 ops same as in a-get D1data = get(D1); V2data = get(V2); D2data = get(D2); if (V1data == V2data) if(D1data != D2data)

if we crash & corrupt D2, will get here again.

put(D1data, D2); else

if we crash and corrupt D1, will get back here

put(D2data, D1);

if we crash and corrupt V1, will get back here

put(V2data, V1);

 In general, coping with failure consists of first defining a

failure model composed of

 Acceptable failures. E.g., the earth is destroyed by aliens from Mars. The loss of a file viewed as unavoidable.  Unacceptable failures. E.g. power outage: lost file not ok

Fighting failure

Unix file system invariants

 File and directory names are unique

 All free objects are on free list

 + free list only holds free objects

 Data blocks have exactly one pointer to them

 Inode’s ref count = the number of pointers to it

 All objects are initialized

 a new file should have no data blocks, a just allocated block should contain all zeros.

 A crash can violate every one of these!