41
Membrane: Operating System support for Restartable File Systems Swaminathan Sundararaman, Sriram Subramanian, Abhishek Rajimwale , Andrea C. Arpaci-Dusseau, Remzi H. Arpaci-Dusseau, Michael M. Swift File System Kernel Membrane is a layer of material which serves as a selective barrier between two phases and remains impermeable to specific particles, molecules, or substances when exposed to the action of a driving force. Membrane Bug

Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Membrane: Operating System support for Restartable File

Systems

Swaminathan Sundararaman, Sriram Subramanian, Abhishek Rajimwale, Andrea C. Arpaci-Dusseau,

Remzi H. Arpaci-Dusseau, Michael M. Swift

File System

Kern

el

Membrane is a layer of material which serves as a selective barrier between two phases andremains impermeable to specific particles, molecules, or substances when exposed to theaction of a driving force.

MembraneBug

Page 2: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Bugs in File-system Code

Bugs are common in any large softwareFile systems contain 1,000 – 100,000 loc

Recent work has uncovered 100s of bugs [Engler OSDI ’00, Musuvathi OSDI ’02, Prabhakaran SOSP ‘03, Yang OSDI ’04, Gunawi FAST ‘08, Rubio-Gonzales PLDI ’09]

Error handling code, recovery code, etc.

File systems are part of core kernelA single bug could make the kernel unusable

2

Page 3: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Bug Detection in File Systems

FS developers are good at detecting bugs “Paranoid” about failures

Lots of checks all over the file system code!

3

File System

assert() BUG() panic()

xfs 2119 18 43

ubifs 369 36 2

ocfs2 261 531 8

gfs2 156 60 0

afs 106 38 0

ext4 42 182 12

reiserfs 1 109 93

ntfs 0 288 2

Number of calls to assert, BUG, and panic in Linux 2.6.27Detection is easy but recovery is hard

Page 4: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Why is Recovery Hard?

4

VFS

File System

App App App

Processes could potentiallyuse corrupt in-memory file-system objects

Crash

File System

App

VFS

No fault isolationInconsistent kernel state

Hard to free FS objects

Common solution: crash file system and hope problem goes away after OS reboot

Inod

e i_count0x00002

Addressmapping

File systems manage theirown in-memory objectsProcess killed on crash

Page 5: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Why not Fix Source Code?

To develop perfect file systemsTools do not uncover all file system bugsBugs still are fixed manuallyCode constantly modified due to new features

Make file systems handle all error cases Interacts with many external components

VFS, memory mgmt., network, page cache, and I/O

5

Cope with bugs than hope to avoid them

Page 6: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Restartable File Systems

Membrane: OS framework to support lightweight, stateful recovery from FS crashes

Upon failure transparently restart FSRestore state and allow pending application

requests to be servicedApplications oblivious to crashes

A generic solution to handle all FS crashesLast resort before file systems decide to give up

6

Page 7: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Results

Implemented Membrane in Linux 2.6.15Evaluated with ext2, VFAT, and ext3

EvaluationTransparency: hide failures (~50 faults) from appl. Performance: < 3% for micro & macro benchmarksRecovery time: < 30 milliseconds to restart FSGenerality: < 5 lines of code for each FS

7

Page 8: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Outline

MotivationRestartable file systemsEvaluationConclusions

8

Page 9: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Components of Membrane

Fault DetectionHelps detect faults quickly

Fault AnticipationRecords file-system state

Fault RecoveryExecutes recovery protocol to cleanup and

restart the failed file system

9

Membrane

FaultAnticipation

FaultDetection

FaultRecovery

Page 10: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Fault Detection

Correct recovery requires early detectionMembrane best handles “fail-stop” failures

Both hardware and software-based detectionH/W: null pointer, general protection error, ... S/W: asserts(), BUG(), BUG_ON(), panic()

Assume transient faults during recoveryNon-transient faults: return error to that process

10

Page 11: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Components of Membrane

11

Membrane

FaultAnticipation

FaultDetection

FaultRecovery

Page 12: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Fault Anticipation

Additional work done in anticipation of a failure

Issue: where to restart the file system from?File systems constantly updated by applications

Possible solutions:Make each operation atomicLeverage in-built crash consistency mechanism

Not all FS have crash consistency mechanism

12

Generic mechanism to checkpoint FS state

Page 13: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Checkpoint File-system State

13

VFS

File System

Page Cache

Disk

App App App

File systems write to disk through page cache

All requests enter via VFS layer

ext3 VFAT Control requests to FS &

dirty pages to disk

Checkpoint: consistent state of the file system that can be safely rolled back to in the event of a crash

Page 14: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Generic COW based Checkpoint

14

VFS

File System

Page Cache

Disk

App

VFS

File System

Page Cache

App

