Source-Changes-HG archive

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

[src/trunk]: src/sys/coda Fix locking for readdir code (Brett Lymn)



details:   https://anonhg.NetBSD.org/src/rev/c91f8f5452d7
branches:  trunk
changeset: 446022:c91f8f5452d7
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Nov 20 19:05:25 2018 +0000

description:
Fix locking for readdir code (Brett Lymn)

diffstat:

 sys/coda/coda_vnops.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (40 lines):

diff -r 3a10def3dd0a -r c91f8f5452d7 sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c     Tue Nov 20 19:02:07 2018 +0000
+++ b/sys/coda/coda_vnops.c     Tue Nov 20 19:05:25 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vnops.c,v 1.106 2017/05/26 14:21:00 riastradh Exp $       */
+/*     $NetBSD: coda_vnops.c,v 1.107 2018/11/20 19:05:25 christos Exp $        */
 
 /*
  *
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.106 2017/05/26 14:21:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.107 2018/11/20 19:05:25 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -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



Home | Main Index | Thread Index | Old Index