next up previous contents
Next: 3.6 Status of Current Up: 3. Mechanisms for Interposition Previous: 3.4 Composition

   
3.5 Private VFS State

Added state must be attached to each vfs structure (the structure that describes whole file systems) just as for vnodes. The vfs structure also contains a pointer to an opaque private area, so I use the same technique as for vnodes.


  
Figure: Private Data Held for Each Interposing VFS

Figure: Private Data Held for Each Interposing VFS


typedef struct fist_wrapinfo {
  struct vfs      *fwi_mountvfs;  /* vfs interposed upon */
  struct vnode    fwi_rootvnode;  /* root vnode */
  int             fwi_num_vnodes; /* # of interposed vnodes */
} fist_wrapinfo_t;





4.5in


typedef struct fist_wrapinfo {
  struct vfs      *fwi_mountvfs;  /* vfs interposed upon */
  struct vnode    fwi_rootvnode;  /* root vnode */
  int             fwi_num_vnodes; /* # of interposed vnodes */
} fist_wrapinfo_t;

An auxiliary fist_wrapinfo_t structure, shown in Figure fig-struct-fist-wrapinfo, houses a pointer to the vfs structure of the interposed-upon file system and a pointer to the root vnode of the interposing file system. Also, while not strictly necessary, for debugging purposes I added a counter that tracks the number of vnodes in use in the file system.

This background makes it possible to understand the actions taken when an interposing file system is mounted on an interposed-upon file system:

1.
Initialize basic fields and assert arguments' validity. One of the important assertions verified is that there are no open files on the mount point and file system being mounted. If there were any, an interposing mount could not ensure that it interposed upon every vnode in the interposed file system.

2.
Prepare the private information stored by the interposing VFS.

3.
Prepare the private information stored by the interposing vnode. This vnode would become the root vnode for Wrapfs.

4.
Fill in the information for the VFS structure. Especially important are the private data held by it (vfs_data), the operations vector (vfs_op), and the vnode it covers (vfs_vnodecovered). See Figure fig-vfs-h for details of all VFS fields.

5.
Allocate a vnode to be used as the root vnode for Wrapfs. Fill in important fields such as the vnode operations vector (v_op), the private data field (v_data) which stores the interposed vnode, and turn on the VROOT flag for that vnode in the v_flag field, indicating that this vnode is a root of its file system. See Figure fig-vnode-h for details of all vnode fields.

6.
This root vnode just created is then stored in the private data field of the vfs we are mounting. The VFS operation vfs_root is called automatically on a vfs in order to retrieve its root vnode. Storing it in the private data field makes it trivial to return.

7.
Indicate in the vnode that is the mount point, that we are mounting this vfs on. This fills in the v_vfsmountedhere field of the mount point vnode.

8.
Return success or error code.

Appendix sec-appendix-wrap-mount includes the code used to interpose a wrapping module on top of another file system.


next up previous contents
Next: 3.6 Status of Current Up: 3. Mechanisms for Interposition Previous: 3.4 Composition
Erez Zadok
1999-12-07