libafs: reduce stack space in VNOPS
authorMichael Meffie <mmeffie@sinenomine.net>
Tue, 8 Apr 2014 20:10:36 +0000 (16:10 -0400)
committerD Brashear <shadow@your-file-system.com>
Wed, 21 May 2014 11:09:44 +0000 (07:09 -0400)
Allocate temporary vrequests to reduce the amount
of stack space used.

Change-Id: Ic14cc4f657f7c7e97ef396601bd6c8c7f91abe55
Reviewed-on: http://gerrit.openafs.org/11004
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: D Brashear <shadow@your-file-system.com>

14 files changed:
src/afs/VNOPS/afs_vnop_access.c
src/afs/VNOPS/afs_vnop_attrs.c
src/afs/VNOPS/afs_vnop_create.c
src/afs/VNOPS/afs_vnop_dirops.c
src/afs/VNOPS/afs_vnop_flock.c
src/afs/VNOPS/afs_vnop_link.c
src/afs/VNOPS/afs_vnop_lookup.c
src/afs/VNOPS/afs_vnop_open.c
src/afs/VNOPS/afs_vnop_read.c
src/afs/VNOPS/afs_vnop_readdir.c
src/afs/VNOPS/afs_vnop_remove.c
src/afs/VNOPS/afs_vnop_rename.c
src/afs/VNOPS/afs_vnop_symlink.c
src/afs/VNOPS/afs_vnop_write.c

index 13bba66..518cb86 100644 (file)
@@ -198,7 +198,7 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
 #endif
 {
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct afs_fakestat_state fakestate;
     OSI_VC_CONVERT(avc);
 
@@ -206,35 +206,40 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
     afs_Trace3(afs_iclSetp, CM_TRACE_ACCESS, ICL_TYPE_POINTER, avc,
               ICL_TYPE_INT32, amode, ICL_TYPE_OFFSET,
               ICL_HANDLE_OFFSET(avc->f.m.Length));
+
     afs_InitFakeStat(&fakestate);
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred))) {
        return code;
+    }
 
     AFS_DISCON_LOCK();
 
     if (afs_fakestat_enable && avc->mvstat == 1) {
-       code = afs_TryEvalFakeStat(&avc, &fakestate, &treq);
+       code = afs_TryEvalFakeStat(&avc, &fakestate, treq);
         if (code == 0 && avc->mvstat == 1) {
            afs_PutFakeStat(&fakestate);
            AFS_DISCON_UNLOCK();
+           afs_DestroyReq(treq);
            return 0;
         }
     } else {
-       code = afs_EvalFakeStat(&avc, &fakestate, &treq);
+       code = afs_EvalFakeStat(&avc, &fakestate, treq);
     }
 
     if (code) {
        afs_PutFakeStat(&fakestate);
        AFS_DISCON_UNLOCK();
+       afs_DestroyReq(treq);
        return code;
     }
 
     if (vType(avc) != VDIR || !afs_InReadDir(avc)) {
-       code = afs_VerifyVCache(avc, &treq);
+       code = afs_VerifyVCache(avc, treq);
        if (code) {
            afs_PutFakeStat(&fakestate);
            AFS_DISCON_UNLOCK();
-           code = afs_CheckCode(code, &treq, 16);
+           code = afs_CheckCode(code, treq, 16);
+           afs_DestroyReq(treq);
            return code;
        }
     }
@@ -243,6 +248,7 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
     if ((amode & VWRITE) && (avc->f.states & CRO)) {
        afs_PutFakeStat(&fakestate);
        AFS_DISCON_UNLOCK();
+       afs_DestroyReq(treq);
        return EROFS;
     }
     
@@ -251,6 +257,7 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
         afs_PutFakeStat(&fakestate);
        AFS_DISCON_UNLOCK();
        /* printf("Network is down in afs_vnop_access\n"); */
+       afs_DestroyReq(treq);
         return ENETDOWN;
     }
     
