Print this page
fsh, fsd, libfsd, fsdadm

@@ -82,10 +82,12 @@
 #include <sys/attr.h>
 #include <sys/zio.h>
 #include <sys/spa.h>
 #include <sys/lofi.h>
 #include <sys/bootprops.h>
+#include <sys/fsh.h>
+#include <sys/fsh_impl.h>
 
 #include <vm/page.h>
 
 #include <fs/fs_subr.h>
 /* Private interfaces to create vopstats-related data structures */

@@ -214,17 +216,17 @@
  */
 
 int
 fsop_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
 {
-        return (*(vfsp)->vfs_op->vfs_mount)(vfsp, mvp, uap, cr);
+        return (fsh_mount(vfsp, mvp, uap, cr));
 }
 
 int
 fsop_unmount(vfs_t *vfsp, int flag, cred_t *cr)
 {
-        return (*(vfsp)->vfs_op->vfs_unmount)(vfsp, flag, cr);
+        return (fsh_unmount(vfsp, flag, cr));
 }
 
 int
 fsop_root(vfs_t *vfsp, vnode_t **vpp)
 {

@@ -1783,10 +1785,11 @@
                                 vfs_unlock(vfsp);
                         }
                 }
                 /* Return vfsp to caller. */
                 *vfspp = vfsp;
+                fsh_exec_mount_callbacks(vfsp);
         }
 errout:
         vfs_freeopttbl(&mnt_mntopts);
         if (resource != NULL)
                 kmem_free(resource, strlen(resource) + 1);

@@ -4233,10 +4236,13 @@
         vn_create_cache();
 
         /* Setup event monitor framework */
         fem_init();
 
+        /* Setup filesystem hook framework */
+        fsh_init();
+
         /* Initialize the dummy stray file system type. */
         error = vfs_setfsops(0, stray_vfsops_template, NULL);
 
         /* Initialize the dummy EIO file system. */
         error = vfs_makefsops(EIO_vfsops_template, &EIO_vfsops);

@@ -4317,10 +4323,17 @@
                 mutex_destroy(&vfsp->vfs_femhead->femh_lock);
                 kmem_free(vfsp->vfs_femhead, sizeof (*(vfsp->vfs_femhead)));
                 vfsp->vfs_femhead = NULL;
         }
 
+        /*
+         * FSH cleanup
+         * There's no need here to use atomic operations on vfs_fshrecord.
+         */
+        fsh_fsrec_destroy(vfsp->vfs_fshrecord);
+        vfsp->vfs_fshrecord = NULL;
+
         if (vfsp->vfs_implp)
                 vfsimpl_teardown(vfsp);
         sema_destroy(&vfsp->vfs_reflock);
         kmem_cache_free(vfs_cache, vfsp);
 }

@@ -4343,10 +4356,11 @@
 void
 vfs_rele(vfs_t *vfsp)
 {
         ASSERT(vfsp->vfs_count != 0);
         if (atomic_add_32_nv(&vfsp->vfs_count, -1) == 0) {
+                fsh_exec_free_callbacks(vfsp);
                 VFS_FREEVFS(vfsp);
                 lofi_remove(vfsp);
                 if (vfsp->vfs_zone)
                         zone_rele_ref(&vfsp->vfs_implp->vi_zone_ref,
                             ZONE_REF_VFS);