Fist: a System for Stackable File-System Code Generation Erez
Total Page:16
File Type:pdf, Size:1020Kb
FiST: A System for Stackable File-System Code Generation Erez Zadok Submitted in partial fulfillment of the requirements for the degree of Doctor of Philosophy in the Graduate School of Arts and Sciences COLUMBIA UNIVERSITY May, 2001 c 2001 Erez Zadok All Rights Reserved ABSTRACT FiST: A System for Stackable File-System Code Generation Erez Zadok File systems often need to evolve and require many changes to support new features. Traditional file-system development is difficult because most of the work is done in the kernel—a hostile development environment where progress is slow, debugging is difficult, and simple mistakes can crash systems. Kernel work also requires deep understanding of system internals, resulting in developers spending a lot of time becoming familiar with the system’s details. Furthermore, any file system written for one system requires significant effort to port to another system. Stackable file systems promise to ease the development of file systems by offering a mechanism for incremental development building on existing file systems. Unfortunately, existing stacking methods often require writing complex low-level kernel code that is specific to a single operating system platform and also difficult to port. We propose a new language, FiST, to describe stackable file systems. FiST uses operations common to file-system interfaces and familiar to user-level developers: creating a directory, reading a file, removing a file, listing the contents of a directory, etc. From a single description, FiST’s compiler produces file-system modules for multiple platforms. FiST does that with the assistance of platform-specific stackable templates. The templates handle many of the internal details of operating systems, and free developers from dealing with these internals. The templates support many features: data copying and file name copying useful for applications that want to modify them; size-changing file systems such as compression; fan-out for access to multiple file systems from one layer; and more. The FiST language compiler uses the templates as a basis for producing code for a new file system, by inserting, removing, or modifying code in the templates. This dissertation describes the design, implementation, and evaluation of FiST. Our thesis is that it is possible to extend file system functionality in a portable way without changing existing kernels. This is possible because the FiST language uses file-system functions that are common across many systems, while the templates execute in-kernel operating systems specific functions unchanged. We built several file systems using FiST on Solaris, FreeBSD, and Linux. Our experiences with these file systems show the following benefits: average code size is reduced ten times as compared to writing code given another null-layer stackable file system; average development time is reduced seven times compared to writing using another null-layer stackable file system; performance overhead of stacking is only 1–2% per layer. Contents List of Tables v List of Figures vi Chapter 1 Introduction 1 1.1 Our Approach . 2 1.2 Contributions . 3 1.3 Thesis Organization . 4 Chapter 2 Background 5 2.1 Evolution of File Systems Development . 5 2.1.1 Native File Systems . 5 2.1.2 User-Level File Systems . 6 2.1.3 The Vnode Interface . 7 2.1.4 A Stackable Vnode Interface . 9 2.1.4.1 First Stacking Interfaces . 11 2.1.4.2 Fanning in Stackable File Systems . 12 2.1.4.3 Interposition and Composition . 13 2.1.4.4 4.4 BSD’s Nullfs . 15 2.1.4.5 Programmed Logic Corp.’s StackFS . 15 2.1.5 HURD . 15 2.1.5.1 How to Write a Translator . 16 2.1.6 Plan 9 . 17 2.1.6.1 Inferno . 18 2.1.7 Spring . 18 2.1.8 Windows NT . 19 2.1.9 Other Extensible File-System Efforts . 20 2.1.9.1 Compression Support . 20 2.1.10 Domain Specific Languages . 21 2.2 File Systems Development Taxonomy . 21 Chapter 3 Design Overview 24 3.1 Layers of Abstraction . 24 3.2 FiST Templates and Code Generator . 25 3.3 The Development Process . 26 i 3.3.1 Developing From Scratch . 26 3.3.2 Developing Using Existing Stacking . 27 3.3.3 Developing Using FiST . 27 3.4 The FiST Programming Model . 28 3.5 The File-System Model . 29 Chapter 4 The FiST Language 31 4.1 Overview of the FiST Input File . 31 4.2 FiST Syntax . 33 4.3 Rules for Controlling Execution and Information Flow . 35 4.4 Filter Declarations and Filter Functions . 37 4.5 Fistgen: The FiST Language Code Generator . 37 Chapter 5 Stackable Templates 39 5.1 Overview of the Basefs Templates . 39 5.2 Manipulating Files . 41 5.3 Encoding and Decoding File Data Pages . 41 5.3.1 Paged Reading and Writing . 42 5.3.1.1 Appending to Files . 43 5.3.2 Memory Mapping . 43 5.3.3 Interaction Between Caches . 43 5.4 Encoding and Decoding File Names . 44 5.5 Error Codes . 44 Chapter 6 Support for Size-Changing File Systems 46 6.1 Size-Changing Algorithms . 46 6.2 Overview of Support for Size-Changing Stackable File Systems . 47 6.3 The Index File . 49 6.3.1 File Operations . 50 6.3.1.1 Fast Tails . 51 6.3.1.2 Write in the Middle . 52 6.3.1.3 Truncate . 53 6.3.2 Additional Benefits of the Index File . 53 6.3.2.1 Low Resource Usage . 54 6.3.2.2 Index File Consistency . 54 6.4 Summary . 55 Chapter 7 Implementation 56 7.1 Templates . 56 7.1.1 Stacking . 56 7.1.2 FreeBSD . 57 7.1.3 Linux . 58 7.1.3.1 Call Sequence and Existence . 58 7.1.3.2 Data Structures . 58 7.2 Size-Changing Algorithms . 60 7.3 Fistgen . 60 ii Chapter 8 File Systems Developed Using FiST 62 8.1 Cryptfs . 62 8.2 Aclfs . 64 8.3 Unionfs . 65 8.4 Copyfs . ..