@@ -258,41 +265,41 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
     if (avc->f.states & CForeign) {
        /* In the dfs xlator the EXEC bit is mapped to LOOKUP */
        if (amode & VEXEC)
-           code = afs_AccessOK(avc, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS);
+           code = afs_AccessOK(avc, PRSFS_LOOKUP, treq, CHECK_MODE_BITS);
        if (code && (amode & VWRITE)) {
-           code = afs_AccessOK(avc, PRSFS_WRITE, &treq, CHECK_MODE_BITS);
+           code = afs_AccessOK(avc, PRSFS_WRITE, treq, CHECK_MODE_BITS);
            if (code && (vType(avc) == VDIR)) {
                if (code)
                    code =
-                       afs_AccessOK(avc, PRSFS_INSERT, &treq,
+                       afs_AccessOK(avc, PRSFS_INSERT, treq,
                                     CHECK_MODE_BITS);
                if (!code)
                    code =
-                       afs_AccessOK(avc, PRSFS_DELETE, &treq,
+                       afs_AccessOK(avc, PRSFS_DELETE, treq,
                                     CHECK_MODE_BITS);
            }
        }
        if (code && (amode & VREAD))
-           code = afs_AccessOK(avc, PRSFS_READ, &treq, CHECK_MODE_BITS);
+           code = afs_AccessOK(avc, PRSFS_READ, treq, CHECK_MODE_BITS);
     } else {
        if (vType(avc) == VDIR) {
            if (amode & VEXEC)
                code =
-                   afs_AccessOK(avc, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS);
+                   afs_AccessOK(avc, PRSFS_LOOKUP, treq, CHECK_MODE_BITS);
            if (code && (amode & VWRITE)) {
                code =
-                   afs_AccessOK(avc, PRSFS_INSERT, &treq, CHECK_MODE_BITS);
+                   afs_AccessOK(avc, PRSFS_INSERT, treq, CHECK_MODE_BITS);
                if (!code)
                    code =
-                       afs_AccessOK(avc, PRSFS_DELETE, &treq,
+                       afs_AccessOK(avc, PRSFS_DELETE, treq,
                                     CHECK_MODE_BITS);
            }
            if (code && (amode & VREAD))
                code =
-                   afs_AccessOK(avc, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS);
+                   afs_AccessOK(avc, PRSFS_LOOKUP, treq, CHECK_MODE_BITS);
        } else {
            if (amode & VEXEC) {
-               code = afs_AccessOK(avc, PRSFS_READ, &treq, CHECK_MODE_BITS);
+               code = afs_AccessOK(avc, PRSFS_READ, treq, CHECK_MODE_BITS);
                if (code) {
                        if ((avc->f.m.Mode & 0100) == 0)
                            code = 0;
@@ -300,7 +307,7 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
                    code = 1;
            }
            if (code && (amode & VWRITE)) {
-               code = afs_AccessOK(avc, PRSFS_WRITE, &treq, CHECK_MODE_BITS);
+               code = afs_AccessOK(avc, PRSFS_WRITE, treq, CHECK_MODE_BITS);
 
                /* The above call fails when the NFS translator tries to copy
                 ** a file with r--r--r-- permissions into a directory which
@@ -312,11 +319,11 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
                if (!code && AFS_NFSXLATORREQ(acred)
                    && avc->f.m.Owner == ANONYMOUSID)
                    code =
-                       afs_AccessOK(avc, PRSFS_WRITE, &treq,
+                       afs_AccessOK(avc, PRSFS_WRITE, treq,
                                     DONT_CHECK_MODE_BITS);
            }
            if (code && (amode & VREAD))
-               code = afs_AccessOK(avc, PRSFS_READ, &treq, CHECK_MODE_BITS);
+               code = afs_AccessOK(avc, PRSFS_READ, treq, CHECK_MODE_BITS);
        }
     }
     afs_PutFakeStat(&fakestate);
@@ -324,9 +331,11 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
     AFS_DISCON_UNLOCK();
     
     if (code) {
+       afs_DestroyReq(treq);
        return 0;               /* if access is ok */
     } else {
-       code = afs_CheckCode(EACCES, &treq, 17);        /* failure code */
+       code = afs_CheckCode(EACCES, treq, 17); /* failure code */
+       afs_DestroyReq(treq);
        return code;
     }
 }
@@ -341,18 +350,21 @@ afs_getRights(OSI_VC_DECL(avc), afs_int32 arights,
              afs_ucred_t *acred)
 {
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     OSI_VC_CONVERT(avc);
 
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        return code;
 
-    code = afs_VerifyVCache(avc, &treq);
+    code = afs_VerifyVCache(avc, treq);
     if (code) {
-       code = afs_CheckCode(code, &treq, 18);
+       code = afs_CheckCode(code, treq, 18);
+       afs_DestroyReq(treq);
        return code;
     }
 
-    return afs_GetAccessBits(avc, arights, &treq);
+    code = afs_GetAccessBits(avc, arights, treq);
+    afs_DestroyReq(treq);
+    return code;
 }
 #endif /* defined(UKERNEL) */
index c25e90d..64797c2 100644 (file)
@@ -194,7 +194,7 @@ afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, afs_ucred_t *acred)
 #endif
 {
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct unixuser *au;
     int inited = 0;
     OSI_VC_CONVERT(avc);
@@ -205,19 +205,23 @@ afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, afs_ucred_t *acred)
 
     if (afs_fakestat_enable && avc->mvstat == 1) {
        struct afs_fakestat_state fakestat;
+       struct vrequest *ureq = NULL;
 
-       code = afs_InitReq(&treq, acred);
-       if (code)
+       code = afs_CreateReq(&ureq, acred);
+       if (code) {
            return code;
+       }
        afs_InitFakeStat(&fakestat);
-       code = afs_TryEvalFakeStat(&avc, &fakestat, &treq);
+       code = afs_TryEvalFakeStat(&avc, &fakestat, ureq);
        if (code) {
            afs_PutFakeStat(&fakestat);
+           afs_DestroyReq(ureq);
            return code;
        }
 
        code = afs_CopyOutAttrs(avc, attrs);
        afs_PutFakeStat(&fakestat);
+       afs_DestroyReq(ureq);
        return code;
     }
 #if defined(AFS_SUN5_ENV)
@@ -248,8 +252,8 @@ afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, afs_ucred_t *acred)
     }
 
     if (!(avc->f.states & CStatd)) {
-       if (!(code = afs_InitReq(&treq, acred))) {
-           code = afs_VerifyVCache2(avc, &treq);
+       if (!(code = afs_CreateReq(&treq, acred))) {
+           code = afs_VerifyVCache2(avc, treq);
            inited = 1;
        }
     } else
@@ -270,19 +274,21 @@ afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, afs_ucred_t *acred)
 
        if (afs_nfsexporter) {
            if (!inited) {
-               if ((code = afs_InitReq(&treq, acred)))
+               if ((code = afs_CreateReq(&treq, acred))) {
                    return code;
+               }
                inited = 1;
            }
            if (AFS_NFSXLATORREQ(acred)) {
                if ((vType(avc) != VDIR)
-                   && !afs_AccessOK(avc, PRSFS_READ, &treq,
+                   && !afs_AccessOK(avc, PRSFS_READ, treq,
                                     CHECK_MODE_BITS |
                                     CMB_ALLOW_EXEC_AS_READ)) {
+                   afs_DestroyReq(treq);
                    return EACCES;
                }
            }
-           if ((au = afs_FindUser(treq.uid, -1, READ_LOCK))) {
+           if ((au = afs_FindUser(treq->uid, -1, READ_LOCK))) {
                struct afs_exporter *exporter = au->exporter;
 
                if (exporter && !(afs_nfsexporter->exp_states & EXP_UNIXMODE)) {
@@ -345,9 +351,12 @@ afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, afs_ucred_t *acred)
 
     AFS_DISCON_UNLOCK();
 
-    if (!code)
+    if (!code) {
+       afs_DestroyReq(treq);
        return 0;
-    code = afs_CheckCode(code, &treq, 14);
+    }
+    code = afs_CheckCode(code, treq, 14);
+    afs_DestroyReq(treq);
     return code;
 }
 
@@ -459,7 +468,7 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs,
            afs_ucred_t *acred)
 #endif
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct AFSStoreStatus astat;
     afs_int32 code;
 #if defined(AFS_FBSD_ENV) || defined(AFS_DFBSD_ENV)
@@ -480,13 +489,13 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs,
               ICL_HANDLE_OFFSET(attrs->va_size), ICL_TYPE_OFFSET,
               ICL_HANDLE_OFFSET(avc->f.m.Length));
 #endif
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        return code;
 
     AFS_DISCON_LOCK();
 
     afs_InitFakeStat(&fakestate);
-    code = afs_EvalFakeStat(&avc, &fakestate, &treq);
+    code = afs_EvalFakeStat(&avc, &fakestate, treq);
     if (code)
        goto done;
 
@@ -518,7 +527,7 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs,
 #else
     if (attrs->va_size != ~0) {
 #endif
-       if (!afs_AccessOK(avc, PRSFS_WRITE, &treq, DONT_CHECK_MODE_BITS)) {
+       if (!afs_AccessOK(avc, PRSFS_WRITE, treq, DONT_CHECK_MODE_BITS)) {
            code = EACCES;
            goto done;
        }
@@ -563,9 +572,9 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs,
         if (AFS_IS_DISCONNECTED && tsize >=avc->f.m.Length) {
            /* If we're growing the file, and we're disconnected, we need
             * to make the relevant dcache chunks appear ourselves. */
-           code = afs_ExtendSegments(avc, tsize, &treq);
+           code = afs_ExtendSegments(avc, tsize, treq);
        } else {
-           code = afs_TruncateAllSegments(avc, tsize, &treq, acred);
+           code = afs_TruncateAllSegments(avc, tsize, treq, acred);
        }
 #ifdef AFS_LINUX26_ENV
        /* We must update the Linux kernel's idea of file size as soon as
@@ -591,7 +600,7 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs,
                /* Store files now if not disconnected. */
                /* XXX: AFS_IS_DISCON_RW handled. */
                if (!AFS_IS_DISCONNECTED) {
-                       code = afs_StoreAllSegments(avc, &treq, AFS_ASYNC);
+                       code = afs_StoreAllSegments(avc, treq, AFS_ASYNC);
                        if (!code)
                                avc->f.states &= ~CDirty;
                }
@@ -607,7 +616,7 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs,
     if (!AFS_IS_DISCONNECTED) {
         if (code == 0) {
            ObtainSharedLock(&avc->lock, 16);   /* lock entry */
-           code = afs_WriteVCache(avc, &astat, &treq); /* send request */
+           code = afs_WriteVCache(avc, &astat, treq);  /* send request */
            ReleaseSharedLock(&avc->lock);      /* release lock */
         }
         if (code) {
@@ -641,6 +650,7 @@ afs_setattr(OSI_VC_DECL(avc), struct vattr *attrs,
     afs_PutFakeStat(&fakestate);
 
     AFS_DISCON_UNLOCK();
-    code = afs_CheckCode(code, &treq, 15);
+    code = afs_CheckCode(code, treq, 15);
+    afs_DestroyReq(treq);
     return code;
 }
index daaa9f0..313187d 100644 (file)
@@ -41,7 +41,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 #endif                         /* AFS_SGI64_ENV */
 {
     afs_int32 origCBs, origZaps, finalZaps;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     afs_int32 code;
     struct afs_conn *tc;
     struct VenusFid newFid;
@@ -65,7 +65,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     OutFidStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
     OutDirStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
 
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        goto done2;
 
     afs_Trace3(afs_iclSetp, CM_TRACE_CREATE, ICL_TYPE_POINTER, adp,
@@ -108,11 +108,11 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     }
     AFS_DISCON_LOCK();
 
-    code = afs_EvalFakeStat(&adp, &fakestate, &treq);
+    code = afs_EvalFakeStat(&adp, &fakestate, treq);
     if (code)
        goto done;
   tagain:
-    code = afs_VerifyVCache(adp, &treq);
+    code = afs_VerifyVCache(adp, treq);
     if (code)
        goto done;
 
@@ -129,7 +129,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
         goto done;
     }
 
-    tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1);
+    tdc = afs_GetDCache(adp, (afs_size_t) 0, treq, &offset, &len, 1);
     ObtainWriteLock(&adp->lock, 135);
     if (tdc)
        ObtainSharedLock(&tdc->lock, 630);
@@ -168,10 +168,10 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
            newFid.Fid.Volume = adp->f.fid.Fid.Volume;
            tvc = NULL;
            if (newFid.Fid.Unique == 0) {
-               tvc = afs_LookupVCache(&newFid, &treq, NULL, adp, aname);
+               tvc = afs_LookupVCache(&newFid, treq, NULL, adp, aname);
            }
            if (!tvc)           /* lookup failed or wasn't called */
-               tvc = afs_GetVCache(&newFid, &treq, NULL, NULL);
+               tvc = afs_GetVCache(&newFid, treq, NULL, NULL);
 
            if (tvc) {
                /* if the thing exists, we need the right access to open it.
@@ -184,7 +184,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
                 * has mode -w-w-w, which is wrong.
                 */
                if ((amode & VREAD)
-                   && !afs_AccessOK(tvc, PRSFS_READ, &treq, CHECK_MODE_BITS)) {
+                   && !afs_AccessOK(tvc, PRSFS_READ, treq, CHECK_MODE_BITS)) {
                    afs_PutVCache(tvc);
                    code = EACCES;
                    goto done;
@@ -202,7 +202,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
                    tvc->f.parent.unique = adp->f.fid.Fid.Unique;
                    /* need write mode for these guys */
                    if (!afs_AccessOK
-                       (tvc, PRSFS_WRITE, &treq, CHECK_MODE_BITS)) {
+                       (tvc, PRSFS_WRITE, treq, CHECK_MODE_BITS)) {
                        afs_PutVCache(tvc);
                        code = EACCES;
                        goto done;
@@ -301,7 +301,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 
        InStatus.UnixModeBits = attrs->va_mode & 0xffff;        /* only care about protection bits */
        do {
-           tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK, &rxconn);
+           tc = afs_Conn(&adp->f.fid, treq, SHARED_LOCK, &rxconn);
            if (tc) {
                hostp = tc->parent->srvr->server; /* remember for callback processing */
                now = osi_Time();
@@ -318,7 +318,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
            } else
                code = -1;
        } while (afs_Analyze
-                (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE,
+                (tc, rxconn, code, &adp->f.fid, treq, AFS_STATS_FS_RPCIDX_CREATEFILE,
                  SHARED_LOCK, NULL));
 
        if ((code == EEXIST || code == UAEEXIST) &&
@@ -455,9 +455,9 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
            ReleaseWriteLock(&afs_xcbhash);
            if (AFS_IS_DISCON_RW) {
                afs_DisconAddDirty(tvc, VDisconCreate, 0);
-               afs_GenDisconStatus(adp, tvc, &newFid, attrs, &treq, VREG);
+               afs_GenDisconStatus(adp, tvc, &newFid, attrs, treq, VREG);
            } else {
-               afs_ProcessFS(tvc, OutFidStatus, &treq);
+               afs_ProcessFS(tvc, OutFidStatus, treq);
            }
 
            tvc->f.parent.vnode = adp->f.fid.Fid.Vnode;
@@ -498,7 +498,8 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     }
 
     afs_PutFakeStat(&fakestate);
-    code = afs_CheckCode(code, &treq, 20);
+    code = afs_CheckCode(code, treq, 20);
+    afs_DestroyReq(treq);
 
   done2:
     osi_FreeSmallSpace(OutFidStatus);
index 47c71a7..b8ce1f9 100644 (file)
@@ -37,7 +37,7 @@ int
 afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, 
      struct vcache **avcp, afs_ucred_t *acred)
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     afs_int32 code;
     struct afs_conn *tc;
     struct rx_connection *rxconn;
@@ -62,7 +62,7 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     OutFidStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
     OutDirStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
 
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        goto done2;
     afs_InitFakeStat(&fakestate);
 
@@ -78,10 +78,10 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     
     AFS_DISCON_LOCK();
 
-    code = afs_EvalFakeStat(&adp, &fakestate, &treq);
+    code = afs_EvalFakeStat(&adp, &fakestate, treq);
     if (code)
        goto done;
-    code = afs_VerifyVCache(adp, &treq);
+    code = afs_VerifyVCache(adp, treq);
     if (code)
        goto done;
 
@@ -102,12 +102,12 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     InStatus.ClientModTime = osi_Time();
     InStatus.UnixModeBits = attrs->va_mode & 0xffff;   /* only care about protection bits */
     InStatus.Group = (afs_int32) afs_cr_gid(acred);
-    tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1);
+    tdc = afs_GetDCache(adp, (afs_size_t) 0, treq, &offset, &len, 1);
     ObtainWriteLock(&adp->lock, 153);
 
     if (!AFS_IS_DISCON_RW) {
        do {
-           tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK, &rxconn);
+           tc = afs_Conn(&adp->f.fid, treq, SHARED_LOCK, &rxconn);
            if (tc) {
                XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_MAKEDIR);
                now = osi_Time();
@@ -129,7 +129,7 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
            } else
                code = -1;
        } while (afs_Analyze
-                   (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_MAKEDIR,
+                   (tc, rxconn, code, &adp->f.fid, treq, AFS_STATS_FS_RPCIDX_MAKEDIR,
                     SHARED_LOCK, NULL));
 
        if (code) {
@@ -202,12 +202,12 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        }
 
        ObtainWriteLock(&tvc->lock, 738);
-       afs_GenDisconStatus(adp, tvc, &newFid, attrs, &treq, VDIR);
+       afs_GenDisconStatus(adp, tvc, &newFid, attrs, treq, VDIR);
        ReleaseWriteLock(&tvc->lock);
 
        /* And now make an empty dir, containing . and .. : */
        /* Get a new dcache for it first. */
-       new_dc = afs_GetDCache(tvc, (afs_size_t) 0, &treq, &offset, &len, 1);
+       new_dc = afs_GetDCache(tvc, (afs_size_t) 0, treq, &offset, &len, 1);
        if (!new_dc) {
            /* printf("afs_mkdir: can't get new dcache for dir.\n"); */
            code = ENOENT;
@@ -231,7 +231,7 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        ReleaseWriteLock(&tvc->lock);
     } else {
        /* now we're done with parent dir, create the real dir's cache entry */
-       tvc = afs_GetVCache(&newFid, &treq, NULL, NULL);
+       tvc = afs_GetVCache(&newFid, treq, NULL, NULL);
        if (tvc) {
            code = 0;
            *avcp = tvc;
@@ -243,7 +243,8 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     AFS_DISCON_UNLOCK();
   done3:
     afs_PutFakeStat(&fakestate);
-    code = afs_CheckCode(code, &treq, 26);
+    code = afs_CheckCode(code, treq, 26);
+    afs_DestroyReq(treq);
   done2:
     osi_FreeSmallSpace(OutFidStatus);
     osi_FreeSmallSpace(OutDirStatus);
@@ -260,7 +261,7 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, struct vnode *cdirp,
 afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
 #endif
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct dcache *tdc;
     struct vcache *tvc = NULL;
     afs_int32 code;
@@ -278,7 +279,7 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
     afs_Trace2(afs_iclSetp, CM_TRACE_RMDIR, ICL_TYPE_POINTER, adp,
               ICL_TYPE_STRING, aname);
 
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        goto done2;
     afs_InitFakeStat(&fakestate);
 
@@ -289,11 +290,11 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
 
     AFS_DISCON_LOCK();
 
-    code = afs_EvalFakeStat(&adp, &fakestate, &treq);
+    code = afs_EvalFakeStat(&adp, &fakestate, treq);
     if (code)
        goto done;
 
-    code = afs_VerifyVCache(adp, &treq);
+    code = afs_VerifyVCache(adp, treq);
     if (code)
        goto done;
 
@@ -311,7 +312,7 @@ afs_rmdir(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, 154);
     if (tdc)
        ObtainSharedLock(&tdc->lock, 633);
@@ -327,7 +328,7 @@ afs_rmdir(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, aname);
+                   afs_LookupVCache(&unlinkFid, treq, &cached, adp, aname);
            } else {
                ObtainReadLock(&afs_xvcache);
                tvc = afs_FindVCache(&unlinkFid, 0, 1 /* do xstats */ );
@@ -339,7 +340,7 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
     if (!AFS_IS_DISCON_RW) {
        /* Not disconnected, can connect to server. */
        do {
-           tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK, &rxconn);
+           tc = afs_Conn(&adp->f.fid, treq, SHARED_LOCK, &rxconn);
            if (tc) {
                XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEDIR);
                RX_AFS_GUNLOCK();
@@ -354,7 +355,7 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
            } else
                code = -1;
        } while (afs_Analyze
-                (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_REMOVEDIR,
+                (tc, rxconn, code, &adp->f.fid, treq, AFS_STATS_FS_RPCIDX_REMOVEDIR,
                 SHARED_LOCK, NULL));
 
        if (code) {
@@ -474,7 +475,8 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
   done:
     AFS_DISCON_UNLOCK();
     afs_PutFakeStat(&fakestate);
-    code = afs_CheckCode(code, &treq, 27);
+    code = afs_CheckCode(code, treq, 27);
+    afs_DestroyReq(treq);
   done2:
     return code;
 }
index f11c60c..9efeeeb 100644 (file)
@@ -566,18 +566,18 @@ int afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
                afs_ucred_t * acred)
 #endif
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     afs_int32 code;
     struct afs_fakestat_state fakestate;
 
     AFS_STATCNT(afs_lockctl);
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        return code;
     afs_InitFakeStat(&fakestate);
 
     AFS_DISCON_LOCK();
 
-    code = afs_EvalFakeStat(&avc, &fakestate, &treq);
+    code = afs_EvalFakeStat(&avc, &fakestate, treq);
     if (code) {
        goto done;
     }
@@ -590,8 +590,8 @@ int afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
            code = 0;
            goto done;
        }
-       code = HandleGetLock(avc, af, &treq, clid);
-       code = afs_CheckCode(code, &treq, 2);   /* defeat buggy AIX optimz */
+       code = HandleGetLock(avc, af, treq, clid);
+       code = afs_CheckCode(code, treq, 2);    /* defeat buggy AIX optimz */
        goto done;
     } else if ((acmd == F_SETLK) || (acmd == F_SETLKW)
 #if defined(AFS_SGI_ENV)
@@ -639,21 +639,22 @@ int afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
        ) && code != LOCK_UN)
        code |= LOCK_NB;        /* non-blocking, s.v.p. */
 #if defined(AFS_DARWIN_ENV)
-    code = HandleFlock(avc, code, &treq, clid, 0 /*!onlymine */ );
+    code = HandleFlock(avc, code, treq, clid, 0 /*!onlymine */ );
 #elif defined(AFS_SGI_ENV)
     AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE);
-    code = HandleFlock(avc, code, &treq, clid, 0 /*!onlymine */ );
+    code = HandleFlock(avc, code, treq, clid, 0 /*!onlymine */ );
     AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE);
 #else
-    code = HandleFlock(avc, code, &treq, 0, 0 /*!onlymine */ );
+    code = HandleFlock(avc, code, treq, 0, 0 /*!onlymine */ );
 #endif
-    code = afs_CheckCode(code, &treq, 3);      /* defeat AIX -O bug */
+    code = afs_CheckCode(code, treq, 3);       /* defeat AIX -O bug */
     goto done;
     }
     code = EINVAL;
 done:
     afs_PutFakeStat(&fakestate);
     AFS_DISCON_UNLOCK();
+    afs_DestroyReq(treq);
     return code;
 }
 
index 3457998..6f6fe0a 100644 (file)
@@ -38,7 +38,7 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname,
         afs_ucred_t *acred)
 #endif
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct dcache *tdc;
     afs_int32 code;
     struct afs_conn *tc;
