Print this page
11679 vn_rele() and friends should VERIFY after mutex
Reviewed by: Dan McDonald <danmcd@joyent.com>

*** 20,29 **** --- 20,30 ---- */ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2020 Joyent, Inc. + * Copyright 2022 Spencer Evans-Cole. * Copyright 2016 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2011, 2017 by Delphix. All rights reserved. */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
*** 835,850 **** * on a vnode. */ void vn_rele(vnode_t *vp) { - VERIFY(vp->v_count > 0); mutex_enter(&vp->v_lock); if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VOP_INACTIVE(vp, CRED(), NULL); return; } VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); } --- 836,852 ---- * on a vnode. */ void vn_rele(vnode_t *vp) { mutex_enter(&vp->v_lock); if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VOP_INACTIVE(vp, CRED(), NULL); return; + } else { + VERIFY(vp->v_count > 0); } VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); }
*** 855,866 **** * only by the DNLC. */ void vn_rele_dnlc(vnode_t *vp) { - VERIFY((vp->v_count > 0) && (vp->v_count_dnlc > 0)); mutex_enter(&vp->v_lock); if (--vp->v_count_dnlc == 0) { if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VOP_INACTIVE(vp, CRED(), NULL); return; --- 857,868 ---- * only by the DNLC. */ void vn_rele_dnlc(vnode_t *vp) { mutex_enter(&vp->v_lock); + VERIFY((vp->v_count > 0) && (vp->v_count_dnlc > 0)); if (--vp->v_count_dnlc == 0) { if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VOP_INACTIVE(vp, CRED(), NULL); return;
*** 878,894 **** * path from accessing a stream head that is going away. */ void vn_rele_stream(vnode_t *vp) { - VERIFY(vp->v_count > 0); mutex_enter(&vp->v_lock); vp->v_stream = NULL; if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VOP_INACTIVE(vp, CRED(), NULL); return; } VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); } --- 880,897 ---- * path from accessing a stream head that is going away. */ void vn_rele_stream(vnode_t *vp) { mutex_enter(&vp->v_lock); vp->v_stream = NULL; if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VOP_INACTIVE(vp, CRED(), NULL); return; + } else { + VERIFY(vp->v_count > 0); } VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); }
*** 909,925 **** * This is because taskqs throttle back allocation if too many are created. */ void vn_rele_async(vnode_t *vp, taskq_t *taskq) { - VERIFY(vp->v_count > 0); mutex_enter(&vp->v_lock); if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VERIFY(taskq_dispatch(taskq, (task_func_t *)vn_rele_inactive, vp, TQ_SLEEP) != TASKQID_INVALID); return; } VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); } --- 912,929 ---- * This is because taskqs throttle back allocation if too many are created. */ void vn_rele_async(vnode_t *vp, taskq_t *taskq) { mutex_enter(&vp->v_lock); if (vp->v_count == 1) { mutex_exit(&vp->v_lock); VERIFY(taskq_dispatch(taskq, (task_func_t *)vn_rele_inactive, vp, TQ_SLEEP) != TASKQID_INVALID); return; + } else { + VERIFY(vp->v_count > 0); } VN_RELE_LOCKED(vp); mutex_exit(&vp->v_lock); }