the design and implementation of a log-structured file...

45
The Design and Implementation of a Log-Structured File System Mendel Rosenblum and John K. Ousterhout 2016-05-30 오기환, 이종백, 김문학

Upload: others

Post on 20-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

TheDesignandImplementationofaLog-StructuredFileSystem

MendelRosenblumandJohnK.Ousterhout

2016-05-30

오기환,이종백,김문학

Page 2: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

TechnologyTrend

• Processorspeedimprovingexponentially

• Diskcapacityimprovingexponentially– But,nottransferbandwidthandseektimes

• Memorycapacityimprovingexponentially– Largermemorysizesmeanlargercaches

• Cacheswillcapturemostreadaccesses• Disktrafficwillbedominatedbywrites• Cachescanactaswritebuffersreplacingmanysmallwritesbyfewerbiggerwrites

2016.5.30. 2

Page 3: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Problemswithexistingfilesystems

• Problem1:Fileinformationisspreadaroundthedisk– inodes areseparate fromfiledata– 5diskI/Ooperationsrequiredtocreateanewfile

• directoryinode,directorydata,file inode (twiceforthesakeofdisasterrecovery),filedata

– Results:lessthan5%ofthedisk’spotentialbandwidthisusedforwrites

• Problem2:Metadataupdatesaresynchronous– Requiredforconsistency– Lessefficientthanasynchronouswrites

Page 4: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Log-structuredFileSystem

• Writeallmodificationstodisksequentially inalog-likestructure

– Convertmanysmallrandomwritesintolargesequentialtransfers– Usefilecacheaswritebuffer

• Twoissuesinobtaininggoal– Retrieving Informationfromthelog– Managingfreespace

Page 5: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Log-structuredFileSystem

• TheLOG– Onlystructureondisk

– Containsinodes anddatablocks

– Includesindexinginformationsothatfilescanbereadbackfromthelogrelativelyefficiently

– Mostreadswillaccessdatathatarealreadyinthecache

Page 6: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Filelocationandreading

• StillusesFFS’sinode structure.Butinodes arenotlocatedatfixedpositions.

• Inode mapisusedtolocateafile’slatestversionofinode.Inode mapitselfislocatedindifferentplacesofthedisk,butitslatestversionisloadedintomemoryforfastaccess.

• FilereadingperformanceofLFSissimilartoFFS.

Page 7: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

DisklayoutsofLFSandUNIX

Page 8: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

FreeSpaceManagement

• Fragmentation fromdeletedandoverwrittenfiles

• Twoapproachestoreducefragmentation– Threading

• Leavelivedatainplaceandthreadthroughthefreeextents• Reducesabilityofsequentialwrites

– Copying• Copylivedataanappendtothefrontofthelog• Leaveslargerfreeextentsforuse• Copyingisveryexpensiveonlong-livedfiles

• SpriteLFSusesacombinationofboththreadingandcopying

Page 9: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Threading&Copying

Page 10: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

SegmentCleaningMechanism

• Segmentcleaningprocessinvolves1. Readinganumberofsegmentsintomemory2. Identifyingthelivedata3. Writingthembacktoasmallernumberofcleansegments

• Howareliveblocksidentified?– Eachsegmentmaintainsasegmentsummaryblock toidentifywhatisineachblockandwhichinode thisblockbelongsto

– crosscheckblockswithowninginode’s blockpointers

Page 11: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

SegmentCleaningPolicies

• Fourpolicyissues1. Whenshouldthesegmentcleanerexecute?2. Howmanysegmentsshoulditcleanatatime?3. Whichsegmentsshouldbecleaned?4. Howshouldtheliveblocksbegroupedwhentheyarewrittenout?

• Writecost– Usedtocomparecleaningpolicies– Averageamountoftimethediskisbusyperbyteofnewdatawritten,includingallthecleaningoverheads

– 1.0isperfect whilehighermeansfractionsofdiskbandwidtharebeingutilized

Page 12: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

SimulationResults

• Considertwofileaccesspatterns– Uniform– Hot-and-cold: (100- x)%oftheaccesses involvex %ofthefiles90%oftheaccesses involve10%ofthefiles

Page 13: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Cost-BenefitPolicy

• GreedyPolicydatashowsthathot-and-coldsegmentsshouldbetreateddifferently– Coldsegmentsshouldbecleanedathighutilization– Hotsegmentsshouldbecleanedatlowutilization

• Cost-Benefitpolicyrateseachsegmentwiththebenefitofcleaningthesegmentandthecostofcleaningthesegment

Page 14: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Cost-BenefitPolicy

Page 15: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

CrashRecovery

• Checkpoint– Positioninthelogatwhichallfilesystemstructuresareconsistentandcomplete

