Index: share/man/man9/vgone.9 =================================================================== --- share/man/man9/vgone.9 +++ share/man/man9/vgone.9 @@ -47,7 +47,7 @@ If the vnode has a .Va v_usecount of zero, and its -.Dv VI_DOOMED +.Dv VIRF_DOOMED flag is not set, it is moved to the head of the free list as in most cases the vnode is about to be reused, or its file system is being unmounted. Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -1413,7 +1413,7 @@ * Relock for the "." case could leave us with * reclaimed vnode. */ - if (dvp->v_iflag & VI_DOOMED) { + if (VN_IS_DOOMED(dvp)) { vrele(dvp); return (SET_ERROR(ENOENT)); } Index: sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c =================================================================== --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c +++ sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c @@ -1216,8 +1216,7 @@ locked = VOP_ISLOCKED(vp); VI_LOCK(vp); - if ((vp->v_iflag & VI_DOOMED) != 0 && - locked != LK_EXCLUSIVE) { + if (VN_IS_DOOMED(vp) && locked != LK_EXCLUSIVE) { /* * The vnode is doomed and this thread doesn't * hold the exclusive lock on it, so the vnode Index: sys/fs/autofs/autofs_vnops.c =================================================================== --- sys/fs/autofs/autofs_vnops.c +++ sys/fs/autofs/autofs_vnops.c @@ -169,8 +169,8 @@ sx_xunlock(&autofs_softc->sc_lock); vn_lock(vp, lock_flags | LK_RETRY); vunref(vp); - if ((vp->v_iflag & VI_DOOMED) != 0) { - AUTOFS_DEBUG("VI_DOOMED"); + if (VN_IS_DOOMED(vp)) { + AUTOFS_DEBUG("VIRF_DOOMED"); return (ENOENT); } Index: sys/fs/nfsclient/nfs_clport.c =================================================================== --- sys/fs/nfsclient/nfs_clport.c +++ sys/fs/nfsclient/nfs_clport.c @@ -149,9 +149,9 @@ * get called on this vnode between when NFSVOPLOCK() drops * the VI_LOCK() and vget() acquires it again, so that it * hasn't yet had v_usecount incremented. If this were to - * happen, the VI_DOOMED flag would be set, so check for + * happen, the VIRF_DOOMED flag would be set, so check for * that here. Since we now have the v_usecount incremented, - * we should be ok until we vrele() it, if the VI_DOOMED + * we should be ok until we vrele() it, if the VIRF_DOOMED * flag isn't set now. */ VI_LOCK(nvp); Index: sys/fs/nfsclient/nfs_clvnops.c =================================================================== --- sys/fs/nfsclient/nfs_clvnops.c +++ sys/fs/nfsclient/nfs_clvnops.c @@ -1235,7 +1235,7 @@ vrele(newvp); *vpp = NULLVP; } else if (error == ENOENT) { - if (dvp->v_iflag & VI_DOOMED) + if (VN_IS_DOOMED(dvp)) return (ENOENT); /* * We only accept a negative hit in the cache if the @@ -1340,7 +1340,7 @@ error = vfs_busy(mp, 0); NFSVOPLOCK(dvp, ltype | LK_RETRY); vfs_rel(mp); - if (error == 0 && (dvp->v_iflag & VI_DOOMED)) { + if (error == 0 && VN_IS_DOOMED(dvp)) { vfs_unbusy(mp); error = ENOENT; } @@ -1355,7 +1355,7 @@ vfs_unbusy(mp); if (newvp != dvp) NFSVOPLOCK(dvp, ltype | LK_RETRY); - if (dvp->v_iflag & VI_DOOMED) { + if (VN_IS_DOOMED(dvp)) { if (error == 0) { if (newvp == dvp) vrele(newvp); Index: sys/fs/nfsserver/nfs_nfsdport.c =================================================================== --- sys/fs/nfsserver/nfs_nfsdport.c +++ sys/fs/nfsserver/nfs_nfsdport.c @@ -1738,7 +1738,7 @@ * Updates the file rev and sets the mtime and ctime * to the current clock time, returning the va_filerev and va_Xtime * values. - * Return ESTALE to indicate the vnode is VI_DOOMED. + * Return ESTALE to indicate the vnode is VIRF_DOOMED. */ int nfsvno_updfilerev(struct vnode *vp, struct nfsvattr *nvap, Index: sys/fs/nfsserver/nfs_nfsdstate.c =================================================================== --- sys/fs/nfsserver/nfs_nfsdstate.c +++ sys/fs/nfsserver/nfs_nfsdstate.c @@ -5133,7 +5133,7 @@ * Return 0 to indicate the conflict can't be revoked and 1 to indicate * the revocation worked and the conflicting client is "bye, bye", so it * can be tried again. - * Return 2 to indicate that the vnode is VI_DOOMED after NFSVOPLOCK(). + * Return 2 to indicate that the vnode is VIRF_DOOMED after NFSVOPLOCK(). * Unlocks State before a non-zero value is returned. */ static int Index: sys/fs/unionfs/union_subr.c =================================================================== --- sys/fs/unionfs/union_subr.c +++ sys/fs/unionfs/union_subr.c @@ -127,7 +127,8 @@ VI_LOCK_FLAGS(vp, MTX_DUPOK); VI_UNLOCK(dvp); vp->v_iflag &= ~VI_OWEINACT; - if ((vp->v_iflag & (VI_DOOMED | VI_DOINGINACT)) != 0) { + if (VN_IS_DOOMED(vp) || + ((vp->v_iflag & VI_DOINGINACT) != 0)) { VI_UNLOCK(vp); vp = NULLVP; } else @@ -163,7 +164,8 @@ vp = UNIONFSTOV(unp); VI_LOCK_FLAGS(vp, MTX_DUPOK); vp->v_iflag &= ~VI_OWEINACT; - if ((vp->v_iflag & (VI_DOOMED | VI_DOINGINACT)) != 0) { + if (VN_IS_DOOMED(vp) || + ((vp->v_iflag & VI_DOINGINACT) != 0)) { LIST_INSERT_HEAD(hd, uncp, un_hash); VI_UNLOCK(vp); vp = NULLVP; Index: sys/kern/kern_lockf.c =================================================================== --- sys/kern/kern_lockf.c +++ sys/kern/kern_lockf.c @@ -655,7 +655,7 @@ /* * Recheck the doomed vnode after state->ls_lock is * locked. lf_purgelocks() requires that no new threads add - * pending locks when vnode is marked by VI_DOOMED flag. + * pending locks when vnode is marked by VIRF_DOOMED flag. */ VI_LOCK(vp); if (vp->v_iflag & VI_DOOMED) { @@ -771,7 +771,7 @@ /* * For this to work correctly, the caller must ensure that no * other threads enter the locking system for this vnode, - * e.g. by checking VI_DOOMED. We wake up any threads that are + * e.g. by checking VIRF_DOOMED. We wake up any threads that are * sleeping waiting for locks on this vnode and then free all * the remaining locks. */ Index: sys/kern/tty.c =================================================================== --- sys/kern/tty.c +++ sys/kern/tty.c @@ -1250,9 +1250,9 @@ * If we did have a vnode, release our reference. Ordinarily we manage * these at the devfs layer, but we can't necessarily know that we were * invoked on the vnode referenced in the session (i.e. the vnode we - * hold a reference to). We explicitly don't check VBAD/VI_DOOMED here + * hold a reference to). We explicitly don't check VBAD/VIRF_DOOMED here * to avoid a vnode leak -- in circumstances elsewhere where we'd hit a - * VI_DOOMED vnode, release has been deferred until the controlling TTY + * VIRF_DOOMED vnode, release has been deferred until the controlling TTY * is either changed or released. */ if (vp != NULL) Index: sys/kern/vfs_default.c =================================================================== --- sys/kern/vfs_default.c +++ sys/kern/vfs_default.c @@ -594,7 +594,7 @@ * Note that having a reference does not prevent forced unmount from * setting ->v_mount to NULL after the lock gets released. This is of * no consequence for typical consumers (most notably vn_start_write) - * since in this case the vnode is VI_DOOMED. Unmount might have + * since in this case the vnode is VIRF_DOOMED. Unmount might have * progressed far enough that its completion is only delayed by the * reference obtained here. The consumer only needs to concern itself * with releasing it. Index: sys/kern/vfs_subr.c =================================================================== --- sys/kern/vfs_subr.c +++ sys/kern/vfs_subr.c @@ -137,7 +137,7 @@ /* * Number of vnodes in existence. Increased whenever getnewvnode() - * allocates a new vnode, decreased in vdropl() for VI_DOOMED vnode. + * allocates a new vnode, decreased in vdropl() for VIRF_DOOMED vnode. */ static unsigned long numvnodes; @@ -1049,7 +1049,7 @@ * v_usecount may have been bumped after VOP_LOCK() dropped * the vnode interlock and before it was locked again. * - * It is not necessary to recheck VI_DOOMED because it can + * It is not necessary to recheck VIRF_DOOMED because it can * only be set by another thread that holds both the vnode * lock and vnode interlock. If another thread has the * vnode lock before we get to VOP_LOCK() and obtains the @@ -1066,8 +1066,8 @@ vdropl(vp); goto next_iter_mntunlocked; } - KASSERT((vp->v_iflag & VI_DOOMED) == 0, - ("VI_DOOMED unexpectedly detected in vlrureclaim()")); + KASSERT(!VN_IS_DOOMED(vp), + ("VIRF_DOOMED unexpectedly detected in vlrureclaim()")); counter_u64_add(recycles_count, 1); vgonel(vp); VOP_UNLOCK(vp, 0); @@ -2696,7 +2696,7 @@ /* * Grab a particular vnode from the free list, increment its - * reference count and lock it. VI_DOOMED is set if the vnode + * reference count and lock it. VIRF_DOOMED is set if the vnode * is being destroyed. Only callers who specify LK_RETRY will * see doomed vnodes. If inactive processing was delayed in * vput try to do it here. @@ -3143,7 +3143,7 @@ /* * Drop the hold count of the vnode. If this is the last reference to * the vnode we place it on the free list unless it has been vgone'd - * (marked VI_DOOMED) in which case we will free it. + * (marked VIRF_DOOMED) in which case we will free it. * * Because the vnode vm object keeps a hold reference on the vnode if * there is at least one resident non-cached page, the vnode cannot @@ -3269,6 +3269,7 @@ vp->v_rdev = NULL; vp->v_fifoinfo = NULL; vp->v_lasta = vp->v_clen = vp->v_cstart = vp->v_lastw = 0; + vp->v_irflag = 0; vp->v_iflag = 0; vp->v_vflag = 0; bo->bo_flag = 0; @@ -3584,9 +3585,9 @@ /* * Don't vgonel if we're already doomed. */ - if (vp->v_iflag & VI_DOOMED) + if (vp->v_irflag & VIRF_DOOMED) return; - vp->v_iflag |= VI_DOOMED; + vp->v_irflag |= VIRF_DOOMED; /* * Check to see if the vnode is in use. If so, we have to call @@ -3768,8 +3769,6 @@ } if (vp->v_iflag & VI_MOUNT) strlcat(buf, "|VI_MOUNT", sizeof(buf)); - if (vp->v_iflag & VI_DOOMED) - strlcat(buf, "|VI_DOOMED", sizeof(buf)); if (vp->v_iflag & VI_FREE) strlcat(buf, "|VI_FREE", sizeof(buf)); if (vp->v_iflag & VI_ACTIVE) @@ -3780,12 +3779,19 @@ strlcat(buf, "|VI_OWEINACT", sizeof(buf)); if (vp->v_iflag & VI_TEXT_REF) strlcat(buf, "|VI_TEXT_REF", sizeof(buf)); - flags = vp->v_iflag & ~(VI_MOUNT | VI_DOOMED | VI_FREE | - VI_ACTIVE | VI_DOINGINACT | VI_OWEINACT | VI_TEXT_REF); + flags = vp->v_iflag & ~(VI_MOUNT | VI_FREE | VI_ACTIVE | VI_DOINGINACT | + VI_OWEINACT | VI_TEXT_REF); if (flags != 0) { snprintf(buf2, sizeof(buf2), "|VI(0x%lx)", flags); strlcat(buf, buf2, sizeof(buf)); } + if (vp->v_irflag & VIRF_DOOMED) + strlcat(buf, "|VIRF_DOOMED", sizeof(buf)); + flags = vp->v_irflag & ~(VIRF_DOOMED); + if (flags != 0) { + snprintf(buf2, sizeof(buf2), "|VIRF(0x%lx)", flags); + strlcat(buf, buf2, sizeof(buf)); + } printf(" flags (%s)\n", buf + 1); if (mtx_owned(VI_MTX(vp))) printf(" VI_LOCKed"); @@ -5788,8 +5794,8 @@ KASSERT((*mvp)->v_mount == mp, ("marker vnode mount list mismatch")); for (vp = TAILQ_NEXT(*mvp, v_nmntvnodes); vp != NULL; vp = TAILQ_NEXT(vp, v_nmntvnodes)) { - /* Allow a racy peek at VI_DOOMED to save a lock acquisition. */ - if (vp->v_type == VMARKER || (vp->v_iflag & VI_DOOMED) != 0) + /* Allow a racy peek at VIRF_DOOMED to save a lock acquisition. */ + if (vp->v_type == VMARKER || VN_IS_DOOMED(vp)) continue; VI_LOCK(vp); if ((vp->v_iflag & VI_DOOMED) != 0) { @@ -5822,8 +5828,8 @@ (*mvp)->v_type = VMARKER; TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { - /* Allow a racy peek at VI_DOOMED to save a lock acquisition. */ - if (vp->v_type == VMARKER || (vp->v_iflag & VI_DOOMED) != 0) + /* Allow a racy peek at VIRF_DOOMED to save a lock acquisition. */ + if (vp->v_type == VMARKER || VN_IS_DOOMED(vp)) continue; VI_LOCK(vp); if ((vp->v_iflag & VI_DOOMED) != 0) { Index: sys/sys/vnode.h =================================================================== --- sys/sys/vnode.h +++ sys/sys/vnode.h @@ -103,7 +103,8 @@ * Fields which define the identity of the vnode. These fields are * owned by the filesystem (XXX: and vgone() ?) */ - enum vtype v_type; /* u vnode type */ + enum vtype v_type:8; /* u vnode type */ + short v_irflag; /* i frequently read flags */ struct vop_vector *v_op; /* u vnode operations vector */ void *v_data; /* u private data for fs */ @@ -231,12 +232,13 @@ * VI flags are protected by interlock and live in v_iflag * VV flags are protected by the vnode lock and live in v_vflag * - * VI_DOOMED is doubly protected by the interlock and vnode lock. Both + * VIRF_DOOMED is doubly protected by the interlock and vnode lock. Both * are required for writing but the status may be checked with either. */ +#define VIRF_DOOMED 0x0001 /* This vnode is being recycled */ + #define VI_TEXT_REF 0x0001 /* Text ref grabbed use ref */ #define VI_MOUNT 0x0020 /* Mount in progress */ -#define VI_DOOMED 0x0080 /* This vnode is being recycled */ #define VI_FREE 0x0100 /* This vnode is on the freelist */ #define VI_ACTIVE 0x0200 /* This vnode is on the active list */ #define VI_DOINGINACT 0x0800 /* VOP_INACTIVE is in progress */ @@ -889,6 +891,8 @@ #define VOP_UNSET_TEXT_CHECKED(vp) VOP_UNSET_TEXT((vp)) #endif +#define VN_IS_DOOMED(vp) ((vp)->v_irflag & VIRF_DOOMED) + void vput(struct vnode *vp); void vrele(struct vnode *vp); void vref(struct vnode *vp); Index: sys/ufs/ffs/ffs_inode.c =================================================================== --- sys/ufs/ffs/ffs_inode.c +++ sys/ufs/ffs/ffs_inode.c @@ -124,7 +124,7 @@ * * Hold a reference to the vnode to protect against * ffs_snapgone(). Since we hold a reference, it can only - * get reclaimed (VI_DOOMED flag) in a forcible downgrade + * get reclaimed (VIRF_DOOMED flag) in a forcible downgrade * or unmount. For an unmount, the entire filesystem will be * gone, so we cannot attempt to touch anything associated * with it while the vnode is unlocked; all we can do is