Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Jul 2015 16:28:56 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285393 - head/sys/kern
Message-ID:  <201507111628.t6BGSuU2074762@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sat Jul 11 16:28:55 2015
New Revision: 285393
URL: https://svnweb.freebsd.org/changeset/base/285393

Log:
  vfs: always clear VI_OWEINACT in consumers bumping v_usecount
  
  Previously vputx would detect the condition and clear the flag.
  
  With this change it is invalid to have both v_usecount > 0 and the flag
  set. Assert the condition is met in all revlevant places.
  
  Reviewed by:	kib

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c	Sat Jul 11 16:28:12 2015	(r285392)
+++ head/sys/kern/vfs_subr.c	Sat Jul 11 16:28:55 2015	(r285393)
@@ -2082,6 +2082,10 @@ v_incr_usecount(struct vnode *vp)
 {
 
 	CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
+	VNASSERT(vp->v_usecount == 0 || (vp->v_iflag & VI_OWEINACT) == 0, vp,
+	    ("vnode with usecount and VI_OWEINACT set"));
+	if (vp->v_iflag & VI_OWEINACT)
+		vp->v_iflag &= ~VI_OWEINACT;
 	vholdl(vp);
 	vp->v_usecount++;
 	v_incr_devcount(vp);
@@ -2199,6 +2203,8 @@ vget(struct vnode *vp, int flags, struct
 	if (vp->v_iflag & VI_DOOMED && (flags & LK_RETRY) == 0)
 		panic("vget: vn_lock failed to return ENOENT\n");
 	VI_LOCK(vp);
+	VNASSERT(vp->v_usecount == 0 || (vp->v_iflag & VI_OWEINACT) == 0, vp,
+	    ("vnode with usecount and VI_OWEINACT set"));
 	/* Upgrade our holdcnt to a usecount. */
 	v_upgrade_usecount(vp);
 	/*
@@ -2318,8 +2324,8 @@ vputx(struct vnode *vp, int func)
 		}
 		break;
 	}
-	if (vp->v_usecount > 0)
-		vp->v_iflag &= ~VI_OWEINACT;
+	VNASSERT(vp->v_usecount == 0 || (vp->v_iflag & VI_OWEINACT) == 0, vp,
+	    ("vnode with usecount and VI_OWEINACT set"));
 	if (error == 0) {
 		if (vp->v_iflag & VI_OWEINACT)
 			vinactive(vp, curthread);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507111628.t6BGSuU2074762>