Source-Changes-HG archive

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

[src/trunk]: src/sys/coda - move debugging functions to vcoda so modules with...



details:   https://anonhg.NetBSD.org/src/rev/1b5dc8311aa2
branches:  trunk
changeset: 780665:1b5dc8311aa2
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Aug 02 16:06:58 2012 +0000

description:
- move debugging functions to vcoda so modules with -DDEBUG link
- fix writing to coda files. this is probably not the right way to do
  this, but it satisfies the locking protocol:
        1. Sometimes coda_open() is called with an unlocked vnode which
           does not satisfy the locking protocol. Lock it for now. We
           need to find out why this happens
        2. VFS_VGET sometimes returns the container vnode unlocked. What
           is the locking protocol for VFS_VGET? We also lock it here.

diffstat:

 sys/coda/coda_namecache.c |  13 +++++--------
 sys/coda/coda_subr.c      |  25 +++++++++++++++++++++++--
 sys/coda/coda_subr.h      |   3 ++-
 sys/coda/coda_vfsops.c    |   6 +++---
 sys/coda/coda_vnops.c     |  38 +++++++++++++-------------------------
 sys/coda/coda_vnops.h     |   4 +---
 6 files changed, 47 insertions(+), 42 deletions(-)

diffs (263 lines):

diff -r ebe80bdeb7a9 -r 1b5dc8311aa2 sys/coda/coda_namecache.c
--- a/sys/coda/coda_namecache.c Thu Aug 02 15:56:06 2012 +0000
+++ b/sys/coda/coda_namecache.c Thu Aug 02 16:06:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_namecache.c,v 1.24 2009/04/18 14:58:02 tsutsui Exp $      */
+/*     $NetBSD: coda_namecache.c,v 1.25 2012/08/02 16:06:58 christos Exp $     */
 
 /*
  *
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_namecache.c,v 1.24 2009/04/18 14:58:02 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_namecache.c,v 1.25 2012/08/02 16:06:58 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -88,10 +88,7 @@
 #include <coda/coda.h>
 #include <coda/cnode.h>
 #include <coda/coda_namecache.h>
-
-#ifdef DEBUG
-#include <coda/coda_vnops.h>
-#endif
+#include <coda/coda_subr.h>
 
 /*
  * Declaration of the name cache data structure.
@@ -202,8 +199,8 @@
                        kauth_cred_getrefcnt(cncp->cred),
                        kauth_cred_geteuid(cncp->cred),
                        kauth_cred_getegid(cncp->cred));
-               print_cred(cred);
-               print_cred(cncp->cred);
+               coda_print_cred(cred);
+               coda_print_cred(cncp->cred);
            }
 #endif
            count++;
diff -r ebe80bdeb7a9 -r 1b5dc8311aa2 sys/coda/coda_subr.c
--- a/sys/coda/coda_subr.c      Thu Aug 02 15:56:06 2012 +0000
+++ b/sys/coda/coda_subr.c      Thu Aug 02 16:06:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_subr.c,v 1.26 2012/04/26 03:04:54 christos Exp $  */
+/*     $NetBSD: coda_subr.c,v 1.27 2012/08/02 16:06:58 christos Exp $  */
 
 /*
  *
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_subr.c,v 1.26 2012/04/26 03:04:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_subr.c,v 1.27 2012/08/02 16:06:58 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,6 +63,7 @@
 #include <sys/proc.h>
 #include <sys/select.h>
 #include <sys/mount.h>
+#include <sys/kauth.h>
 
 #include <coda/coda.h>
 #include <coda/cnode.h>
@@ -98,6 +99,8 @@
 #define IS_DIR(cnode)        (cnode.opaque[2] & 0x1)
 #endif
 
+struct vnode *coda_ctlvp;
+
 /*
  * Allocate a cnode.
  */
@@ -550,6 +553,24 @@
     coda_vfsop_print_entry = 0;
 }
 
+/* How to print a ucred */
+void
+coda_print_cred(kauth_cred_t cred)
+{
+
+       uint16_t ngroups;
+       int i;
+
+       myprintf(("ref %d\tuid %d\n", kauth_cred_getrefcnt(cred),
+                kauth_cred_geteuid(cred)));
+
+       ngroups = kauth_cred_ngroups(cred);
+       for (i=0; i < ngroups; i++)
+               myprintf(("\tgroup %d: (%d)\n", i, kauth_cred_group(cred, i)));
+       myprintf(("\n"));
+
+}
+
 /*
  * Utilities used by both client and server
  * Standard levels:
diff -r ebe80bdeb7a9 -r 1b5dc8311aa2 sys/coda/coda_subr.h
--- a/sys/coda/coda_subr.h      Thu Aug 02 15:56:06 2012 +0000
+++ b/sys/coda/coda_subr.h      Thu Aug 02 16:06:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_subr.h,v 1.8 2005/12/11 12:19:50 christos Exp $   */
+/*     $NetBSD: coda_subr.h,v 1.9 2012/08/02 16:06:58 christos Exp $   */
 
 /*
  *
@@ -43,5 +43,6 @@
 int  coda_kill(struct mount *whoIam, enum dc_status dcstat);
 void coda_save(struct cnode *cp);
 void coda_unsave(struct cnode *cp);
+void coda_print_cred(kauth_cred_t cred);
 
 
diff -r ebe80bdeb7a9 -r 1b5dc8311aa2 sys/coda/coda_vfsops.c
--- a/sys/coda/coda_vfsops.c    Thu Aug 02 15:56:06 2012 +0000
+++ b/sys/coda/coda_vfsops.c    Thu Aug 02 16:06:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vfsops.c,v 1.73 2012/05/04 02:06:27 christos Exp $        */
+/*     $NetBSD: coda_vfsops.c,v 1.74 2012/08/02 16:06:58 christos Exp $        */
 
 /*
  *
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.73 2012/05/04 02:06:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.74 2012/08/02 16:06:58 christos Exp $");
 
 #ifndef _KERNEL_OPT
 #define        NVCODA 4
@@ -80,7 +80,7 @@
 
 #define ENTRY if(coda_vfsop_print_entry) myprintf(("Entered %s\n",__func__))
 
-struct vnode *coda_ctlvp;
+extern struct vnode *coda_ctlvp;
 extern struct coda_mntinfo coda_mnttbl[NVCODA]; /* indexed by minor device number */
 
 /* structure to keep statistics of internally generated/satisfied calls */
