svn commit: r215797 - head/sys/kern

2010-11-24 Thread Konstantin Belousov
Author: kib
Date: Wed Nov 24 12:30:41 2010
New Revision: 215797
URL: http://svn.freebsd.org/changeset/base/215797

Log:
  Allow shared-locked vnode to be passed to vunref(9).
  When shared-locked vnode is supplied as an argument to vunref(9) and
  resulting usecount is 0, set VI_OWEINACT and do not try to upgrade vnode
  lock. The later could cause vnode unlock, allowing the vnode to be
  reclaimed meantime.
  
  Tested by:pho
  MFC after:1 week

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cWed Nov 24 12:25:17 2010(r215796)
+++ head/sys/kern/vfs_subr.cWed Nov 24 12:30:41 2010(r215797)
@@ -2186,7 +2186,7 @@ vputx(struct vnode *vp, int func)
 
KASSERT(vp != NULL, (vputx: null vp));
if (func == VPUTX_VUNREF)
-   ASSERT_VOP_ELOCKED(vp, vunref);
+   ASSERT_VOP_LOCKED(vp, vunref);
else if (func == VPUTX_VPUT)
ASSERT_VOP_LOCKED(vp, vput);
else
@@ -2224,12 +2224,22 @@ vputx(struct vnode *vp, int func)
 * as VI_DOINGINACT to avoid recursion.
 */
vp-v_iflag |= VI_OWEINACT;
-   if (func == VPUTX_VRELE) {
+   switch (func) {
+   case VPUTX_VRELE:
error = vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK);
VI_LOCK(vp);
-   } else if (func == VPUTX_VPUT  VOP_ISLOCKED(vp) != LK_EXCLUSIVE) {
-   error = VOP_LOCK(vp, LK_UPGRADE | LK_INTERLOCK | LK_NOWAIT);
-   VI_LOCK(vp);
+   break;
+   case VPUTX_VPUT:
+   if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE) {
+   error = VOP_LOCK(vp, LK_UPGRADE | LK_INTERLOCK |
+   LK_NOWAIT);
+   VI_LOCK(vp);
+   }
+   break;
+   case VPUTX_VUNREF:
+   if (VOP_ISLOCKED(vp) != LK_EXCLUSIVE)
+   error = EBUSY;
+   break;
}
if (vp-v_usecount  0)
vp-v_iflag = ~VI_OWEINACT;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r215797 - head/sys/kern

2010-11-24 Thread Attilio Rao
2010/11/24 Konstantin Belousov k...@freebsd.org:
 Author: kib
 Date: Wed Nov 24 12:30:41 2010
 New Revision: 215797
 URL: http://svn.freebsd.org/changeset/base/215797

 Log:
  Allow shared-locked vnode to be passed to vunref(9).
  When shared-locked vnode is supplied as an argument to vunref(9) and
  resulting usecount is 0, set VI_OWEINACT and do not try to upgrade vnode
  lock. The later could cause vnode unlock, allowing the vnode to be
  reclaimed meantime.

Thanks a lot, I really appreciate that.

The story here is that kib really wanted to commit another patch
aiming for the vnode lock upgrade with a modify to lockmgr that I
wasn't happy with (or more specifically that I really wished could be
carried on in a different way).

As this is a time-critical fix for him, that is probabilly a better compromise.
I'll try to find some time and go with the full patchset I have in
mind, changing this to using upgrade.

Attilio


-- 
Peace can only be achieved by understanding - A. Einstein
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org