From: Andrew Deason Date: Thu, 5 May 2011 16:18:08 +0000 (-0500) Subject: libafs: Get rx conn ref with afs conn ref X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=910f3d4cbba4cd78a8e6afa0b32e37ed7f292d18 libafs: Get rx conn ref with afs conn ref When we get a reference to an afs_conn with afs_Conn and its variants, we assume we can use the tc->id rx connection without holding any locks. However, if tc->forceConnectFS gets set, the tc->id connection can be destroyed and recreated out from under us. So, to avoid using a possibly freed rx connection, grab a reference to the rx connection at the same time as we grab a reference to the afs conn. And also put back the same reference with afs_PutConn. Reviewed-on: http://gerrit.openafs.org/4625 Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit 03f0c656c1734b9be4debdf19b8f10771ff4420a) Change-Id: I5bef36da0a4337d923a68f1d352b4aad1143395a Reviewed-on: http://gerrit.openafs.org/4648 Reviewed-by: Derrick Brashear Tested-by: BuildBot --- diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index 5e2dfda..997352e 100644 --- a/src/afs/VNOPS/afs_vnop_create.c +++ b/src/afs/VNOPS/afs_vnop_create.c @@ -56,6 +56,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, struct vcache *tvc; struct volume *volp = 0; struct afs_fakestat_state fakestate; + struct rx_connection *rxconn; XSTATS_DECLS; OSI_VC_CONVERT(adp); @@ -286,14 +287,14 @@ 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->fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK, &rxconn); if (tc) { hostp = tc->srvr->server; /* remember for callback processing */ now = osi_Time(); XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_CREATEFILE); RX_AFS_GUNLOCK(); code = - RXAFS_CreateFile(tc->id, (struct AFSFid *)&adp->fid.Fid, + RXAFS_CreateFile(rxconn, (struct AFSFid *)&adp->fid.Fid, aname, &InStatus, (struct AFSFid *) &newFid.Fid, &OutFidStatus, &OutDirStatus, &CallBack, &tsync); @@ -303,7 +304,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, } else code = -1; } while (afs_Analyze - (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE, + (tc, rxconn, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE, SHARED_LOCK, NULL)); if ((code == EEXIST || code == UAEEXIST) && diff --git a/src/afs/VNOPS/afs_vnop_dirops.c b/src/afs/VNOPS/afs_vnop_dirops.c index 33be5e6..a0a5f79 100644 --- a/src/afs/VNOPS/afs_vnop_dirops.c +++ b/src/afs/VNOPS/afs_vnop_dirops.c @@ -40,6 +40,7 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, struct vrequest treq; register afs_int32 code; register struct afs_conn *tc; + struct rx_connection *rxconn; struct VenusFid newFid; register struct dcache *tdc; afs_size_t offset, len; @@ -92,13 +93,13 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); ObtainWriteLock(&adp->lock, 153); do { - tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_MAKEDIR); now = osi_Time(); RX_AFS_GUNLOCK(); code = - RXAFS_MakeDir(tc->id, (struct AFSFid *)&adp->fid.Fid, aname, + RXAFS_MakeDir(rxconn, (struct AFSFid *)&adp->fid.Fid, aname, &InStatus, (struct AFSFid *)&newFid.Fid, &OutFidStatus, &OutDirStatus, &CallBack, &tsync); @@ -109,7 +110,7 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, } else code = -1; } while (afs_Analyze - (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_MAKEDIR, + (tc, rxconn, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_MAKEDIR, SHARED_LOCK, NULL)); if (code) { @@ -179,6 +180,7 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, struct AFS_UCRED *acred) struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state fakestate; + struct rx_connection *rxconn; XSTATS_DECLS; OSI_VC_CONVERT(adp); @@ -238,19 +240,19 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, struct AFS_UCRED *acred) } do { - tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEDIR); RX_AFS_GUNLOCK(); code = - RXAFS_RemoveDir(tc->id, (struct AFSFid *)&adp->fid.Fid, aname, + RXAFS_RemoveDir(rxconn, (struct AFSFid *)&adp->fid.Fid, aname, &OutDirStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_REMOVEDIR, + (tc, rxconn, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_REMOVEDIR, SHARED_LOCK, NULL)); if (code) { diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index f569b87..1557e2a 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -293,19 +293,20 @@ HandleFlock(register struct vcache *avc, int acom, struct vrequest *areq, avc->slocks = 0; } if (avc->flockCount == 0) { + struct rx_connection *rxconn; do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RELEASELOCK); RX_AFS_GUNLOCK(); - code = RXAFS_ReleaseLock(tc->id, (struct AFSFid *) + code = RXAFS_ReleaseLock(rxconn, (struct AFSFid *) &avc->fid.Fid, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_RELEASELOCK, SHARED_LOCK, NULL)); } } else { @@ -346,14 +347,15 @@ HandleFlock(register struct vcache *avc, int acom, struct vrequest *areq, } } if (!code && avc->flockCount == 0) { + struct rx_connection *rxconn; do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME (AFS_STATS_FS_RPCIDX_RELEASELOCK); RX_AFS_GUNLOCK(); code = - RXAFS_ReleaseLock(tc->id, + RXAFS_ReleaseLock(rxconn, (struct AFSFid *)&avc->fid. Fid, &tsync); RX_AFS_GLOCK(); @@ -361,7 +363,7 @@ HandleFlock(register struct vcache *avc, int acom, struct vrequest *areq, } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_RELEASELOCK, SHARED_LOCK, NULL)); } @@ -377,14 +379,15 @@ HandleFlock(register struct vcache *avc, int acom, struct vrequest *areq, * we've already checked for compatibility), we shouldn't send * the call through to the server again */ if (avc->flockCount == 0) { + struct rx_connection *rxconn; /* we're the first on our block, send the call through */ lockType = ((acom & LOCK_EX) ? LockWrite : LockRead); do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETLOCK); RX_AFS_GUNLOCK(); - code = RXAFS_SetLock(tc->id, (struct AFSFid *) + code = RXAFS_SetLock(rxconn, (struct AFSFid *) &avc->fid.Fid, lockType, &tsync); RX_AFS_GLOCK(); @@ -392,7 +395,7 @@ HandleFlock(register struct vcache *avc, int acom, struct vrequest *areq, } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_SETLOCK, SHARED_LOCK, NULL)); } else @@ -801,25 +804,26 @@ GetFlockCount(struct vcache *avc, struct vrequest *areq) struct AFSFetchStatus OutStatus; struct AFSCallBack CallBack; struct AFSVolSync tsync; + struct rx_connection *rxconn; int temp; XSTATS_DECLS; temp = areq->flags & O_NONBLOCK; areq->flags |= O_NONBLOCK; do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHSTATUS); RX_AFS_GUNLOCK(); code = - RXAFS_FetchStatus(tc->id, (struct AFSFid *)&avc->fid.Fid, + RXAFS_FetchStatus(rxconn, (struct AFSFid *)&avc->fid.Fid, &OutStatus, &CallBack, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_FETCHSTATUS, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_FETCHSTATUS, SHARED_LOCK, NULL)); if (temp) diff --git a/src/afs/VNOPS/afs_vnop_link.c b/src/afs/VNOPS/afs_vnop_link.c index f6bc93f..9f9a8d5 100644 --- a/src/afs/VNOPS/afs_vnop_link.c +++ b/src/afs/VNOPS/afs_vnop_link.c @@ -48,6 +48,7 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) struct AFSFetchStatus OutFidStatus, OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state vfakestate, dfakestate; + struct rx_connection *rxconn; XSTATS_DECLS; OSI_VC_CONVERT(adp); @@ -91,12 +92,12 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) 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->fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_LINK); RX_AFS_GUNLOCK(); code = - RXAFS_Link(tc->id, (struct AFSFid *)&adp->fid.Fid, aname, + RXAFS_Link(rxconn, (struct AFSFid *)&adp->fid.Fid, aname, (struct AFSFid *)&avc->fid.Fid, &OutFidStatus, &OutDirStatus, &tsync); RX_AFS_GLOCK(); @@ -105,7 +106,7 @@ afs_link(avc, OSI_VC_ARG(adp), aname, acred) } else code = -1; } while (afs_Analyze - (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_LINK, + (tc, rxconn, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_LINK, SHARED_LOCK, NULL)); if (code) { diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 85e01eb..d99f016 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -566,6 +566,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) struct VenusFid dotdot; int flagIndex = 0; /* First file with bulk fetch flag set */ int inlinebulk = 0; /* Did we use InlineBulk RPC or not? */ + struct rx_connection *rxconn; XSTATS_DECLS; #ifdef AFS_DARWIN80_ENV panic("bulkstatus doesn't work on AFS_DARWIN80_ENV. don't call it"); @@ -807,7 +808,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) /* start the timer; callback expirations are relative to this */ startTime = osi_Time(); - tcp = afs_Conn(&adp->fid, areqp, SHARED_LOCK); + tcp = afs_Conn(&adp->fid, areqp, SHARED_LOCK, &rxconn); if (tcp) { hostp = tcp->srvr->server; XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_BULKSTATUS); @@ -815,20 +816,20 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) if (!(tcp->srvr->server->flags & SNO_INLINEBULK)) { code = - RXAFS_InlineBulkStatus(tcp->id, &fidParm, &statParm, + RXAFS_InlineBulkStatus(rxconn, &fidParm, &statParm, &cbParm, &volSync); if (code == RXGEN_OPCODE) { tcp->srvr->server->flags |= SNO_INLINEBULK; inlinebulk = 0; code = - RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, + RXAFS_BulkStatus(rxconn, &fidParm, &statParm, &cbParm, &volSync); } else inlinebulk = 1; } else { inlinebulk = 0; code = - RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, &cbParm, + RXAFS_BulkStatus(rxconn, &fidParm, &statParm, &cbParm, &volSync); } RX_AFS_GLOCK(); @@ -836,7 +837,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) } else code = -1; } while (afs_Analyze - (tcp, code, &adp->fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS, + (tcp, rxconn, code, &adp->fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL)); /* now, if we didnt get the info, bail out. */ @@ -1077,7 +1078,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) /* If we did the InlineBulk RPC pull out the return code */ if (inlinebulk && code == 0) { if ((&statsp[0])->errorCode) { - afs_Analyze(tcp, (&statsp[0])->errorCode, &adp->fid, areqp, + afs_Analyze(tcp, rxconn, (&statsp[0])->errorCode, &adp->fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL); code = (&statsp[0])->errorCode; } diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c index e199817..b0512b0 100644 --- a/src/afs/VNOPS/afs_vnop_remove.c +++ b/src/afs/VNOPS/afs_vnop_remove.c @@ -106,21 +106,22 @@ afsremove(register struct vcache *adp, register struct dcache *tdc, register struct afs_conn *tc; struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; + struct rx_connection *rxconn; XSTATS_DECLS; do { - tc = afs_Conn(&adp->fid, treqp, SHARED_LOCK); + tc = afs_Conn(&adp->fid, treqp, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE); RX_AFS_GUNLOCK(); code = - RXAFS_RemoveFile(tc->id, (struct AFSFid *)&adp->fid.Fid, + RXAFS_RemoveFile(rxconn, (struct AFSFid *)&adp->fid.Fid, aname, &OutDirStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &adp->fid, treqp, AFS_STATS_FS_RPCIDX_REMOVEFILE, + (tc, rxconn, code, &adp->fid, treqp, AFS_STATS_FS_RPCIDX_REMOVEFILE, SHARED_LOCK, NULL)); osi_dnlc_remove(adp, aname, tvc); diff --git a/src/afs/VNOPS/afs_vnop_rename.c b/src/afs/VNOPS/afs_vnop_rename.c index 8f601f0..82f095e 100644 --- a/src/afs/VNOPS/afs_vnop_rename.c +++ b/src/afs/VNOPS/afs_vnop_rename.c @@ -44,6 +44,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, struct dcache *tdc1, *tdc2; struct AFSFetchStatus OutOldDirStatus, OutNewDirStatus; struct AFSVolSync tsync; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(afs_rename); afs_Trace4(afs_iclSetp, CM_TRACE_RENAME, ICL_TYPE_POINTER, aodp, @@ -161,12 +162,12 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, /* locks are now set, proceed to do the real work */ do { - tc = afs_Conn(&aodp->fid, areq, SHARED_LOCK); + tc = afs_Conn(&aodp->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RENAME); RX_AFS_GUNLOCK(); code = - RXAFS_Rename(tc->id, (struct AFSFid *)&aodp->fid.Fid, aname1, + RXAFS_Rename(rxconn, (struct AFSFid *)&aodp->fid.Fid, aname1, (struct AFSFid *)&andp->fid.Fid, aname2, &OutOldDirStatus, &OutNewDirStatus, &tsync); RX_AFS_GLOCK(); @@ -175,7 +176,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, code = -1; } while (afs_Analyze - (tc, code, &andp->fid, areq, AFS_STATS_FS_RPCIDX_RENAME, + (tc, rxconn, code, &andp->fid, areq, AFS_STATS_FS_RPCIDX_RENAME, SHARED_LOCK, NULL)); returnCode = code; /* remember for later */ diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c index b57e206..5950d6d 100644 --- a/src/afs/VNOPS/afs_vnop_symlink.c +++ b/src/afs/VNOPS/afs_vnop_symlink.c @@ -63,6 +63,7 @@ int afs_symlink struct AFSVolSync tsync; struct volume *volp = 0; struct afs_fakestat_state fakestate; + struct rx_connection *rxconn; XSTATS_DECLS; OSI_VC_CONVERT(adp); @@ -121,7 +122,7 @@ int afs_symlink ObtainSharedLock(&afs_xvcache, 17); /* prevent others from creating this entry */ /* XXX Pay attention to afs_xvcache around the whole thing!! XXX */ do { - tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->fid, &treq, SHARED_LOCK, &rxconn); if (tc) { hostp = tc->srvr->server; XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SYMLINK); @@ -129,7 +130,7 @@ int afs_symlink now = osi_Time(); RX_AFS_GUNLOCK(); code = - RXAFS_DFSSymlink(tc->id, (struct AFSFid *)&adp->fid.Fid, + RXAFS_DFSSymlink(rxconn, (struct AFSFid *)&adp->fid.Fid, aname, atargetName, &InStatus, (struct AFSFid *)&newFid.Fid, &OutFidStatus, &OutDirStatus, &CallBack, @@ -138,7 +139,7 @@ int afs_symlink } else { RX_AFS_GUNLOCK(); code = - RXAFS_Symlink(tc->id, (struct AFSFid *)&adp->fid.Fid, + RXAFS_Symlink(rxconn, (struct AFSFid *)&adp->fid.Fid, aname, atargetName, &InStatus, (struct AFSFid *)&newFid.Fid, &OutFidStatus, &OutDirStatus, &tsync); @@ -148,7 +149,7 @@ int afs_symlink } else code = -1; } while (afs_Analyze - (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_SYMLINK, + (tc, rxconn, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_SYMLINK, SHARED_LOCK, NULL)); UpgradeSToWLock(&afs_xvcache, 40); diff --git a/src/afs/afs_analyze.c b/src/afs/afs_analyze.c index d58f5e7..c586f41 100644 --- a/src/afs/afs_analyze.c +++ b/src/afs/afs_analyze.c @@ -333,6 +333,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) char *bp, tbuf[CVBS]; /* biggest volume id is 2^32, ~ 4*10^9 */ unsigned int changed; struct server *(oldhosts[NMAXNSERVERS]); + struct rx_connection *rxconn; AFS_STATCNT(CheckVLDB); afs_FinalizeReq(areq); @@ -346,34 +347,34 @@ 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); + &treq, SHARED_LOCK, &rxconn); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameO(tconn->id, bp, &v->tve); + i = VL_GetEntryByNameO(rxconn, bp, &v->tve); RX_AFS_GLOCK(); } else if (tconn->srvr->server->flags & SYES_LHOSTS) { type = 1; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve); + i = VL_GetEntryByNameN(rxconn, bp, &v->ntve); RX_AFS_GLOCK(); } else { type = 2; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameU(tconn->id, bp, &v->utve); + i = VL_GetEntryByNameU(rxconn, bp, &v->utve); RX_AFS_GLOCK(); if (!(tconn->srvr->server->flags & SVLSRV_UUID)) { if (i == RXGEN_OPCODE) { type = 1; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve); + i = VL_GetEntryByNameN(rxconn, bp, &v->ntve); RX_AFS_GLOCK(); if (i == RXGEN_OPCODE) { type = 0; tconn->srvr->server->flags |= SNO_LHOSTS; RX_AFS_GUNLOCK(); - i = VL_GetEntryByNameO(tconn->id, bp, &v->tve); + i = VL_GetEntryByNameO(rxconn, bp, &v->tve); RX_AFS_GLOCK(); } else if (!i) tconn->srvr->server->flags |= SYES_LHOSTS; @@ -384,7 +385,7 @@ VLDB_Same(struct VenusFid *afid, struct vrequest *areq) } } else i = -1; - } while (afs_Analyze(tconn, 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); @@ -535,7 +536,8 @@ afs_BlackListOnce(struct vrequest *areq, struct VenusFid *afid, * if this is a temporary or permanent error. *------------------------------------------------------------------------*/ int -afs_Analyze(register struct afs_conn *aconn, afs_int32 acode, +afs_Analyze(register struct afs_conn *aconn, struct rx_connection *rxconn, + afs_int32 acode, struct VenusFid *afid, register struct vrequest *areq, int op, afs_int32 locktype, struct cell *cellp) { @@ -658,7 +660,7 @@ afs_Analyze(register struct afs_conn *aconn, afs_int32 acode, } } - afs_PutConn(aconn, locktype); + afs_PutConn(aconn, rxconn, locktype); return 0; } @@ -864,6 +866,6 @@ afs_Analyze(register struct afs_conn *aconn, afs_int32 acode, } out: /* now unlock the connection and return */ - afs_PutConn(aconn, locktype); + afs_PutConn(aconn, rxconn, locktype); return (shouldRetry); } /*afs_Analyze */ diff --git a/src/afs/afs_conn.c b/src/afs/afs_conn.c index 1594044..c806d22 100644 --- a/src/afs/afs_conn.c +++ b/src/afs/afs_conn.c @@ -52,7 +52,7 @@ afs_int32 cryptall = 0; /* encrypt all communications */ unsigned int VNOSERVERS = 0; struct afs_conn * afs_Conn(register struct VenusFid *afid, register struct vrequest *areq, - afs_int32 locktype) + afs_int32 locktype, struct rx_connection **rxconn) { u_short fsport = AFS_FSPORT; struct volume *tv; @@ -63,6 +63,8 @@ afs_Conn(register struct VenusFid *afid, register struct vrequest *areq, int i; struct srvAddr *sa1p; + *rxconn = NULL; + AFS_STATCNT(afs_Conn); tv = afs_GetVolume(afid, areq, READ_LOCK); if (!tv) { @@ -121,7 +123,7 @@ afs_Conn(register struct VenusFid *afid, register struct vrequest *areq, if (lowp) { tu = afs_GetUser(areq->uid, afid->Cell, SHARED_LOCK); tconn = afs_ConnBySA(lowp, fsport, afid->Cell, tu, 0 /*!force */ , - 1 /*create */ , locktype); + 1 /*create */ , locktype, rxconn); afs_PutUser(tu, SHARED_LOCK); } @@ -133,13 +135,15 @@ afs_Conn(register struct VenusFid *afid, register struct vrequest *areq, struct afs_conn * afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, struct unixuser *tu, int force_if_down, afs_int32 create, - afs_int32 locktype) + afs_int32 locktype, struct rx_connection **rxconn) { struct afs_conn *tc = 0; struct rx_securityClass *csec; /*Security class object */ int isec; /*Security index */ int service; + *rxconn = NULL; + if (!sap || ((sap->sa_flags & SRVR_ISDOWN) && !force_if_down)) { /* sa is known down, and we don't want to force it. */ return NULL; @@ -257,6 +261,9 @@ afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, ConvertWToSLock(&afs_xconn); } + *rxconn = tc->id; + rx_GetConnection(*rxconn); + ReleaseSharedLock(&afs_xconn); return tc; } @@ -272,12 +279,15 @@ afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, */ struct afs_conn * afs_ConnByHost(struct server *aserver, unsigned short aport, afs_int32 acell, - struct vrequest *areq, int aforce, afs_int32 locktype) + struct vrequest *areq, int aforce, afs_int32 locktype, + struct rx_connection **rxconn) { struct unixuser *tu; struct afs_conn *tc = 0; struct srvAddr *sa = 0; + *rxconn = NULL; + AFS_STATCNT(afs_ConnByHost); /* 1. look for an existing connection @@ -290,7 +300,7 @@ afs_ConnByHost(struct server *aserver, unsigned short aport, afs_int32 acell, for (sa = aserver->addr; sa; sa = sa->next_sa) { tc = afs_ConnBySA(sa, aport, acell, tu, aforce, 0 /*don't create one */ , - locktype); + locktype, rxconn); if (tc) break; } @@ -299,7 +309,7 @@ afs_ConnByHost(struct server *aserver, unsigned short aport, afs_int32 acell, for (sa = aserver->addr; sa; sa = sa->next_sa) { tc = afs_ConnBySA(sa, aport, acell, tu, aforce, 1 /*create one */ , - locktype); + locktype, rxconn); if (tc) break; } @@ -314,18 +324,20 @@ afs_ConnByHost(struct server *aserver, unsigned short aport, afs_int32 acell, struct afs_conn * afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, afs_int32 acell, register struct vrequest *areq, - afs_int32 locktype) + afs_int32 locktype, struct rx_connection **rxconn) { register afs_int32 i; register struct afs_conn *tconn; register struct server *ts; + *rxconn = NULL; + /* try to find any connection from the set */ AFS_STATCNT(afs_ConnByMHosts); for (i = 0; i < MAXCELLHOSTS; i++) { if ((ts = ahosts[i]) == NULL) break; - tconn = afs_ConnByHost(ts, aport, acell, areq, 0, locktype); + tconn = afs_ConnByHost(ts, aport, acell, areq, 0, locktype, rxconn); if (tconn) { return tconn; } @@ -336,10 +348,12 @@ afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, void -afs_PutConn(register struct afs_conn *ac, afs_int32 locktype) +afs_PutConn(register struct afs_conn *ac, struct rx_connection *rxconn, + afs_int32 locktype) { AFS_STATCNT(afs_PutConn); ac->refCount--; + rx_PutConnection(rxconn); } /*afs_PutConn */ diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index c612113..9471c24 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -1522,6 +1522,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, int doAdjustSize = 0; int doReallyAdjustSize = 0; int overWriteWholeChunk = 0; + struct rx_connection *rxconn; XSTATS_DECLS; #ifndef AFS_NOSTATS @@ -2102,7 +2103,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, * tdc->lock(W) */ - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { afs_int32 length_hi, length, bytes; #ifndef AFS_NOSTATS @@ -2119,7 +2120,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, } i = osi_Time(); RX_AFS_GUNLOCK(); - tcall = rx_NewCall(tc->id); + tcall = rx_NewCall(rxconn); RX_AFS_GLOCK(); XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHDATA); @@ -2162,7 +2163,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, pos = Position; RX_AFS_GUNLOCK(); if (!tcall) - tcall = rx_NewCall(tc->id); + tcall = rx_NewCall(rxconn); code = StartRXAFS_FetchData(tcall, (struct AFSFid *) &avc->fid.Fid, pos, @@ -2364,7 +2365,7 @@ afs_GetDCache(register struct vcache *avc, afs_size_t abyte, } } while (afs_Analyze - (tc, code, &avc->fid, areq, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_FETCHDATA, SHARED_LOCK, NULL)); /* diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index 854e513..0352e0e 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -1243,6 +1243,7 @@ DECL_PIOCTL(PSetAcl) struct AFSOpaque acl; struct AFSVolSync tsync; struct AFSFetchStatus OutStatus; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PSetAcl); @@ -1253,19 +1254,19 @@ DECL_PIOCTL(PSetAcl) acl.AFSOpaque_val = ain; do { - tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tconn) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREACL); RX_AFS_GUNLOCK(); code = - RXAFS_StoreACL(tconn->id, (struct AFSFid *)&avc->fid.Fid, + RXAFS_StoreACL(rxconn, (struct AFSFid *)&avc->fid.Fid, &acl, &OutStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STOREACL, + (tconn, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STOREACL, SHARED_LOCK, NULL)); /* now we've forgotten all of the access info */ @@ -1329,6 +1330,7 @@ DECL_PIOCTL(PGetAcl) afs_int32 code; struct afs_conn *tconn; struct AFSFid Fid; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PGetAcl); @@ -1351,18 +1353,18 @@ DECL_PIOCTL(PGetAcl) } acl.AFSOpaque_val = aout; do { - tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tconn) { *aout = 0; XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHACL); RX_AFS_GUNLOCK(); - code = RXAFS_FetchACL(tconn->id, &Fid, &acl, &OutStatus, &tsync); + code = RXAFS_FetchACL(rxconn, &Fid, &acl, &OutStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_FETCHACL, + (tconn, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_FETCHACL, SHARED_LOCK, NULL)); if (code == 0) { @@ -1585,6 +1587,7 @@ DECL_PIOCTL(PGetVolumeStatus) struct AFSFetchVolumeStatus volstat; register char *cp; char *Name, *OfflineMsg, *MOTD; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PGetVolumeStatus); @@ -1596,19 +1599,19 @@ DECL_PIOCTL(PGetVolumeStatus) OfflineMsg = offLineMsg; MOTD = motd; do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS); RX_AFS_GUNLOCK(); code = - RXAFS_GetVolumeStatus(tc->id, avc->fid.Fid.Volume, &volstat, + RXAFS_GetVolumeStatus(rxconn, avc->fid.Fid.Volume, &volstat, &Name, &OfflineMsg, &MOTD); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS, SHARED_LOCK, NULL)); if (code) @@ -1641,6 +1644,7 @@ DECL_PIOCTL(PSetVolumeStatus) struct AFSStoreVolumeStatus storeStat; register struct volume *tvp; register char *cp; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PSetVolumeStatus); @@ -1692,19 +1696,19 @@ DECL_PIOCTL(PSetVolumeStatus) storeStat.Mask |= AFS_SETMAXQUOTA; } do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS); RX_AFS_GUNLOCK(); code = - RXAFS_SetVolumeStatus(tc->id, avc->fid.Fid.Volume, &storeStat, + RXAFS_SetVolumeStatus(rxconn, avc->fid.Fid.Volume, &storeStat, volName, offLineMsg, motd); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS, SHARED_LOCK, NULL)); if (code) @@ -2245,6 +2249,7 @@ DECL_PIOCTL(PRemoveCallBack) struct AFSCallBack CallBacks_Array[1]; struct AFSCBFids theFids; struct AFSCBs theCBs; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PRemoveCallBack); @@ -2260,17 +2265,17 @@ DECL_PIOCTL(PRemoveCallBack) CallBacks_Array[0].CallBackType = CB_DROPPED; if (avc->callback) { do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS); RX_AFS_GUNLOCK(); - code = RXAFS_GiveUpCallBacks(tc->id, &theFids, &theCBs); + code = RXAFS_GiveUpCallBacks(rxconn, &theFids, &theCBs); RX_AFS_GLOCK(); XSTATS_END_TIME; } /* don't set code on failure since we wouldn't use it */ } while (afs_Analyze - (tc, code, &avc->fid, areq, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, SHARED_LOCK, NULL)); ObtainWriteLock(&afs_xcbhash, 457); @@ -2439,6 +2444,7 @@ DECL_PIOCTL(PRemoveMount) struct AFSFetchStatus OutDirStatus; struct VenusFid tfid; struct AFSVolSync tsync; + struct rx_connection *rxconn; XSTATS_DECLS; @@ -2504,19 +2510,19 @@ DECL_PIOCTL(PRemoveMount) ObtainWriteLock(&avc->lock, 231); osi_dnlc_remove(avc, bufp, tvc); do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE); RX_AFS_GUNLOCK(); code = - RXAFS_RemoveFile(tc->id, (struct AFSFid *)&avc->fid.Fid, bufp, + RXAFS_RemoveFile(rxconn, (struct AFSFid *)&avc->fid.Fid, bufp, &OutDirStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_REMOVEFILE, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_REMOVEFILE, SHARED_LOCK, NULL)); if (code) { @@ -3765,6 +3771,7 @@ DECL_PIOCTL(PPrefetchFromTape) struct VenusFid tfid; struct AFSFid *Fid; struct vcache *tvc; + struct rx_connection *rxconn; AFS_STATCNT(PSetAcl); if (!avc) @@ -3789,11 +3796,11 @@ DECL_PIOCTL(PPrefetchFromTape) ICL_TYPE_FID, &tfid, ICL_TYPE_FID, &tvc->fid); do { - tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { RX_AFS_GUNLOCK(); - tcall = rx_NewCall(tc->id); + tcall = rx_NewCall(rxconn); code = StartRXAFS_FetchData(tcall, (struct AFSFid *)&tvc->fid.Fid, 0, 0); @@ -3807,7 +3814,7 @@ DECL_PIOCTL(PPrefetchFromTape) } else code = -1; } while (afs_Analyze - (tc, code, &tvc->fid, areq, AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, + (tc, rxconn, code, &tvc->fid, areq, AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK, NULL)); /* This call is done only to have the callback things handled correctly */ afs_FetchStatus(tvc, &tfid, areq, &OutStatus); @@ -3828,6 +3835,7 @@ DECL_PIOCTL(PFsCmd) struct FsCmdOutputs *Outputs; struct VenusFid tfid; struct AFSFid *Fid; + struct rx_connection *rxconn; Inputs = (struct FsCmdInputs *)ain; Outputs = (struct FsCmdOutputs *)aout; @@ -3853,17 +3861,17 @@ DECL_PIOCTL(PFsCmd) if (Inputs->command) { do { - tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { RX_AFS_GUNLOCK(); code = - RXAFS_FsCmd(tc->id, Fid, Inputs, + RXAFS_FsCmd(rxconn, Fid, Inputs, (struct FsCmdOutputs *)aout); RX_AFS_GLOCK(); } else code = -1; } while (afs_Analyze - (tc, code, &tvc->fid, areq, + (tc, rxconn, code, &tvc->fid, areq, AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK, NULL)); /* This call is done to have the callback things handled correctly */ afs_FetchStatus(tvc, &tfid, areq, &Outputs->status); @@ -3935,6 +3943,7 @@ DECL_PIOCTL(PCallBackAddr) afs_int32 i, j; struct unixuser *tu; struct srvAddr **addrs; + struct rx_connection *rxconn; /*AFS_STATCNT(PCallBackAddr); */ if (!afs_resourceinit_flag) /* afs deamons havn't started yet */ @@ -3999,24 +4008,24 @@ DECL_PIOCTL(PCallBackAddr) /* get a connection, even if host is down; bumps conn ref count */ tu = afs_GetUser(areq->uid, ts->cell->cellNum, SHARED_LOCK); tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu, - 1 /*force */ , 1 /*create */ , SHARED_LOCK); + 1 /*force */ , 1 /*create */ , SHARED_LOCK, &rxconn); afs_PutUser(tu, SHARED_LOCK); if (!tc) continue; if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(ts)) { if (sa->sa_flags & SRVADDR_ISDOWN) { - rx_SetConnDeadTime(tc->id, 3); + rx_SetConnDeadTime(rxconn, 3); } #ifdef RX_ENABLE_LOCKS AFS_GUNLOCK(); #endif /* RX_ENABLE_LOCKS */ - code = RXAFS_CallBackRxConnAddr(tc->id, &addr); + code = RXAFS_CallBackRxConnAddr(rxconn, &addr); #ifdef RX_ENABLE_LOCKS AFS_GLOCK(); #endif /* RX_ENABLE_LOCKS */ } - afs_PutConn(tc, SHARED_LOCK); /* done with it now */ + afs_PutConn(tc, rxconn, SHARED_LOCK); /* done with it now */ } /* Outer loop over addrs */ #endif /* UKERNEL */ return 0; diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index e391c19..49ddea9 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -13,7 +13,8 @@ /* afs_analyze.c */ extern void init_et_to_sys_error(void); extern void afs_FinalizeReq(struct vrequest *areq); -extern int afs_Analyze(register struct afs_conn *aconn, afs_int32 acode, +extern int afs_Analyze(register struct afs_conn *aconn, + struct rx_connection *rxconn, afs_int32 acode, struct VenusFid *afid, register struct vrequest *areq, int op, afs_int32 locktype, struct cell *cellp); extern int afs_CheckCode(afs_int32 acode, struct vrequest *areq, int where); @@ -255,20 +256,26 @@ extern afs_rwlock_t afs_xinterface; extern afs_rwlock_t afs_xconn; extern struct afs_conn *afs_Conn(register struct VenusFid *afid, register struct vrequest *areq, - afs_int32 locktype); + afs_int32 locktype, + struct rx_connection **rxconn); extern struct afs_conn *afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, struct unixuser *tu, int force_if_down, afs_int32 create, - afs_int32 locktype); + afs_int32 locktype, + struct rx_connection **rxconn); extern struct afs_conn *afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, afs_int32 acell, register struct vrequest *areq, - afs_int32 locktype); + afs_int32 locktype, + struct rx_connection **rxconn); extern struct afs_conn *afs_ConnByHost(struct server *aserver, unsigned short aport, afs_int32 acell, struct vrequest *areq, int aforce, - afs_int32 locktype); -extern void afs_PutConn(register struct afs_conn *ac, afs_int32 locktype); + afs_int32 locktype, + struct rx_connection **rxconn); +extern void afs_PutConn(register struct afs_conn *ac, + struct rx_connection *rxconn, + afs_int32 locktype); extern void ForceNewConnections(struct srvAddr *sap); diff --git a/src/afs/afs_segments.c b/src/afs/afs_segments.c index 66fa1fe..d22e411 100644 --- a/src/afs/afs_segments.c +++ b/src/afs/afs_segments.c @@ -44,6 +44,7 @@ afs_StoreMini(register struct vcache *avc, struct vrequest *areq) struct AFSVolSync tsync; register afs_int32 code; register struct rx_call *tcall; + struct rx_connection *rxconn; afs_size_t tlen, xlen = 0; XSTATS_DECLS; AFS_STATCNT(afs_StoreMini); @@ -56,11 +57,11 @@ afs_StoreMini(register struct vcache *avc, struct vrequest *areq) avc->states &= ~CExtendedFile; do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { retry: RX_AFS_GUNLOCK(); - tcall = rx_NewCall(tc->id); + tcall = rx_NewCall(rxconn); RX_AFS_GLOCK(); /* Set the client mod time since we always want the file * to have the client's mod time and not the server's one @@ -119,7 +120,7 @@ afs_StoreMini(register struct vcache *avc, struct vrequest *areq) } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA, SHARED_LOCK, NULL)); if (code == 0) { @@ -321,6 +322,7 @@ afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, } } if (bytes && (j == high || !dcList[j + 1])) { + struct rx_connection *rxconn; /* base = AFS_CHUNKTOBASE(dcList[first]->f.chunk); */ base = AFS_CHUNKTOBASE(first + minj); /* @@ -355,11 +357,11 @@ afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, do { stored = 0; - tc = afs_Conn(&avc->fid, areq, 0); + tc = afs_Conn(&avc->fid, areq, 0, &rxconn); if (tc) { restart: RX_AFS_GUNLOCK(); - tcall = rx_NewCall(tc->id); + tcall = rx_NewCall(rxconn); #ifdef AFS_64BIT_CLIENT if (!afs_serverHasNo64Bit(tc)) { code = @@ -569,7 +571,7 @@ afs_StoreAllSegments(register struct vcache *avc, struct vrequest *areq, } #endif /* AFS_64BIT_CLIENT */ } while (afs_Analyze - (tc, code, &avc->fid, areq, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA, SHARED_LOCK, NULL)); diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 6a7e688..319077b 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -288,6 +288,7 @@ CheckVLServer(register struct srvAddr *sa, struct vrequest *areq) register struct server *aserver = sa->server; register struct afs_conn *tc; register afs_int32 code; + struct rx_connection *rxconn; AFS_STATCNT(CheckVLServer); /* Ping dead servers to see if they're back */ @@ -298,16 +299,16 @@ CheckVLServer(register struct srvAddr *sa, struct vrequest *areq) return; /* can't do much */ tc = afs_ConnByHost(aserver, aserver->cell->vlport, - aserver->cell->cellNum, areq, 1, SHARED_LOCK); + aserver->cell->cellNum, areq, 1, SHARED_LOCK, &rxconn); if (!tc) return; - rx_SetConnDeadTime(tc->id, 3); + rx_SetConnDeadTime(rxconn, 3); RX_AFS_GUNLOCK(); - code = VL_ProbeServer(tc->id); + code = VL_ProbeServer(rxconn); RX_AFS_GLOCK(); - rx_SetConnDeadTime(tc->id, afs_rx_deadtime); - afs_PutConn(tc, SHARED_LOCK); + rx_SetConnDeadTime(rxconn, afs_rx_deadtime); + afs_PutConn(tc, rxconn, SHARED_LOCK); /* * If probe worked, or probe call not yet defined (for compatibility * with old vlsevers), then we treat this server as running again @@ -582,6 +583,8 @@ afs_CheckServers(int adown, struct cell *acellp) results = (afs_int32 *)afs_osi_Alloc(j * sizeof (afs_int32)); for (i = 0; i < j; i++) { + struct rx_connection *rxconn; + deltas[i] = 0; sa = addrs[i]; ts = sa->server; @@ -610,7 +613,7 @@ afs_CheckServers(int adown, struct cell *acellp) /* get a connection, even if host is down; bumps conn ref count */ 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); + 1 /*force */ , 1 /*create */ , SHARED_LOCK, &rxconn); afs_PutUser(tu, SHARED_LOCK); if (!tc) continue; @@ -618,9 +621,9 @@ afs_CheckServers(int adown, struct cell *acellp) if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(sa->server) || (tc->srvr->server == afs_setTimeHost)) { conns[nconns]=tc; - rxconns[nconns]=tc->id; + rxconns[nconns]=rxconn; if (sa->sa_flags & SRVADDR_ISDOWN) { - rx_SetConnDeadTime(tc->id, 3); + rx_SetConnDeadTime(rxconn, 3); conntimer[nconns]=1; } else { conntimer[nconns]=0; @@ -638,7 +641,7 @@ afs_CheckServers(int adown, struct cell *acellp) tc = conns[multi_i]; sa = tc->srvr; if (conntimer[multi_i] == 1) - rx_SetConnDeadTime(tc->id, afs_rx_deadtime); + rx_SetConnDeadTime(rxconns[multi_i], afs_rx_deadtime); end = osi_Time(); results[multi_i]=multi_error; if ((start == end) && !multi_error) @@ -739,7 +742,7 @@ afs_CheckServers(int adown, struct cell *acellp) } } for (i = 0; i < nconns; i++) { - afs_PutConn(conns[i], SHARED_LOCK); /* done with it now */ + afs_PutConn(conns[i], rxconns[i], SHARED_LOCK); /* done with it now */ } afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs)); diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 24edf0d..d163f83 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -423,6 +423,7 @@ afs_FlushVCBs(afs_int32 lockit) tcount = 0; /* number found so far */ for (safety2 = 0; safety2 < afs_cacheStats; safety2++) { if (tcount >= AFS_MAXCBRSCALL || !tsp->cbrs) { + struct rx_connection *rxconn; /* if buffer is full, or we've queued all we're going * to from this server, we should flush out the * callbacks. @@ -436,20 +437,20 @@ afs_FlushVCBs(afs_int32 lockit) for (safety3 = 0; safety3 < MAXHOSTS * 2; safety3++) { tc = afs_ConnByHost(tsp, tsp->cell->fsport, tsp->cell->cellNum, &treq, 0, - SHARED_LOCK); + SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME (AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS); RX_AFS_GUNLOCK(); code = - RXAFS_GiveUpCallBacks(tc->id, &fidArray, + RXAFS_GiveUpCallBacks(rxconn, &fidArray, &cbArray); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; if (!afs_Analyze - (tc, code, 0, &treq, + (tc, rxconn, code, 0, &treq, AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, SHARED_LOCK, tsp->cell)) { break; @@ -1296,6 +1297,7 @@ afs_FlushActiveVcaches(register afs_int32 doflocks) tvc->flockCount)) panic("Dead vnode has core/unlinkedel/flock"); #endif if (doflocks && tvc->flockCount != 0) { + struct rx_connection *rxconn; /* if this entry has an flock, send a keep-alive call out */ osi_vnhold(tvc, 0); ReleaseReadLock(&afs_xvcache); @@ -1304,12 +1306,12 @@ afs_FlushActiveVcaches(register afs_int32 doflocks) afs_InitReq(&treq, afs_osi_credp); treq.flags |= O_NONBLOCK; - tc = afs_Conn(&tvc->fid, &treq, SHARED_LOCK); + tc = afs_Conn(&tvc->fid, &treq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_EXTENDLOCK); RX_AFS_GUNLOCK(); code = - RXAFS_ExtendLock(tc->id, + RXAFS_ExtendLock(rxconn, (struct AFSFid *)&tvc->fid.Fid, &tsync); RX_AFS_GLOCK(); @@ -1317,7 +1319,7 @@ afs_FlushActiveVcaches(register afs_int32 doflocks) } else code = -1; } while (afs_Analyze - (tc, code, &tvc->fid, &treq, + (tc, rxconn, code, &tvc->fid, &treq, AFS_STATS_FS_RPCIDX_EXTENDLOCK, SHARED_LOCK, NULL)); ReleaseWriteLock(&tvc->lock); @@ -1608,25 +1610,26 @@ afs_WriteVCache(register struct vcache *avc, struct afs_conn *tc; struct AFSFetchStatus OutStatus; struct AFSVolSync tsync; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(afs_WriteVCache); afs_Trace2(afs_iclSetp, CM_TRACE_WVCACHE, ICL_TYPE_POINTER, avc, ICL_TYPE_OFFSET, ICL_HANDLE_OFFSET(avc->m.Length)); do { - tc = afs_Conn(&avc->fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STORESTATUS); RX_AFS_GUNLOCK(); code = - RXAFS_StoreStatus(tc->id, (struct AFSFid *)&avc->fid.Fid, + RXAFS_StoreStatus(rxconn, (struct AFSFid *)&avc->fid.Fid, astatus, &OutStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STORESTATUS, + (tc, rxconn, code, &avc->fid, areq, AFS_STATS_FS_RPCIDX_STORESTATUS, SHARED_LOCK, NULL)); UpgradeSToWLock(&avc->lock, 20); @@ -1765,12 +1768,13 @@ afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, afs_int32 code; afs_uint32 start; register struct afs_conn *tc; + struct rx_connection *rxconn; struct AFSFetchStatus OutDirStatus; XSTATS_DECLS; if (!name) name = ""; /* XXX */ do { - tc = afs_Conn(afid, areq, SHARED_LOCK); + tc = afs_Conn(afid, areq, SHARED_LOCK, &rxconn); if (tc) { if (serverp) *serverp = tc->srvr->server; @@ -1778,7 +1782,7 @@ afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_XLOOKUP); RX_AFS_GUNLOCK(); code = - RXAFS_Lookup(tc->id, (struct AFSFid *)&afid->Fid, name, + RXAFS_Lookup(rxconn, (struct AFSFid *)&afid->Fid, name, (struct AFSFid *)&nfid->Fid, OutStatusp, &OutDirStatus, CallBackp, tsyncp); RX_AFS_GLOCK(); @@ -1786,7 +1790,7 @@ afs_RemoteLookup(register struct VenusFid *afid, struct vrequest *areq, } else code = -1; } while (afs_Analyze - (tc, code, afid, areq, AFS_STATS_FS_RPCIDX_XLOOKUP, SHARED_LOCK, + (tc, rxconn, code, afid, areq, AFS_STATS_FS_RPCIDX_XLOOKUP, SHARED_LOCK, NULL)); return code; @@ -2468,9 +2472,10 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid, struct AFSCallBack CallBack; struct AFSVolSync tsync; struct volume *volp; + struct rx_connection *rxconn; XSTATS_DECLS; do { - tc = afs_Conn(afid, areq, SHARED_LOCK); + tc = afs_Conn(afid, areq, SHARED_LOCK, &rxconn); avc->dchint = NULL; /* invalidate hints */ if (tc) { avc->callback = tc->srvr->server; @@ -2478,7 +2483,7 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid, XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHSTATUS); RX_AFS_GUNLOCK(); code = - RXAFS_FetchStatus(tc->id, (struct AFSFid *)&afid->Fid, Outsp, + RXAFS_FetchStatus(rxconn, (struct AFSFid *)&afid->Fid, Outsp, &CallBack, &tsync); RX_AFS_GLOCK(); @@ -2487,7 +2492,7 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid, } else code = -1; } while (afs_Analyze - (tc, code, afid, areq, AFS_STATS_FS_RPCIDX_FETCHSTATUS, + (tc, rxconn, code, afid, areq, AFS_STATS_FS_RPCIDX_FETCHSTATUS, SHARED_LOCK, NULL)); if (!code) { diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c index 2ca4fe1..1058476 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -660,6 +660,7 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, char *tbuffer, *ve; struct afs_conn *tconn; struct vrequest treq; + struct rx_connection *rxconn; if (strlen(aname) > VL_MAXNAMELEN) /* Invalid volume name */ return NULL; @@ -684,34 +685,34 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, do { tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum, - &treq, SHARED_LOCK); + &treq, SHARED_LOCK, &rxconn); if (tconn) { if (tconn->srvr->server->flags & SNO_LHOSTS) { type = 0; RX_AFS_GUNLOCK(); - code = VL_GetEntryByNameO(tconn->id, aname, tve); + code = VL_GetEntryByNameO(rxconn, aname, tve); RX_AFS_GLOCK(); } else if (tconn->srvr->server->flags & SYES_LHOSTS) { type = 1; RX_AFS_GUNLOCK(); - code = VL_GetEntryByNameN(tconn->id, aname, ntve); + code = VL_GetEntryByNameN(rxconn, aname, ntve); RX_AFS_GLOCK(); } else { type = 2; RX_AFS_GUNLOCK(); - code = VL_GetEntryByNameU(tconn->id, aname, utve); + code = VL_GetEntryByNameU(rxconn, aname, utve); RX_AFS_GLOCK(); if (!(tconn->srvr->server->flags & SVLSRV_UUID)) { if (code == RXGEN_OPCODE) { type = 1; RX_AFS_GUNLOCK(); - code = VL_GetEntryByNameN(tconn->id, aname, ntve); + code = VL_GetEntryByNameN(rxconn, aname, ntve); RX_AFS_GLOCK(); if (code == RXGEN_OPCODE) { type = 0; tconn->srvr->server->flags |= SNO_LHOSTS; RX_AFS_GUNLOCK(); - code = VL_GetEntryByNameO(tconn->id, aname, tve); + code = VL_GetEntryByNameO(rxconn, aname, tve); RX_AFS_GLOCK(); } else if (!code) tconn->srvr->server->flags |= SYES_LHOSTS; @@ -722,7 +723,7 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood, } } else code = -1; - } while (afs_Analyze(tconn, 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) { @@ -1028,6 +1029,7 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell, bulkaddrs addrs; ListAddrByAttributes attrs; afsUUID uuid; + struct rx_connection *rxconn; memset((char *)&attrs, 0, sizeof(attrs)); attrs.Mask = VLADDR_UUID; @@ -1037,11 +1039,12 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell, do { tconn = afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, - tcell->cellNum, areq, SHARED_LOCK); + tcell->cellNum, areq, SHARED_LOCK, + &rxconn); if (tconn) { RX_AFS_GUNLOCK(); code = - VL_GetAddrsU(tconn->id, &attrs, &uuid, &unique, + VL_GetAddrsU(rxconn, &attrs, &uuid, &unique, &nentries, &addrs); RX_AFS_GLOCK(); } else { @@ -1053,7 +1056,7 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell, code = VL_NOENT; } while (afs_Analyze - (tconn, code, NULL, areq, -1, SHARED_LOCK, tcell)); + (tconn, rxconn, code, NULL, areq, -1, SHARED_LOCK, tcell)); if (code) { /* Better handing of such failures; for now we'll simply retry this call */ areq->volumeError = 1;