Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Sep 2009 12:10:41 +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: r196921 - head/sys/fs/pseudofs
Message-ID:  <200909071210.n87CAflU014082@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Sep  7 12:10:41 2009
New Revision: 196921
URL: http://svn.freebsd.org/changeset/base/196921

Log:
  If a race is detected, pfs_vncache_alloc() may reclaim a vnode that had
  never been inserted into the pfs_vncache list. Since pfs_vncache_free()
  does not anticipate this case, it decrements pfs_vncache_entries
  unconditionally; if the vnode was not in the list, pfs_vncache_entries
  will no longer reflect the actual number of list entries. This may cause
  size of the cache to exceed the configured maximum. It may also trigger
  a panic during module unload or system shutdown.
  
  Do not decrement pfs_vncache_entries for the vnode that was not in the
  list.
  
  Submitted by:	tegge
  Reviewed by:	des
  MFC after:	1 week

Modified:
  head/sys/fs/pseudofs/pseudofs_vncache.c

Modified: head/sys/fs/pseudofs/pseudofs_vncache.c
==============================================================================
--- head/sys/fs/pseudofs/pseudofs_vncache.c	Mon Sep  7 11:55:34 2009	(r196920)
+++ head/sys/fs/pseudofs/pseudofs_vncache.c	Mon Sep  7 12:10:41 2009	(r196921)
@@ -246,11 +246,13 @@ pfs_vncache_free(struct vnode *vp)
 	KASSERT(pvd != NULL, ("pfs_vncache_free(): no vnode data\n"));
 	if (pvd->pvd_next)
 		pvd->pvd_next->pvd_prev = pvd->pvd_prev;
-	if (pvd->pvd_prev)
+	if (pvd->pvd_prev) {
 		pvd->pvd_prev->pvd_next = pvd->pvd_next;
-	else if (pfs_vncache == pvd)
+		--pfs_vncache_entries;
+	} else if (pfs_vncache == pvd) {
 		pfs_vncache = pvd->pvd_next;
-	--pfs_vncache_entries;
+		--pfs_vncache_entries;
+	}
 	mtx_unlock(&pfs_vncache_mutex);
 
 	free(pvd, M_PFSVNCACHE);



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