Module Name:    src
Committed By:   manu
Date:           Fri Aug 10 08:42:11 UTC 2012

Modified Files:
        src/lib/libpuffs: dispatcher.c
        src/sys/fs/puffs: puffs_vnops.c

Log Message:
Fix race condition between (create|mknod|mkdir|symlino) and reclaim, just
like we did it between lookup and reclaim.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/lib/libpuffs/dispatcher.c
cvs rdiff -u -r1.171 -r1.172 src/sys/fs/puffs/puffs_vnops.c

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

Modified files:

Index: src/lib/libpuffs/dispatcher.c
diff -u src/lib/libpuffs/dispatcher.c:1.42 src/lib/libpuffs/dispatcher.c:1.43
--- src/lib/libpuffs/dispatcher.c:1.42	Sat Jul 21 05:17:10 2012
+++ src/lib/libpuffs/dispatcher.c	Fri Aug 10 08:42:10 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: dispatcher.c,v 1.42 2012/07/21 05:17:10 manu Exp $	*/
+/*	$NetBSD: dispatcher.c,v 1.43 2012/08/10 08:42:10 manu Exp $	*/
 
 /*
  * Copyright (c) 2006, 2007, 2008 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: dispatcher.c,v 1.42 2012/07/21 05:17:10 manu Exp $");
+__RCSID("$NetBSD: dispatcher.c,v 1.43 2012/08/10 08:42:10 manu Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -315,6 +315,7 @@ dispatch(struct puffs_cc *pcc)
 			struct puffs_vnmsg_create *auxt = auxbuf;
 			struct puffs_newinfo pni;
 			struct puffs_cn pcn;
+			struct puffs_node *pn = NULL;
 
 			if (pops->puffs_node_create == NULL) {
 				error = 0;
@@ -343,13 +344,16 @@ dispatch(struct puffs_cc *pcc)
 				if (error) {
 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
 				} else {
-					struct puffs_node *pn;
-
 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
 					pn->pn_po = pcn.pcn_po_full;
 				}
 			}
 
+			if (!error) {
+				if (pn == NULL)
+					pn = PU_CMAP(pu, auxt->pvnr_newnode);
+				pn->pn_nlookup++;
+			}
 			break;
 		}
 
@@ -358,6 +362,7 @@ dispatch(struct puffs_cc *pcc)
 			struct puffs_vnmsg_mknod *auxt = auxbuf;
 			struct puffs_newinfo pni;
 			struct puffs_cn pcn;
+			struct puffs_node *pn = NULL;
 
 			if (pops->puffs_node_mknod == NULL) {
 				error = 0;
@@ -386,13 +391,16 @@ dispatch(struct puffs_cc *pcc)
 				if (error) {
 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
 				} else {
-					struct puffs_node *pn;
-
 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
 					pn->pn_po = pcn.pcn_po_full;
 				}
 			}
 
+			if (!error) {
+				if (pn == NULL)
+					pn = PU_CMAP(pu, auxt->pvnr_newnode);
+				pn->pn_nlookup++;
+			}
 			break;
 		}
 
@@ -659,6 +667,7 @@ dispatch(struct puffs_cc *pcc)
 			struct puffs_vnmsg_mkdir *auxt = auxbuf;
 			struct puffs_newinfo pni;
 			struct puffs_cn pcn;
+			struct puffs_node *pn = NULL;
 
 			if (pops->puffs_node_mkdir == NULL) {
 				error = 0;
@@ -687,13 +696,16 @@ dispatch(struct puffs_cc *pcc)
 				if (error) {
 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
 				} else {
-					struct puffs_node *pn;
-
 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
 					pn->pn_po = pcn.pcn_po_full;
 				}
 			}
 
+			if (!error) {
+				if (pn == NULL)
+					pn = PU_CMAP(pu, auxt->pvnr_newnode);
+				pn->pn_nlookup++;
+			}
 			break;
 		}
 
@@ -719,6 +731,7 @@ dispatch(struct puffs_cc *pcc)
 			struct puffs_vnmsg_symlink *auxt = auxbuf;
 			struct puffs_newinfo pni;
 			struct puffs_cn pcn;
+			struct puffs_node *pn = NULL;
 
 			if (pops->puffs_node_symlink == NULL) {
 				error = 0;
@@ -748,13 +761,16 @@ dispatch(struct puffs_cc *pcc)
 				if (error) {
 					pu->pu_pathfree(pu, &pcn.pcn_po_full);
 				} else {
-					struct puffs_node *pn;
-
 					pn = PU_CMAP(pu, auxt->pvnr_newnode);
 					pn->pn_po = pcn.pcn_po_full;
 				}
 			}
 
+			if (!error) {
+				if (pn == NULL)
+					pn = PU_CMAP(pu, auxt->pvnr_newnode);
+				pn->pn_nlookup++;
+			}
 			break;
 		}
 

Index: src/sys/fs/puffs/puffs_vnops.c
diff -u src/sys/fs/puffs/puffs_vnops.c:1.171 src/sys/fs/puffs/puffs_vnops.c:1.172
--- src/sys/fs/puffs/puffs_vnops.c:1.171	Fri Jul 27 07:38:44 2012
+++ src/sys/fs/puffs/puffs_vnops.c	Fri Aug 10 08:42:11 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs_vnops.c,v 1.171 2012/07/27 07:38:44 manu Exp $	*/
+/*	$NetBSD: puffs_vnops.c,v 1.172 2012/08/10 08:42:11 manu Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.171 2012/07/27 07:38:44 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.172 2012/08/10 08:42:11 manu Exp $");
 
 #include <sys/param.h>
 #include <sys/buf.h>
@@ -446,7 +446,7 @@ puffs_abortbutton(struct puffs_mount *pm
 	}
 
 	callinactive(pmp, ck, 0);
-	callreclaim(pmp, ck, 0);
+	callreclaim(pmp, ck, 1);
 }
 
 /*

Reply via email to