afs: Clarify vcache->mvid accesses
[openafs.git] / src / afs / VNOPS / afs_vnop_remove.c
index cda6f8e..b5f53b4 100644 (file)
@@ -124,11 +124,8 @@ afsremove(struct vcache *adp, struct dcache *tdc,
      * call FindVCache instead of GetVCache since if the file's really
      * gone, we won't be able to fetch the status info anyway.  */
     if (tvc) {
-       afs_MarinerLog("store$Removing", tvc);
-#ifdef AFS_BOZONLOCK_ENV
-       afs_BozonLock(&tvc->pvnLock, tvc);
-       /* Since afs_TryToSmush will do a pvn_vptrunc */
-#endif
+       if (afs_mariner)
+           afs_MarinerLog("store$Removing", tvc);
        ObtainWriteLock(&tvc->lock, 141);
        /* note that callback will be broken on the deleted file if there are
         * still >0 links left to it, so we'll get the stat right */
@@ -139,9 +136,6 @@ afsremove(struct vcache *adp, struct dcache *tdc,
                afs_TryToSmush(tvc, acred, 0);
        }
        ReleaseWriteLock(&tvc->lock);
-#ifdef AFS_BOZONLOCK_ENV
-       afs_BozonUnlock(&tvc->pvnLock, tvc);
-#endif
        afs_PutVCache(tvc);
     }
     return (0);
@@ -175,7 +169,7 @@ char *Tnam1;
 int
 afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct dcache *tdc;
     struct VenusFid unlinkFid;
     afs_int32 code;
@@ -189,13 +183,13 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
               ICL_TYPE_STRING, aname);
 
 
-    if ((code = afs_InitReq(&treq, acred))) {
+    if ((code = afs_CreateReq(&treq, acred))) {
        return code;
     }
 
     afs_InitFakeStat(&fakestate);
     AFS_DISCON_LOCK();
-    code = afs_EvalFakeStat(&adp, &fakestate, &treq);
+    code = afs_EvalFakeStat(&adp, &fakestate, treq);
     if (code)
        goto done;
 
@@ -214,10 +208,10 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
        goto done;
     }
   tagain:
-    code = afs_VerifyVCache(adp, &treq);
+    code = afs_VerifyVCache(adp, treq);
     tvc = NULL;
     if (code) {
-       code = afs_CheckCode(code, &treq, 23);
+       code = afs_CheckCode(code, treq, 23);
        goto done;
     }
 
@@ -235,7 +229,7 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
        goto done;
     }
     
-    tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */
+    tdc = afs_GetDCache(adp, (afs_size_t) 0, treq, &offset, &len, 1);  /* test for error below */
     ObtainWriteLock(&adp->lock, 142);
     if (tdc)
        ObtainSharedLock(&tdc->lock, 638);
@@ -271,7 +265,7 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
                unlinkFid.Fid.Volume = adp->f.fid.Fid.Volume;
                if (unlinkFid.Fid.Unique == 0) {
                    tvc =
-                       afs_LookupVCache(&unlinkFid, &treq, &cached, adp,
+                       afs_LookupVCache(&unlinkFid, treq, &cached, adp,
                                         aname);
                } else {
                    ObtainReadLock(&afs_xvcache);
@@ -315,7 +309,7 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
        if (tdc)
            ReleaseSharedLock(&tdc->lock);
        ObtainWriteLock(&tvc->lock, 143);
-       FetchWholeEnchilada(tvc, &treq);
+       FetchWholeEnchilada(tvc, treq);
        ReleaseWriteLock(&tvc->lock);
        ObtainWriteLock(&adp->lock, 144);
        /* Technically I don't think we need this back, but let's hold it 
@@ -349,13 +343,13 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
        ReleaseWriteLock(&adp->lock);
        if (tdc)
            ReleaseSharedLock(&tdc->lock);
-       code = afsrename(adp, aname, adp, unlname, acred, &treq);
+       code = afsrename(adp, aname, adp, unlname, acred, treq);
        Tnam1 = unlname;
        if (!code) {
-           struct VenusFid *oldmvid = NULL;
-           if (tvc->mvid) 
-               oldmvid = tvc->mvid;
-           tvc->mvid = (struct VenusFid *)unlname;
+           void *oldmvid = NULL;
+           if (tvc->mvid.silly_name)
+               oldmvid = tvc->mvid.silly_name;
+           tvc->mvid.silly_name = unlname;
            if (oldmvid)
                osi_FreeSmallSpace(oldmvid);
            crhold(acred);
@@ -377,7 +371,7 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
            afs_PutDCache(tdc);
        afs_PutVCache(tvc);
     } else {
-       code = afsremove(adp, tdc, tvc, aname, acred, &treq);
+       code = afsremove(adp, tdc, tvc, aname, acred, treq);
     }
     done:
     afs_PutFakeStat(&fakestate);
@@ -387,6 +381,7 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
     osi_Assert(!WriteLocked(&adp->lock) || (adp->lock.pid_writer != MyPidxx));
 #endif
     AFS_DISCON_UNLOCK();
+    afs_DestroyReq(treq);
     return code;
 }
 
@@ -402,7 +397,6 @@ afs_remunlink(struct vcache *avc, int doit)
     afs_ucred_t *cred;
     char *unlname;
     struct vcache *adp;
-    struct vrequest treq;
     struct VenusFid dirFid;
     struct dcache *tdc;
     afs_int32 code = 0;
@@ -416,15 +410,17 @@ afs_remunlink(struct vcache *avc, int doit)
     }
 #endif
 
-    if (avc->mvid && (doit || (avc->f.states & CUnlinkedDel))) {
-       if ((code = afs_InitReq(&treq, avc->uncred))) {
+    if (avc->mvid.silly_name && (doit || (avc->f.states & CUnlinkedDel))) {
+       struct vrequest *treq = NULL;
+
+       if ((code = afs_CreateReq(&treq, avc->uncred))) {
            ReleaseWriteLock(&avc->lock);
        } else {
            /* Must bump the refCount because GetVCache may block.
             * Also clear mvid so no other thread comes here if we block.
             */
-           unlname = (char *)avc->mvid;
-           avc->mvid = NULL;
+           unlname = avc->mvid.silly_name;
+           avc->mvid.silly_name = NULL;
            cred = avc->uncred;
            avc->uncred = NULL;
 
@@ -445,7 +441,7 @@ afs_remunlink(struct vcache *avc, int doit)
            dirFid.Fid.Volume = avc->f.fid.Fid.Volume;
            dirFid.Fid.Vnode = avc->f.parent.vnode;
            dirFid.Fid.Unique = avc->f.parent.unique;
-           adp = afs_GetVCache(&dirFid, &treq, NULL, NULL);
+           adp = afs_GetVCache(&dirFid, treq, NULL, NULL);
 
            if (adp) {
                tdc = afs_FindDCache(adp, (afs_size_t) 0);
@@ -454,7 +450,7 @@ afs_remunlink(struct vcache *avc, int doit)
                    ObtainSharedLock(&tdc->lock, 639);
 
                /* afsremove releases the adp & tdc locks, and does vn_rele(avc) */
-               code = afsremove(adp, tdc, avc, unlname, cred, &treq);
+               code = afsremove(adp, tdc, avc, unlname, cred, treq);
                afs_PutVCache(adp);
            } else {
                /* we failed - and won't be back to try again. */
@@ -462,6 +458,7 @@ afs_remunlink(struct vcache *avc, int doit)
            }
            osi_FreeSmallSpace(unlname);
            crfree(cred);
+           afs_DestroyReq(treq);
        }
     } else {
 #if defined(AFS_DARWIN80_ENV)