diff -r ebe80bdeb7a9 -r 1b5dc8311aa2 sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c     Thu Aug 02 15:56:06 2012 +0000
+++ b/sys/coda/coda_vnops.c     Thu Aug 02 16:06:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vnops.c,v 1.89 2012/07/28 00:10:22 matt Exp $     */
+/*     $NetBSD: coda_vnops.c,v 1.90 2012/08/02 16:06:58 christos Exp $ */
 
 /*
  *
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.89 2012/07/28 00:10:22 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.90 2012/08/02 16:06:58 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -140,6 +140,8 @@
     { NULL, NULL }
 };
 
+static void coda_print_vattr(struct vattr *);
+
 int (**coda_vnodeop_p)(void *);
 const struct vnodeopv_desc coda_vnodeop_opv_desc =
         { &coda_vnodeop_p, coda_vnodeop_entries };
@@ -227,6 +229,8 @@
 
     MARK_ENTRY(CODA_OPEN_STATS);
 
+    if (!VOP_ISLOCKED(vp))
+       VOP_LOCK(vp, LK_EXCLUSIVE);
     /* Check for open of control file. */
     if (IS_CTL_VP(vp)) {
        /* if (WRITABLE(flag)) */
@@ -591,7 +595,7 @@
        CODADEBUG(CODA_GETATTR, { myprintf(("%s: attr cache hit: %s\n",
            __func__, coda_f2s(&cp->c_fid)));})
        CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
-           print_vattr(&cp->c_vattr); )
+           coda_print_vattr(&cp->c_vattr); )
 
        *vap = cp->c_vattr;
        MARK_INT_SAT(CODA_GETATTR_STATS);
@@ -605,7 +609,7 @@
            __func__, coda_f2s(&cp->c_fid), error)); )
 
        CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
-           print_vattr(vap);   )
+           coda_print_vattr(vap);      )
 
        /* If not open for write, store attributes in cnode */
        if ((cp->c_owrite == 0) && (coda_attr_cache)) {
@@ -638,7 +642,7 @@
     }
 
     if (codadebug & CODADBGMSK(CODA_SETATTR)) {
-       print_vattr(vap);
+       coda_print_vattr(vap);
     }
     error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, curlwp);
 
@@ -1816,11 +1820,13 @@
     /* share the underlying vnode lock with the coda vnode */
     mutex_obj_hold((*vpp)->v_interlock);
     uvm_obj_setlock(&uvp->v_uobj, (*vpp)->v_interlock);
+    if (!VOP_ISLOCKED(*vpp))
+       VOP_LOCK(*vpp, LK_EXCLUSIVE);
     return(0);
 }
 
-void
-print_vattr(struct vattr *attr)
+static void
+coda_print_vattr(struct vattr *attr)
 {
     const char *typestr;
 
@@ -1876,24 +1882,6 @@
              (int)attr->va_ctime.tv_sec, (int)attr->va_ctime.tv_nsec));
 }
 
-/* How to print a ucred */
-void
-print_cred(kauth_cred_t cred)
-{
-
-       uint16_t ngroups;
-       int i;
-
-       myprintf(("ref %d\tuid %d\n", kauth_cred_getrefcnt(cred),
-                kauth_cred_geteuid(cred)));
-
-       ngroups = kauth_cred_ngroups(cred);
-       for (i=0; i < ngroups; i++)
-               myprintf(("\tgroup %d: (%d)\n", i, kauth_cred_group(cred, i)));
-       myprintf(("\n"));
-
-}
-
 /*
  * Return a vnode for the given fid.
  * If no cnode exists for this fid create one and put it
diff -r ebe80bdeb7a9 -r 1b5dc8311aa2 sys/coda/coda_vnops.h
--- a/sys/coda/coda_vnops.h     Thu Aug 02 15:56:06 2012 +0000
+++ b/sys/coda/coda_vnops.h     Thu Aug 02 16:06:58 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vnops.h,v 1.15 2012/07/28 00:10:22 matt Exp $     */
+/*     $NetBSD: coda_vnops.h,v 1.16 2012/08/02 16:06:59 christos Exp $ */
 
 /*
  *
@@ -83,5 +83,3 @@
 int coda_rdwr(vnode_t *, struct uio *, enum uio_rw, int, kauth_cred_t,
     struct lwp *);
 int coda_grab_vnode(vnode_t *, dev_t, ino_t, vnode_t **);
-void print_vattr(struct vattr *);
-void print_cred(kauth_cred_t);



Home | Main Index | Thread Index | Old Index