Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jan 2017 12:17:36 +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-10@freebsd.org
Subject:   svn commit: r312286 - stable/10/sys/fs/pseudofs
Message-ID:  <201701161217.v0GCHatu031032@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Jan 16 12:17:35 2017
New Revision: 312286
URL: https://svnweb.freebsd.org/changeset/base/312286

Log:
  MFC r311815:
  Forcibly remove the cached items from pseudofs vncache on module unload.

Modified:
  stable/10/sys/fs/pseudofs/pseudofs_vncache.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/fs/pseudofs/pseudofs_vncache.c
==============================================================================
--- stable/10/sys/fs/pseudofs/pseudofs_vncache.c	Mon Jan 16 12:13:49 2017	(r312285)
+++ stable/10/sys/fs/pseudofs/pseudofs_vncache.c	Mon Jan 16 12:17:35 2017	(r312286)
@@ -51,6 +51,7 @@ static struct mtx pfs_vncache_mutex;
 static struct pfs_vdata *pfs_vncache;
 static eventhandler_tag pfs_exit_tag;
 static void pfs_exit(void *arg, struct proc *p);
+static void pfs_purge_locked(struct pfs_node *pn, bool force);
 
 static SYSCTL_NODE(_vfs_pfs, OID_AUTO, vncache, CTLFLAG_RW, 0,
     "pseudofs vnode cache");
@@ -97,6 +98,9 @@ pfs_vncache_unload(void)
 {
 
 	EVENTHANDLER_DEREGISTER(process_exit, pfs_exit_tag);
+	mtx_lock(&pfs_vncache_mutex);
+	pfs_purge_locked(NULL, true);
+	mtx_unlock(&pfs_vncache_mutex);
 	KASSERT(pfs_vncache_entries == 0,
 	    ("%d vncache entries remaining", pfs_vncache_entries));
 	mtx_destroy(&pfs_vncache_mutex);
@@ -272,7 +276,7 @@ pfs_vncache_free(struct vnode *vp)
  * used to implement the cache.
  */
 static void
-pfs_purge_locked(struct pfs_node *pn)
+pfs_purge_locked(struct pfs_node *pn, bool force)
 {
 	struct pfs_vdata *pvd;
 	struct vnode *vnp;
@@ -280,7 +284,8 @@ pfs_purge_locked(struct pfs_node *pn)
 	mtx_assert(&pfs_vncache_mutex, MA_OWNED);
 	pvd = pfs_vncache;
 	while (pvd != NULL) {
-		if (pvd->pvd_dead || (pn != NULL && pvd->pvd_pn == pn)) {
+		if (force || pvd->pvd_dead ||
+		    (pn != NULL && pvd->pvd_pn == pn)) {
 			vnp = pvd->pvd_vnode;
 			vhold(vnp);
 			mtx_unlock(&pfs_vncache_mutex);
@@ -301,7 +306,7 @@ pfs_purge(struct pfs_node *pn)
 {
 
 	mtx_lock(&pfs_vncache_mutex);
-	pfs_purge_locked(pn);
+	pfs_purge_locked(pn, false);
 	mtx_unlock(&pfs_vncache_mutex);
 }
 
@@ -321,6 +326,6 @@ pfs_exit(void *arg, struct proc *p)
 		if (pvd->pvd_pid == p->p_pid)
 			dead = pvd->pvd_dead = 1;
 	if (dead)
-		pfs_purge_locked(NULL);
+		pfs_purge_locked(NULL, false);
 	mtx_unlock(&pfs_vncache_mutex);
 }



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