Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/puffs In case the operations thread has exited, do no...



details:   https://anonhg.NetBSD.org/src/rev/aa091e2e98f0
branches:  trunk
changeset: 750796:aa091e2e98f0
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Jan 14 19:50:07 2010 +0000

description:
In case the operations thread has exited, do not queue any more
operations.  This prevents kernel memory leaks (one of which happened
every time the file system was unmounted via PUFFSOP_UNMOUNT ...
and incidentally would've been trivially caught with the old
malloc(9) interface.  I wonder if the message is to use a ton of
pools instead of regression-attractive kmem interface).

diffstat:

 sys/fs/puffs/puffs_msgif.c  |  33 ++++++++++++++++++++++++---------
 sys/fs/puffs/puffs_vfsops.c |  16 ++++++++++++----
 2 files changed, 36 insertions(+), 13 deletions(-)

diffs (109 lines):

diff -r c0c1915d45ed -r aa091e2e98f0 sys/fs/puffs/puffs_msgif.c
--- a/sys/fs/puffs/puffs_msgif.c        Thu Jan 14 18:56:01 2010 +0000
+++ b/sys/fs/puffs/puffs_msgif.c        Thu Jan 14 19:50:07 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_msgif.c,v 1.79 2010/01/07 23:02:34 pooka Exp $   */
+/*     $NetBSD: puffs_msgif.c,v 1.80 2010/01/14 19:50:07 pooka Exp $   */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.79 2010/01/07 23:02:34 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.80 2010/01/14 19:50:07 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -873,9 +873,16 @@
                psopr->psopr_sopreq = PUFFS_SOPREQ_FLUSH;
 
                mutex_enter(&pmp->pmp_sopmtx);
-               TAILQ_INSERT_TAIL(&pmp->pmp_sopreqs, psopr, psopr_entries);
-               cv_signal(&pmp->pmp_sopcv);
-               mutex_exit(&pmp->pmp_sopmtx);
+               if (pmp->pmp_sopthrcount == 0) {
+                       mutex_exit(&pmp->pmp_sopmtx);
+                       kmem_free(psopr, sizeof(*psopr));
+                       puffs_msg_sendresp(pmp, preq, ENXIO);
+               } else {
+                       TAILQ_INSERT_TAIL(&pmp->pmp_sopreqs,
+                           psopr, psopr_entries);
+                       cv_signal(&pmp->pmp_sopcv);
+                       mutex_exit(&pmp->pmp_sopmtx);
+               }
                break;
        }
 
@@ -889,9 +896,16 @@
                psopr->psopr_sopreq = PUFFS_SOPREQ_UNMOUNT;
 
                mutex_enter(&pmp->pmp_sopmtx);
-               TAILQ_INSERT_TAIL(&pmp->pmp_sopreqs, psopr, psopr_entries);
-               cv_signal(&pmp->pmp_sopcv);
-               mutex_exit(&pmp->pmp_sopmtx);
+               if (pmp->pmp_sopthrcount == 0) {
+                       mutex_exit(&pmp->pmp_sopmtx);
+                       kmem_free(psopr, sizeof(*psopr));
+                       puffs_msg_sendresp(pmp, preq, ENXIO);
+               } else {
+                       TAILQ_INSERT_TAIL(&pmp->pmp_sopreqs,
+                           psopr, psopr_entries);
+                       cv_signal(&pmp->pmp_sopcv);
+                       mutex_exit(&pmp->pmp_sopmtx);
+               }
                break;
        }
 
@@ -953,11 +967,12 @@
        }
 
        /*
-        * Purge remaining ops.  could send error, but ...
+        * Purge remaining ops.
         */
        while ((psopr = TAILQ_FIRST(&pmp->pmp_sopreqs)) != NULL) {
                TAILQ_REMOVE(&pmp->pmp_sopreqs, psopr, psopr_entries);
                mutex_exit(&pmp->pmp_sopmtx);
+               puffs_msg_sendresp(pmp, &psopr->psopr_preq, ENXIO);
                kmem_free(psopr, sizeof(*psopr));
                mutex_enter(&pmp->pmp_sopmtx);
        }
diff -r c0c1915d45ed -r aa091e2e98f0 sys/fs/puffs/puffs_vfsops.c
--- a/sys/fs/puffs/puffs_vfsops.c       Thu Jan 14 18:56:01 2010 +0000
+++ b/sys/fs/puffs/puffs_vfsops.c       Thu Jan 14 19:50:07 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_vfsops.c,v 1.85 2010/01/07 23:02:34 pooka Exp $  */
+/*     $NetBSD: puffs_vfsops.c,v 1.86 2010/01/14 19:50:07 pooka 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.85 2010/01/07 23:02:34 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.86 2010/01/14 19:50:07 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -372,8 +372,16 @@
                psopr = kmem_alloc(sizeof(*psopr), KM_SLEEP);
                psopr->psopr_sopreq = PUFFS_SOPREQSYS_EXIT;
                mutex_enter(&pmp->pmp_sopmtx);
-               TAILQ_INSERT_TAIL(&pmp->pmp_sopreqs, psopr, psopr_entries);
-               cv_signal(&pmp->pmp_sopcv);
+               if (pmp->pmp_sopthrcount == 0) {
+                       mutex_exit(&pmp->pmp_sopmtx);
+                       kmem_free(psopr, sizeof(*psopr));
+                       mutex_enter(&pmp->pmp_sopmtx);
+                       KASSERT(pmp->pmp_sopthrcount == 0);
+               } else {
+                       TAILQ_INSERT_TAIL(&pmp->pmp_sopreqs,
+                           psopr, psopr_entries);
+                       cv_signal(&pmp->pmp_sopcv);
+               }
                while (pmp->pmp_sopthrcount > 0)
                        cv_wait(&pmp->pmp_sopcv, &pmp->pmp_sopmtx);
                mutex_exit(&pmp->pmp_sopmtx);



Home | Main Index | Thread Index | Old Index