Print this page
fixes to fsh

@@ -93,18 +93,18 @@
 /*
  * It is assumed that VFS_HOLD() has been called before calling any of the
  * fsh_fs_xxx()/fsh_hook_xxx() API. VFS_RELE() should be called after.
  */
 
-#define FSH_GET_FSREC(vfsp)     (vfsp->vfs_fshrecord)
+#define FSH_GET_FSRECP(vfsp)    (vfsp->vfs_fshrecord)
 
 int
 fsh_fs_enable(vfs_t *vfsp)
 {
         fsh_fsrecord_t *fsrec;
 
-        fsrec = FSH_GET_FSREC(vfsp);
+        fsrec = FSH_GET_FSRECP(vfsp);
         rw_enter(&fsrec->fshfsr_en_lock, RW_WRITER);
         fsrec->fshfsr_enabled = 1;
         rw_exit(&fsrec->fshfsr_en_lock);
 
         return (0);

@@ -113,11 +113,11 @@
 int
 fsh_fs_disable(vfs_t *vfsp)
 {
         fsh_fsrecord_t *fsrec;
 
-        fsrec = FSH_GET_FSREC(vfsp);
+        fsrec = FSH_GET_FSRECP(vfsp);
         rw_enter(&fsrec->fshfsr_en_lock, RW_WRITER);
         fsrec->fshfsr_enabled = 0;
         rw_exit(&fsrec->fshfsr_en_lock);
 
         return (0);

@@ -131,18 +131,20 @@
                                         KM_SLEEP);                      \
                 nodep->fshn_hooki.fshi_fn.hook_##lower =                \
                         hooks->hook_##lower;                            \
                 nodep->fshn_hooki.fshi_arg = hooks->arg;                \
                                                                         \
+                listp = &fsrecp->fshfsr_opv[FSH_##type##_##upper];      \
                 rw_enter(&listp->fshl_lock, RW_WRITER);                 \
                 nodep->fshn_next =                                      \
                         fsrecp                                          \
                         ->fshfsr_opv[FSH_##type##_##upper].fshl_head;   \
                 fsrecp->fshfsr_opv[FSH_##type##_##upper].fshl_head      \
                         = nodep;                                        \
                 rw_exit(&listp->fshl_lock);                             \
         }                                                               \
+_NOTE(CONSTCOND)                                                        \
 } while (0)
 
 #define FSH_INSTALL_VN(hooks, fsrecp, listp, nodep, lower, upper)       \
         FSH_INSTALL(VOP, hooks, fsrecp, listp, nodep, lower, upper)
 

@@ -154,11 +156,11 @@
 {
         fsh_fsrecord_t  *fsrec;
         fsh_list_t      *list;
         fsh_node_t      *node;
 
-        fsrec = FSH_GET_FSREC(vfsp);
+        fsrec = FSH_GET_FSRECP(vfsp);
 
         FSH_INSTALL_VN(hooks, fsrec, list, node, open, OPEN);
         FSH_INSTALL_VN(hooks, fsrec, list, node, close, CLOSE);
         FSH_INSTALL_VN(hooks, fsrec, list, node, read, READ);
         FSH_INSTALL_VN(hooks, fsrec, list, node, write, WRITE);

@@ -204,10 +206,11 @@
         else                                                            \
                 prev->fshn_next = node->fshn_next;                      \
         rw_exit(&list->fshl_lock);                                      \
                                                                         \
         kmem_free(node, sizeof (*node));                                \
+_NOTE(CONSTCOND)                                                        \
 } while (0)
 
 #define FSH_REMOVE_VN(hooks, fsrec, list, node, prev, lower, upper)     \
         FSH_REMOVE(VOP, hooks, fsrec, list, node, prev, lower, upper)
 

@@ -220,11 +223,11 @@
         fsh_fsrecord_t  *fsrec;
         fsh_list_t      *list;
         fsh_node_t      *node;
         fsh_node_t      *prev;
 
-        fsrec = FSH_GET_FSREC(vfsp);
+        fsrec = FSH_GET_FSRECP(vfsp);
 
         FSH_REMOVE_VN(hooks, fsrec, list, node, prev, open, OPEN);
         FSH_REMOVE_VN(hooks, fsrec, list, node, prev, close, CLOSE);
         FSH_REMOVE_VN(hooks, fsrec, list, node, prev, read, READ);
         FSH_REMOVE_VN(hooks, fsrec, list, node, prev, write, WRITE);

@@ -292,13 +295,14 @@
 
 
 
 #define FSH_ENABLED(vfsp, enabled)                                      \
 do {                                                                    \
-        rw_enter(&FSH_GET_FSREC(vfsp)->fshfsr_en_lock, RW_READER);      \
-        *enabled = FSH_GET_FSREC(vfsp)->fshfsr_enabled;                 \
-        rw_exit(&FSH_GET_FSREC(vfsp)->fshfsr_en_lock);          \
+        rw_enter(&FSH_GET_FSRECP(vfsp)->fshfsr_en_lock, RW_READER);     \
+        *enabled = FSH_GET_FSRECP(vfsp)->fshfsr_enabled;                        \
+        rw_exit(&FSH_GET_FSRECP(vfsp)->fshfsr_en_lock);                 \
+_NOTE(CONSTCOND)                                                        \
 } while (0)
 
 int
 fsh_open(vnode_t **vpp, int mode, cred_t *cr, caller_context_t *ct)
 {

@@ -308,11 +312,11 @@
 
         FSH_ENABLED((*vpp)->v_vfsp, &enabled);
         if (!enabled)
                 return ((*((*vpp)->v_op->vop_open))(vpp, mode, cr, ct));
 
-        list = &FSH_GET_FSREC((*vpp)->v_vfsp)->fshfsr_opv[FSH_VOP_OPEN];
+        list = &FSH_GET_FSRECP((*vpp)->v_vfsp)->fshfsr_opv[FSH_VOP_OPEN];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret =  (*((*vpp)->v_op->vop_open))(vpp, mode, cr, ct);
         else
                 ret = fsh_next_open(list->fshl_head, vpp, mode, cr, ct);

@@ -332,11 +336,11 @@
         FSH_ENABLED(vp->v_vfsp, &enabled);
         if (!enabled)
                 return ((*(vp->v_op->vop_close))(vp, flag, count, offset,
                         cr, ct));
 
-        list = &FSH_GET_FSREC(vp->v_vfsp)->fshfsr_opv[FSH_VOP_CLOSE];
+        list = &FSH_GET_FSRECP(vp->v_vfsp)->fshfsr_opv[FSH_VOP_CLOSE];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret =  (*(vp->v_op->vop_close))(vp, flag, count, offset,
                         cr, ct);
         else

@@ -357,11 +361,11 @@
 
         FSH_ENABLED(vp->v_vfsp, &enabled);
         if (!enabled)
                 return ((*(vp->v_op->vop_read))(vp, uiop, ioflag, cr, ct));
 
-        list = &FSH_GET_FSREC(vp->v_vfsp)->fshfsr_opv[FSH_VOP_READ];
+        list = &FSH_GET_FSRECP(vp->v_vfsp)->fshfsr_opv[FSH_VOP_READ];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret =  (*(vp->v_op->vop_read))(vp, uiop, ioflag, cr, ct);
         else
                 ret = fsh_next_read(list->fshl_head, vp, uiop, ioflag,

@@ -381,11 +385,11 @@
 
         FSH_ENABLED(vp->v_vfsp, &enabled);
         if (!enabled)
                 return ((*(vp->v_op->vop_write))(vp, uiop, ioflag, cr, ct));
 
-        list = &FSH_GET_FSREC(vp->v_vfsp)->fshfsr_opv[FSH_VOP_WRITE];
+        list = &FSH_GET_FSRECP(vp->v_vfsp)->fshfsr_opv[FSH_VOP_WRITE];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret =  (*(vp->v_op->vop_write))(vp, uiop, ioflag, cr, ct);
         else
                 ret = fsh_next_write(list->fshl_head, vp, uiop, ioflag,

@@ -399,11 +403,11 @@
 fsh_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
 {
         fsh_list_t *list;
         int ret;
 
-        list = &FSH_GET_FSREC(vfsp)->fshfsr_opv[FSH_VFS_MOUNT];
+        list = &FSH_GET_FSRECP(vfsp)->fshfsr_opv[FSH_VFS_MOUNT];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret = (*(vfsp->vfs_op->vfs_mount))(vfsp, mvp, uap, cr);
         else
                 ret = fsh_next_mount(list->fshl_head, vfsp, mvp, uap,

@@ -417,11 +421,11 @@
 fsh_unmount(vfs_t *vfsp, int flag, cred_t *cr)
 {
         fsh_list_t *list;
         int ret;
 
-        list = &FSH_GET_FSREC(vfsp)->fshfsr_opv[FSH_VFS_UNMOUNT];
+        list = &FSH_GET_FSRECP(vfsp)->fshfsr_opv[FSH_VFS_UNMOUNT];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret = (*(vfsp->vfs_op->vfs_unmount))(vfsp, flag, cr);
         else
                 ret = fsh_next_unmount(list->fshl_head, vfsp, flag, cr);

@@ -434,11 +438,11 @@
 fsh_root(vfs_t *vfsp, vnode_t **vpp)
 {
         fsh_list_t *list;
         int ret;
 
-        list = &FSH_GET_FSREC(vfsp)->fshfsr_opv[FSH_VFS_ROOT];
+        list = &FSH_GET_FSRECP(vfsp)->fshfsr_opv[FSH_VFS_ROOT];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret = (*(vfsp->vfs_op->vfs_root))(vfsp, vpp);
         else
                 ret = fsh_next_root(list->fshl_head, vfsp, vpp);

@@ -451,11 +455,11 @@
 fsh_statfs(vfs_t *vfsp, statvfs64_t *sp)
 {
         fsh_list_t *list;
         int ret;
 
-        list = &FSH_GET_FSREC(vfsp)->fshfsr_opv[FSH_VFS_STATFS];
+        list = &FSH_GET_FSRECP(vfsp)->fshfsr_opv[FSH_VFS_STATFS];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret = (*(vfsp->vfs_op->vfs_statvfs))(vfsp, sp);
         else
                 ret = fsh_next_statfs(list->fshl_head, vfsp, sp);

@@ -468,11 +472,11 @@
 fsh_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
 {
         fsh_list_t *list;
         int ret;
 
-        list = &FSH_GET_FSREC(vfsp)->fshfsr_opv[FSH_VFS_VGET];
+        list = &FSH_GET_FSRECP(vfsp)->fshfsr_opv[FSH_VFS_VGET];
         rw_enter(&list->fshl_lock, RW_READER);
         if (list->fshl_head == NULL)
                 ret = (*(vfsp->vfs_op->vfs_vget))(vfsp, vpp, fidp);
         else
                 ret = fsh_next_vget(list->fshl_head, vfsp, vpp, fidp);

@@ -522,16 +526,16 @@
 
         fsrecp = (fsh_fsrecord_t *) kmem_alloc(sizeof (*fsrecp), KM_SLEEP);
         bzero(fsrecp, sizeof (*fsrecp));
 
         rw_init(&fsrecp->fshfsr_en_lock, NULL, RW_DRIVER, NULL);
-        fsrecp->fshfsr_enabled = 1;
+        fsrecp->fshfsr_enabled = 0; // DEBUG
 
         for (i = 0; i < FSH_SUPPORTED_OPS_COUNT; i++)
                 rw_init(&fsrecp->fshfsr_opv[i].fshl_lock, NULL, RW_DRIVER,
                         NULL);
-        return fsrecp;
+        return (fsrecp);
 }
 
 /* To be used ONLY in vfs_free() */
 void
 fsh_fsrec_destroy(fsh_fsrecord_t *fsrecp)