@@ -58,7 +58,7 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname,
     OutDirStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
 
     /* create a hard link; new entry is aname in dir adp */
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        goto done2;
 
     afs_InitFakeStat(&vfakestate);
@@ -66,10 +66,10 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname,
 
     AFS_DISCON_LOCK();
 
-    code = afs_EvalFakeStat(&avc, &vfakestate, &treq);
+    code = afs_EvalFakeStat(&avc, &vfakestate, treq);
     if (code)
        goto done;
-    code = afs_EvalFakeStat(&adp, &dfakestate, &treq);
+    code = afs_EvalFakeStat(&adp, &dfakestate, treq);
     if (code)
        goto done;
 
@@ -82,7 +82,7 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname,
        code = ENAMETOOLONG;
        goto done;
     }
-    code = afs_VerifyVCache(adp, &treq);
+    code = afs_VerifyVCache(adp, treq);
     if (code)
        goto done;
 
@@ -99,10 +99,10 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname,
         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, 145);
     do {
-       tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK, &rxconn);
+       tc = afs_Conn(&adp->f.fid, treq, SHARED_LOCK, &rxconn);
        if (tc) {
            XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_LINK);
            RX_AFS_GUNLOCK();
@@ -116,7 +116,7 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname,
        } else
            code = -1;
     } while (afs_Analyze
-            (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_LINK,
+            (tc, rxconn, code, &adp->f.fid, treq, AFS_STATS_FS_RPCIDX_LINK,
              SHARED_LOCK, NULL));
 
     if (code) {
@@ -167,7 +167,8 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname,
     ReleaseWriteLock(&avc->lock);
     code = 0;
   done:
-    code = afs_CheckCode(code, &treq, 24);
+    code = afs_CheckCode(code, treq, 24);
+    afs_DestroyReq(treq);
     afs_PutFakeStat(&vfakestate);
     afs_PutFakeStat(&dfakestate);
     AFS_DISCON_UNLOCK();
index ee95ac5..73f83e0 100644 (file)
@@ -1373,7 +1373,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acred)
 #endif
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     char *tname = NULL;
     struct vcache *tvc = 0;
     afs_int32 code;
@@ -1393,8 +1393,8 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     afs_InitFakeStat(&fakestate);
 
     AFS_DISCON_LOCK();
-    
-    if ((code = afs_InitReq(&treq, acred)))
+
+    if ((code = afs_CreateReq(&treq, acred)))
        goto done;
 
     if (afs_fakestat_enable && adp->mvstat == 1) {
@@ -1419,9 +1419,9 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 #endif
 
     if (tryEvalOnly)
-       code = afs_TryEvalFakeStat(&adp, &fakestate, &treq);
+       code = afs_TryEvalFakeStat(&adp, &fakestate, treq);
     else
-       code = afs_EvalFakeStat(&adp, &fakestate, &treq);
+       code = afs_EvalFakeStat(&adp, &fakestate, treq);
 
     /*printf("Code is %d\n", code);*/
     
@@ -1437,7 +1437,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     bulkcode = 0;
 
     if (!(adp->f.states & CStatd) && !afs_InReadDir(adp)) {
-       if ((code = afs_VerifyVCache2(adp, &treq))) {
+       if ((code = afs_VerifyVCache2(adp, treq))) {
            goto done;
        }
     } else
@@ -1452,7 +1452,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
        }
        /* otherwise we have the fid here, so we use it */
        /*printf("Getting vcache\n");*/
-       tvc = afs_GetVCache(adp->mvid, &treq, NULL, NULL);
+       tvc = afs_GetVCache(adp->mvid, treq, NULL, NULL);
        afs_Trace3(afs_iclSetp, CM_TRACE_GETVCDOTDOT, ICL_TYPE_FID, adp->mvid,
                   ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, code);
        *avcp = tvc;
@@ -1468,18 +1468,18 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     }
 
     /* now check the access */
-    if (treq.uid != adp->last_looker) {
-       if (!afs_AccessOK(adp, PRSFS_LOOKUP, &treq, CHECK_MODE_BITS)) {
+    if (treq->uid != adp->last_looker) {
+       if (!afs_AccessOK(adp, PRSFS_LOOKUP, treq, CHECK_MODE_BITS)) {
            *avcp = NULL;
            code = EACCES;
            goto done;
        } else
-           adp->last_looker = treq.uid;
+           adp->last_looker = treq->uid;
     }
 
     /* Check for read access as well.  We need read access in order to
      * stat files, but not to stat subdirectories. */
-    if (!afs_AccessOK(adp, PRSFS_READ, &treq, CHECK_MODE_BITS))
+    if (!afs_AccessOK(adp, PRSFS_READ, treq, CHECK_MODE_BITS))
        no_read_access = 1;
 
     /* special case lookup of ".".  Can we check for it sooner in this code,
@@ -1532,7 +1532,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
        struct VenusFid tfid;
        afs_uint32 cellidx, volid, vnoid, uniq;
 
-       code = EvalMountData('%', aname, 0, 0, NULL, &treq, &cellidx, &volid, &vnoid, &uniq);
+       code = EvalMountData('%', aname, 0, 0, NULL, treq, &cellidx, &volid, &vnoid, &uniq);
        if (code)
            goto done;
        /* If a vnode was returned, it's not a real mount point */
@@ -1548,7 +1548,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
            tfid.Fid.Vnode = VNUM_FROM_TYPEID(VN_TYPE_MOUNT, cellidx << 2);
            tfid.Fid.Unique = volid;
        }
-       *avcp = tvc = afs_GetVCache(&tfid, &treq, NULL, NULL);
+       *avcp = tvc = afs_GetVCache(&tfid, treq, NULL, NULL);
        code = (tvc ? 0 : ENOENT);
        hit = 1;
        goto done;
@@ -1564,14 +1564,14 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
        struct VenusFid tfid;
 
        afs_GetDynrootMountFid(&tfid);
-       *avcp = tvc = afs_GetVCache(&tfid, &treq, NULL, NULL);
+       *avcp = tvc = afs_GetVCache(&tfid, treq, NULL, NULL);
        code = 0;
        hit = 1;
        goto done;
     }
 #endif
 
-    Check_AtSys(adp, aname, &sysState, &treq);
+    Check_AtSys(adp, aname, &sysState, treq);
     tname = sysState.name;
 
     /* 1st Check_AtSys and lookup by tname is required here, for now,
@@ -1616,7 +1616,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
        if (afs_InReadDir(adp))
            tdc = adp->dcreaddir;
        else
-           tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq,
+           tdc = afs_GetDCache(adp, (afs_size_t) 0, treq,
                                &dirOffset, &dirLen, 1);
        if (!tdc) {
            *avcp = NULL;       /* redundant, but harmless */
@@ -1681,7 +1681,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
                                 &dirCookie);
 
        /* If the first lookup doesn't succeed, maybe it's got @sys in the name */
