Lines 4270-4282
zfs_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
Link Here
|
4270 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
4270 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
4271 |
int error; |
4271 |
int error; |
4272 |
|
4272 |
|
4273 |
ZFS_RLOCK_TEARDOWN_INACTIVE(zfsvfs); |
|
|
4274 |
if (zp->z_sa_hdl == NULL) { |
4273 |
if (zp->z_sa_hdl == NULL) { |
4275 |
/* |
4274 |
/* |
4276 |
* The fs has been unmounted, or we did a |
4275 |
* The fs has been unmounted, or we did a |
4277 |
* suspend/resume and this file no longer exists. |
4276 |
* suspend/resume and this file no longer exists. |
4278 |
*/ |
4277 |
*/ |
4279 |
ZFS_RUNLOCK_TEARDOWN_INACTIVE(zfsvfs); |
|
|
4280 |
vrecycle(vp); |
4278 |
vrecycle(vp); |
4281 |
return; |
4279 |
return; |
4282 |
} |
4280 |
} |
Lines 4285-4291
zfs_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
Link Here
|
4285 |
/* |
4283 |
/* |
4286 |
* Fast path to recycle a vnode of a removed file. |
4284 |
* Fast path to recycle a vnode of a removed file. |
4287 |
*/ |
4285 |
*/ |
4288 |
ZFS_RUNLOCK_TEARDOWN_INACTIVE(zfsvfs); |
|
|
4289 |
vrecycle(vp); |
4286 |
vrecycle(vp); |
4290 |
return; |
4287 |
return; |
4291 |
} |
4288 |
} |
Lines 4305-4311
zfs_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct)
Link Here
|
4305 |
dmu_tx_commit(tx); |
4302 |
dmu_tx_commit(tx); |
4306 |
} |
4303 |
} |
4307 |
} |
4304 |
} |
4308 |
ZFS_RUNLOCK_TEARDOWN_INACTIVE(zfsvfs); |
|
|
4309 |
} |
4305 |
} |
4310 |
|
4306 |
|
4311 |
|
4307 |
|
Lines 5416-5438
zfs_freebsd_reclaim(ap)
Link Here
|
5416 |
{ |
5412 |
{ |
5417 |
vnode_t *vp = ap->a_vp; |
5413 |
vnode_t *vp = ap->a_vp; |
5418 |
znode_t *zp = VTOZ(vp); |
5414 |
znode_t *zp = VTOZ(vp); |
5419 |
zfsvfs_t *zfsvfs = zp->z_zfsvfs; |
5415 |
zfsvfs_t *zfsvfs; |
5420 |
|
5416 |
|
5421 |
ASSERT(zp != NULL); |
5417 |
ASSERT(zp != NULL); |
|
|
5418 |
zfsvfs = zp->z_zfsvfs; |
5422 |
|
5419 |
|
5423 |
/* |
|
|
5424 |
* z_teardown_inactive_lock protects from a race with |
5425 |
* zfs_znode_dmu_fini in zfsvfs_teardown during |
5426 |
* force unmount. |
5427 |
*/ |
5428 |
ZFS_RLOCK_TEARDOWN_INACTIVE(zfsvfs); |
5429 |
if (zp->z_sa_hdl == NULL) |
5420 |
if (zp->z_sa_hdl == NULL) |
5430 |
zfs_znode_free(zp); |
5421 |
zfs_znode_free(zp); |
5431 |
else |
5422 |
else |
5432 |
zfs_zinactive(zp); |
5423 |
zfs_zinactive(zp); |
5433 |
ZFS_RUNLOCK_TEARDOWN_INACTIVE(zfsvfs); |
|
|
5434 |
|
5424 |
|
5435 |
vp->v_data = NULL; |
5425 |
vp->v_data = NULL; |
|
|
5426 |
|
5427 |
/* |
5428 |
* Drop z_teardown_lock acquired in zfs_freebsd_lock, |
5429 |
* because zfs_freebsd_unlock won't be called on this vnode. |
5430 |
*/ |
5431 |
lockmgr_assert(vp->v_vnlock, KA_XLOCKED | KA_NOTRECURSED); |
5432 |
rrm_exit(&zfsvfs->z_teardown_lock, vp); |
5433 |
|
5436 |
return (0); |
5434 |
return (0); |
5437 |
} |
5435 |
} |
5438 |
|
5436 |
|
Lines 6010-6018
zfs_vptocnp(struct vop_vptocnp_args *ap)
Link Here
|
6010 |
return (error); |
6008 |
return (error); |
6011 |
} |
6009 |
} |
6012 |
|
6010 |
|
6013 |
#ifdef DIAGNOSTIC |
6011 |
int |
6014 |
static int |
6012 |
zfs_freebsd_lock(ap) |
6015 |
zfs_lock(ap) |
|
|
6016 |
struct vop_lock1_args /* { |
6013 |
struct vop_lock1_args /* { |
6017 |
struct vnode *a_vp; |
6014 |
struct vnode *a_vp; |
6018 |
int a_flags; |
6015 |
int a_flags; |
Lines 6020-6040
zfs_lock(ap)
Link Here
|
6020 |
int line; |
6017 |
int line; |
6021 |
} */ *ap; |
6018 |
} */ *ap; |
6022 |
{ |
6019 |
{ |
6023 |
vnode_t *vp; |
6020 |
struct vnode *vp = ap->a_vp; |
6024 |
znode_t *zp; |
6021 |
zfsvfs_t *zfsvfs; |
6025 |
int err; |
6022 |
int error; |
|
|
6023 |
int op; |
6026 |
|
6024 |
|
6027 |
err = vop_lock(ap); |
6025 |
op = ap->a_flags & LK_TYPE_MASK; |
6028 |
if (err == 0 && (ap->a_flags & LK_NOWAIT) == 0) { |
6026 |
if (op == LK_UPGRADE) { |
6029 |
vp = ap->a_vp; |
6027 |
/* |
6030 |
zp = vp->v_data; |
6028 |
* Failure to upgrade means losing shared lock. |
6031 |
if (vp->v_mount != NULL && !VN_IS_DOOMED(vp) && |
6029 |
* We drop z_teardown_lock now and re-acquire it |
6032 |
zp != NULL && (zp->z_pflags & ZFS_XATTR) == 0) |
6030 |
* if the upgrade is successful. |
6033 |
VERIFY(!RRM_LOCK_HELD(&zp->z_zfsvfs->z_teardown_lock)); |
6031 |
*/ |
|
|
6032 |
ASSERT(VTOZ(vp) != NULL && VTOZ(vp)->z_zfsvfs != NULL); |
6033 |
zfsvfs = VTOZ(vp)->z_zfsvfs; |
6034 |
rrm_exit(&zfsvfs->z_teardown_lock, vp); |
6034 |
} |
6035 |
} |
6035 |
return (err); |
6036 |
error = vop_lock(ap); |
6036 |
} |
6037 |
if (op == LK_DOWNGRADE) { |
|
|
6038 |
ASSERT(error == 0); |
6039 |
return (error); |
6040 |
} |
6041 |
if (op == LK_TRYUPGRADE) |
6042 |
return (error); |
6043 |
ASSERT(op == LK_SHARED || op == LK_EXCLUSIVE || op == LK_UPGRADE); |
6044 |
if (error != 0 || VN_IS_DOOMED(vp)) |
6045 |
return (error); |
6046 |
ASSERT(VTOZ(vp) != NULL && VTOZ(vp)->z_zfsvfs != NULL); |
6047 |
zfsvfs = VTOZ(vp)->z_zfsvfs; |
6048 |
|
6049 |
/* |
6050 |
* zfsvfs_teardown -> zil_close -> zil_commit -> |
6051 |
* zfs_get_data -> zfs_zget -> zfs_znode_alloc |
6052 |
*/ |
6053 |
if (!RRM_WRITE_HELD(&zfsvfs->z_teardown_lock)) { |
6054 |
if ((ap->a_flags & LK_NOWAIT) == 0) { |
6055 |
#ifdef DIAGNOSTIC |
6056 |
if (vp->v_mount != NULL && (VTOZ(vp)->z_pflags & ZFS_XATTR) == 0) |
6057 |
ASSERT(!RRM_LOCK_HELD(&zp->z_zfsvfs->z_teardown_lock)); |
6037 |
#endif |
6058 |
#endif |
|
|
6059 |
rrm_enter(&zfsvfs->z_teardown_lock, RW_READER, vp); |
6060 |
} else if (!rrm_tryenter(&zfsvfs->z_teardown_lock, RW_READER, |
6061 |
vp)) { |
6062 |
(void)lockmgr_unlock(&vp->v_lock); |
6063 |
return (EBUSY); |
6064 |
} |
6065 |
} |
6066 |
return (0); |
6067 |
} |
6068 |
|
6069 |
int |
6070 |
zfs_freebsd_unlock(ap) |
6071 |
struct vop_unlock_args /* { |
6072 |
struct vnode *a_vp; |
6073 |
int a_flags; |
6074 |
} */ *ap; |
6075 |
{ |
6076 |
struct vnode *vp = ap->a_vp; |
6077 |
zfsvfs_t *zfsvfs = VTOZ(vp)->z_zfsvfs; |
6078 |
int error; |
6079 |
|
6080 |
error = vop_unlock(ap); |
6081 |
if (!RRM_WRITE_HELD(&zfsvfs->z_teardown_lock)) |
6082 |
rrm_exit(&zfsvfs->z_teardown_lock, vp); |
6083 |
return (error); |
6084 |
} |
6038 |
|
6085 |
|
6039 |
struct vop_vector zfs_vnodeops; |
6086 |
struct vop_vector zfs_vnodeops; |
6040 |
struct vop_vector zfs_fifoops; |
6087 |
struct vop_vector zfs_fifoops; |
Lines 6081-6092
struct vop_vector zfs_vnodeops = {
Link Here
|
6081 |
.vop_getpages = zfs_freebsd_getpages, |
6128 |
.vop_getpages = zfs_freebsd_getpages, |
6082 |
.vop_putpages = zfs_freebsd_putpages, |
6129 |
.vop_putpages = zfs_freebsd_putpages, |
6083 |
.vop_vptocnp = zfs_vptocnp, |
6130 |
.vop_vptocnp = zfs_vptocnp, |
6084 |
#ifdef DIAGNOSTIC |
6131 |
.vop_lock1 = zfs_freebsd_lock, |
6085 |
.vop_lock1 = zfs_lock, |
6132 |
.vop_unlock = zfs_freebsd_unlock, |
6086 |
#else |
|
|
6087 |
.vop_lock1 = vop_lock, |
6088 |
#endif |
6089 |
.vop_unlock = vop_unlock, |
6090 |
.vop_islocked = vop_islocked, |
6133 |
.vop_islocked = vop_islocked, |
6091 |
}; |
6134 |
}; |
6092 |
VFS_VOP_VECTOR_REGISTER(zfs_vnodeops); |
6135 |
VFS_VOP_VECTOR_REGISTER(zfs_vnodeops); |
Lines 6106-6111
struct vop_vector zfs_fifoops = {
Link Here
|
6106 |
.vop_getacl = zfs_freebsd_getacl, |
6149 |
.vop_getacl = zfs_freebsd_getacl, |
6107 |
.vop_setacl = zfs_freebsd_setacl, |
6150 |
.vop_setacl = zfs_freebsd_setacl, |
6108 |
.vop_aclcheck = zfs_freebsd_aclcheck, |
6151 |
.vop_aclcheck = zfs_freebsd_aclcheck, |
|
|
6152 |
.vop_lock1 = zfs_freebsd_lock, |
6153 |
.vop_unlock = zfs_freebsd_unlock, |
6109 |
}; |
6154 |
}; |
6110 |
VFS_VOP_VECTOR_REGISTER(zfs_fifoops); |
6155 |
VFS_VOP_VECTOR_REGISTER(zfs_fifoops); |
6111 |
|
6156 |
|
Lines 6120-6124
struct vop_vector zfs_shareops = {
Link Here
|
6120 |
.vop_reclaim = zfs_freebsd_reclaim, |
6165 |
.vop_reclaim = zfs_freebsd_reclaim, |
6121 |
.vop_fid = zfs_freebsd_fid, |
6166 |
.vop_fid = zfs_freebsd_fid, |
6122 |
.vop_pathconf = zfs_freebsd_pathconf, |
6167 |
.vop_pathconf = zfs_freebsd_pathconf, |
|
|
6168 |
.vop_lock1 = zfs_freebsd_lock, |
6169 |
.vop_unlock = zfs_freebsd_unlock, |
6123 |
}; |
6170 |
}; |
6124 |
VFS_VOP_VECTOR_REGISTER(zfs_shareops); |
6171 |
VFS_VOP_VECTOR_REGISTER(zfs_shareops); |