summaryrefslogtreecommitdiffstats
path: root/sys/fs/pseudofs/pseudofs_vncache.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2017-01-16 12:17:35 +0000
committerkib <kib@FreeBSD.org>2017-01-16 12:17:35 +0000
commitf3618207e45a686a2d9d1b2d53110d2ec606b308 (patch)
treea40f75284d7059b47215760c7c1251b2e032285b /sys/fs/pseudofs/pseudofs_vncache.c
parent1febf07b311aa656217e6fd540903d95987529d3 (diff)
downloadFreeBSD-src-f3618207e45a686a2d9d1b2d53110d2ec606b308.zip
FreeBSD-src-f3618207e45a686a2d9d1b2d53110d2ec606b308.tar.gz
MFC r311815:
Forcibly remove the cached items from pseudofs vncache on module unload.
Diffstat (limited to 'sys/fs/pseudofs/pseudofs_vncache.c')
-rw-r--r--sys/fs/pseudofs/pseudofs_vncache.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c
index 1bec5a4..093d805 100644
--- a/sys/fs/pseudofs/pseudofs_vncache.c
+++ b/sys/fs/pseudofs/pseudofs_vncache.c
@@ -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);
}
OpenPOWER on IntegriCloud