Print this page
fixes to fsh
*** 93,110 ****
/*
* 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)
int
fsh_fs_enable(vfs_t *vfsp)
{
fsh_fsrecord_t *fsrec;
! fsrec = FSH_GET_FSREC(vfsp);
rw_enter(&fsrec->fshfsr_en_lock, RW_WRITER);
fsrec->fshfsr_enabled = 1;
rw_exit(&fsrec->fshfsr_en_lock);
return (0);
--- 93,110 ----
/*
* 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_FSRECP(vfsp) (vfsp->vfs_fshrecord)
int
fsh_fs_enable(vfs_t *vfsp)
{
fsh_fsrecord_t *fsrec;
! 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,123 ****
int
fsh_fs_disable(vfs_t *vfsp)
{
fsh_fsrecord_t *fsrec;
! fsrec = FSH_GET_FSREC(vfsp);
rw_enter(&fsrec->fshfsr_en_lock, RW_WRITER);
fsrec->fshfsr_enabled = 0;
rw_exit(&fsrec->fshfsr_en_lock);
return (0);
--- 113,123 ----
int
fsh_fs_disable(vfs_t *vfsp)
{
fsh_fsrecord_t *fsrec;
! 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,148 ****
--- 131,150 ----
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,164 ****
{
fsh_fsrecord_t *fsrec;
fsh_list_t *list;
fsh_node_t *node;
! fsrec = FSH_GET_FSREC(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);
--- 156,166 ----
{
fsh_fsrecord_t *fsrec;
fsh_list_t *list;
fsh_node_t *node;
! 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,213 ****
--- 206,216 ----
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,230 ****
fsh_fsrecord_t *fsrec;
fsh_list_t *list;
fsh_node_t *node;
fsh_node_t *prev;
! fsrec = FSH_GET_FSREC(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);
--- 223,233 ----
fsh_fsrecord_t *fsrec;
fsh_list_t *list;
fsh_node_t *node;
fsh_node_t *prev;
! 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,304 ****
#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); \
} while (0)
int
fsh_open(vnode_t **vpp, int mode, cred_t *cr, caller_context_t *ct)
{
--- 295,308 ----
#define FSH_ENABLED(vfsp, enabled) \
do { \
! 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,318 ****
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];
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);
--- 312,322 ----
FSH_ENABLED((*vpp)->v_vfsp, &enabled);
if (!enabled)
return ((*((*vpp)->v_op->vop_open))(vpp, mode, cr, ct));
! 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,342 ****
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];
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
--- 336,346 ----
FSH_ENABLED(vp->v_vfsp, &enabled);
if (!enabled)
return ((*(vp->v_op->vop_close))(vp, flag, count, offset,
cr, ct));
! 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,367 ****
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];
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,
--- 361,371 ----
FSH_ENABLED(vp->v_vfsp, &enabled);
if (!enabled)
return ((*(vp->v_op->vop_read))(vp, uiop, ioflag, cr, ct));
! 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,391 ****
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];
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,
--- 385,395 ----
FSH_ENABLED(vp->v_vfsp, &enabled);
if (!enabled)
return ((*(vp->v_op->vop_write))(vp, uiop, ioflag, cr, ct));
! 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,409 ****
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];
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,
--- 403,413 ----
fsh_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
{
fsh_list_t *list;
int ret;
! 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,427 ****
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];
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);
--- 421,431 ----
fsh_unmount(vfs_t *vfsp, int flag, cred_t *cr)
{
fsh_list_t *list;
int ret;
! 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,444 ****
fsh_root(vfs_t *vfsp, vnode_t **vpp)
{
fsh_list_t *list;
int ret;
! list = &FSH_GET_FSREC(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);
--- 438,448 ----
fsh_root(vfs_t *vfsp, vnode_t **vpp)
{
fsh_list_t *list;
int ret;
! 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,461 ****
fsh_statfs(vfs_t *vfsp, statvfs64_t *sp)
{
fsh_list_t *list;
int ret;
! list = &FSH_GET_FSREC(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);
--- 455,465 ----
fsh_statfs(vfs_t *vfsp, statvfs64_t *sp)
{
fsh_list_t *list;
int ret;
! 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,478 ****
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];
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);
--- 472,482 ----
fsh_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
{
fsh_list_t *list;
int ret;
! 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,537 ****
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;
for (i = 0; i < FSH_SUPPORTED_OPS_COUNT; i++)
rw_init(&fsrecp->fshfsr_opv[i].fshl_lock, NULL, RW_DRIVER,
NULL);
! return fsrecp;
}
/* To be used ONLY in vfs_free() */
void
fsh_fsrec_destroy(fsh_fsrecord_t *fsrecp)
--- 526,541 ----
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 = 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);
}
/* To be used ONLY in vfs_free() */
void
fsh_fsrec_destroy(fsh_fsrecord_t *fsrecp)