– CheckpointRegion• Containstheaddressesofalltheblocksintheinode mapandsegmentusagetable,plusthecurrenttimeandapointertothelastsegmentwritten

• Performedatperiodicintervals• Systemusesthecheckpointregiontoreturnlogtothisstate

• Roll-forward– Usesdataafterthecheckpointtorecoverasmanyfilesaspossible

Page 16: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Micro-BenchmarkResults

SmallFileBenchmark LargeFileBenchmark

Page 17: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

CleaningOverheads

• Testedon5differentfilesystemsover4monthperiod

• Waitedseveralmonthstoallowfilesystemtobalance

• Writecostsmallerthansimulated– Thiswasduetoblocksizesusedinsimulation

Page 18: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Conclusion

• Log-structuredfilesystem– WritesmuchlargeramountsofnewdatatodiskperdiskI/O– Usesmostofthedisk’sbandwidth

• Freespacemanagementdonethroughdividingdiskintofixed-sizesegments

• Lowestsegmentcleaningoverheadachievedwithcost-benefitpolicy

Page 19: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

FLASHMEMORYSTORAGE(SSD)

5/30/16 19

Page 20: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

SolidStateDrive(SSD)

• SSDstypicallyuseNANDFlash

• Lowerlatency

• HigherIOPSandThroughput

• LowerPower

• Morereliable

Page 21: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

SSDComponents

• DRAM

• NANDController

• NANDFlash– Pages:Smallestunitthatcanberead/written– Eraseblock:Groupsofpagestobeerased– LimitedP/ECycles

• Firmware– FlashTranslationLayer(FTL)andetc.

21

Page 22: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

NANDFlashMemory

• Read/WriteUnit:Page(4KB~32KB)

• Noin-placeupdate:‘Erase-before-write’– EraseUnit:Block(512KB~)– Blockwearsoutafterlimitederases

22

Page0

Block1Page1

Pagem-1

Blockn-1Block0

FlashChip

Read Write Erase25us(2KB)

200us(2KB)

1,500us(128KB)

NANDFlash[1]

Access latencyMedia

[1]:SamsungLarge-blockSLCNAND(K9WAG08U1A)

Page 23: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

FlashTranslationLayer(FTL)

• AsoftwarelayerthatallowstheflashmemorytolooklikeaHDD– Addressmapping:LogicaltoPhysical– Garbagecollection,Wear-leveling, etc.

23

FileSystem

Low-levelDeviceDriver

Flashmemory

Read Write

FileSystem

Low-levelDeviceDriver

FTL

Flashmemory

Read Write

Read Write Erase

Mismatch

Page 24: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Page-LevelMappingFTL

24

(A)(B)

Mapping table

1 Initial page address mapping for page (B)

(B)(C)

Mapping table

2 Update data (write new data) in an empty page

(A)X

(B)(C)

Mapping table

3 Page address re-mapping for page (B)

(A)X

(C)

X

1 Collect (copy) valid pages into an empty block

2 Page address re-mapping

(B)(C)(A)

XXX

(B)

XX

(C)

(A)

(B)(C)(A)

XXXX

XX

X

X

(B)(C)(A)

Empty block Empty block

3 Erase invalid blocks (can be re-used now)

Page 25: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

WriteAmplificationFactor(WAF)

• Bytesphysicallywritten toNANDversusbytesrequestedfromPC/Server

• FactorsthatcanaffectWAF– SSDComponents

• FlashTranslationLayer(FTL):WearLeveling,GarbageCollection• Over-provisioning

– HostApplication• WriteProfile(Randomvs.Sequential)• FreeUserspace/UseofTRIM

25

WAF=ByteswrittentoNAND

BytesrequestedfromHost

Page 26: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

ImpactofWriteProfile

26

1 Initial state by random writes

2 Series of random writes

(B)(F)(C)(E)

(G)(A)

(D)

(A)

(F)X

(E)

(B)X(C)X

(G)X

X

(D)

3 Erase block after copying 2 valid pages

1 Initial State by sequential writes

2 Series of sequential writes

(A)(B)(C)(D)

(F)(G)

(E)

(E)

(B)(C)(D)

XXXX

(F)(G)

X

(A)

(E)

(B)(c)(D)

(F)(G)

X

(A)

3 Erase block without copying valid page

(B)(C)(G)

X

X

(D) (A)

(F)X

(E)

Page 27: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

ImpactofOthers

27

※More chances to be invalidated

※ Use TRIM commands

(A)

(F)X

(E)

(B)X(C)X

(G)X

X

(D)

※ Align page boundaries

(E)

(B)(c)(D)

(X)(X)(X)(X)

※ Erase block after copying 3 valid pages

(F)(G)(A)

(F)

(B)(G)(C)

(A)

XX

(E)

XXXX

XX

X

(D)

Data

Data

DifferentGC&Wear-leveling

