]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
macos-vnode-get-fixes-20060105
authorChaskiel M Grundman <cg2v@andrew.cmu.edu>
Thu, 5 Jan 2006 05:31:34 +0000 (05:31 +0000)
committerDerrick Brashear <shadow@dementia.org>
Thu, 5 Jan 2006 05:31:34 +0000 (05:31 +0000)
The afs_pioctl.c change should fix a real crash (panic), but fs flushv isn't
that common an operation.
Other changes:
don't GUNLOCK() around vnode_get(). we weren't consistent about it, and it
doesn't appear to be strictly required.
handle vnode_get() failures in more cases
darwin_vn_hold will panic if vnode is terminating rather than mess up the
refcounts.

src/afs/DARWIN/osi_vnodeops.c
src/afs/afs_osidnlc.c
src/afs/afs_pioctl.c
src/afs/afs_vcache.c
src/afs/afs_volume.c

index 06e43147a73fbf7cb1385d44ddede05c69785184..97741b0931a121ae00ebb29038fe2be86d2dbeb6 100644 (file)
@@ -247,7 +247,16 @@ darwin_vn_hold(struct vnode *vp)
     if (haveGlock) AFS_GUNLOCK(); 
 
 #ifdef AFS_DARWIN80_ENV
-       vnode_get(vp);
+       if (vnode_get(vp)) {
+           /* being terminated. kernel won't give us a ref. Now what? our
+              callers don't expect us to fail */
+#if 1
+           panic("vn_hold on terminating vnode");
+#else           
+           if (haveGlock) AFS_GLOCK(); 
+           return;
+#endif
+        }
        vnode_ref(vp);
        vnode_put(vp);
 #else
index 9ece5a1ec1e1415b9c7f27c925d2541659beb4cf..cee981484153834ab4283502d3f8222d33448008 100644 (file)
@@ -243,7 +243,12 @@ osi_dnlc_lookup(struct vcache *adp, char *aname, int locktype)
        VN_HOLD((vnode_t *) tvc);
 #else
 #ifdef AFS_DARWIN80_ENV
-        vnode_get(tvc->v);
+        if (vnode_get(tvc->v)) {
+           ReleaseReadLock(&afs_xvcache);
+           dnlcstats.misses++;
+            osi_dnlc_remove(adp, aname, tvc);
+            return 0;
+        }
 #endif
        osi_vnhold(tvc, 0);
 #endif
index 962164347eb517ca9696c6954835620ae8b23525..7aa595408ca8f1918bd816766d9dfe72da9592b7 100644 (file)
@@ -2586,6 +2586,10 @@ DECL_PIOCTL(PFlushVolumeData)
                VN_HOLD(AFSTOV(tvc));
 #else
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#ifdef AFS_DARWIN80_ENV
+                if (vnode_get(AFSTOV(tvc)))
+                    continue;
+#endif
                osi_vnhold(tvc, 0);
 #else
                VREFCOUNT_INC(tvc); /* AIX, apparently */
@@ -2610,6 +2614,7 @@ DECL_PIOCTL(PFlushVolumeData)
 #endif
 #ifdef AFS_DARWIN80_ENV
                /* our tvc ptr is still good until now */
+                vnode_put(AFSTOV(tvc));
                AFS_FAST_RELE(tvc);
                ObtainReadLock(&afs_xvcache);
 #else
index b059ef18dbd77f3bbd89bea3cac366104f9c85d9..1d2e08db5fcd49e8bb03ba5b6863b0c38351016b 100644 (file)
@@ -760,20 +760,20 @@ restart:
 #if defined (AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #ifdef AFS_DARWIN80_ENV
                vnode_t tvp = AFSTOV(tvc);
-               fv_slept=1;
-               /* must release lock, since vnode_recycle will immediately
-                  reclaim if there are no other users */
-               ReleaseWriteLock(&afs_xvcache);
-               AFS_GUNLOCK();
                /* VREFCOUNT_GT only sees usecounts, not iocounts */
                /* so this may fail to actually recycle the vnode now */
                /* must call vnode_get to avoid races. */
                if (vnode_get(tvp) == 0) {
+                   fv_slept=1;
+                   /* must release lock, since vnode_put will immediately
+                      reclaim if there are no other users */
+                   ReleaseWriteLock(&afs_xvcache);
+                   AFS_GUNLOCK();
                    vnode_recycle(tvp);
                    vnode_put(tvp);
+                   AFS_GLOCK();
+                   ObtainWriteLock(&afs_xvcache, 336);
                }
