Module Name:    src
Committed By:   pooka
Date:           Thu Apr  1 02:34:09 UTC 2010

Modified Files:
        src/usr.sbin/puffs/mount_psshfs: fs.c node.c psshfs.h subr.c

Log Message:
In case we create a file, reclaim the vnode, and lookup the file
without the directory timeout expiring, we get vattr_null as the
attributes for that file.  Ensure that we always report sane
attributes by getting them from the server if this is the case.
(also, sprinkle some const)

Fixes problem reported by dyoung.   But wait!  The bug's medallion
begins to glow!  The bug looks much better!  I crumble to dust.

There's probably another similar bug related to "lazy open".  It
will trigger if we reclaim a node before the response to the open
arrives.  Even the comments (typoless) know about this bug ...
But verifying it exists and fixing it will have to wait for another
day.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/puffs/mount_psshfs/fs.c
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/puffs/mount_psshfs/node.c
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/puffs/mount_psshfs/psshfs.h
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/puffs/mount_psshfs/subr.c

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

Modified files:

Index: src/usr.sbin/puffs/mount_psshfs/fs.c
diff -u src/usr.sbin/puffs/mount_psshfs/fs.c:1.21 src/usr.sbin/puffs/mount_psshfs/fs.c:1.22
--- src/usr.sbin/puffs/mount_psshfs/fs.c:1.21	Wed Feb  3 17:02:52 2010
+++ src/usr.sbin/puffs/mount_psshfs/fs.c	Thu Apr  1 02:34:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: fs.c,v 1.21 2010/02/03 17:02:52 pooka Exp $	*/
+/*	$NetBSD: fs.c,v 1.22 2010/04/01 02:34:09 pooka Exp $	*/
 
 /*
  * Copyright (c) 2006-2009  Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: fs.c,v 1.21 2010/02/03 17:02:52 pooka Exp $");
+__RCSID("$NetBSD: fs.c,v 1.22 2010/04/01 02:34:09 pooka Exp $");
 #endif /* !lint */
 
 #include <err.h>
@@ -269,7 +269,7 @@
 		return EINVAL;
 
 	/* update node attributes */
-	rv = getnodeattr(pu, pn);
+	rv = getnodeattr(pu, pn, NULL);
 	if (rv)
 		return EINVAL;
 

Index: src/usr.sbin/puffs/mount_psshfs/node.c
diff -u src/usr.sbin/puffs/mount_psshfs/node.c:1.60 src/usr.sbin/puffs/mount_psshfs/node.c:1.61
--- src/usr.sbin/puffs/mount_psshfs/node.c:1.60	Thu Jan  7 21:05:50 2010
+++ src/usr.sbin/puffs/mount_psshfs/node.c	Thu Apr  1 02:34:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: node.c,v 1.60 2010/01/07 21:05:50 pooka Exp $	*/
+/*	$NetBSD: node.c,v 1.61 2010/04/01 02:34:09 pooka Exp $	*/
 
 /*
  * Copyright (c) 2006-2009  Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: node.c,v 1.60 2010/01/07 21:05:50 pooka Exp $");
+__RCSID("$NetBSD: node.c,v 1.61 2010/04/01 02:34:09 pooka Exp $");
 #endif /* !lint */
 
 #include <assert.h>
@@ -90,7 +90,17 @@
 		if (pd->entry)
 			pn = pd->entry;
 		else
-			pn = makenode(pu, pn_dir, pd, &pd->va);
+			pd->entry = pn = makenode(pu, pn_dir, pd, &pd->va);
+
+		/*
+		 * sure sure we have fresh attributes.  most likely we will
+		 * have them cached.  we might not if we go through:
+		 * create - reclaim - lookup (this).
+		 */
+		rv = getnodeattr(pu, pn, PCNPATH(pcn));
+		if (rv)
+			return rv;
+
 		psn = pn->pn_data;
 	}
 
@@ -110,7 +120,7 @@
 	struct puffs_node *pn = opc;
 	int rv;
 
-	rv = getnodeattr(pu, pn);
+	rv = getnodeattr(pu, pn, NULL);
 	if (rv)
 		return rv;
 