MoreOver-Provisioning

SSD-awareapplications#1

SSD-awareapplications#2

Page 28: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

F2FS:ANewFileSystemforFlashStorage

Changman Leeet,FAST’2015

Page 29: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Introduction

• Randomwritesisbadtoflashstoragedevice– Freespacefragmentation

• Sustainedrandomwriteperformancedegrades• Lifetimereduced

• Sequentialwriteorientedfilesystems– LFS,CoW filesystems

• F2FSContribution– DesignandimplementationofapracticalLFStofullyleverageandoptimizetheusageofNANDflashsolutions

– PerformancecomparisonwithLinuxfilesystems(Ext4,Btrfs,Nilfs2)• Mobilesystemandserversystem

29

Page 30: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

KeyDesignConsiderations

• Flash-friendlyon-disklayout

• Cost-effective indexstructure

• Multi-head logging

• Adaptive logging

• Fsync accelerationwithroll-forwardrecovery

30

Page 31: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Flash-friendlyOn-DiskLayout

• Flashawareness– AlltheFSmetadataarelocatedtogetherforlocality– Startaddressofmainareainalignedtothezonesize– Filesystemcleaningisdoneinaunitofsection(FTL’sGCunit)

• CleaningCostReduction– Multi-headloggingforhot/colddataseparation

31

Page 32: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

F2FSIndexStructure

• Restrainedupdatepropagation– NodeAddressTranslation(NAT)method

• Multi-headlog

32

SB CP NAT

SegmentInfo.Table(SIT)

SegmentSummaryArea(SSA)

Inode fordirectory

Inode forregularfile

IndirectNode

DirectoryData

FileData

DirectNode

FileData

Page 33: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Multi-headLogging

• Datatemperature classification

• Separation ofmulti-head logsinNANDflash

33

Page 34: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Cleaning

• Cleaningisdone insectionunit– SectiontobealignedwithFTL’sGCunit

• Cleaningprocedure– Victimselection:ThroughreferencingSIT

• Greedyforforegroundcleaning• Cost-benefit forbackgroundcleaning

– Validblockcheck:ThroughSSA– Migration:copy-backvalidblocks– Markvictimsectionas“pre-free”

• Pre-freesectionsarefreedafterthenextcheckpoint

34

Page 35: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

AdaptiveLogging

• Toreducecleaningcostathighlyagedconditions,F2FSchangeswritepolicy– Appendlogging(loggingtocleansegments)

• Causessequentialwrites– Threaded logging(loggingtodirtysegments)

• Causesrandomwrites

35

Page 36: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

CheckpointandRollback

• Maintainsshadowcopyofcheckpoint,NAT,SITblocks

• Recoversthelatestcheckpoint

• KeepsNAT/SIT journalincheckpointtoavoidNAT,SITwrites

36

Page 37: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

CheckpointandRollback

37

Page 38: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Recovery

• Fsync handling– Onfsync,checkpointisnotnecessary– Directnodeblocksarewrittenwithfsync mark

• Roll-forwardrecoveryprocedure– Searchmarkeddirectnodeblocks– UpdateSIT;invalidateolddatablocks– UpdateNAT,SIT– Createcheckpoint

38

Page 39: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Evaluation

• ExperimentalEnvironment

39

Page 40: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Mobilebenchmark

• InF2FS,morethan90%ofwritesaresequential

• F2FSreduceswriteamountperfsync– usingroll-forwardrecovery

40

Page 41: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Serverbenchmark

• PerformancegainismoreonSATASSD– Varmail:2.5xontheSATA,1.8xonthePCIe– Oltp:16%ontheSATA,13%onthePCIe

• F2FSissueslargesizediscard(TRIM)command

41

Page 42: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

EffectofMulti-headLogging

• Usingmorelogsgivesbetterhot/coldseparation–2Logs:node,data–4Logs:hotnode,coldnode,hotdata,colddata

42

Page 43: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

CleaningCostAnalysis

• F2FSusesadaptiveloggingunderhighutilization–Even in97.5%util.,WAFislessthan1.025

• Withoutadaptivelogging,WAFgoesuptomorethan3

43

Page 44: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

AdaptiveLoggingPerformance

• Gracefulperformancedegradationunderhighlyagedvolumeconditions

44

Page 45: The Design and Implementation of a Log-Structured File Systemcsl.skku.edu/uploads/ECE5658S16/pr14.pdf · 2016-05-30 · The Design and Implementation of a Log-Structured File System

Conclusion

• F2FSfeatures– Flash-friendlyon-disklayout– Costeffective indexstructure(NAT)– Multi-headlogging– Adaptivelogging– Roll-forwardrecovery

• F2FSshowperformancegainoverotherFSs

• F2FSispubliclyavailableinLinuxmainline

45