Download A File System Component Compiler

Transcript
15
3
Mechanisms for Interposition and Composition
I have conducted a feasibility study by implementing, by hand, in Solaris 2.4, much of the code that
FiST will have to produce automatically. This section explains the operation of that code, which will
be used as templates by the FiST compiler. Section 4 describes the FiST language.
3.1
Interposition API
The mount system call is used to interpose one file system on top
of another. Likewise, umount unmounts and hence de-interposes
a file system. Mounting can be relative to any file system
above or below, so that file systems can be “stacked” into a
X
Z
X
DAG. As an example, suppose that file system X is interposed on file system Y . To create fan-in, file system Z can
be mounted above Y . To create fan-out, Z can be mounted
Y
Y
Z
below X.
Figure 7 shows what mounts result in a fan-in vs. a fanFan-In
Fan-Out
out. The information of how many file systems are mounted
at a mount point is stored in a private VFS data structure,
Figure 7: Interposition Resulting in Fanand is described in Section 3.5.
in or Fan-out
3.2
Creating Links Among Vnodes
For each open file or directory, a vnode is allocated for each level of interposition. If there have been
N interpositions, then an open file will have N + 1 associated vnodes, one for the “base” file system
and one for each file system that has been interposed.
Each vnode of an interposing file system must have access to the vnode(s) that it interposes upon,
and this must be accomplished without changing the vnode definition. Fortunately, the vnode contains
a pointer (called v data) to an opaque private area. For each type of file system (e.g., NFS, UFS) this
pointer may point to a structure that includes extra information needed by that type of file system.
typedef struct fist_wrapnode {
vnode_t * fwn_vnodep[];
/* pointers to interposed-on vnodes */
int
count;
/* # of pointers; >1 indicates fanout */
/* additional per-vnode data here */
} fist_wrapnode_t;
Figure 8: Private Data of an Interposing Vnode
I have created a new “wrap” vnode type for interposing vnodes. For this type of vnode, v data
points to the private fist wrapnode t data structure shown in Figure 8. This structure contains
pointers to the vnodes it interposes upon. Pointers link vnodes from the top down, representing the
DAG of interposed file systems for each open file. Figure 9 shows an example of a caching file system,
and the relationship between the vnodes in use and their respective private data, especially that of the
interposing file system.