Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jun 2009 18:54:56 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r194993 - head/sys/kern
Message-ID:  <200906251854.n5PIsuRx061362@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Jun 25 18:54:56 2009
New Revision: 194993
URL: http://svn.freebsd.org/changeset/base/194993

Log:
  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.
  
  Reported and tested by:	pho
  MFC after:	2 weeks

Modified:
  head/sys/kern/kern_lockf.c

Modified: head/sys/kern/kern_lockf.c
==============================================================================
--- head/sys/kern/kern_lockf.c	Thu Jun 25 18:51:35 2009	(r194992)
+++ head/sys/kern/kern_lockf.c	Thu Jun 25 18:54:56 2009	(r194993)
@@ -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?200906251854.n5PIsuRx061362>