Module Name:    src
Committed By:   pooka
Date:           Wed Feb 17 14:32:08 UTC 2010

Modified Files:
        src/sys/fs/puffs: puffs_vfsops.c

Log Message:
* add a rant about why MPSAFE isn't enabled even though puffs code is
* predict_false that we are mounting when calling statvfs
* KNF


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/fs/puffs/puffs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/puffs/puffs_vfsops.c
diff -u src/sys/fs/puffs/puffs_vfsops.c:1.86 src/sys/fs/puffs/puffs_vfsops.c:1.87
--- src/sys/fs/puffs/puffs_vfsops.c:1.86	Thu Jan 14 19:50:07 2010
+++ src/sys/fs/puffs/puffs_vfsops.c	Wed Feb 17 14:32:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs_vfsops.c,v 1.86 2010/01/14 19:50:07 pooka Exp $	*/
+/*	$NetBSD: puffs_vfsops.c,v 1.87 2010/02/17 14:32:08 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.86 2010/01/14 19:50:07 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.87 2010/02/17 14:32:08 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -222,13 +222,39 @@
 	mp->mnt_flag &= ~MNT_LOCAL; /* we don't really know, so ... */
 	mp->mnt_data = pmp;
 
+#if 0
+	/*
+	 * XXX: puffs code is MPSAFE.  However, VFS really isn't.
+	 * Currently, there is nothing which protects an inode from
+	 * reclaim while there are threads inside the file system.
+	 * This means that in the event of a server crash, an MPSAFE
+	 * mount is likely to end up accessing invalid memory.  For the
+	 * non-mpsafe case, the kernel lock, general structure of
+	 * puffs and pmp_refcount protect the threads during escape.
+	 *
+	 * Fixing this will require:
+	 *  a) fixing vfs
+	 * OR
+	 *  b) adding a small sleep to puffs_msgif_close() between
+	 *     userdead() and dounmount().
+	 *     (well, this isn't really a fix, but would solve
+	 *     99.999% of the race conditions).
+	 *
+	 * Also, in the event of "b", unmount -f should be used,
+	 * like with any other file system, sparingly and only when
+	 * it is "known" to be safe.
+	 */
+	mp->mnt_iflags |= IMNT_MPSAFE;
+#endif
+
 	pmp->pmp_status = PUFFSTAT_MOUNTING;
 	pmp->pmp_mp = mp;
 	pmp->pmp_msg_maxsize = args->pa_maxmsglen;
 	pmp->pmp_args = *args;
 
 	pmp->pmp_npnodehash = args->pa_nhashbuckets;
-	pmp->pmp_pnodehash = kmem_alloc(BUCKETALLOC(pmp->pmp_npnodehash), KM_SLEEP);
+	pmp->pmp_pnodehash = kmem_alloc(BUCKETALLOC(pmp->pmp_npnodehash),
+	    KM_SLEEP);
 	for (i = 0; i < pmp->pmp_npnodehash; i++)
 		LIST_INIT(&pmp->pmp_pnodehash[i]);
 	LIST_INIT(&pmp->pmp_newcookie);
@@ -435,7 +461,7 @@
 	 * requesting statvfs from userspace would mean a deadlock.
 	 * Compensate.
 	 */
-	if (pmp->pmp_status == PUFFSTAT_MOUNTING)
+	if (__predict_false(pmp->pmp_status == PUFFSTAT_MOUNTING))
 		return EINPROGRESS;
 
 	PUFFS_MSG_ALLOC(vfs, statvfs);

Reply via email to