Index: src/usr.sbin/puffs/mount_psshfs/psshfs.h
diff -u src/usr.sbin/puffs/mount_psshfs/psshfs.h:1.39 src/usr.sbin/puffs/mount_psshfs/psshfs.h:1.40
--- src/usr.sbin/puffs/mount_psshfs/psshfs.h:1.39	Thu Jan  7 21:05:50 2010
+++ src/usr.sbin/puffs/mount_psshfs/psshfs.h	Thu Apr  1 02:34:09 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: psshfs.h,v 1.39 2010/01/07 21:05:50 pooka Exp $	*/
+/*	$NetBSD: psshfs.h,v 1.40 2010/04/01 02:34:09 pooka Exp $	*/
 
 /*
  * Copyright (c) 2006-2009  Antti Kantee.  All Rights Reserved.
@@ -230,14 +230,14 @@
 
 struct psshfs_dir *lookup(struct psshfs_dir *, size_t, const char *);
 struct puffs_node *makenode(struct puffs_usermount *, struct puffs_node *,
-			    struct psshfs_dir *, const struct vattr *);
+			    const struct psshfs_dir *, const struct vattr *);
 struct puffs_node *allocnode(struct puffs_usermount *, struct puffs_node *,
 			    const char *, const struct vattr *);
 struct psshfs_dir *direnter(struct puffs_node *, const char *);
 void nukenode(struct puffs_node *, const char *, int);
 void doreclaim(struct puffs_node *);
 int getpathattr(struct puffs_usermount *, const char *, struct vattr *);
-int getnodeattr(struct puffs_usermount *, struct puffs_node *);
+int getnodeattr(struct puffs_usermount *, struct puffs_node *, const char *);
 
 void closehandles(struct puffs_usermount *, struct psshfs_node *, int);
 void lazyopen_rresp(struct puffs_usermount *, struct puffs_framebuf *,

Index: src/usr.sbin/puffs/mount_psshfs/subr.c
diff -u src/usr.sbin/puffs/mount_psshfs/subr.c:1.49 src/usr.sbin/puffs/mount_psshfs/subr.c:1.50
--- src/usr.sbin/puffs/mount_psshfs/subr.c:1.49	Wed Feb 17 15:47:36 2010
+++ src/usr.sbin/puffs/mount_psshfs/subr.c	Thu Apr  1 02:34:09 2010
@@ -1,4 +1,4 @@
-/*      $NetBSD: subr.c,v 1.49 2010/02/17 15:47:36 pooka Exp $        */
+/*      $NetBSD: subr.c,v 1.50 2010/04/01 02:34:09 pooka Exp $        */
 
 /*
  * Copyright (c) 2006  Antti Kantee.  All Rights Reserved.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: subr.c,v 1.49 2010/02/17 15:47:36 pooka Exp $");
+__RCSID("$NetBSD: subr.c,v 1.50 2010/04/01 02:34:09 pooka Exp $");
 #endif /* !lint */
 
 #include <assert.h>
@@ -237,7 +237,7 @@
 }
 
 int
-getnodeattr(struct puffs_usermount *pu, struct puffs_node *pn)
+getnodeattr(struct puffs_usermount *pu, struct puffs_node *pn, const char *path)
 {
 	struct psshfs_ctx *pctx = puffs_getspecific(pu);
 	struct psshfs_node *psn = pn->pn_data;
@@ -245,7 +245,7 @@
 	int rv;
 
 	if (!psn->attrread || REFRESHTIMEOUT(pctx, time(NULL)-psn->attrread)) {
-		rv = getpathattr(pu, PNPATH(pn), &va);
+		rv = getpathattr(pu, path ? path : PNPATH(pn), &va);
 		if (rv)
 			return rv;
 
@@ -420,7 +420,7 @@
 
 struct puffs_node *
 makenode(struct puffs_usermount *pu, struct puffs_node *parent,
-	struct psshfs_dir *pd, const struct vattr *vap)
+	const struct psshfs_dir *pd, const struct vattr *vap)
 {
 	struct psshfs_node *psn_parent = parent->pn_data;
 	struct psshfs_node *psn;
@@ -438,7 +438,6 @@
 	setpnva(pu, pn, vap);
 	psn->attrread = pd->attrread;
 
-	pd->entry = pn;
 	psn->parent = parent;
 	psn_parent->childcount++;
 
@@ -466,8 +465,10 @@
 	}
 
 	pn = makenode(pu, parent, pd, vap);
-	if (pn)
+	if (pn) {
 		pd->va.va_fileid = pn->pn_va.va_fileid;
+		pd->entry = pn;
+	}
 
 	return pn;
 }

Reply via email to