Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Jul 2009 09:12:16 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r195485 - in stable/7/sys: . contrib/pf kern
Message-ID:  <200907090912.n699CGx0077581@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Jul  9 09:12:16 2009
New Revision: 195485
URL: http://svn.freebsd.org/changeset/base/195485

Log:
  MFC r194993:
  In lf_iteratelocks_vnode, increment state->ls_threads around iterating
  of the vnode advisory lock list. This prevents deallocation of state
  while inside the loop.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/kern/kern_lockf.c

Modified: stable/7/sys/kern/kern_lockf.c
==============================================================================
--- stable/7/sys/kern/kern_lockf.c	Thu Jul  9 01:58:59 2009	(r195484)
+++ stable/7/sys/kern/kern_lockf.c	Thu Jul  9 09:12:16 2009	(r195485)
@@ -1937,9 +1937,14 @@ lf_iteratelocks_vnode(struct vnode *vp, 
 	 * make sure it doesn't go away before we are finished.
 	 */
 	STAILQ_INIT(&locks);
+	VI_LOCK(vp);
 	ls = vp->v_lockf;
-	if (!ls)
+	if (!ls) {
+		VI_UNLOCK(vp);
 		return (0);
+	}
+	ls->ls_threads++;
+	VI_UNLOCK(vp);
 
 	sx_xlock(&ls->ls_lock);
 	LIST_FOREACH(lf, &ls->ls_active, lf_link) {
@@ -1960,6 +1965,10 @@ lf_iteratelocks_vnode(struct vnode *vp, 
 		STAILQ_INSERT_TAIL(&locks, ldesc, link);
 	}
 	sx_xunlock(&ls->ls_lock);
+	VI_LOCK(vp);
+	ls->ls_threads--;
+	wakeup(ls);
+	VI_UNLOCK(vp);
 
 	/*
 	 * Call the iterator function for each lock in turn. If the



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