Design and Implementation of the Spad Filesystem
Total Page:16
File Type:pdf, Size:1020Kb
Charles University in Prague Faculty of Mathematics and Physics DOCTORAL THESIS Mikul´aˇsPatoˇcka Design and Implementation of the Spad Filesystem Department of Software Engineering Advisor: RNDr. Filip Zavoral, Ph.D. Abstract Title: Design and Implementation of the Spad Filesystem Author: Mgr. Mikul´aˇsPatoˇcka email: [email protected]ff.cuni.cz Department: Department of Software Engineering Faculty of Mathematics and Physics Charles University in Prague, Czech Republic Advisor: RNDr. Filip Zavoral, Ph.D. email: Filip.Zavoral@mff.cuni.cz Mailing address (advisor): Dept. of Software Engineering Charles University in Prague Malostransk´en´am. 25 118 00 Prague, Czech Republic WWW: http://artax.karlin.mff.cuni.cz/~mikulas/spadfs/ Abstract: This thesis describes design and implementation of the Spad filesystem. I present my novel method for maintaining filesystem consistency — crash counts. I describe architecture of other filesystems and present my own de- sign decisions in directory management, file allocation information, free space management, block allocation strategy and filesystem checking algorithm. I experimentally evaluate performance of the filesystem. I evaluate performance of the same filesystem on two different operating systems, enabling the reader to make a conclusion on how much the performance of various tasks is affected by operating system and how much by physical layout of data on disk. Keywords: filesystem, operating system, crash counts, extendible hashing, SpadFS Acknowledgments I would like to thank my advisor Filip Zavoral for supporting my work and for reading and making comments on this thesis. I would also like to thank to colleague Leo Galamboˇsfor testing my filesystem on his search engine with 1TB RAID array, which led to fixing some bugs and improving performance. The work was partly supported by the project 1ET100300419 of the Program Infor- mation Society of the Thematic Program II of the National Research Program of the Czech Republic. Content 1. Introduction ..............................................................................................................11 1.1 The structure of this thesis......................................................................................11 1.2 General filesystem architecture ................................................................................12 1.2.1 File allocation subsystem ......................................................................................14 1.2.2 Directory organization subsystem .........................................................................14 1.2.3 Free space management.........................................................................................14 1.2.4 Block allocation strategy.......................................................................................14 1.2.5 Crash recovery subsystem .....................................................................................15 1.2.6 Transparent compression.......................................................................................15 1.2.7 Security information..............................................................................................15 1.2.8 Transparent encryption.........................................................................................16 1.3 Related work............................................................................................................16 1.3.1 The FAT................................................................................................................16 1.3.2 The HPFS .............................................................................................................17 1.3.3 The NTFS.............................................................................................................17 1.3.4 The FFS................................................................................................................18 1.3.5 Ext2 ......................................................................................................................18 1.3.6 Ext3 ......................................................................................................................19 1.3.7 Ext4 ......................................................................................................................19 1.3.8 ReiserFS................................................................................................................19 1.3.9 Reiser4 ..................................................................................................................20 1.3.10 The JFS...............................................................................................................20 1.3.11 The XFS..............................................................................................................21 1.3.12 The ZFS ..............................................................................................................21 1.3.13 The GFS..............................................................................................................21 2. Design goals of the Spad filesystem...........................................................................23 2.1 Extensibility to arbitrarily fast devices....................................................................23 2.2 Good efficiency for both small and large files ..........................................................24 2.3 Reduced code complexity.........................................................................................24 2.4 Fast recovery after crash..........................................................................................25 2.5 Data layout suitable for prefetching.........................................................................25 3. Crash count method..................................................................................................27 3.1 Related work............................................................................................................27 3.1.1 Journaling .............................................................................................................27 3.1.2 Log-structured filesystems.....................................................................................28 3.1.3 Phase tree .............................................................................................................28 3.1.4 Soft updates ..........................................................................................................29 3.1.5 Conclusion.............................................................................................................29 3.2 Overview of crash counts .........................................................................................29 3.3 Data structures ........................................................................................................30 3.4 Mounting, unmounting, syncing ..............................................................................31 3.5 Managing directory entries using crash counts ........................................................32 3.6 Managing other disk structures ...............................................................................33 3.7 Managing file allocation info....................................................................................34 3.8 Requirement of atomic disk sector write..................................................................34 3.9 Avoiding blocking of filesystem activity during sync ...............................................35 3.9.1 Writing buffers twice.............................................................................................36 3.9.2 Write barriers........................................................................................................36 3.9.3 Cache in VFS........................................................................................................37 3.10 Summary................................................................................................................37 4. Directories .................................................................................................................39 4.1 Methods in existing filesystems................................................................................39 4.1.1 The HPFS .............................................................................................................39 4.1.2 The JFS ................................................................................................................40 4.1.3 The XFS ...............................................................................................................40 4.1.4 ReiserFS................................................................................................................41 4.1.5 Ext3 ......................................................................................................................41 4.1.6 Extendible hashing: ZFS and GFS .......................................................................42 4.2 Directories in the Spad filesystem............................................................................43 4.2.1 Modification of the algorithm for the Spad filesystem ..........................................43 4.2.2 Description of the algorithm for managing directories in the Spad filesystem......44 4.3 Summary..................................................................................................................46 5. File allocation information