diff --git a/sys/fs/puffs/puffs_msgif.c b/sys/fs/puffs/puffs_msgif.c index caf13d09f877..2e7b692f1cf6 100644 --- a/sys/fs/puffs/puffs_msgif.c +++ b/sys/fs/puffs/puffs_msgif.c @@ -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 -__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 #include @@ -873,9 +873,16 @@ puffs_msgif_dispatch(void *this, struct putter_hdr *pth) 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 @@ puffs_msgif_dispatch(void *this, struct putter_hdr *pth) 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 @@ puffs_sop_thread(void *arg) } /* - * 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 --git a/sys/fs/puffs/puffs_vfsops.c b/sys/fs/puffs/puffs_vfsops.c index a32d37682c5c..e4de292a789f 100644 --- a/sys/fs/puffs/puffs_vfsops.c +++ b/sys/fs/puffs/puffs_vfsops.c @@ -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 -__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 #include @@ -372,8 +372,16 @@ puffs_vfsop_unmount(struct mount *mp, int mntflags) 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);