Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpvfs Add parsepath for rumpfs in place o...



details:   https://anonhg.NetBSD.org/src/rev/25b051ea132c
branches:  trunk
changeset: 1022018:25b051ea132c
user:      dholland <dholland%NetBSD.org@localhost>
date:      Tue Jun 29 22:38:10 2021 +0000

description:
Add parsepath for rumpfs in place of using cn_consume.

diffstat:

 sys/rump/librump/rumpvfs/rumpfs.c |  58 ++++++++++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 16 deletions(-)

diffs (108 lines):

diff -r 9813cda7474c -r 25b051ea132c sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Tue Jun 29 22:37:50 2021 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Tue Jun 29 22:38:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpfs.c,v 1.163 2021/06/29 22:34:09 dholland Exp $    */
+/*     $NetBSD: rumpfs.c,v 1.164 2021/06/29 22:38:10 dholland Exp $    */
 
 /*
  * Copyright (c) 2009, 2010, 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.163 2021/06/29 22:34:09 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.164 2021/06/29 22:38:10 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -61,6 +61,7 @@
 #include <rump/rumpfs.h>
 #include <rump/rumpuser.h>
 
+static int rump_vop_parsepath(void *);
 static int rump_vop_lookup(void *);
 static int rump_vop_getattr(void *);
 static int rump_vop_setattr(void *);
@@ -90,7 +91,7 @@
 int (**rump_vnodeop_p)(void *);
 const struct vnodeopv_entry_desc rump_vnodeop_entries[] = {
        { &vop_default_desc, vn_default_error },
-       { &vop_parsepath_desc, genfs_parsepath },
+       { &vop_parsepath_desc, rump_vop_parsepath },
        { &vop_lookup_desc, rump_vop_lookup },
        { &vop_getattr_desc, rump_vop_getattr },
        { &vop_setattr_desc, rump_vop_setattr },
@@ -634,6 +635,33 @@
 }
 
 /*
+ * parsepath for rump file systems - check for etfs entries.
+ */
+static int
+rump_vop_parsepath(void *v)
+{
+       struct vop_parsepath_args /* {
+               struct vnode *a_dvp;
+               const char *a_name;
+               size_t *a_retval;
+       }; */ *ap = v;
+       struct etfs *et;
+       bool found;
+
+       /* check for etfs */
+       if (ap->a_dvp == rootvnode) {
+               mutex_enter(&etfs_lock);
+               found = etfs_find(ap->a_name, &et, false);
+               mutex_exit(&etfs_lock);
+               if (found) {
+                       *ap->a_retval = et->et_keylen;
+                       return 0;
+               }
+       }
+       return genfs_parsepath(v);
+}
+
+/*
  * Simple lookup for rump file systems.
  *
  * uhm, this is twisted.  C F C C, hope of C C F C looming
@@ -654,7 +682,6 @@
        struct etfs *et;
        bool dotdot = (cnp->cn_flags & ISDOTDOT) != 0;
        int rv = 0;
-       const char *cp;
 
        *vpp = NULL;
 
@@ -687,19 +714,18 @@
                mutex_exit(&etfs_lock);
 
                if (found) {
+                       if (et->et_keylen != cnp->cn_namelen) {
+                               /*
+                                * This can theoretically happen if an
+                                * etfs entry is added or removed
+                                * while lookups are being done as we
+                                * don't hold etfs_lock across here
+                                * and parsepath. Won't ordinarily be
+                                * the case. No biggie, just retry.
+                                */
+                               return ERESTART;
+                       }
                        rn = et->et_rn;
-                       cnp->cn_consume += et->et_keylen - cnp->cn_namelen;
-                       /*
-                        * consume trailing slashes if any and clear
-                        * REQUIREDIR if we consumed the full path.
-                        */
-                       cp = &cnp->cn_nameptr[cnp->cn_namelen];
-                       cp += cnp->cn_consume;
-                       KASSERT(*cp == '\0' || *cp == '/');
-                       if (*cp == '\0' && rn->rn_va.va_type != VDIR)
-                               cnp->cn_flags &= ~REQUIREDIR;
-                       while (*cp++ == '/')
-                               cnp->cn_consume++;
                        goto getvnode;
                }
        }



Home | Main Index | Thread Index | Old Index