Disk

Regular

VFS

File System

Page Cache

App

Disk

STOP STOP

Membrane

STOP

Cons

iste

nt im

age

✓✓✓✓

Copy-on-Write

Can be written back to disk

Disk Disk Disk

Consistent Image #1

Consistent Image #2

On crash roll back to last consistent Image

Consistent Image #3

Page 15: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

After Recovery

State after checkpoint?

On crash: flush dirty pages of last checkpoint

Throw away the in-memory state

Remount from the last checkpoint Consistent file-system image on disk

Issue: state after checkpoint would be lost Operations completed after checkpoint returned

back to applications

15

VFS

File System

Page Cache

App

Disk

✓✓✓

Crash

STOP

On CrashNeed to recreate state after checkpoint

Page 16: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Operation-level Logging

Log operations along with their return value Replay completed operations after checkpoint

Operations are logged at the VFS layer File-system independent approach

Logs are maintained in-memory and not on disk

How long should we keep the log records? Log thrown away at checkpoint completion

16

Page 17: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Components of Membrane

17

Membrane

FaultAnticipation

FaultDetection

FaultRecovery

Page 18: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Fault Recovery

Important steps in recovery:

1. Cleanup state of partially-completed operations

2. Cleanup in-memory state of file system

3. Remount file system from last checkpoint

4. Replay completed operations after checkpoint

5. Re-execute partially complete operations

18

Page 19: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

File System

Partially completed Operations

19

VFS

File System

App App App

VFS

File System

App

Page Cache

Kern

elU

ser

FS code should not be trusted after crash

Multiple threads inside file system

Crash

Intertwined execution

Processes cannot be killed after crashApplication threads killed?

- application state will be lost

Clean way to undo incomplete operations

Page 20: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

A Skip/Trust Unwind Protocol

Skip: file-system codeTrust: kernel code (VFS, memory mgmt., …)

- Cleanup state on error from file systems

How to prevent execution of FS code?Control capture mechanism: marks file-system

code pages as non-executableUnwind Stack: stores return address (of last

kernel function) along with expected error value

20

Page 21: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Skip/Trust Unwind Protocol in Action

E.g., create code path in ext2

21

sys_open()do_sys_open()

filp_open()open_namei()

ext2_create()

Unwind Stack

block_prepare_write()

ext2_prepare_write()

ext2_addlink()

ext2_get_block()

vfs_create

regs

rval

fn

-ENOMEM

rax rbp rsirdi rbx rcxrdx r8 …

blk..._write

regs

rval

fn

-EIO

rax rbp rsirdi rbx rcxrdx r8 …

1Release fd

1

2

3

Clear bufferZero page

Mark not dirty

3Release

namei data

2

vfs_create()

fault membrane

fault membrane

Crash

Non-executable

ext2_create()

ext2_get_block()

-EIO

-ENOMEM

Kernel File systemKernel is restored to a consistent state

Page 22: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Components of Membrane

22

Membrane

FaultAnticipation

FaultDetection

FaultRecovery

Page 23: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Putting All Pieces Together

23

VFS

File System

Application

T0 T1

time

chec

kpoi

ntOpen (“file”) write() read()

Completed In-progressLegend: Crash

write()Periodically create

checkpoints1

Move to recent checkpoint

4

Replay completed operations

5

Unwind in-flight processes

3

File System Crash2

Re-execute unwound process

6

1

2

4

5

6

link() Close()3

T2

Page 24: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Outline

MotivationRestartable file systemsEvaluationConclusions

24

Page 25: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Evaluation

Questions that we want to answer:Can membrane hide failures from applications?What is the overhead during user workloads?Portability of existing FS to work with Membrane?How much time does it take to recover the FS?

Setup: 2.2 GHz Opteron processor & 2 GB RAM Two 80 GB western digital disk Linux 2.6.15 64bit kernel, 5.5K LOC were added File systems: ext2, VFAT, ext3

25

Page 26: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

How Transparent are Failures?

Ext3_Function Fault

Ext3 +Native

Ext3 + Membrane

De

te

ct

ed

?

Ap

pli

cati

on

?

FSC

onsi

sten

t?

FS

Us

ab

le?

De

te

ct

ed

?

Ap

pli

cati

on

?

FSC

onsi

sten

t?

FS

Us

ab

le?

create null-pointer o ✗ ✗ ✗ d ✓ ✓ ✓

get_blk_handle bh_result o ✗ ✗ ✗ d ✓ ✓ ✓

follow_link nd_set_link o ✗ ✗ ✓ d ✓ ✓ ✓

mkdir d_instantiate o ✗ ✗ ✗ d ✓ ✓ ✓

free_inode clear_inode o ✗ ✗ ✗ d ✓ ✓ ✓