-       while (code == ENOENT && Next_AtSys(adp, &treq, &sysState))
+       while (code == ENOENT && Next_AtSys(adp, treq, &sysState))
            code =
                afs_dir_LookupOffset(tdc, sysState.name, &tfid.Fid,
                                     &dirCookie);
@@ -1750,7 +1750,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
            } while (tvc && retry);
 
            if (!tvc || !(tvc->f.states & CStatd))
-               bulkcode = afs_DoBulkStat(adp, dirCookie, &treq);
+               bulkcode = afs_DoBulkStat(adp, dirCookie, treq);
            else
                bulkcode = 0;
 
@@ -1774,10 +1774,10 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
        if (!tvc) {
            afs_int32 cached = 0;
            if (!tfid.Fid.Unique && (adp->f.states & CForeign)) {
-               tvc = afs_LookupVCache(&tfid, &treq, &cached, adp, tname);
+               tvc = afs_LookupVCache(&tfid, treq, &cached, adp, tname);
            }
            if (!tvc && !bulkcode) {    /* lookup failed or wasn't called */
-               tvc = afs_GetVCache(&tfid, &treq, &cached, NULL);
+               tvc = afs_GetVCache(&tfid, treq, &cached, NULL);
            }
        }                       /* if !tvc */
     }                          /* sub-block just to reduce stack usage */
