MFp4: Rearange the code so vobject is destroyed from reclaim() method like
in all other file system on FreeBSD (instead from inactive() method). A nice side-effect of this change, except that it speedups file system when mmaped file are often open/closed, is that it makes FreeBSD's namecache work:)
This commit is contained in:
parent
0cdad5e228
commit
f13f738876
@ -3400,11 +3400,6 @@ zfs_freebsd_inactive(ap)
|
||||
{
|
||||
vnode_t *vp = ap->a_vp;
|
||||
|
||||
/*
|
||||
* Destroy the vm object and flush associated pages.
|
||||
*/
|
||||
vnode_destroy_vobject(vp);
|
||||
|
||||
zfs_inactive(vp, ap->a_td->td_ucred);
|
||||
return (0);
|
||||
}
|
||||
@ -3416,28 +3411,38 @@ zfs_freebsd_reclaim(ap)
|
||||
struct thread *a_td;
|
||||
} */ *ap;
|
||||
{
|
||||
vnode_t *vp = ap->a_vp;
|
||||
vnode_t *vp = ap->a_vp;
|
||||
znode_t *zp = VTOZ(vp);
|
||||
zfsvfs_t *zfsvfs;
|
||||
int rele = 1;
|
||||
|
||||
ASSERT(zp != NULL);
|
||||
|
||||
if (zp != NULL)
|
||||
mutex_enter(&zp->z_lock);
|
||||
#if 0 /*
|
||||
* We do it from zfs_inactive(), because after zfs_inactive() we can't
|
||||
* VOP_WRITE() to the vnode.
|
||||
*/
|
||||
/*
|
||||
* Destroy the vm object and flush associated pages.
|
||||
*/
|
||||
vnode_destroy_vobject(vp);
|
||||
#endif
|
||||
|
||||
mutex_enter(&zp->z_lock);
|
||||
ASSERT(zp->z_phys);
|
||||
ASSERT(zp->z_dbuf_held);
|
||||
zfsvfs = zp->z_zfsvfs;
|
||||
if (!zp->z_unlinked) {
|
||||
zp->z_dbuf_held = 0;
|
||||
ZTOV(zp) = NULL;
|
||||
mutex_exit(&zp->z_lock);
|
||||
dmu_buf_rele(zp->z_dbuf, NULL);
|
||||
} else {
|
||||
mutex_exit(&zp->z_lock);
|
||||
}
|
||||
VI_LOCK(vp);
|
||||
if (vp->v_count > 0)
|
||||
rele = 0;
|
||||
vp->v_data = NULL;
|
||||
if (zp != NULL)
|
||||
zp->z_vnode = NULL;
|
||||
ASSERT(vp->v_holdcnt > 1);
|
||||
vdropl(vp);
|
||||
if (zp != NULL)
|
||||
mutex_exit(&zp->z_lock);
|
||||
if (!zp->z_unlinked && rele)
|
||||
VFS_RELE(zfsvfs->z_vfs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -683,12 +683,8 @@ zfs_zinactive(znode_t *zp)
|
||||
}
|
||||
ASSERT(zp->z_phys);
|
||||
ASSERT(zp->z_dbuf_held);
|
||||
|
||||
zp->z_dbuf_held = 0;
|
||||
mutex_exit(&zp->z_lock);
|
||||
dmu_buf_rele(zp->z_dbuf, NULL);
|
||||
ZFS_OBJ_HOLD_EXIT(zfsvfs, z_id);
|
||||
VFS_RELE(zfsvfs->z_vfs);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3400,11 +3400,6 @@ zfs_freebsd_inactive(ap)
|
||||
{
|
||||
vnode_t *vp = ap->a_vp;
|
||||
|
||||
/*
|
||||
* Destroy the vm object and flush associated pages.
|
||||
*/
|
||||
vnode_destroy_vobject(vp);
|
||||
|
||||
zfs_inactive(vp, ap->a_td->td_ucred);
|
||||
return (0);
|
||||
}
|
||||
@ -3416,28 +3411,38 @@ zfs_freebsd_reclaim(ap)
|
||||
struct thread *a_td;
|
||||
} */ *ap;
|
||||
{
|
||||
vnode_t *vp = ap->a_vp;
|
||||
vnode_t *vp = ap->a_vp;
|
||||
znode_t *zp = VTOZ(vp);
|
||||
zfsvfs_t *zfsvfs;
|
||||
int rele = 1;
|
||||
|
||||
ASSERT(zp != NULL);
|
||||
|
||||
if (zp != NULL)
|
||||
mutex_enter(&zp->z_lock);
|
||||
#if 0 /*
|
||||
* We do it from zfs_inactive(), because after zfs_inactive() we can't
|
||||
* VOP_WRITE() to the vnode.
|
||||
*/
|
||||
/*
|
||||
* Destroy the vm object and flush associated pages.
|
||||
*/
|
||||
vnode_destroy_vobject(vp);
|
||||
#endif
|
||||
|
||||
mutex_enter(&zp->z_lock);
|
||||
ASSERT(zp->z_phys);
|
||||
ASSERT(zp->z_dbuf_held);
|
||||
zfsvfs = zp->z_zfsvfs;
|
||||
if (!zp->z_unlinked) {
|
||||
zp->z_dbuf_held = 0;
|
||||
ZTOV(zp) = NULL;
|
||||
mutex_exit(&zp->z_lock);
|
||||
dmu_buf_rele(zp->z_dbuf, NULL);
|
||||
} else {
|
||||
mutex_exit(&zp->z_lock);
|
||||
}
|
||||
VI_LOCK(vp);
|
||||
if (vp->v_count > 0)
|
||||
rele = 0;
|
||||
vp->v_data = NULL;
|
||||
if (zp != NULL)
|
||||
zp->z_vnode = NULL;
|
||||
ASSERT(vp->v_holdcnt > 1);
|
||||
vdropl(vp);
|
||||
if (zp != NULL)
|
||||
mutex_exit(&zp->z_lock);
|
||||
if (!zp->z_unlinked && rele)
|
||||
VFS_RELE(zfsvfs->z_vfs);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -683,12 +683,8 @@ zfs_zinactive(znode_t *zp)
|
||||
}
|
||||
ASSERT(zp->z_phys);
|
||||
ASSERT(zp->z_dbuf_held);
|
||||
|
||||
zp->z_dbuf_held = 0;
|
||||
mutex_exit(&zp->z_lock);
|
||||
dmu_buf_rele(zp->z_dbuf, NULL);
|
||||
ZFS_OBJ_HOLD_EXIT(zfsvfs, z_id);
|
||||
VFS_RELE(zfsvfs->z_vfs);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user