read_blk_bmap sb_bread o ✗ ✓ ✗ d ✓ ✓ ✓

readdir null-pointer o ✗ ✗ ✗ d ✓ ✓ ✓

file_write file_aio_write G ✗ ✓ ✓ d ✓ ✓ ✓

26

Legend: O – oops, G- prot. fault, d – detected, o

– cannot unmount, ✗ - no, ✓- yes Membrane successfully hides faults

Page 27: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Overheads during User Workloads?

27

Tim

e in

Sec

onds

Workload: Copy, untar, make of OpenSSH 4.51

Page 28: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Overheads during User Workloads?

28

Tim

e in

Sec

onds

Workload: Copy, untar, make of OpenSSH 4.51 1.4% 2.3% 1.4%

Reliability almost comes for free

Page 29: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Generality of Membrane?

File System

Added Modified Deleted

Ext2 4 0 0VFAT 5 0 0Ext3 1 0 0JBD 4 0 0

29

Individual file system changes

Minimal changes to port existing FS to Membrane

Existing code remains unchanged

Additions: track allocations and write super block

No crash-consistency

crash-consistency

Page 30: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Outline

MotivationRestartable file systemsEvaluationConclusions

30

Page 31: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Conclusions

Failures are inevitable in file systems Learn to cope and not hope to avoid them

Membrane: Generic recovery mechanismUsers: Build trust in new file systems (e.g., btrfs)Developers: Quick-fix bug patching

Encourage more integrity checks in FS codeDetection is easy but recovery is hard

31

Page 32: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Thank You!Questions?

32

Advanced Systems Lab (ADSL)University of Wisconsin-Madison

http://www.cs.wisc.edu/adsl

Page 33: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Are Failures Always Transparent?

Files may be recreated during recovery Inode numbers could change after restart

Solution: make create() part of a checkpoint33

VFS

File System

Application

Epoch 0After Crash RecoveryBefore Crash

Epoch 0

create (“file1”) stat (“file1”) write (“file1”, 4k)

File : file1Inode# : 15

create (“file1”) stat (“file1”)write (“file1”, 4k)

File1: inode# 12 File1: inode# 15Inode# Mismatch

File : file1Inode# : 12

Page 34: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Postmark Benchmark

34

Tim

e in

Sec

onds

3000 files (sizes 4K to 4MB), 60K transactions

0.6% 1.6%

1.2%

Page 35: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Recovery Time

Data(Mb)

RecoveryTime (ms)

10 12.9

20 13.2

40 16.1

35

OpenSessions

RecoveryTime (ms)

200 11.4

400 14.6

800 22.0

Log Records

RecoveryTime (ms)

1K 15.3

10K 16.8

100K 25.2

Recovery time is a function of: Dirty blocks, open sessions, and log records We varied each of them individually

Recovery time is in the order of a few milliseconds

Page 36: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Recovery Time (Cont.)

Restart ext2 during random-read benchmark

36

Page 37: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Generality and Code Complexity

File System

Added Modified

Ext2 4 0

VFAT 5 0

Ext3 1 0

JBD 4 0

37

Components

No Checkpoint With Checkpoint

Added Modified Added Modified

FS 1929 30 2979 64

MM 779 5 867 15

Arch 0 0 733 4

Headers 522 6 552 6

Module 238 0 238 0

Total 3468 41 5369 89

Individual file system changes Kernel changes

Page 38: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Interaction with Modern FSes

Have built-in crash consistency mechanism Journaling or Snapshotting

Seamlessly integrate with these mechanismNeed FSes to indicate beginning and end of an

transactionWorks for data and ordered journaling modeNeed to combine writeback mode with COW

38

Page 39: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Page Stealing Mechanism

Goal: Reduce the overhead of logging writes Soln: Grab data from page cache during recovery

39

VFS

File System

Page Cache

VFS

File System

Page Cache

VFS

File System

Page Cache

Write (fd, buf, offset, count)

Page 40: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Handling Non-Determinism

During log replay could data be written in different order?Log entries need not represent actual order

Not a problem for meta-data updatesOnly one of them succeed and is recorded in log

Deterministic data-block updates with page stealing mechanismLatest version of the page is used during replay

40

Page 41: Membrane: Operating System support for Restartable File … · 2021. 2. 10. · VFS File System App: App App Processes could potentially: use corrupt in-memory . file-system ... FS

2010 Storage Developer Conference. Insert Your Company Name. All Rights Reserved.

Possible Solutions

1. Code to recover from all failures Not feasible in reality

2. Restart on failurePrevious work have taken

this approach

FS need: stateful & lightweightrecovery

41

HeavyweightLightweight

Stat

eles

sSt

atef

ulNooks/Shadow

Xen, MinixL4, Nexus

SafeDriveSingularity

CuriOSEROS