-               AFS_GLOCK();
-               ObtainWriteLock(&afs_xvcache, 336);
                /* we can't use the vnode_recycle return value to figure
                 * this out, since the iocount we have to hold makes it
                 * always "fail" */
@@ -2037,6 +2037,9 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
     struct AFSCallBack CallBack;
     struct AFSVolSync tsync;
     int origCBs = 0;
+#ifdef AFS_OSF_ENV
+    int vg;
+#endif
 
     start = osi_Time();
 
@@ -2080,7 +2083,6 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
            /* for the present (95.05.25) everything on the hash table is
             * definitively NOT in the free list -- at least until afs_reclaim
             * can be safely implemented */
-           int vg;
            AFS_GUNLOCK();
            vg = vget(AFSTOV(tvc));     /* this bumps ref count */
            AFS_GLOCK();
@@ -2088,16 +2090,12 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
                continue;
 #endif /* AFS_OSF_ENV */
 #ifdef AFS_DARWIN80_ENV
-            int vg;
             if (tvc->states & CDeadVnode) {
                ReleaseSharedLock(&afs_xvcache);
                afs_osi_Sleep(&tvc->states);
                goto rootvc_loop;
             }
-            AFS_GUNLOCK();
-            vg = vnode_get(AFSTOV(tvc));        /* this bumps ref count */
-            AFS_GLOCK();
-            if (vg)
+            if (vnode_get(AFSTOV(tvc)))       /* this bumps ref count */
                 continue;
 #endif
            break;
@@ -2113,8 +2111,11 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
        getNewFid = 1;
        ReleaseSharedLock(&afs_xvcache);
 #ifdef AFS_DARWIN80_ENV
-        if (tvc)
+        if (tvc) {
+            AFS_GUNLOCK();
             vnode_put(AFSTOV(tvc));
+            AFS_GLOCK();
+        }
 #endif
         tvc = NULL;
        goto newmtpt;
@@ -2566,6 +2567,9 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
 
     register struct vcache *tvc;
     afs_int32 i;
+#if defined( AFS_OSF_ENV)
+    int vg;
+#endif
 
     AFS_STATCNT(afs_FindVCache);
 
@@ -2579,7 +2583,6 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
             }
 #ifdef  AFS_OSF_ENV
            /* Grab this vnode, possibly reactivating from the free list */
-           int vg;
            AFS_GUNLOCK();
            vg = vget(AFSTOV(tvc));
            AFS_GLOCK();
@@ -2587,15 +2590,11 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
                continue;
 #endif /* AFS_OSF_ENV */
 #ifdef  AFS_DARWIN80_ENV
-            int vg;
             if (tvc->states & CDeadVnode) {
                 findvc_sleep(tvc, flag);
                goto findloop;
             }
-            AFS_GUNLOCK();
-            vg = vnode_get(AFSTOV(tvc));
-            AFS_GLOCK();
-            if (vg)
+            if (vnode_get(AFSTOV(tvc)))
                 continue;
 #endif
            break;
@@ -2697,6 +2696,9 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
     afs_int32 i;
     afs_int32 count = 0;
     struct vcache *found_tvc = NULL;
+#ifdef  AFS_OSF_ENV
+    int vg;
+#endif
 
     AFS_STATCNT(afs_FindVCache);
 
@@ -2719,7 +2721,6 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
             }
 #ifdef  AFS_OSF_ENV
            /* Grab this vnode, possibly reactivating from the free list */
-           int vg;
            AFS_GUNLOCK();
            vg = vget(AFSTOV(tvc));
            AFS_GLOCK();
@@ -2729,16 +2730,12 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
            }
 #endif /* AFS_OSF_ENV */
 #ifdef  AFS_DARWIN80_ENV
-            int vg;
             if (tvc->states & CDeadVnode) {
                ReleaseSharedLock(&afs_xvcache);
                afs_osi_Sleep(&tvc->states);
                goto loop;
             }
-            AFS_GUNLOCK();
-            vg = vnode_get(AFSTOV(tvc));
-            AFS_GLOCK();
-            if (vg) {
+            if (vnode_get(AFSTOV(tvc))) {
                 /* This vnode no longer exists. */
                 continue;
             }
index 727812994b7960a779c0437dc41be1971b047cd2..0c0d08485c6c0cfd0aaa26d9036624b838c1ef08 100644 (file)
@@ -318,6 +318,8 @@ loop:
                        afs_osi_Sleep(&tvc->states);
                         goto loop;
                     }
+                    if (vnode_get(AFSTOV(tvc)))
+                        continue;
 #endif
                    AFS_FAST_HOLD(tvc);
                    ReleaseReadLock(&afs_xvcache);