Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture (2nd Edition)

14.12. File System Conversion to Solaris 10

If you are porting a file system source to Solaris 10, you can follow these steps to convert an older file system to the new Solaris 10 APIs.

  1. Vnodes must be separated from FS-specific nodes (for example, inodes). Previously, most file systems embedded the vnode in the FS-specific node. The node should now have a pointer to the vnode. vnodes are allocated by the file system with vn_alloc() and freed with vn_free(). If the file system recycles vnodes (by means of a node cache), then vnodes can be reinitialized with vn_reinit().

    Note: Make sure the VTO{node}() and {node}TOV() routines and the corresponding FS-node macros are updated.

  2. Change all references to the "private" vnode fields to use accessors. The only "public" fields are listed below.

    kmutex_t v_lock; /* protects vnode fields */ uint_t v_flag; /* vnode flags (see below) */ uint_t v_count; /* reference count */ caddr_t v_data; /* private data for fs */ struct vfs *v_vfsp; /* ptr to containing VFS */ struct stdata *v_stream; /* associated stream */ enum vtype v_type; /* vnode type */ dev_t v_rdev; /* device (VCHR, VBLK) */

    Otherwise, information about the vnode can be accessed, as shown below.

    For: Use: v_vfsmountedhere vn_ismntpt() or vn_mountedvfs() v_op vn_setops(), vn_getops(), vn_matchops(), vn_matchopval() v_pages vn_has_cached_data() v_filocks vn_has_flocks(), vn_has_mandatory_locks()

  3. The only significant change to the vfs structure is that the vfs_op field should not be used directly. Any references or accesses to that field must go through one of the following: vfs_setops(), vfs_getops(), vfs_matchops(), vfs_can_sync().

  4. Create an FS definition structure (vfsdef_t). This is similar to, but replaces, the vfssw table entry.

  5. Create the operation definition tables for vnode and vfs operations.

  6. Update (or create) the FS initialization routine (called at module-loader time) to create the vfsops and vnodeops structures. You do this by calling vn_make_ops() and either vfs_setfsops() (or vfs_makefsops()), using the "operations definition table" (created above).

  7. Update the following vnode operation routines (if applicable):

    Add a pointer to the caller_context structure to the argument list for the following FS-specific routines: xxx_read(), xxx_write(), xxx_space(), xxx_setattr(), xxx_rwlock(), xxx_rwunlock().

    Add a pointer to the cred structure to the argument list for the following FS-specific routine: xxx_shrlock().

    Important note: Because the compilers don't yet support "designated initializers," the compiler cannot strongly type-check the file-system-specific vnode/vfs operations through the registration system. It's important that any changes to the argument list be done very carefully.

  8. vnode life cycle: When a vnode is created (fully initialized, after locks are dropped but before anyone can get to it), call vn_exists(vnode *vp). This notifies anyone with registered interest on this file system that a new vnode has been created. If just the vnode is to be torn down (still fully functional, but before any locks are taken), call vn_invalid(vnode_t *vp) so that anyone with registered interest can be notified that this vnode is about to go away.

Категории