tech-kern archive

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

fixing coda in -current



I am guessing that not many people use coda (or they just haven't
complained) as it seems like the coda kernel support has suffered some
bit-rot.  Trying to access a coda file system on -current results in a
couple of KASSERTs firing - the first is easy, we need to lock the vnode
on readdir but after doing that there is a check in ufs_readwrite.c to
ensure the vnode is either a VDIR or VLNK type, neither of which is true
for coda because the whole coda file system is contained in a regular
file on the host file system so the vnode type is VREG.  The following
patch makes coda work for me.  I don't think that manipulating the vnode
type is really great but a lesser evil than trying to create a duplicate
of the ufs readdir code and also not as bad as removing the KASSERTs
which are useful sanity checks in the majority of use cases.

Comments? Anyone really care?

Index: coda_vnops.c
===================================================================
RCS file: /cvsroot/src/sys/coda/coda_vnops.c,v
retrieving revision 1.106
diff -u -r1.106 coda_vnops.c
--- coda_vnops.c        26 May 2017 14:21:00 -0000      1.106
+++ coda_vnops.c        20 Nov 2018 09:42:31 -0000
@@ -1537,6 +1537,7 @@
 /* upcall decl */
 /* locals */
     int error = 0;
+    enum vtype saved_type;
 
     MARK_ENTRY(CODA_READDIR_STATS);
 
@@ -1569,7 +1570,13 @@
        /* Have UFS handle the call. */
        CODADEBUG(CODA_READDIR, myprintf(("%s: fid = %s, refcnt = %d\n",
            __func__, coda_f2s(&cp->c_fid), vp->v_usecount)); )
+        saved_type = vp->v_type;
+       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+        vp->v_type = VDIR; /* pretend the container file is a dir */
        error = VOP_READDIR(vp, uiop, cred, eofflag, cookies, ncookies);
+        vp->v_type = saved_type;
+       VOP_UNLOCK(vp);
+
        if (error)
            MARK_INT_FAIL(CODA_READDIR_STATS);
        else

-- 
Brett Lymn
Let go, or be dragged - Zen proverb.


Home | Main Index | Thread Index | Old Index