From: Michael Meffie Date: Thu, 27 Mar 2014 23:36:29 +0000 (+0100) Subject: libafs: reduce stack space X-Git-Tag: upstream/1.6.10_pre1^2~69 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=fb32fcf4f711c525b0c1504b2ca831362b75f131;p=packages%2Fo%2Fopenafs.git libafs: reduce stack space Allocate temporary vrequests to reduce the amount of stack space used. Reviewed-on: http://gerrit.openafs.org/11003 Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: D Brashear (cherry picked from commit 027e2bbb1191c31dbbe968a925c192b064d52c47) Change-Id: I2dc6d49c7d3b7578359930f7fd922f177729281f Reviewed-on: http://gerrit.openafs.org/11165 Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Gergely Madarasz Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- diff --git a/src/afs/afs_analyze.c b/src/afs/afs_analyze.c index 2ecd38ef7..dea580ba7 100644 --- a/src/afs/afs_analyze.c +++ b/src/afs/afs_analyze.c @@ -90,7 +90,7 @@ int lastcode; static int VLDB_Same(struct VenusFid *afid, struct vrequest *areq) { - struct vrequest treq; + struct vrequest *treq = NULL; struct afs_conn *tconn; int i, type = 0; union { @@ -108,7 +108,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) AFS_STATCNT(CheckVLDB); afs_FinalizeReq(areq); - if ((i = afs_InitReq(&treq, afs_osi_credp))) + if ((i = afs_CreateReq(&treq, afs_osi_credp))) return DUNNO; v = afs_osi_Alloc(sizeof(*v)); osi_Assert(v != NULL); @@ -118,7 +118,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) VSleep(2); /* Better safe than sorry. */ tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum, - &treq, SHARED_LOCK, 0, &rxconn); + treq, SHARED_LOCK, 0, &rxconn); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -156,7 +156,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) } } else i = -1; - } while (afs_Analyze(tconn, rxconn, i, NULL, &treq, -1, /* no op code for this */ + } while (afs_Analyze(tconn, rxconn, i, NULL, treq, -1, /* no op code for this */ SHARED_LOCK, tcell)); afs_PutCell(tcell, READ_LOCK); @@ -164,6 +164,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) ICL_TYPE_INT32, i); if (i) { + afs_DestroyReq(treq); afs_osi_Free(v, sizeof(*v)); return DUNNO; } @@ -178,7 +179,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) ReleaseWriteLock(&tvp->lock); if (type == 2) { - LockAndInstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq); + LockAndInstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, treq); } else if (type == 1) { LockAndInstallNVolumeEntry(tvp, &v->ntve, afid->Cell); } else { @@ -197,17 +198,20 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) ReleaseWriteLock(&tvp->lock); afs_PutVolume(tvp, WRITE_LOCK); } else { /* can't find volume */ - tvp = afs_GetVolume(afid, &treq, WRITE_LOCK); + tvp = afs_GetVolume(afid, treq, WRITE_LOCK); if (tvp) { afs_PutVolume(tvp, WRITE_LOCK); + afs_DestroyReq(treq); afs_osi_Free(v, sizeof(*v)); return DIFFERENT; } else { + afs_DestroyReq(treq); afs_osi_Free(v, sizeof(*v)); return DUNNO; } } + afs_DestroyReq(treq); afs_osi_Free(v, sizeof(*v)); return (changed ? DIFFERENT : SAME); } /*VLDB_Same */ diff --git a/src/afs/afs_bypasscache.c b/src/afs/afs_bypasscache.c index c8f3f7eec..744feb2b2 100644 --- a/src/afs/afs_bypasscache.c +++ b/src/afs/afs_bypasscache.c @@ -128,7 +128,6 @@ afs_TransitionToBypass(struct vcache *avc, { afs_int32 code; - struct vrequest treq; int setDesire = 0; int setManual = 0; @@ -162,9 +161,13 @@ afs_TransitionToBypass(struct vcache *avc, /* cg2v, try to store any chunks not written 20071204 */ if (avc->execsOrWriters > 0) { - code = afs_InitReq(&treq, acred); - if (!code) - code = afs_StoreAllSegments(avc, &treq, AFS_SYNC | AFS_LASTSTORE); + struct vrequest *treq = NULL; + + code = afs_CreateReq(&treq, acred); + if (!code) { + code = afs_StoreAllSegments(avc, treq, AFS_SYNC | AFS_LASTSTORE); + afs_DestroyReq(treq); + } } #if 0 @@ -480,28 +483,29 @@ afs_ReadNoCache(struct vcache *avc, afs_int32 code; afs_int32 bcnt; struct brequest *breq; - struct vrequest *areq; - - /* the reciever will free this */ - areq = osi_Alloc(sizeof(struct vrequest)); + struct vrequest *areq = NULL; if (avc && avc->vc_error) { code = EIO; afs_warn("afs_ReadNoCache VCache Error!\n"); goto cleanup; } - if ((code = afs_InitReq(areq, acred))) { - afs_warn("afs_ReadNoCache afs_InitReq error!\n"); - goto cleanup; - } AFS_GLOCK(); - code = afs_VerifyVCache(avc, areq); + /* the receiver will free areq */ + code = afs_CreateReq(&areq, acred); + if (code) { + afs_warn("afs_ReadNoCache afs_CreateReq error!\n"); + } else { + code = afs_VerifyVCache(avc, areq); + if (code) { + afs_warn("afs_ReadNoCache Failed to verify VCache!\n"); + } + } AFS_GUNLOCK(); if (code) { code = afs_CheckCode(code, areq, 11); /* failed to get it */ - afs_warn("afs_ReadNoCache Failed to verify VCache!\n"); goto cleanup; } @@ -534,7 +538,9 @@ cleanup: * processed, like unlocking the pages and freeing memory. */ unlock_and_release_pages(bparms->auio); - osi_Free(areq, sizeof(struct vrequest)); + AFS_GLOCK(); + afs_DestroyReq(areq); + AFS_GUNLOCK(); osi_Free(bparms->auio->uio_iov, bparms->auio->uio_iovcnt * sizeof(struct iovec)); osi_Free(bparms->auio, sizeof(struct uio)); diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c index a35f2cb3b..8e5f6ad1e 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -365,7 +365,7 @@ afs_CheckRootVolume(void) */ #ifdef AFS_LINUX20_ENV { - struct vrequest treq; + struct vrequest *treq = NULL; struct vattr vattr; cred_t *credp; struct dentry *dp; @@ -376,9 +376,9 @@ afs_CheckRootVolume(void) afs_rootFid.Fid.Unique = 1; credp = crref(); - if (afs_InitReq(&treq, credp)) + if (afs_CreateReq(&treq, credp)) goto out; - vcp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL); + vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL); if (!vcp) goto out; afs_getattr(vcp, &vattr, credp); @@ -420,6 +420,7 @@ afs_CheckRootVolume(void) afs_globalVp = vcp; out: crfree(credp); + afs_DestroyReq(treq); } #else #ifdef AFS_DARWIN80_ENV @@ -457,12 +458,13 @@ BPath(struct brequest *ab) struct dentry *dp = NULL; #endif afs_size_t offset, len; - struct vrequest treq; + struct vrequest *treq = NULL; afs_int32 code; AFS_STATCNT(BPath); - if ((code = afs_InitReq(&treq, ab->cred))) + if ((code = afs_CreateReq(&treq, ab->cred))) { return; + } AFS_GUNLOCK(); #ifdef AFS_LINUX22_ENV code = gop_lookupname((char *)ab->ptr_parm[0], AFS_UIOSYS, 1, &dp); @@ -473,8 +475,10 @@ BPath(struct brequest *ab) #endif AFS_GLOCK(); osi_FreeLargeSpace((char *)ab->ptr_parm[0]); /* free path name buffer here */ - if (code) + if (code) { + afs_DestroyReq(treq); return; + } /* now path may not have been in afs, so check that before calling our cache manager */ if (!tvn || !IsAfsVnode(tvn)) { /* release it and give up */ @@ -485,11 +489,12 @@ BPath(struct brequest *ab) AFS_RELE(tvn); #endif } + afs_DestroyReq(treq); return; } tvc = VTOAFS(tvn); /* here we know its an afs vnode, so we can get the data for the chunk */ - tdc = afs_GetDCache(tvc, ab->size_parm[0], &treq, &offset, &len, 1); + tdc = afs_GetDCache(tvc, ab->size_parm[0], treq, &offset, &len, 1); if (tdc) { afs_PutDCache(tdc); } @@ -498,6 +503,7 @@ BPath(struct brequest *ab) #else AFS_RELE(tvn); #endif + afs_DestroyReq(treq); } /* size_parm 0 to the fetch is the chunk number, @@ -510,15 +516,16 @@ BPrefetch(struct brequest *ab) struct dcache *tdc; struct vcache *tvc; afs_size_t offset, len, abyte, totallen = 0; - struct vrequest treq; + struct vrequest *treq = NULL; + int code; AFS_STATCNT(BPrefetch); - if ((len = afs_InitReq(&treq, ab->cred))) + if ((code = afs_CreateReq(&treq, ab->cred))) return; abyte = ab->size_parm[0]; tvc = ab->vc; do { - tdc = afs_GetDCache(tvc, abyte, &treq, &offset, &len, 1); + tdc = afs_GetDCache(tvc, abyte, treq, &offset, &len, 1); if (tdc) { afs_PutDCache(tdc); } @@ -542,22 +549,24 @@ BPrefetch(struct brequest *ab) if (ab->size_parm[1]) { afs_PutDCache(tdc); /* put this one back, too */ } + afs_DestroyReq(treq); } #if defined(AFS_CACHE_BYPASS) static void BPrefetchNoCache(struct brequest *ab) { - struct vrequest treq; - afs_size_t len; + struct vrequest *treq = NULL; + int code; - if ((len = afs_InitReq(&treq, ab->cred))) + if ((code = afs_CreateReq(&treq, ab->cred))) return; #ifndef UKERNEL /* OS-specific prefetch routine */ afs_PrefetchNoCache(ab->vc, ab->cred, (struct nocache_read_request *) ab->ptr_parm[0]); #endif + afs_DestroyReq(treq); } #endif @@ -566,13 +575,13 @@ BStore(struct brequest *ab) { struct vcache *tvc; afs_int32 code; - struct vrequest treq; + struct vrequest *treq = NULL; #if defined(AFS_SGI_ENV) struct cred *tmpcred; #endif AFS_STATCNT(BStore); - if ((code = afs_InitReq(&treq, ab->cred))) + if ((code = afs_CreateReq(&treq, ab->cred))) return; code = 0; tvc = ab->vc; @@ -593,7 +602,7 @@ BStore(struct brequest *ab) AFS_RWLOCK((vnode_t *) tvc, 1); #endif ObtainWriteLock(&tvc->lock, 209); - code = afs_StoreOnLastReference(tvc, &treq); + code = afs_StoreOnLastReference(tvc, treq); ReleaseWriteLock(&tvc->lock); #if defined(AFS_SGI_ENV) OSI_SET_CURRENT_CRED(tmpcred); @@ -610,7 +619,7 @@ BStore(struct brequest *ab) * can know the "raw" value for interpreting the value internally, as * well as the afs_CheckCode value to give to the OS. */ ab->code_raw = code; - ab->code_checkcode = afs_CheckCode(code, &treq, 43); + ab->code_checkcode = afs_CheckCode(code, treq, 43); ab->flags |= BUVALID; if (ab->flags & BUWAIT) { @@ -618,6 +627,7 @@ BStore(struct brequest *ab) afs_osi_Wakeup(ab); } } + afs_DestroyReq(treq); } /* release a held request buffer */ diff --git a/src/afs/afs_osi_vget.c b/src/afs/afs_osi_vget.c index 2a2268377..822ab0811 100644 --- a/src/afs/afs_osi_vget.c +++ b/src/afs/afs_osi_vget.c @@ -29,7 +29,7 @@ afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp) struct VenusFid vfid; struct SmallFid Sfid; struct cell *tcell; - struct vrequest treq; + struct vrequest *treq = NULL; afs_int32 code = 0, cellindex; afs_int32 ret; @@ -60,7 +60,11 @@ afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp) code = ENOENT; } else if (ret == 0) { /* didn't find an entry. */ - *avcpp = afs_GetVCache(&vfid, &treq, NULL, NULL); + code = afs_CreateReq(&treq, NULL); + if (code == 0) { + *avcpp = afs_GetVCache(&vfid, treq, NULL, NULL); + afs_DestroyReq(treq); + } } if (!*avcpp) { code = ENOENT; diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index d3ff50906..e9a84e3d2 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -1267,7 +1267,7 @@ afs_HandlePioctl(struct vnode *avp, afs_int32 acom, afs_ucred_t **acred) { struct vcache *avc; - struct vrequest treq; + struct vrequest *treq = NULL; afs_int32 code; afs_int32 function, device; struct afs_pdata input, output; @@ -1285,13 +1285,13 @@ afs_HandlePioctl(struct vnode *avp, afs_int32 acom, ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, afollow); AFS_STATCNT(HandlePioctl); - code = afs_InitReq(&treq, *acred); + code = afs_CreateReq(&treq, *acred); if (code) return code; afs_InitFakeStat(&fakestate); if (avc) { - code = afs_EvalFakeStat(&avc, &fakestate, &treq); + code = afs_EvalFakeStat(&avc, &fakestate, treq); if (code) goto out; } @@ -1349,7 +1349,7 @@ afs_HandlePioctl(struct vnode *avp, afs_int32 acom, copyOutput = output; code = - (*pioctlSw[function]) (avc, function, &treq, ©Input, + (*pioctlSw[function]) (avc, function, treq, ©Input, ©Output, acred); outSize = copyOutput.ptr - output.ptr; @@ -1367,7 +1367,9 @@ out: afs_pd_free(&output); afs_PutFakeStat(&fakestate); - return afs_CheckCode(code, &treq, 41); + code = afs_CheckCode(code, treq, 41); + afs_DestroyReq(treq); + return code; } /*! @@ -1803,7 +1805,7 @@ DECL_PIOCTL(PSetTokens) char *stp, *stpNew; char *cellName; int stLen, stLenOld; - struct vrequest treq; + struct vrequest *treq = NULL; afs_int32 flag, set_parent_pag = 0; int code; @@ -1881,11 +1883,11 @@ DECL_PIOCTL(PSetTokens) *acred = crref(); crfree(old_cred); #endif - code = afs_InitReq(&treq, *acred); + code = afs_CreateReq(&treq, *acred); if (code) { return code; } - areq = &treq; + areq = treq; } } @@ -1915,6 +1917,7 @@ DECL_PIOCTL(PSetTokens) afs_ResetUserConns(tu); afs_NotifyUser(tu, UTokensObtained); afs_PutUser(tu, WRITE_LOCK); + afs_DestroyReq(treq); if (stp) { afs_osi_Free(stp, stLenOld); diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 396c15638..1cbdf5def 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -761,7 +761,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, void (*func2) (int nservers, struct rx_connection **rxconns, struct afs_conn **conns)) { - struct vrequest treq; + struct vrequest *treq = NULL; struct server *ts; struct srvAddr *sa; struct afs_conn *tc = NULL; @@ -789,7 +789,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, conntimer = 0; nconns = 0; - if ((code = afs_InitReq(&treq, afs_osi_credp))) + if ((code = afs_CreateReq(&treq, afs_osi_credp))) return; ObtainReadLock(&afs_xserver); /* Necessary? */ ObtainReadLock(&afs_xsrvAddr); @@ -843,7 +843,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, /* check vlserver with special code */ if (sa->sa_portal == AFS_VLPORT) { if (vlalso) - CheckVLServer(sa, &treq); + CheckVLServer(sa, treq); continue; } @@ -851,7 +851,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, continue; /* have just been added by setsprefs */ /* get a connection, even if host is down; bumps conn ref count */ - tu = afs_GetUser(treq.uid, ts->cell->cellNum, SHARED_LOCK); + tu = afs_GetUser(treq->uid, ts->cell->cellNum, SHARED_LOCK); tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu, 1 /*force */ , 1 /*create */ , SHARED_LOCK, 0, &rxconn); @@ -892,6 +892,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, afs_osi_Free(conns, j * sizeof(struct afs_conn *)); afs_osi_Free(rxconns, j * sizeof(struct rx_connection *)); afs_osi_Free(conntimer, j * sizeof(afs_int32)); + afs_DestroyReq(treq); } /*afs_CheckServers*/ @@ -1781,7 +1782,7 @@ void afs_GetCapabilities(struct server *ts) { Capabilities caps = {0, NULL}; - struct vrequest treq; + struct vrequest *treq = NULL; struct afs_conn *tc; struct unixuser *tu; struct rx_connection *rxconn; @@ -1792,16 +1793,20 @@ afs_GetCapabilities(struct server *ts) if ( !afs_osi_credp ) return; - if ((code = afs_InitReq(&treq, afs_osi_credp))) + if ((code = afs_CreateReq(&treq, afs_osi_credp))) return; - tu = afs_GetUser(treq.uid, ts->cell->cellNum, SHARED_LOCK); - if ( !tu ) + tu = afs_GetUser(treq->uid, ts->cell->cellNum, SHARED_LOCK); + if ( !tu ) { + afs_DestroyReq(treq); return; + } tc = afs_ConnBySA(ts->addr, ts->cell->fsport, ts->cell->cellNum, tu, 0, 1, SHARED_LOCK, 0, &rxconn); afs_PutUser(tu, SHARED_LOCK); - if ( !tc ) + if ( !tc ) { + afs_DestroyReq(treq); return; + } /* InitCallBackStateN, triggered by our RPC, may need this */ ReleaseWriteLock(&afs_xserver); code = RXAFS_GetCapabilities(rxconn, &caps); @@ -1815,6 +1820,7 @@ afs_GetCapabilities(struct server *ts) if ( code && code != RXGEN_OPCODE ) { afs_warn("RXAFS_GetCapabilities failed with code %d\n", code); /* better not be anything to free. we failed! */ + afs_DestroyReq(treq); return; } @@ -1827,6 +1833,7 @@ afs_GetCapabilities(struct server *ts) caps.Capabilities_val = NULL; } + afs_DestroyReq(treq); } static struct server * diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 73cc13bfb..bcaf8d2a6 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -403,7 +403,7 @@ afs_FlushVCBs(afs_int32 lockit) int tcount; struct server *tsp; int i; - struct vrequest treq; + struct vrequest *treq = NULL; struct afs_conn *tc; int safety1, safety2, safety3; XSTATS_DECLS; @@ -411,9 +411,9 @@ afs_FlushVCBs(afs_int32 lockit) if (AFS_IS_DISCONNECTED) return ENETDOWN; - if ((code = afs_InitReq(&treq, afs_osi_credp))) + if ((code = afs_CreateReq(&treq, afs_osi_credp))) return code; - treq.flags |= O_NONBLOCK; + treq->flags |= O_NONBLOCK; tfids = afs_osi_Alloc(sizeof(struct AFSFid) * AFS_MAXCBRSCALL); osi_Assert(tfids != NULL); @@ -456,7 +456,7 @@ afs_FlushVCBs(afs_int32 lockit) callBacks[0].CallBackType = CB_EXCLUSIVE; for (safety3 = 0; safety3 < AFS_MAXHOSTS * 2; safety3++) { tc = afs_ConnByHost(tsp, tsp->cell->fsport, - tsp->cell->cellNum, &treq, 0, + tsp->cell->cellNum, treq, 0, SHARED_LOCK, 0, &rxconn); if (tc) { XSTATS_START_TIME @@ -470,7 +470,7 @@ afs_FlushVCBs(afs_int32 lockit) } else code = -1; if (!afs_Analyze - (tc, rxconn, code, 0, &treq, + (tc, rxconn, code, 0, treq, AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, SHARED_LOCK, tsp->cell)) { break; @@ -515,6 +515,7 @@ afs_FlushVCBs(afs_int32 lockit) if (lockit) ReleaseWriteLock(&afs_xvcb); afs_osi_Free(tfids, sizeof(struct AFSFid) * AFS_MAXCBRSCALL); + afs_DestroyReq(treq); return 0; } @@ -995,11 +996,18 @@ afs_FlushActiveVcaches(afs_int32 doflocks) struct afs_conn *tc; afs_int32 code; afs_ucred_t *cred = NULL; - struct vrequest treq, ureq; + struct vrequest *treq = NULL; struct AFSVolSync tsync; int didCore; XSTATS_DECLS; AFS_STATCNT(afs_FlushActiveVcaches); + + code = afs_CreateReq(&treq, NULL); + if (code) { + afs_warn("unable to alloc treq\n"); + return; + } + ObtainReadLock(&afs_xvcache); for (i = 0; i < VCSIZE; i++) { for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) { @@ -1016,14 +1024,14 @@ afs_FlushActiveVcaches(afs_int32 doflocks) ReleaseReadLock(&afs_xvcache); ObtainWriteLock(&tvc->lock, 51); do { - code = afs_InitReq(&treq, afs_osi_credp); + code = afs_InitReq(treq, afs_osi_credp); if (code) { code = -1; break; /* shutting down: do not try to extend the lock */ } - treq.flags |= O_NONBLOCK; + treq->flags |= O_NONBLOCK; - tc = afs_Conn(&tvc->f.fid, &treq, SHARED_LOCK, &rxconn); + tc = afs_Conn(&tvc->f.fid, treq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_EXTENDLOCK); RX_AFS_GUNLOCK(); @@ -1036,7 +1044,7 @@ afs_FlushActiveVcaches(afs_int32 doflocks) } else code = -1; } while (afs_Analyze - (tc, rxconn, code, &tvc->f.fid, &treq, + (tc, rxconn, code, &tvc->f.fid, treq, AFS_STATS_FS_RPCIDX_EXTENDLOCK, SHARED_LOCK, NULL)); ReleaseWriteLock(&tvc->lock); @@ -1073,12 +1081,12 @@ afs_FlushActiveVcaches(afs_int32 doflocks) /* XXXX Find better place-holder for cred XXXX */ cred = (afs_ucred_t *)tvc->linkData; tvc->linkData = NULL; /* XXX */ - code = afs_InitReq(&ureq, cred); + code = afs_InitReq(treq, cred); afs_Trace2(afs_iclSetp, CM_TRACE_ACTCCORE, ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, tvc->execsOrWriters); if (!code) { /* avoid store when shutting down */ - code = afs_StoreOnLastReference(tvc, &ureq); + code = afs_StoreOnLastReference(tvc, treq); } ReleaseWriteLock(&tvc->lock); #ifdef AFS_BOZONLOCK_ENV @@ -1137,6 +1145,7 @@ afs_FlushActiveVcaches(afs_int32 doflocks) } } ReleaseReadLock(&afs_xvcache); + afs_DestroyReq(treq); } diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 54717e9e2..eee883ad1 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -754,7 +754,7 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, struct cell *tcell; char *tbuffer, *ve; struct afs_conn *tconn; - struct vrequest treq; + struct vrequest *treq = NULL; struct rx_connection *rxconn; if (strlen(aname) > VL_MAXNAMELEN) /* Invalid volume name */ @@ -765,14 +765,14 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, return NULL; } - code = afs_InitReq(&treq, afs_osi_credp); /* *must* be unauth for vldb */ + code = afs_CreateReq(&treq, afs_osi_credp); /* *must* be unauth for vldb */ if (code) { return NULL; } /* allow null request if we don't care about ENODEV/ETIMEDOUT distinction */ if (!areq) - areq = &treq; + areq = treq; afs_Trace2(afs_iclSetp, CM_TRACE_GETVOL, ICL_TYPE_STRING, aname, @@ -781,10 +781,11 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, tve = (struct vldbentry *)(tbuffer + 1024); ntve = (struct nvldbentry *)tve; utve = (struct uvldbentry *)tve; + do { tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum, - &treq, SHARED_LOCK, 0, &rxconn); + treq, SHARED_LOCK, 0, &rxconn); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -822,7 +823,7 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, } } else code = -1; - } while (afs_Analyze(tconn, rxconn, code, NULL, &treq, -1, /* no op code for this */ + } while (afs_Analyze(tconn, rxconn, code, NULL, treq, -1, /* no op code for this */ SHARED_LOCK, tcell)); if (code) { @@ -845,9 +846,10 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, } } #endif - afs_CopyError(&treq, areq); + afs_CopyError(treq, areq); osi_FreeLargeSpace(tbuffer); afs_PutCell(tcell, READ_LOCK); + afs_DestroyReq(treq); return NULL; } /* @@ -867,14 +869,14 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, ve = (char *)ntve; else ve = (char *)tve; - tv = afs_SetupVolume(0, aname, ve, tcell, agood, type, &treq); + tv = afs_SetupVolume(0, aname, ve, tcell, agood, type, treq); if ((agood == 3) && tv && tv->backVol) { /* * This means that very soon we'll ask for the BK volume so * we'll prefetch it (well we did already.) */ tv1 = - afs_SetupVolume(tv->backVol, (char *)0, ve, tcell, 0, type, &treq); + afs_SetupVolume(tv->backVol, (char *)0, ve, tcell, 0, type, treq); if (tv1) { tv1->refCount--; } @@ -884,13 +886,14 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, * This means that very soon we'll ask for the RO volume so * we'll prefetch it (well we did already.) */ - tv1 = afs_SetupVolume(tv->roVol, NULL, ve, tcell, 0, type, &treq); + tv1 = afs_SetupVolume(tv->roVol, NULL, ve, tcell, 0, type, treq); if (tv1) { tv1->refCount--; } } osi_FreeLargeSpace(tbuffer); afs_PutCell(tcell, READ_LOCK); + afs_DestroyReq(treq); return tv; } /*afs_NewVolumeByName */