From 027e2bbb1191c31dbbe968a925c192b064d52c47 Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Fri, 28 Mar 2014 00:36:29 +0100 Subject: [PATCH] libafs: reduce stack space Allocate temporary vrequests to reduce the amount of stack space used. Change-Id: I8c50a3af3028512003a02e46a2960b9b135213a5 Reviewed-on: http://gerrit.openafs.org/11003 Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: D Brashear --- src/afs/afs_analyze.c | 16 +++++++----- src/afs/afs_bypasscache.c | 36 +++++++++++++++----------- src/afs/afs_daemons.c | 53 +++++++++++++++++++++++---------------- src/afs/afs_osi_vget.c | 8 ++++-- src/afs/afs_pioctl.c | 26 +++++++++++-------- src/afs/afs_server.c | 25 +++++++++++------- src/afs/afs_vcache.c | 33 +++++++++++++++--------- src/afs/afs_volume.c | 21 +++++++++------- 8 files changed, 133 insertions(+), 85 deletions(-) diff --git a/src/afs/afs_analyze.c b/src/afs/afs_analyze.c index 54b89ca47..e34edcd11 100644 --- a/src/afs/afs_analyze.c +++ b/src/afs/afs_analyze.c @@ -92,7 +92,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 { @@ -110,7 +110,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); @@ -120,7 +120,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->parent->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -158,7 +158,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); @@ -166,6 +166,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; } @@ -180,7 +181,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 { @@ -199,17 +200,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 508ccfcff..55f74e049 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 @@ -481,28 +484,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->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; } @@ -535,7 +539,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 e50431f79..4f51b508b 100644 --- a/src/afs/afs_daemons.c +++ b/src/afs/afs_daemons.c @@ -364,7 +364,7 @@ afs_CheckRootVolume(void) */ #ifdef AFS_LINUX20_ENV { - struct vrequest treq; + struct vrequest *treq = NULL; struct vattr vattr; cred_t *credp; struct dentry *dp; @@ -375,9 +375,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); @@ -419,6 +419,7 @@ afs_CheckRootVolume(void) afs_globalVp = vcp; out: crfree(credp); + afs_DestroyReq(treq); } #else #ifdef AFS_DARWIN80_ENV @@ -456,12 +457,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); @@ -472,8 +474,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 */ @@ -484,11 +488,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); } @@ -497,6 +502,7 @@ BPath(struct brequest *ab) #else AFS_RELE(tvn); #endif + afs_DestroyReq(treq); } /* size_parm 0 to the fetch is the chunk number, @@ -509,15 +515,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); } @@ -541,22 +548,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 @@ -565,13 +574,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; tvc = ab->vc; #if defined(AFS_SGI_ENV) @@ -591,7 +600,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); @@ -608,7 +617,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, 430); + ab->code_checkcode = afs_CheckCode(code, treq, 430); ab->flags |= BUVALID; if (ab->flags & BUWAIT) { @@ -616,6 +625,7 @@ BStore(struct brequest *ab) afs_osi_Wakeup(ab); } } + afs_DestroyReq(treq); } static void @@ -623,11 +633,11 @@ BPartialStore(struct brequest *ab) { struct vcache *tvc; afs_int32 code; - struct vrequest treq; + struct vrequest *treq = NULL; int locked, shared_locked = 0; AFS_STATCNT(BStore); - if ((code = afs_InitReq(&treq, ab->cred))) + if ((code = afs_CreateReq(&treq, ab->cred))) return; tvc = ab->vc; locked = tvc->lock.excl_locked? 1:0; @@ -637,7 +647,7 @@ BPartialStore(struct brequest *ab) shared_locked = 1; ConvertSToRLock(&tvc->lock); } - code = afs_StoreAllSegments(tvc, &treq, AFS_ASYNC); + code = afs_StoreAllSegments(tvc, treq, AFS_ASYNC); if (!locked) ReleaseWriteLock(&tvc->lock); else if (shared_locked) @@ -646,13 +656,14 @@ BPartialStore(struct brequest *ab) if ((ab->flags & BUVALID) == 0) { /* set final code, since treq doesn't go across processes */ 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) { ab->flags &= ~BUWAIT; 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 4be603833..062fe99eb 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -1287,7 +1287,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; @@ -1305,13 +1305,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; } @@ -1370,7 +1370,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; @@ -1388,7 +1388,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; } /*! @@ -1871,7 +1873,7 @@ DECL_PIOCTL(PSetTokens) char *stp; char *cellName; int stLen; - struct vrequest treq; + struct vrequest *treq = NULL; afs_int32 flag, set_parent_pag = 0; AFS_STATCNT(PSetTokens); @@ -1928,11 +1930,11 @@ DECL_PIOCTL(PSetTokens) if (set_parent_pag) { if (_settok_setParentPag(acred) == 0) { - code = afs_InitReq(&treq, *acred); + code = afs_CreateReq(&treq, *acred); if (code) { return code; } - areq = &treq; + areq = treq; } } @@ -1952,6 +1954,7 @@ DECL_PIOCTL(PSetTokens) afs_ResetUserConns(tu); afs_NotifyUser(tu, UTokensObtained); afs_PutUser(tu, WRITE_LOCK); + afs_DestroyReq(treq); return 0; } @@ -5342,7 +5345,7 @@ DECL_PIOCTL(PSetTokens2) int i, cellNum, primaryFlag; XDR xdrs; struct unixuser *tu; - struct vrequest treq; + struct vrequest *treq = NULL; struct ktc_setTokenData tokenSet; struct ktc_tokenUnion decodedToken; @@ -5386,12 +5389,12 @@ DECL_PIOCTL(PSetTokens2) *acred = crref(); crfree(old_cred); #endif - code = afs_InitReq(&treq, *acred); + code = afs_CreateReq(&treq, *acred); if (code) { xdr_free((xdrproc_t) xdr_ktc_setTokenData, &tokenSet); return code; } - areq = &treq; + areq = treq; } } @@ -5446,6 +5449,7 @@ DECL_PIOCTL(PSetTokens2) out: afs_ResetUserConns(tu); afs_PutUser(tu, WRITE_LOCK); + afs_DestroyReq(treq); return code; } diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index d7e3d46e2..afce4e678 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -621,7 +621,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; @@ -644,7 +644,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, if (AFS_IS_DISCONNECTED) return; - if ((code = afs_InitReq(&treq, afs_osi_credp))) + if ((code = afs_CreateReq(&treq, afs_osi_credp))) return; ObtainReadLock(&afs_xserver); /* Necessary? */ ObtainReadLock(&afs_xsrvAddr); @@ -698,7 +698,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; } @@ -706,7 +706,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); @@ -746,6 +746,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*/ @@ -1489,7 +1490,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; @@ -1500,16 +1501,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); @@ -1523,6 +1528,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; } @@ -1535,6 +1541,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 281b79d7f..dcdc8d971 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; } @@ -994,11 +995,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) { @@ -1015,14 +1023,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(); @@ -1035,7 +1043,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); @@ -1072,12 +1080,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 @@ -1136,6 +1144,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 a08ae513d..e9996e7d0 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -796,7 +796,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 */ @@ -807,14 +807,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, @@ -823,10 +823,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->parent->srvr->server->flags & SNO_LHOSTS) { type = 0; @@ -864,7 +865,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) { @@ -887,9 +888,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; } /* @@ -909,14 +911,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--; } @@ -926,13 +928,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 */ -- 2.39.5