Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/puffs/mount_psshfs In case we create a file, reclai...



details:   https://anonhg.NetBSD.org/src/rev/654e1cf34055
branches:  trunk
changeset: 753544:654e1cf34055
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Apr 01 02:34:09 2010 +0000

description:
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.

diffstat:

 usr.sbin/puffs/mount_psshfs/fs.c     |   6 +++---
 usr.sbin/puffs/mount_psshfs/node.c   |  18 ++++++++++++++----
 usr.sbin/puffs/mount_psshfs/psshfs.h |   6 +++---
 usr.sbin/puffs/mount_psshfs/subr.c   |  15 ++++++++-------
 4 files changed, 28 insertions(+), 17 deletions(-)

diffs (164 lines):

diff -r 26feef511170 -r 654e1cf34055 usr.sbin/puffs/mount_psshfs/fs.c
--- a/usr.sbin/puffs/mount_psshfs/fs.c  Thu Apr 01 01:23:32 2010 +0000
+++ b/usr.sbin/puffs/mount_psshfs/fs.c  Thu Apr 01 02:34:09 2010 +0000
@@ -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;
 
diff -r 26feef511170 -r 654e1cf34055 usr.sbin/puffs/mount_psshfs/node.c
--- a/usr.sbin/puffs/mount_psshfs/node.c        Thu Apr 01 01:23:32 2010 +0000
+++ b/usr.sbin/puffs/mount_psshfs/node.c        Thu Apr 01 02:34:09 2010 +0000
@@ -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;
 
diff -r 26feef511170 -r 654e1cf34055 usr.sbin/puffs/mount_psshfs/psshfs.h
--- a/usr.sbin/puffs/mount_psshfs/psshfs.h      Thu Apr 01 01:23:32 2010 +0000
+++ b/usr.sbin/puffs/mount_psshfs/psshfs.h      Thu Apr 01 02:34:09 2010 +0000
@@ -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 *,
diff -r 26feef511170 -r 654e1cf34055 usr.sbin/puffs/mount_psshfs/subr.c
--- a/usr.sbin/puffs/mount_psshfs/subr.c        Thu Apr 01 01:23:32 2010 +0000
+++ b/usr.sbin/puffs/mount_psshfs/subr.c        Thu Apr 01 02:34:09 2010 +0000
@@ -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;
 }



Home | Main Index | Thread Index | Old Index