Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/puffs puffs mounts share global pools. This means tha...



details:   https://anonhg.NetBSD.org/src/rev/b31bcbf25c28
branches:  trunk
changeset: 780489:b31bcbf25c28
user:      manu <manu%NetBSD.org@localhost>
date:      Fri Jul 27 07:25:56 2012 +0000

description:
puffs mounts share global pools. This means that the puffs_vfsops cannot
be vfs_detach'ed by module autounload before puffs_vfsop_unmount() completes
and has freed ressource from the pools. By holding a reference on
puffs_vfsops from each mount, we ensure that no race can occur here.

Works around the crash in kern/46734

diffstat:

 sys/fs/puffs/puffs_vfsops.c |  18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diffs (53 lines):

diff -r 41d83dfa9c78 -r b31bcbf25c28 sys/fs/puffs/puffs_vfsops.c
--- a/sys/fs/puffs/puffs_vfsops.c       Fri Jul 27 07:21:01 2012 +0000
+++ b/sys/fs/puffs/puffs_vfsops.c       Fri Jul 27 07:25:56 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vfsops.c,v 1.103 2012/07/22 17:40:46 manu Exp $  */
+/*     $NetBSD: puffs_vfsops.c,v 1.104 2012/07/27 07:25:56 manu Exp $  */
 
 /*
  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.103 2012/07/22 17:40:46 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.104 2012/07/27 07:25:56 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -61,6 +61,7 @@
 MODULE(MODULE_CLASS_VFS, puffs, "putter");
 
 VFS_PROTOS(puffs_vfsop);
+extern struct vfsops puffs_vfsops;
 
 #ifndef PUFFS_PNODEBUCKETS
 #define PUFFS_PNODEBUCKETS 256
@@ -320,6 +321,14 @@
 
        vfs_getnewfsid(mp);
 
+       /*
+        * Hold a reference on vfs so that the puffs module cannot be 
+        * unloaded while the pools items have not been freed by unmount.
+        */
+       mutex_enter(&vfs_list_lock);
+       puffs_vfsops.vfs_refcount++;
+       mutex_exit(&vfs_list_lock);
+
  out:
        if (error && pmp && pmp->pmp_pi)
                putter_detach(pmp->pmp_pi);
@@ -448,6 +457,11 @@
                kmem_free(pmp->pmp_pnodehash, BUCKETALLOC(pmp->pmp_npnodehash));
                kmem_free(pmp, sizeof(struct puffs_mount));
                error = 0;
+
+               /*
+                * One less user for puffs pools
+                */
+               vfs_delref(&puffs_vfsops);
        } else {
                mutex_exit(&pmp->pmp_lock);
        }



Home | Main Index | Thread Index | Old Index