@@ -1793,7 +1793,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
            ObtainSharedLock(&tvc->lock, 680);
            if (!tvc->linkData) {
                UpgradeSToWLock(&tvc->lock, 681);
-               code = afs_HandleLink(tvc, &treq);
+               code = afs_HandleLink(tvc, treq);
                ConvertWToRLock(&tvc->lock);
            } else {
                ConvertSToRLock(&tvc->lock);
@@ -1815,7 +1815,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
                struct volume *tvolp;
 
                ObtainWriteLock(&tvc->lock, 133);
-               code = EvalMountPoint(tvc, adp, &tvolp, &treq);
+               code = EvalMountPoint(tvc, adp, &tvolp, treq);
                ReleaseWriteLock(&tvc->lock);
 
                if (code) {
@@ -1837,9 +1837,9 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
                    if (tvolp && (tvolp->states & VForeign)) {
                        /* XXXX tvolp has ref cnt on but not locked! XXX */
                        tvc =
-                           afs_GetRootVCache(tvc->mvid, &treq, NULL, tvolp);
+                           afs_GetRootVCache(tvc->mvid, treq, NULL, tvolp);
                    } else {
-                       tvc = afs_GetVCache(tvc->mvid, &treq, NULL, NULL);
+                       tvc = afs_GetVCache(tvc->mvid, treq, NULL, NULL);
                    }
                    afs_PutVCache(uvc); /* we're done with it */
 
@@ -1886,7 +1886,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
        if (!AFS_IS_DISCONNECTED) {
            if (pass == 0) {
                struct volume *tv;
-               tv = afs_GetVolume(&adp->f.fid, &treq, READ_LOCK);
+               tv = afs_GetVolume(&adp->f.fid, treq, READ_LOCK);
                if (tv) {
                    if (tv->states & VRO) {
                        pass = 1;       /* try this *once* */
@@ -1929,7 +1929,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
            } else {
 #ifdef AFS_LINUX20_ENV
                /* So Linux inode cache is up to date. */
-               code = afs_VerifyVCache(tvc, &treq);
+               code = afs_VerifyVCache(tvc, treq);
 #else
                afs_PutFakeStat(&fakestate);
                AFS_DISCON_UNLOCK();
@@ -1943,7 +1943,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     if (bulkcode)
        code = bulkcode;
 
-    code = afs_CheckCode(code, &treq, 19);
+    code = afs_CheckCode(code, treq, 19);
     if (code) {
        /* If there is an error, make sure *avcp is null.
         * Alphas panic otherwise - defect 10719.
@@ -1952,6 +1952,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     }
 
     afs_PutFakeStat(&fakestate);
+    afs_DestroyReq(treq);
     AFS_DISCON_UNLOCK();
     return code;
 }
index b6532c2..0c90bf1 100644 (file)
@@ -40,13 +40,13 @@ afs_open(struct vcache **avcp, afs_int32 aflags, afs_ucred_t *acred)
 #endif
 {
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct vcache *tvc;
     int writing;
     struct afs_fakestat_state fakestate;
 
     AFS_STATCNT(afs_open);
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        return code;
 #ifdef AFS_SGI64_ENV
     /* avcpp can be, but is not necesarily, bhp's vnode. */
@@ -60,10 +60,10 @@ afs_open(struct vcache **avcp, afs_int32 aflags, afs_ucred_t *acred)
 
     AFS_DISCON_LOCK();
 
-    code = afs_EvalFakeStat(&tvc, &fakestate, &treq);
+    code = afs_EvalFakeStat(&tvc, &fakestate, treq);
     if (code)
        goto done;
-    code = afs_VerifyVCache(tvc, &treq);
+    code = afs_VerifyVCache(tvc, treq);
     if (code)
        goto done;
 
@@ -90,7 +90,7 @@ afs_open(struct vcache **avcp, afs_int32 aflags, afs_ucred_t *acred)
        } else {
            if (!afs_AccessOK
                (tvc, ((tvc->f.states & CForeign) ? PRSFS_READ : PRSFS_LOOKUP),
-                &treq, CHECK_MODE_BITS)) {
+                treq, CHECK_MODE_BITS)) {
                code = EACCES;
                /* printf("afs_Open: no access for dir\n"); */
                goto done;
@@ -100,7 +100,7 @@ afs_open(struct vcache **avcp, afs_int32 aflags, afs_ucred_t *acred)
 #ifdef AFS_SUN5_ENV
        if (AFS_NFSXLATORREQ(acred) && (aflags & FREAD)) {
            if (!afs_AccessOK
-               (tvc, PRSFS_READ, &treq,
+               (tvc, PRSFS_READ, treq,
                 CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) {
                code = EACCES;
                goto done;
@@ -169,7 +169,7 @@ afs_open(struct vcache **avcp, afs_int32 aflags, afs_ucred_t *acred)
        struct dcache *tdc;
        afs_size_t offset, len;
 
-       tdc = afs_GetDCache(tvc, 0, &treq, &offset, &len, 1);
+       tdc = afs_GetDCache(tvc, 0, treq, &offset, &len, 1);
        if (tdc) {
            ObtainSharedLock(&tdc->mflock, 865);
            if (!(tdc->mflags & DFFetchReq)) {
@@ -199,7 +199,8 @@ afs_open(struct vcache **avcp, afs_int32 aflags, afs_ucred_t *acred)
     afs_PutFakeStat(&fakestate);
     AFS_DISCON_UNLOCK();
 
-    code = afs_CheckCode(code, &treq, 4);      /* avoid AIX -O bug */
+    code = afs_CheckCode(code, treq, 4);       /* avoid AIX -O bug */
+    afs_DestroyReq(treq);
 
     afs_Trace2(afs_iclSetp, CM_TRACE_OPEN, ICL_TYPE_POINTER, tvc,
               ICL_TYPE_INT32, 999999);
index 56179e9..66370f3 100644 (file)
@@ -55,7 +55,7 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
     afs_int32 error, trybusy = 1;
     struct uio *tuiop = NULL;
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
 
     AFS_STATCNT(afs_read);
 
@@ -65,25 +65,25 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
     AFS_DISCON_LOCK();
 
     /* check that we have the latest status info in the vnode cache */
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        goto out;
 
     if (!noLock) {
        if (!avc)
            osi_Panic("null avc in afs_GenericRead");
 
-       code = afs_VerifyVCache(avc, &treq);
+       code = afs_VerifyVCache(avc, treq);
        if (code) {
-           code = afs_CheckCode(code, &treq, 8);       /* failed to get it */
+           code = afs_CheckCode(code, treq, 8);        /* failed to get it */
            goto out;
        }
     }
 #ifndef        AFS_VM_RDWR_ENV
     if (AFS_NFSXLATORREQ(acred)) {
        if (!afs_AccessOK
-           (avc, PRSFS_READ, &treq,
+           (avc, PRSFS_READ, treq,
             CHECK_MODE_BITS | CMB_ALLOW_EXEC_AS_READ)) {
-           code = afs_CheckCode(EACCES, &treq, 9);
+           code = afs_CheckCode(EACCES, treq, 9);
            goto out;
        }
     }
@@ -178,7 +178,7 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
                ReleaseReadLock(&tdc->lock);
                afs_PutDCache(tdc);     /* before reusing tdc */
            }
-           tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 2);
+           tdc = afs_GetDCache(avc, filePos, treq, &offset, &len, 2);
            if (!tdc) {
                error = ENETDOWN;
                break;
@@ -291,7 +291,7 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
                 * does the FetchData rpc synchronously.
                 */
                ReleaseReadLock(&avc->lock);
-               tdc = afs_GetDCache(avc, filePos, &treq, &offset, &len, 1);
+               tdc = afs_GetDCache(avc, filePos, treq, &offset, &len, 1);
                ObtainReadLock(&avc->lock);
                if (tdc)
                    ObtainReadLock(&tdc->lock);
@@ -379,7 +379,7 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
        /* try to queue prefetch, if needed */
        if (!noLock) {
            if (!(tdc->mflags &DFNextStarted))
-               afs_PrefetchChunk(avc, tdc, acred, &treq);
+               afs_PrefetchChunk(avc, tdc, acred, treq);
        }
 #endif
        afs_PutDCache(tdc);
@@ -387,13 +387,14 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
     if (!noLock)
        ReleaseReadLock(&avc->lock);
 
-    code = afs_CheckCode(error, &treq, 10);
+    code = afs_CheckCode(error, treq, 10);
 
     if (tuiop)
        afsio_free(tuiop);
 
 out:
     AFS_DISCON_UNLOCK();
+    afs_DestroyReq(treq);
     return code;
 }
 
index 5efe300..774da55 100644 (file)
@@ -580,7 +580,7 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
 #endif
 #endif
 {
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     struct dcache *tdc;
     afs_size_t origOffset, tlen;
     afs_int32 len;
@@ -646,7 +646,7 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
        return EFBIG;
 #endif
 
-    if ((code = afs_InitReq(&treq, acred))) {
+    if ((code = afs_CreateReq(&treq, acred))) {
 #ifdef AFS_HPUX_ENV
        osi_FreeSmallSpace((char *)sdirEntry);
 #endif
@@ -657,15 +657,15 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
 
     AFS_DISCON_LOCK();
 
-    code = afs_EvalFakeStat(&avc, &fakestate, &treq);
+    code = afs_EvalFakeStat(&avc, &fakestate, treq);
     if (code)
        goto done;
   tagain:
-    code = afs_VerifyVCache(avc, &treq);
+    code = afs_VerifyVCache(avc, treq);
     if (code)
        goto done;
     /* get a reference to the entire directory */
-    tdc = afs_GetDCache(avc, (afs_size_t) 0, &treq, &origOffset, &tlen, 1);
+    tdc = afs_GetDCache(avc, (afs_size_t) 0, treq, &origOffset, &tlen, 1);
     if (!tdc) {
        code = ENOENT;
        goto done;
@@ -926,7 +926,8 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
 #endif
     AFS_DISCON_UNLOCK();
     afs_PutFakeStat(&fakestate);
-    code = afs_CheckCode(code, &treq, 28);
+    code = afs_CheckCode(code, treq, 28);
+    afs_DestroyReq(treq);
     return code;
 }
 
index 3d6c402..70d6c1a 100644 (file)
@@ -176,7 +176,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;
@@ -190,13 +190,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;
 
@@ -215,10 +215,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;
     }
 
@@ -236,7 +236,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);
@@ -272,7 +272,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);
@@ -316,7 +316,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 
@@ -350,7 +350,7 @@ 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;
@@ -378,7 +378,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);
@@ -388,6 +388,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;
 }
 
@@ -403,7 +404,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;
@@ -418,7 +418,9 @@ afs_remunlink(struct vcache *avc, int doit)
 #endif
 
     if (avc->mvid && (doit || (avc->f.states & CUnlinkedDel))) {
-       if ((code = afs_InitReq(&treq, avc->uncred))) {
+       struct vrequest *treq = NULL;
+
+       if ((code = afs_CreateReq(&treq, avc->uncred))) {
            ReleaseWriteLock(&avc->lock);
        } else {
            /* Must bump the refCount because GetVCache may block.
@@ -446,7 +448,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);
@@ -455,7 +457,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. */
@@ -463,6 +465,7 @@ afs_remunlink(struct vcache *avc, int doit)
            }
            osi_FreeSmallSpace(unlname);
            crfree(cred);
+           afs_DestroyReq(treq);
        }
     } else {
 #if defined(AFS_DARWIN80_ENV)
index cc3f1f5..0fe76c8 100644 (file)
@@ -454,30 +454,32 @@ afs_rename(OSI_VC_DECL(aodp), char *aname1, struct vcache *andp, char *aname2, a
     afs_int32 code;
     struct afs_fakestat_state ofakestate;
     struct afs_fakestat_state nfakestate;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     OSI_VC_CONVERT(aodp);
 
-    code = afs_InitReq(&treq, acred);
+    code = afs_CreateReq(&treq, acred);
     if (code)
        return code;
+
     afs_InitFakeStat(&ofakestate);
     afs_InitFakeStat(&nfakestate);
 
     AFS_DISCON_LOCK();
     
-    code = afs_EvalFakeStat(&aodp, &ofakestate, &treq);
+    code = afs_EvalFakeStat(&aodp, &ofakestate, treq);
     if (code)
        goto done;
-    code = afs_EvalFakeStat(&andp, &nfakestate, &treq);
+    code = afs_EvalFakeStat(&andp, &nfakestate, treq);
     if (code)
        goto done;
-    code = afsrename(aodp, aname1, andp, aname2, acred, &treq);
+    code = afsrename(aodp, aname1, andp, aname2, acred, treq);
   done:
     afs_PutFakeStat(&ofakestate);
     afs_PutFakeStat(&nfakestate);
 
     AFS_DISCON_UNLOCK();
     
-    code = afs_CheckCode(code, &treq, 25);
+    code = afs_CheckCode(code, treq, 25);
+    afs_DestroyReq(treq);
     return code;
 }
index 8d4c17a..4c38198 100644 (file)
@@ -69,7 +69,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
            char *atargetName, struct vcache **tvcp, afs_ucred_t *acred)
 {
     afs_uint32 now = 0;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     afs_int32 code = 0;
     struct afs_conn *tc;
     struct VenusFid newFid;
@@ -95,14 +95,14 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     OutFidStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
     OutDirStatus = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
 
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        goto done2;
 
     afs_InitFakeStat(&fakestate);
 
     AFS_DISCON_LOCK();
     
-    code = afs_EvalFakeStat(&adp, &fakestate, &treq);
+    code = afs_EvalFakeStat(&adp, &fakestate, treq);
     if (code)
        goto done;
 
@@ -120,9 +120,9 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        goto done;
     }
 
-    code = afs_VerifyVCache(adp, &treq);
+    code = afs_VerifyVCache(adp, treq);
     if (code) {
-       code = afs_CheckCode(code, &treq, 30);
+       code = afs_CheckCode(code, treq, 30);
        goto done;
     }
 
@@ -150,7 +150,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        InStatus.UnixModeBits = 0755;
        alen++;                 /* add in the null */
     }
-    tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1);
+    tdc = afs_GetDCache(adp, (afs_size_t) 0, treq, &offset, &len, 1);
     volp = afs_FindVolume(&adp->f.fid, READ_LOCK);     /*parent is also in same vol */
     ObtainWriteLock(&adp->lock, 156);
     if (tdc)
@@ -160,7 +160,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
      * the copy will be invalidated */
     if (!AFS_IS_DISCON_RW) {
        do {
-           tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK, &rxconn);
+           tc = afs_Conn(&adp->f.fid, treq, SHARED_LOCK, &rxconn);
            if (tc) {
                hostp = tc->parent->srvr->server;
                XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SYMLINK);
@@ -188,7 +188,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
            } else
                code = -1;
        } while (afs_Analyze
-                   (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_SYMLINK,
+                   (tc, rxconn, code, &adp->f.fid, treq, AFS_STATS_FS_RPCIDX_SYMLINK,
                     SHARED_LOCK, NULL));
     } else {
        newFid.Cell = adp->f.fid.Cell;
@@ -264,8 +264,8 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 
     if (AFS_IS_DISCON_RW) {
        attrs->va_mode = InStatus.UnixModeBits;
-       afs_GenDisconStatus(adp, tvc, &newFid, attrs, &treq, VLNK);
-       code = afs_DisconCreateSymlink(tvc, atargetName, &treq);
+       afs_GenDisconStatus(adp, tvc, &newFid, attrs, treq, VLNK);
+       code = afs_DisconCreateSymlink(tvc, atargetName, treq);
        if (code) {
            /* XXX - When this goes wrong, we need to tidy up the changes we made to
             * the parent, and get rid of the vcache we just created */
@@ -276,7 +276,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
        }
        afs_DisconAddDirty(tvc, VDisconCreate, 0);
     } else {
-       afs_ProcessFS(tvc, OutFidStatus, &treq);
+       afs_ProcessFS(tvc, OutFidStatus, treq);
     }
 
     if (!tvc->linkData) {
@@ -297,7 +297,8 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
     if (volp)
        afs_PutVolume(volp, READ_LOCK);
     AFS_DISCON_UNLOCK();
-    code = afs_CheckCode(code, &treq, 31);
+    code = afs_CheckCode(code, treq, 31);
+    afs_DestroyReq(treq);
   done2:
     osi_FreeSmallSpace(OutFidStatus);
     osi_FreeSmallSpace(OutDirStatus);
@@ -416,23 +417,23 @@ int
 afs_readlink(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
 {
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     char *tp;
     struct afs_fakestat_state fakestat;
     OSI_VC_CONVERT(avc);
 
     AFS_STATCNT(afs_readlink);
     afs_Trace1(afs_iclSetp, CM_TRACE_READLINK, ICL_TYPE_POINTER, avc);
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        return code;
     afs_InitFakeStat(&fakestat);
 
     AFS_DISCON_LOCK();
     
-    code = afs_EvalFakeStat(&avc, &fakestat, &treq);
+    code = afs_EvalFakeStat(&avc, &fakestat, treq);
     if (code)
        goto done;
-    code = afs_VerifyVCache(avc, &treq);
+    code = afs_VerifyVCache(avc, treq);
     if (code)
        goto done;
     if (vType(avc) != VLNK) {
@@ -440,7 +441,7 @@ afs_readlink(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
        goto done;
     }
     ObtainWriteLock(&avc->lock, 158);
-    code = afs_HandleLink(avc, &treq);
+    code = afs_HandleLink(avc, treq);
     /* finally uiomove it to user-land */
     if (code == 0) {
        tp = avc->linkData;
@@ -454,6 +455,7 @@ afs_readlink(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
   done:
     afs_PutFakeStat(&fakestat);
     AFS_DISCON_UNLOCK();
-    code = afs_CheckCode(code, &treq, 32);
+    code = afs_CheckCode(code, treq, 32);
+    afs_DestroyReq(treq);
     return code;
 }
index fee9326..44d0728 100644 (file)
@@ -223,7 +223,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
 #endif
     struct uio *tuiop = NULL;
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
 
     AFS_STATCNT(afs_write);
 
@@ -234,7 +234,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
        return ENETDOWN;
     
     startDate = osi_Time();
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        return code;
     /* otherwise we read */
     totalLength = AFS_UIO_RESID(auio);
@@ -288,6 +288,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
 #endif
        if (!noLock)
            ReleaseWriteLock(&avc->lock);
+       afs_DestroyReq(treq);
        return (EFBIG);
     }
 #endif
@@ -306,7 +307,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
     avc->f.states |= CDirty;
 
     while (totalLength > 0) {
-       tdc = afs_ObtainDCacheForWriting(avc, filePos, totalLength, &treq, 
+       tdc = afs_ObtainDCacheForWriting(avc, filePos, totalLength, treq,
                                         noLock);
        if (!tdc) {
            error = EIO;
@@ -365,7 +366,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
 #else
        if (filePos > avc->f.m.Length) {
            if (AFS_IS_DISCON_RW)
-               afs_PopulateDCache(avc, filePos, &treq);
+               afs_PopulateDCache(avc, filePos, treq);
            afs_Trace4(afs_iclSetp, CM_TRACE_SETLENGTH, ICL_TYPE_STRING,
                       __FILE__, ICL_TYPE_LONG, __LINE__, ICL_TYPE_OFFSET,
                       ICL_HANDLE_OFFSET(avc->f.m.Length), ICL_TYPE_OFFSET,
@@ -384,7 +385,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
         * the high-level write op.
         */
        if (!noLock) {
-           code = afs_DoPartialWrite(avc, &treq);
+           code = afs_DoPartialWrite(avc, treq);
            if (code) {
                error = code;
                break;
@@ -395,7 +396,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
 #if !defined(AFS_VM_RDWR_ENV) || defined(AFS_FAKEOPEN_ENV)
     afs_FakeClose(avc, acred);
 #endif
-    error = afs_CheckCode(error, &treq, 7);
+    error = afs_CheckCode(error, treq, 7);
     /* This set is here so we get the CheckCode. */
     if (error && !avc->vc_error)
        avc->vc_error = error;
@@ -426,6 +427,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
            afs_fsync(avc, acred);
     }
 #endif
+    afs_DestroyReq(treq);
     return error;
 }
 
@@ -472,7 +474,7 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
     afs_int32 code;
     afs_int32 code_checkcode = 0;
     struct brequest *tb;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
 #ifdef AFS_SGI65_ENV
     struct flid flid;
 #endif
@@ -482,25 +484,27 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
     AFS_STATCNT(afs_close);
     afs_Trace2(afs_iclSetp, CM_TRACE_CLOSE, ICL_TYPE_POINTER, avc,
               ICL_TYPE_INT32, aflags);
-    code = afs_InitReq(&treq, acred);
+    code = afs_CreateReq(&treq, acred);
     if (code)
        return code;
     afs_InitFakeStat(&fakestat);
-    code = afs_EvalFakeStat(&avc, &fakestat, &treq);
+    code = afs_EvalFakeStat(&avc, &fakestat, treq);
     if (code) {
        afs_PutFakeStat(&fakestat);
+       afs_DestroyReq(treq);
        return code;
     }
     AFS_DISCON_LOCK();
 #ifdef AFS_SUN5_ENV
     if (avc->flockCount) {
-       HandleFlock(avc, LOCK_UN, &treq, 0, 1 /*onlymine */ );
+       HandleFlock(avc, LOCK_UN, treq, 0, 1 /*onlymine */ );
     }
 #endif
 #if defined(AFS_SGI_ENV)
     if (!lastclose) {
        afs_PutFakeStat(&fakestat);
         AFS_DISCON_UNLOCK();
+       afs_DestroyReq(treq);
        return 0;
     }
     /* unlock any locks for pid - could be wrong for child .. */
@@ -508,14 +512,14 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
 # ifdef AFS_SGI65_ENV
     get_current_flid(&flid);
     cleanlocks((vnode_t *) avc, flid.fl_pid, flid.fl_sysid);
-    HandleFlock(avc, LOCK_UN, &treq, flid.fl_pid, 1 /*onlymine */ );
+    HandleFlock(avc, LOCK_UN, treq, flid.fl_pid, 1 /*onlymine */ );
 # else
 #  ifdef AFS_SGI64_ENV
     cleanlocks((vnode_t *) avc, flp);
 #  else /* AFS_SGI64_ENV */
     cleanlocks((vnode_t *) avc, u.u_procp->p_epid, u.u_procp->p_sysid);
 #  endif /* AFS_SGI64_ENV */
-    HandleFlock(avc, LOCK_UN, &treq, OSI_GET_CURRENT_PID(), 1 /*onlymine */ );
+    HandleFlock(avc, LOCK_UN, treq, OSI_GET_CURRENT_PID(), 1 /*onlymine */ );
 # endif /* AFS_SGI65_ENV */
     /* afs_chkpgoob will drop and re-acquire the global lock. */
     afs_chkpgoob(&avc->v, btoc(avc->f.m.Length));
@@ -526,18 +530,19 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
         * with the close. */
        afs_PutFakeStat(&fakestat);
        AFS_DISCON_UNLOCK();
+       afs_DestroyReq(treq);
        return 0;
     }
 #else
     if (avc->flockCount) {     /* Release Lock */
-       HandleFlock(avc, LOCK_UN, &treq, 0, 1 /*onlymine */ );
+       HandleFlock(avc, LOCK_UN, treq, 0, 1 /*onlymine */ );
     }
 #endif
     if (aflags & (FWRITE | FTRUNC)) {
        if (afs_BBusy() || (AFS_NFSXLATORREQ(acred)) || AFS_IS_DISCONNECTED) {
            /* do it yourself if daemons are all busy */
            ObtainWriteLock(&avc->lock, 124);
-           code = afs_StoreOnLastReference(avc, &treq);
+           code = afs_StoreOnLastReference(avc, treq);
            ReleaseWriteLock(&avc->lock);
 #if defined(AFS_SGI_ENV)
            AFS_RWUNLOCK((vnode_t *) avc, VRWLOCK_WRITE);
@@ -649,8 +654,9 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
     if (code_checkcode) {
        code = code_checkcode;
     } else {
-       code = afs_CheckCode(code, &treq, 5);
+       code = afs_CheckCode(code, treq, 5);
     }
+    afs_DestroyReq(treq);
     return code;
 }
 
@@ -667,7 +673,7 @@ afs_fsync(OSI_VC_DECL(avc), afs_ucred_t *acred)
 #endif 
 {
     afs_int32 code;
-    struct vrequest treq;
+    struct vrequest *treq = NULL;
     OSI_VC_CONVERT(avc);
 
     if (avc->vc_error)
@@ -681,7 +687,7 @@ afs_fsync(OSI_VC_DECL(avc), afs_ucred_t *acred)
 
     AFS_STATCNT(afs_fsync);
     afs_Trace1(afs_iclSetp, CM_TRACE_FSYNC, ICL_TYPE_POINTER, avc);
-    if ((code = afs_InitReq(&treq, acred)))
+    if ((code = afs_CreateReq(&treq, acred)))
        return code;
     AFS_DISCON_LOCK();
 #if defined(AFS_SGI_ENV)
@@ -698,7 +704,7 @@ afs_fsync(OSI_VC_DECL(avc), afs_ucred_t *acred)
            
            /* put the file back */
            UpgradeSToWLock(&avc->lock, 41);
-           code = afs_StoreAllSegments(avc, &treq, AFS_SYNC);
+           code = afs_StoreAllSegments(avc, treq, AFS_SYNC);
            ConvertWToSLock(&avc->lock);
        } else {
            UpgradeSToWLock(&avc->lock, 711);
@@ -717,7 +723,8 @@ afs_fsync(OSI_VC_DECL(avc), afs_ucred_t *acred)
     }
 #endif
     AFS_DISCON_UNLOCK();
-    code = afs_CheckCode(code, &treq, 33);
+    code = afs_CheckCode(code, treq, 33);
+    afs_DestroyReq(treq);
     ReleaseSharedLock(&avc->lock);
     return code;
 }