From 5abed0aa67092cc488a8f8a343282188f00297e0 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 5 May 2011 11:18:08 -0500 Subject: [PATCH] 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. (cherry picked from commit 03f0c656c1734b9be4debdf19b8f10771ff4420a) Reviewed-on: http://gerrit.openafs.org/4625 Tested-by: BuildBot Reviewed-by: Derrick Brashear Change-Id: If19a267e23941e3305f4f13cd91a0935d214f1b1 Reviewed-on: http://gerrit.openafs.org/5232 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/VNOPS/afs_vnop_create.c | 7 +- src/afs/VNOPS/afs_vnop_dirops.c | 14 +-- src/afs/VNOPS/afs_vnop_flock.c | 30 ++++--- src/afs/VNOPS/afs_vnop_link.c | 7 +- src/afs/VNOPS/afs_vnop_lookup.c | 11 +-- src/afs/VNOPS/afs_vnop_remove.c | 7 +- src/afs/VNOPS/afs_vnop_rename.c | 7 +- src/afs/VNOPS/afs_vnop_symlink.c | 9 +- src/afs/afs_analyze.c | 24 ++--- src/afs/afs_bypasscache.c | 9 +- src/afs/afs_conn.c | 32 +++++-- src/afs/afs_dcache.c | 7 +- src/afs/afs_disconnected.c | 147 +++++++++++++++++-------------- src/afs/afs_fetchstore.c | 27 +++--- src/afs/afs_pioctl.c | 65 ++++++++------ src/afs/afs_prototypes.h | 30 ++++--- src/afs/afs_segments.c | 7 +- src/afs/afs_server.c | 31 ++++--- src/afs/afs_vcache.c | 35 ++++---- src/afs/afs_volume.c | 23 ++--- 20 files changed, 304 insertions(+), 225 deletions(-) diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c index e598007a4..edd75a835 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); @@ -297,14 +298,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->f.fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->f.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->f.fid.Fid, + RXAFS_CreateFile(rxconn, (struct AFSFid *)&adp->f.fid.Fid, aname, &InStatus, (struct AFSFid *) &newFid.Fid, &OutFidStatus, &OutDirStatus, &CallBack, &tsync); @@ -314,7 +315,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, } else code = -1; } while (afs_Analyze - (tc, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE, + (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE, SHARED_LOCK, NULL)); if ((code == EEXIST || code == UAEEXIST) && diff --git a/src/afs/VNOPS/afs_vnop_dirops.c b/src/afs/VNOPS/afs_vnop_dirops.c index 4e5140f35..6128d7df5 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; afs_int32 code; struct afs_conn *tc; + struct rx_connection *rxconn; struct VenusFid newFid; struct dcache *tdc; struct dcache *new_dc; @@ -103,13 +104,13 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, if (!AFS_IS_DISCON_RW) { do { - tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->f.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, + RXAFS_MakeDir(rxconn, (struct AFSFid *)&adp->f.fid.Fid, aname, &InStatus, @@ -125,7 +126,7 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, } else code = -1; } while (afs_Analyze - (tc, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_MAKEDIR, + (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_MAKEDIR, SHARED_LOCK, NULL)); if (code) { @@ -263,6 +264,7 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred) struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state fakestate; + struct rx_connection *rxconn; XSTATS_DECLS; OSI_VC_CONVERT(adp); @@ -332,12 +334,12 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred) if (!AFS_IS_DISCON_RW) { /* Not disconnected, can connect to server. */ do { - tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEDIR); RX_AFS_GUNLOCK(); code = - RXAFS_RemoveDir(tc->id, + RXAFS_RemoveDir(rxconn, (struct AFSFid *)&adp->f.fid.Fid, aname, &OutDirStatus, @@ -347,7 +349,7 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred) } else code = -1; } while (afs_Analyze - (tc, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_REMOVEDIR, + (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_REMOVEDIR, SHARED_LOCK, NULL)); if (code) { diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c index d7698f841..f904d50c4 100644 --- a/src/afs/VNOPS/afs_vnop_flock.c +++ b/src/afs/VNOPS/afs_vnop_flock.c @@ -325,19 +325,20 @@ HandleFlock(struct vcache *avc, int acom, struct vrequest *areq, } if (avc->flockCount == 0) { if (!AFS_IS_DISCONNECTED) { + struct rx_connection *rxconn; do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.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->f.fid.Fid, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_RELEASELOCK, SHARED_LOCK, NULL)); } else { /*printf("Network is dooooooowwwwwwwnnnnnnn\n");*/ @@ -382,23 +383,24 @@ HandleFlock(struct vcache *avc, int acom, struct vrequest *areq, } } if (!code && avc->flockCount == 0) { + struct rx_connection *rxconn; if (!AFS_IS_DISCONNECTED) { do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.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-> f.fid.Fid, &tsync); RX_AFS_GLOCK(); - XSTATS_END_TIME; + XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_RELEASELOCK, SHARED_LOCK, NULL)); } @@ -415,15 +417,16 @@ HandleFlock(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); if (!AFS_IS_DISCONNECTED) { do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.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->f.fid.Fid, lockType, &tsync); RX_AFS_GLOCK(); @@ -431,7 +434,7 @@ HandleFlock(struct vcache *avc, int acom, struct vrequest *areq, } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_SETLOCK, SHARED_LOCK, NULL)); if ((lockType == LockWrite) && (code == VREADONLY)) @@ -843,6 +846,7 @@ 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; @@ -853,19 +857,19 @@ GetFlockCount(struct vcache *avc, struct vrequest *areq) return 0; do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.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->f.fid.Fid, + RXAFS_FetchStatus(rxconn, (struct AFSFid *)&avc->f.fid.Fid, &OutStatus, &CallBack, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_FETCHSTATUS, + (tc, rxconn, code, &avc->f.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 50b69a973..26b6c71a2 100644 --- a/src/afs/VNOPS/afs_vnop_link.c +++ b/src/afs/VNOPS/afs_vnop_link.c @@ -46,6 +46,7 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname, struct AFSFetchStatus OutFidStatus, OutDirStatus; struct AFSVolSync tsync; struct afs_fakestat_state vfakestate, dfakestate; + struct rx_connection *rxconn; XSTATS_DECLS; OSI_VC_CONVERT(adp); @@ -97,12 +98,12 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname, tdc = afs_GetDCache(adp, (afs_size_t) 0, &treq, &offset, &len, 1); /* test for error below */ ObtainWriteLock(&adp->lock, 145); do { - tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->f.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->f.fid.Fid, aname, + RXAFS_Link(rxconn, (struct AFSFid *)&adp->f.fid.Fid, aname, (struct AFSFid *)&avc->f.fid.Fid, &OutFidStatus, &OutDirStatus, &tsync); RX_AFS_GLOCK(); @@ -111,7 +112,7 @@ afs_link(struct vcache *avc, OSI_VC_DECL(adp), char *aname, } else code = -1; } while (afs_Analyze - (tc, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_LINK, + (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_LINK, SHARED_LOCK, NULL)); if (code) { diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 850bc06ad..3559d9b24 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -683,6 +683,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) struct volume *volp = 0; /* volume ptr */ struct VenusFid dotdot = {0, {0, 0, 0}}; int flagIndex = 0; /* First file with bulk fetch flag set */ + struct rx_connection *rxconn; XSTATS_DECLS; dotdot.Cell = 0; dotdot.Fid.Unique = 0; @@ -938,7 +939,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->f.fid, areqp, SHARED_LOCK); + tcp = afs_Conn(&adp->f.fid, areqp, SHARED_LOCK, &rxconn); if (tcp) { hostp = tcp->srvr->server; XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_BULKSTATUS); @@ -946,14 +947,14 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) if (!(tcp->srvr->server->flags & SNO_INLINEBULK)) { RX_AFS_GUNLOCK(); code = - RXAFS_InlineBulkStatus(tcp->id, &fidParm, &statParm, + RXAFS_InlineBulkStatus(rxconn, &fidParm, &statParm, &cbParm, &volSync); RX_AFS_GLOCK(); if (code == RXGEN_OPCODE) { tcp->srvr->server->flags |= SNO_INLINEBULK; RX_AFS_GUNLOCK(); code = - RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, + RXAFS_BulkStatus(rxconn, &fidParm, &statParm, &cbParm, &volSync); RX_AFS_GLOCK(); } else if (!code) { @@ -965,7 +966,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) } else { RX_AFS_GUNLOCK(); code = - RXAFS_BulkStatus(tcp->id, &fidParm, &statParm, &cbParm, + RXAFS_BulkStatus(rxconn, &fidParm, &statParm, &cbParm, &volSync); RX_AFS_GLOCK(); } @@ -973,7 +974,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) } else code = -1; } while (afs_Analyze - (tcp, code, &adp->f.fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS, + (tcp, rxconn, code, &adp->f.fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL)); /* now, if we didnt get the info, bail out. */ diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c index 7b679b361..3890f0dc9 100644 --- a/src/afs/VNOPS/afs_vnop_remove.c +++ b/src/afs/VNOPS/afs_vnop_remove.c @@ -61,22 +61,23 @@ afsremove(struct vcache *adp, struct dcache *tdc, struct afs_conn *tc; struct AFSFetchStatus OutDirStatus; struct AFSVolSync tsync; + struct rx_connection *rxconn; XSTATS_DECLS; if (!AFS_IS_DISCONNECTED) { do { - tc = afs_Conn(&adp->f.fid, treqp, SHARED_LOCK); + tc = afs_Conn(&adp->f.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->f.fid.Fid, + RXAFS_RemoveFile(rxconn, (struct AFSFid *)&adp->f.fid.Fid, aname, &OutDirStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &adp->f.fid, treqp, AFS_STATS_FS_RPCIDX_REMOVEFILE, + (tc, rxconn, code, &adp->f.fid, treqp, AFS_STATS_FS_RPCIDX_REMOVEFILE, SHARED_LOCK, NULL)); } diff --git a/src/afs/VNOPS/afs_vnop_rename.c b/src/afs/VNOPS/afs_vnop_rename.c index 45aaefa22..ca7bf9b53 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, @@ -168,12 +169,12 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, if (!AFS_IS_DISCON_RW) { /* Connected. */ do { - tc = afs_Conn(&aodp->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&aodp->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RENAME); RX_AFS_GUNLOCK(); code = - RXAFS_Rename(tc->id, + RXAFS_Rename(rxconn, (struct AFSFid *)&aodp->f.fid.Fid, aname1, (struct AFSFid *)&andp->f.fid.Fid, @@ -187,7 +188,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp, code = -1; } while (afs_Analyze - (tc, code, &andp->f.fid, areq, AFS_STATS_FS_RPCIDX_RENAME, + (tc, rxconn, code, &andp->f.fid, areq, AFS_STATS_FS_RPCIDX_RENAME, SHARED_LOCK, NULL)); } else { diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c index 73f208670..3e0810846 100644 --- a/src/afs/VNOPS/afs_vnop_symlink.c +++ b/src/afs/VNOPS/afs_vnop_symlink.c @@ -84,6 +84,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, struct AFSVolSync tsync; struct volume *volp = 0; struct afs_fakestat_state fakestate; + struct rx_connection *rxconn; XSTATS_DECLS; OSI_VC_CONVERT(adp); @@ -156,7 +157,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, * the copy will be invalidated */ if (!AFS_IS_DISCON_RW) { do { - tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK); + tc = afs_Conn(&adp->f.fid, &treq, SHARED_LOCK, &rxconn); if (tc) { hostp = tc->srvr->server; XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SYMLINK); @@ -164,7 +165,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, now = osi_Time(); RX_AFS_GUNLOCK(); code = - RXAFS_DFSSymlink(tc->id, + RXAFS_DFSSymlink(rxconn, (struct AFSFid *)&adp->f.fid.Fid, aname, atargetName, &InStatus, (struct AFSFid *)&newFid.Fid, @@ -174,7 +175,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, } else { RX_AFS_GUNLOCK(); code = - RXAFS_Symlink(tc->id, (struct AFSFid *)&adp->f.fid.Fid, + RXAFS_Symlink(rxconn, (struct AFSFid *)&adp->f.fid.Fid, aname, atargetName, &InStatus, (struct AFSFid *)&newFid.Fid, &OutFidStatus, &OutDirStatus, &tsync); @@ -184,7 +185,7 @@ afs_symlink(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, } else code = -1; } while (afs_Analyze - (tc, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_SYMLINK, + (tc, rxconn, code, &adp->f.fid, &treq, AFS_STATS_FS_RPCIDX_SYMLINK, SHARED_LOCK, NULL)); } else { newFid.Cell = adp->f.fid.Cell; diff --git a/src/afs/afs_analyze.c b/src/afs/afs_analyze.c index 1834e6d88..1a6c16772 100644 --- a/src/afs/afs_analyze.c +++ b/src/afs/afs_analyze.c @@ -103,6 +103,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); @@ -116,34 +117,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; @@ -154,7 +155,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); @@ -305,7 +306,8 @@ afs_BlackListOnce(struct vrequest *areq, struct VenusFid *afid, * if this is a temporary or permanent error. *------------------------------------------------------------------------*/ int -afs_Analyze(struct afs_conn *aconn, afs_int32 acode, +afs_Analyze(struct afs_conn *aconn, struct rx_connection *rxconn, + afs_int32 acode, struct VenusFid *afid, struct vrequest *areq, int op, afs_int32 locktype, struct cell *cellp) { @@ -328,7 +330,7 @@ afs_Analyze(struct afs_conn *aconn, afs_int32 acode, if (aconn) { /* SXW - I suspect that this will _never_ happen - we shouldn't * get a connection because we're disconnected !!!*/ - afs_PutConn(aconn, locktype); + afs_PutConn(aconn, rxconn, locktype); } return 0; } @@ -447,7 +449,7 @@ afs_Analyze(struct afs_conn *aconn, afs_int32 acode, } } - afs_PutConn(aconn, locktype); + afs_PutConn(aconn, rxconn, locktype); return 0; } @@ -679,6 +681,6 @@ afs_Analyze(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_bypasscache.c b/src/afs/afs_bypasscache.c index 6f8820325..5a888eb8c 100644 --- a/src/afs/afs_bypasscache.c +++ b/src/afs/afs_bypasscache.c @@ -513,6 +513,7 @@ afs_PrefetchNoCache(struct vcache *avc, struct iovec *iovecp; struct vrequest *areq; afs_int32 code = 0; + struct rx_connection *rxconn; #ifdef AFS_64BIT_CLIENT afs_int32 length_hi, bytes, locked; #endif @@ -533,11 +534,11 @@ afs_PrefetchNoCache(struct vcache *avc, tcallspec = (struct tlocal1 *) osi_Alloc(sizeof(struct tlocal1)); do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK /* ignored */); + tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK /* ignored */, &rxconn); if (tc) { avc->callback = tc->srvr->server; i = osi_Time(); - tcall = rx_NewCall(tc->id); + tcall = rx_NewCall(rxconn); #ifdef AFS_64BIT_CLIENT if (!afs_serverHasNo64Bit(tc)) { code = StartRXAFS_FetchData64(tcall, @@ -568,7 +569,7 @@ afs_PrefetchNoCache(struct vcache *avc, pos = auio->uio_offset; COND_GUNLOCK(locked); if (!tcall) - tcall = rx_NewCall(tc->id); + tcall = rx_NewCall(rxconn); code = StartRXAFS_FetchData(tcall, (struct AFSFid *) &avc->f.fid.Fid, pos, bparms->length); @@ -604,7 +605,7 @@ afs_PrefetchNoCache(struct vcache *avc, unlock_and_release_pages(auio); goto done; } - } while (afs_Analyze(tc, code, &avc->f.fid, areq, + } while (afs_Analyze(tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_FETCHDATA, SHARED_LOCK,0)); done: diff --git a/src/afs/afs_conn.c b/src/afs/afs_conn.c index 0fa9f5ca3..d9173dbb2 100644 --- a/src/afs/afs_conn.c +++ b/src/afs/afs_conn.c @@ -101,7 +101,7 @@ afs_pickSecurityObject(struct afs_conn *conn, int *secLevel) */ struct afs_conn * afs_Conn(struct VenusFid *afid, struct vrequest *areq, - afs_int32 locktype) + afs_int32 locktype, struct rx_connection **rxconn) { u_short fsport = AFS_FSPORT; struct volume *tv; @@ -112,6 +112,8 @@ afs_Conn(struct VenusFid *afid, struct vrequest *areq, int i; struct srvAddr *sa1p; + *rxconn = NULL; + AFS_STATCNT(afs_Conn); /* Get fid's volume. */ tv = afs_GetVolume(afid, areq, READ_LOCK); @@ -171,7 +173,7 @@ afs_Conn(struct VenusFid *afid, 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); } @@ -196,13 +198,15 @@ afs_Conn(struct VenusFid *afid, 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; @@ -312,6 +316,9 @@ afs_ConnBySA(struct srvAddr *sap, unsigned short aport, afs_int32 acell, ConvertWToSLock(&afs_xconn); } /* end of if (tc->forceConnectFS)*/ + *rxconn = tc->id; + rx_GetConnection(*rxconn); + ReleaseSharedLock(&afs_xconn); return tc; } @@ -334,12 +341,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); if (AFS_IS_DISCONNECTED && !AFS_IN_SYNC) { @@ -358,7 +368,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; } @@ -367,7 +377,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; } @@ -394,18 +404,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, struct vrequest *areq, - afs_int32 locktype) + afs_int32 locktype, struct rx_connection **rxconn) { afs_int32 i; struct afs_conn *tconn; struct server *ts; + *rxconn = NULL; + /* try to find any connection from the set */ AFS_STATCNT(afs_ConnByMHosts); for (i = 0; i < AFS_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; } @@ -421,10 +433,12 @@ afs_ConnByMHosts(struct server *ahosts[], unsigned short aport, * @param locktype */ void -afs_PutConn(struct afs_conn *ac, afs_int32 locktype) +afs_PutConn(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 6584bd247..038057eaf 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -1636,6 +1636,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, int doAdjustSize = 0; int doReallyAdjustSize = 0; int overWriteWholeChunk = 0; + struct rx_connection *rxconn; #ifndef AFS_NOSTATS struct afs_stats_AccessInfo *accP; /*Ptr to access record in stats */ @@ -2197,7 +2198,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, * tdc->lock(W) */ - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { #ifndef AFS_NOSTATS numFetchLoops++; @@ -2212,7 +2213,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, setNewCallback = 1; } i = osi_Time(); - code = afs_CacheFetchProc(tc, file, Position, tdc, + code = afs_CacheFetchProc(tc, rxconn, file, Position, tdc, avc, size, tsmall); } else code = -1; @@ -2257,7 +2258,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, } } while (afs_Analyze - (tc, code, &avc->f.fid, areq, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_FETCHDATA, SHARED_LOCK, NULL)); /* diff --git a/src/afs/afs_disconnected.c b/src/afs/afs_disconnected.c index f85c26ebc..d07df6029 100644 --- a/src/afs/afs_disconnected.c +++ b/src/afs/afs_disconnected.c @@ -552,6 +552,7 @@ afs_ProcessOpRename(struct vcache *avc, struct vrequest *areq) struct AFSFetchStatus OutOldDirStatus, OutNewDirStatus; struct AFSVolSync tsync; struct afs_conn *tc; + struct rx_connection *rxconn; afs_uint32 code = 0; XSTATS_DECLS; @@ -604,11 +605,11 @@ afs_ProcessOpRename(struct vcache *avc, struct vrequest *areq) /* Send to data to server. */ do { - tc = afs_Conn(&old_pdir_fid, areq, SHARED_LOCK); + tc = afs_Conn(&old_pdir_fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RENAME); RX_AFS_GUNLOCK(); - code = RXAFS_Rename(tc->id, + code = RXAFS_Rename(rxconn, (struct AFSFid *)&old_pdir_fid.Fid, old_name, (struct AFSFid *)&new_pdir_fid.Fid, @@ -622,12 +623,13 @@ afs_ProcessOpRename(struct vcache *avc, struct vrequest *areq) code = -1; } while (afs_Analyze(tc, - code, - &new_pdir_fid, - areq, - AFS_STATS_FS_RPCIDX_RENAME, - SHARED_LOCK, - NULL)); + rxconn, + code, + &new_pdir_fid, + areq, + AFS_STATS_FS_RPCIDX_RENAME, + SHARED_LOCK, + NULL)); /* if (code) printf("afs_ProcessOpRename: server code=%u\n", code); */ done: @@ -658,6 +660,7 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq, struct vcache *tdp = NULL, *tvc = NULL; struct dcache *tdc = NULL; struct afs_conn *tc; + struct rx_connection *rxconn; afs_int32 hash, new_hash, index; afs_size_t tlen; int code, op = 0; @@ -716,7 +719,7 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq, InStatus.UnixModeBits = avc->f.m.Mode & 0xffff; do { - tc = afs_Conn(&tdp->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&tdp->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { switch (vType(avc)) { case VREG: @@ -738,7 +741,7 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq, op = AFS_STATS_FS_RPCIDX_MAKEDIR; XSTATS_START_TIME(op); RX_AFS_GUNLOCK(); - code = RXAFS_MakeDir(tc->id, (struct AFSFid *) &tdp->f.fid.Fid, + code = RXAFS_MakeDir(rxconn, (struct AFSFid *) &tdp->f.fid.Fid, tname, &InStatus, (struct AFSFid *) &newFid.Fid, &OutFidStatus, &OutDirStatus, @@ -751,7 +754,7 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq, op = AFS_STATS_FS_RPCIDX_SYMLINK; XSTATS_START_TIME(op); RX_AFS_GUNLOCK(); - code = RXAFS_Symlink(tc->id, + code = RXAFS_Symlink(rxconn, (struct AFSFid *) &tdp->f.fid.Fid, tname, ttargetName, &InStatus, (struct AFSFid *) &newFid.Fid, @@ -766,7 +769,7 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq, } } else code = -1; - } while (afs_Analyze(tc, code, &tdp->f.fid, areq, op, SHARED_LOCK, NULL)); + } while (afs_Analyze(tc, rxconn, code, &tdp->f.fid, areq, op, SHARED_LOCK, NULL)); /* TODO: Handle errors. */ if (code) { @@ -910,6 +913,7 @@ afs_ProcessOpRemove(struct vcache *avc, struct vrequest *areq) struct VenusFid pdir_fid; struct AFSVolSync tsync; struct afs_conn *tc; + struct rx_connection *rxconn; struct vcache *tdp = NULL; int code = 0; XSTATS_DECLS; @@ -935,11 +939,11 @@ afs_ProcessOpRemove(struct vcache *avc, struct vrequest *areq) if (vType(avc) == VREG || vType(avc) == VLNK) { /* Remove file on server. */ do { - tc = afs_Conn(&pdir_fid, areq, SHARED_LOCK); + tc = afs_Conn(&pdir_fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE); RX_AFS_GUNLOCK(); - code = RXAFS_RemoveFile(tc->id, + code = RXAFS_RemoveFile(rxconn, &pdir_fid.Fid, tname, &OutDirStatus, @@ -950,21 +954,22 @@ afs_ProcessOpRemove(struct vcache *avc, struct vrequest *areq) } else code = -1; } while (afs_Analyze(tc, - code, - &pdir_fid, - areq, - AFS_STATS_FS_RPCIDX_REMOVEFILE, - SHARED_LOCK, - NULL)); + rxconn, + code, + &pdir_fid, + areq, + AFS_STATS_FS_RPCIDX_REMOVEFILE, + SHARED_LOCK, + NULL)); } else if (vType(avc) == VDIR) { /* Remove dir on server. */ do { - tc = afs_Conn(&pdir_fid, areq, SHARED_LOCK); + tc = afs_Conn(&pdir_fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEDIR); RX_AFS_GUNLOCK(); - code = RXAFS_RemoveDir(tc->id, + code = RXAFS_RemoveDir(rxconn, &pdir_fid.Fid, tname, &OutDirStatus, @@ -974,12 +979,13 @@ afs_ProcessOpRemove(struct vcache *avc, struct vrequest *areq) } else code = -1; } while (afs_Analyze(tc, - code, - &pdir_fid, - areq, - AFS_STATS_FS_RPCIDX_REMOVEDIR, - SHARED_LOCK, - NULL)); + rxconn, + code, + &pdir_fid, + areq, + AFS_STATS_FS_RPCIDX_REMOVEDIR, + SHARED_LOCK, + NULL)); } /* if (vType(avc) == VREG) */ @@ -1004,6 +1010,7 @@ int afs_SendChanges(struct vcache *avc, struct vrequest *areq) { struct afs_conn *tc; + struct rx_connection *rxconn; struct AFSStoreStatus sstat; struct AFSFetchStatus fstat; struct AFSVolSync tsync; @@ -1017,12 +1024,12 @@ afs_SendChanges(struct vcache *avc, struct vrequest *areq) /* Turn dirty vc data into a new store status... */ if (afs_GenStoreStatus(avc, &sstat) > 0) { do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { /* ... and send it. */ XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STORESTATUS); RX_AFS_GUNLOCK(); - code = RXAFS_StoreStatus(tc->id, + code = RXAFS_StoreStatus(rxconn, (struct AFSFid *) &avc->f.fid.Fid, &sstat, &fstat, @@ -1034,12 +1041,13 @@ afs_SendChanges(struct vcache *avc, struct vrequest *areq) code = -1; } while (afs_Analyze(tc, - code, - &avc->f.fid, - areq, - AFS_STATS_FS_RPCIDX_STORESTATUS, - SHARED_LOCK, - NULL)); + rxconn, + code, + &avc->f.fid, + areq, + AFS_STATS_FS_RPCIDX_STORESTATUS, + SHARED_LOCK, + NULL)); } /* if (afs_GenStoreStatus() > 0)*/ } /* disconnected SETATTR */ @@ -1055,7 +1063,7 @@ afs_SendChanges(struct vcache *avc, struct vrequest *areq) /* Truncate OP: */ do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { /* Set storing flags. XXX: A tad inefficient ... */ if (avc->f.ddirty_flags & VDisconWriteClose) @@ -1072,12 +1080,13 @@ afs_SendChanges(struct vcache *avc, struct vrequest *areq) code = -1; } while (afs_Analyze(tc, - code, - &avc->f.fid, - areq, - AFS_STATS_FS_RPCIDX_STOREDATA, - SHARED_LOCK, - NULL)); + rxconn, + code, + &avc->f.fid, + areq, + AFS_STATS_FS_RPCIDX_STOREDATA, + SHARED_LOCK, + NULL)); } /* disconnected TRUNC | WRITE */ @@ -1101,6 +1110,7 @@ int afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred) { struct afs_conn *tc; + struct rx_connection *rxconn; struct vcache *tvc; struct AFSFetchStatus fstat; struct AFSCallBack callback; @@ -1141,11 +1151,11 @@ afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred) #if 0 /* Get server write lock. */ do { - tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETLOCK); RX_AFS_GUNLOCK(); - code = RXAFS_SetLock(tc->id, + code = RXAFS_SetLock(rxconn, (struct AFSFid *)&tvc->f.fid.Fid, LockWrite, &tsync); @@ -1155,12 +1165,13 @@ afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred) code = -1; } while (afs_Analyze(tc, - code, - &tvc->f.fid, - areq, - AFS_STATS_FS_RPCIDX_SETLOCK, - SHARED_LOCK, - NULL)); + rxconn, + code, + &tvc->f.fid, + areq, + AFS_STATS_FS_RPCIDX_SETLOCK, + SHARED_LOCK, + NULL)); if (code) goto next_file; @@ -1174,13 +1185,13 @@ afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred) /* Issue a FetchStatus to get info about DV and callbacks. */ do { - tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { tvc->callback = tc->srvr->server; start = osi_Time(); XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHSTATUS); RX_AFS_GUNLOCK(); - code = RXAFS_FetchStatus(tc->id, + code = RXAFS_FetchStatus(rxconn, (struct AFSFid *)&tvc->f.fid.Fid, &fstat, &callback, @@ -1191,12 +1202,13 @@ afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred) code = -1; } while (afs_Analyze(tc, - code, - &tvc->f.fid, - areq, - AFS_STATS_FS_RPCIDX_FETCHSTATUS, - SHARED_LOCK, - NULL)); + rxconn, + code, + &tvc->f.fid, + areq, + AFS_STATS_FS_RPCIDX_FETCHSTATUS, + SHARED_LOCK, + NULL)); if (code) { goto unlock_srv_file; @@ -1230,11 +1242,11 @@ unlock_srv_file: /* Release server write lock. */ #if 0 do { - tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RELEASELOCK); RX_AFS_GUNLOCK(); - ucode = RXAFS_ReleaseLock(tc->id, + ucode = RXAFS_ReleaseLock(rxconn, (struct AFSFid *) &tvc->f.fid.Fid, &tsync); RX_AFS_GLOCK(); @@ -1242,12 +1254,13 @@ unlock_srv_file: } else ucode = -1; } while (afs_Analyze(tc, - ucode, - &tvc->f.fid, - areq, - AFS_STATS_FS_RPCIDX_RELEASELOCK, - SHARED_LOCK, - NULL)); + rxconn, + ucode, + &tvc->f.fid, + areq, + AFS_STATS_FS_RPCIDX_RELEASELOCK, + SHARED_LOCK, + NULL)); #endif next_file: ObtainWriteLock(&afs_disconDirtyLock, 710); diff --git a/src/afs/afs_fetchstore.c b/src/afs/afs_fetchstore.c index f34c96eb7..34736469e 100644 --- a/src/afs/afs_fetchstore.c +++ b/src/afs/afs_fetchstore.c @@ -361,9 +361,10 @@ struct storeOps rxfs_storeMemOps = { }; afs_int32 -rxfs_storeInit(struct vcache *avc, struct afs_conn *tc, afs_size_t base, - afs_size_t bytes, afs_size_t length, - int sync, struct storeOps **ops, void **rock) +rxfs_storeInit(struct vcache *avc, struct afs_conn *tc, + struct rx_connection *rxconn, afs_size_t base, + afs_size_t bytes, afs_size_t length, + int sync, struct storeOps **ops, void **rock) { afs_int32 code; struct rxfs_storeVariables *v; @@ -582,6 +583,7 @@ afs_CacheStoreVCache(struct dcache **dcList, struct vcache *avc, int nomore; unsigned int first = 0; struct afs_conn *tc; + struct rx_connection *rxconn; for (bytes = 0, j = 0; !code && j <= high; j++) { if (dcList[j]) { @@ -626,12 +628,12 @@ afs_CacheStoreVCache(struct dcache **dcList, struct vcache *avc, ICL_HANDLE_OFFSET(length)); do { - tc = afs_Conn(&avc->f.fid, areq, 0); + tc = afs_Conn(&avc->f.fid, areq, 0, &rxconn); #ifdef AFS_64BIT_CLIENT restart: #endif - code = rxfs_storeInit(avc, tc, base, bytes, length, + code = rxfs_storeInit(avc, tc, rxconn, base, bytes, length, sync, &ops, &rock); if ( !code ) { code = afs_CacheStoreDCaches(avc, dclist, bytes, anewDV, @@ -646,7 +648,7 @@ afs_CacheStoreVCache(struct dcache **dcList, struct vcache *avc, } #endif /* AFS_64BIT_CLIENT */ } while (afs_Analyze - (tc, code, &avc->f.fid, areq, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA, SHARED_LOCK, NULL)); @@ -895,7 +897,8 @@ struct fetchOps rxfs_fetchMemOps = { }; afs_int32 -rxfs_fetchInit(struct afs_conn *tc, struct vcache *avc, afs_offs_t base, +rxfs_fetchInit(struct afs_conn *tc, struct rx_connection *rxconn, + struct vcache *avc, afs_offs_t base, afs_uint32 size, afs_int32 *alength, struct dcache *adc, struct osi_file *fP, struct fetchOps **ops, void **rock) { @@ -913,7 +916,7 @@ rxfs_fetchInit(struct afs_conn *tc, struct vcache *avc, afs_offs_t base, memset(v, 0, sizeof(struct rxfs_fetchVariables)); RX_AFS_GUNLOCK(); - v->call = rx_NewCall(tc->id); + v->call = rx_NewCall(rxconn); RX_AFS_GLOCK(); if (v->call) { #ifdef AFS_64BIT_CLIENT @@ -950,7 +953,7 @@ rxfs_fetchInit(struct afs_conn *tc, struct vcache *avc, afs_offs_t base, pos = base; RX_AFS_GUNLOCK(); if (!v->call) - v->call = rx_NewCall(tc->id); + v->call = rx_NewCall(rxconn); code = StartRXAFS_FetchData( v->call, (struct AFSFid*)&avc->f.fid.Fid, @@ -1055,6 +1058,7 @@ rxfs_fetchInit(struct afs_conn *tc, struct vcache *avc, afs_offs_t base, * that more has arrived. * * \param tc Ptr to the Rx connection structure. + * \param rxconn Ptr to the Rx connection structure. * \param fP File descriptor for the cache file. * \param base Base offset to fetch. * \param adc Ptr to the dcache entry for the file, write-locked. @@ -1065,7 +1069,8 @@ rxfs_fetchInit(struct afs_conn *tc, struct vcache *avc, afs_offs_t base, * \note Environment: Nothing interesting. */ int -afs_CacheFetchProc(struct afs_conn *tc, struct osi_file *fP, afs_size_t base, +afs_CacheFetchProc(struct afs_conn *tc, struct rx_connection *rxconn, + struct osi_file *fP, afs_size_t base, struct dcache *adc, struct vcache *avc, afs_int32 size, struct afs_FetchOutput *tsmall) { @@ -1094,7 +1099,7 @@ afs_CacheFetchProc(struct afs_conn *tc, struct osi_file *fP, afs_size_t base, * adc->lock(W) */ code = rxfs_fetchInit( - tc, avc, base, size, &length, adc, fP, &ops, &rock); + tc, rxconn, avc, base, size, &length, adc, fP, &ops, &rock); #ifndef AFS_NOSTATS osi_GetuTime(&xferStartTime); diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index f2825102c..4edeadac0 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -1403,6 +1403,7 @@ DECL_PIOCTL(PSetAcl) struct AFSOpaque acl; struct AFSVolSync tsync; struct AFSFetchStatus OutStatus; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PSetAcl); @@ -1416,19 +1417,19 @@ DECL_PIOCTL(PSetAcl) return EINVAL; do { - tconn = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tconn = afs_Conn(&avc->f.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->f.fid.Fid, + RXAFS_StoreACL(rxconn, (struct AFSFid *)&avc->f.fid.Fid, &acl, &OutStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STOREACL, + (tconn, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STOREACL, SHARED_LOCK, NULL)); /* now we've forgotten all of the access info */ @@ -1543,6 +1544,7 @@ DECL_PIOCTL(PGetAcl) afs_int32 code; struct afs_conn *tconn; struct AFSFid Fid; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PGetAcl); @@ -1565,18 +1567,18 @@ DECL_PIOCTL(PGetAcl) } acl.AFSOpaque_val = aout->ptr; do { - tconn = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tconn = afs_Conn(&avc->f.fid, areq, SHARED_LOCK, &rxconn); if (tconn) { acl.AFSOpaque_val[0] = '\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->f.fid, areq, AFS_STATS_FS_RPCIDX_FETCHACL, + (tconn, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_FETCHACL, SHARED_LOCK, NULL)); if (code == 0) { @@ -1921,6 +1923,7 @@ DECL_PIOCTL(PGetVolumeStatus) afs_int32 code = 0; struct AFSFetchVolumeStatus volstat; char *Name; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PGetVolumeStatus); @@ -1930,19 +1933,19 @@ DECL_PIOCTL(PGetVolumeStatus) } Name = volName; do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS); RX_AFS_GUNLOCK(); code = - RXAFS_GetVolumeStatus(tc->id, avc->f.fid.Fid.Volume, &volstat, + RXAFS_GetVolumeStatus(rxconn, avc->f.fid.Fid.Volume, &volstat, &Name, &offLineMsg, &motd); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS, SHARED_LOCK, NULL)); if (code) @@ -1996,6 +1999,7 @@ DECL_PIOCTL(PSetVolumeStatus) struct AFSFetchVolumeStatus volstat; struct AFSStoreVolumeStatus storeStat; struct volume *tvp; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PSetVolumeStatus); @@ -2043,19 +2047,19 @@ DECL_PIOCTL(PSetVolumeStatus) storeStat.Mask |= AFS_SETMAXQUOTA; } do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS); RX_AFS_GUNLOCK(); code = - RXAFS_SetVolumeStatus(tc->id, avc->f.fid.Fid.Volume, &storeStat, + RXAFS_SetVolumeStatus(rxconn, avc->f.fid.Fid.Volume, &storeStat, volName, offLineMsg, motd); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS, SHARED_LOCK, NULL)); if (code) @@ -2897,6 +2901,7 @@ DECL_PIOCTL(PRemoveCallBack) struct AFSCallBack CallBacks_Array[1]; struct AFSCBFids theFids; struct AFSCBs theCBs; + struct rx_connection *rxconn; XSTATS_DECLS; AFS_STATCNT(PRemoveCallBack); @@ -2912,17 +2917,17 @@ DECL_PIOCTL(PRemoveCallBack) CallBacks_Array[0].CallBackType = CB_DROPPED; if (avc->callback) { do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.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->f.fid, areq, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS, SHARED_LOCK, NULL)); ObtainWriteLock(&afs_xcbhash, 457); @@ -3163,6 +3168,7 @@ DECL_PIOCTL(PRemoveMount) struct AFSFetchStatus OutDirStatus; struct VenusFid tfid; struct AFSVolSync tsync; + struct rx_connection *rxconn; XSTATS_DECLS; /* "ain" is the name of the file in this dir to remove */ @@ -3230,19 +3236,19 @@ DECL_PIOCTL(PRemoveMount) ObtainWriteLock(&avc->lock, 231); osi_dnlc_remove(avc, bufp, tvc); do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.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->f.fid.Fid, bufp, + RXAFS_RemoveFile(rxconn, (struct AFSFid *)&avc->f.fid.Fid, bufp, &OutDirStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_REMOVEFILE, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_REMOVEFILE, SHARED_LOCK, NULL)); if (code) { @@ -4841,6 +4847,7 @@ DECL_PIOCTL(PPrefetchFromTape) struct VenusFid tfid; struct AFSFid *Fid; struct vcache *tvc; + struct rx_connection *rxconn; AFS_STATCNT(PSetAcl); if (!avc) @@ -4865,11 +4872,11 @@ DECL_PIOCTL(PPrefetchFromTape) ICL_TYPE_FID, &tfid, ICL_TYPE_FID, &tvc->f.fid); do { - tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&tvc->f.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->f.fid.Fid, 0, 0); @@ -4883,7 +4890,7 @@ DECL_PIOCTL(PPrefetchFromTape) } else code = -1; } while (afs_Analyze - (tc, code, &tvc->f.fid, areq, AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, + (tc, rxconn, code, &tvc->f.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); @@ -4904,6 +4911,7 @@ DECL_PIOCTL(PFsCmd) struct FsCmdOutputs *Outputs; struct VenusFid tfid; struct AFSFid *Fid; + struct rx_connection *rxconn; if (!avc) return EINVAL; @@ -4933,17 +4941,17 @@ DECL_PIOCTL(PFsCmd) if (Inputs->command) { do { - tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&tvc->f.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->f.fid, areq, + (tc, rxconn, code, &tvc->f.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); @@ -5029,6 +5037,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 */ @@ -5091,24 +5100,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 8ef955aa1..4d8a26e72 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -11,7 +11,8 @@ #define _AFS_PROTOTYPES_H_ /* afs_analyze.c */ -extern int afs_Analyze(struct afs_conn *aconn, afs_int32 acode, +extern int afs_Analyze(struct afs_conn *aconn, + struct rx_connection *rxconn, afs_int32 acode, struct VenusFid *afid, struct vrequest *areq, int op, afs_int32 locktype, struct cell *cellp); @@ -174,21 +175,27 @@ extern afs_int32 cryptall; extern afs_rwlock_t afs_xinterface; extern afs_rwlock_t afs_xconn; extern struct afs_conn *afs_Conn(struct VenusFid *afid, - struct vrequest *areq, - afs_int32 locktype); + struct vrequest *areq, + 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, 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(struct afs_conn *ac, afs_int32 locktype); + afs_int32 locktype, + struct rx_connection **rxconn); +extern void afs_PutConn(struct afs_conn *ac, + struct rx_connection *rxconn, + afs_int32 locktype); extern void ForceNewConnections(struct srvAddr *sap); @@ -493,10 +500,11 @@ extern int afs_CacheStoreVCache(struct dcache **dcList, struct vcache *avc, unsigned int high, unsigned int moredata, afs_hyper_t *anewDV, afs_size_t *amaxStoredLength); -extern int afs_CacheFetchProc(struct afs_conn *tc, struct osi_file *fP, - afs_size_t abase, struct dcache *adc, - struct vcache *avc, afs_int32 size, - struct afs_FetchOutput *tsmall); +extern int afs_CacheFetchProc(struct afs_conn *tc, struct rx_connection *rxconn, + struct osi_file *fP, + afs_size_t abase, struct dcache *adc, + struct vcache *avc, afs_int32 size, + struct afs_FetchOutput *tsmall); /* afs_memcache.c */ extern int afs_InitMemCache(int blkCount, int blkSize, int flags); diff --git a/src/afs/afs_segments.c b/src/afs/afs_segments.c index 911504c22..e5c9eb257 100644 --- a/src/afs/afs_segments.c +++ b/src/afs/afs_segments.c @@ -44,6 +44,7 @@ afs_StoreMini(struct vcache *avc, struct vrequest *areq) struct AFSVolSync tsync; afs_int32 code; struct rx_call *tcall; + struct rx_connection *rxconn; afs_size_t tlen, xlen = 0; XSTATS_DECLS; AFS_STATCNT(afs_StoreMini); @@ -56,13 +57,13 @@ afs_StoreMini(struct vcache *avc, struct vrequest *areq) avc->f.states &= ~CExtendedFile; do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK, &rxconn); if (tc) { #ifdef AFS_64BIT_CLIENT retry: #endif 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 @@ -126,7 +127,7 @@ afs_StoreMini(struct vcache *avc, struct vrequest *areq) } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STOREDATA, SHARED_LOCK, NULL)); if (code == 0) diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 049829627..a9fd5d993 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -288,6 +288,7 @@ CheckVLServer(struct srvAddr *sa, struct vrequest *areq) struct server *aserver = sa->server; struct afs_conn *tc; afs_int32 code; + struct rx_connection *rxconn; AFS_STATCNT(CheckVLServer); /* Ping dead servers to see if they're back */ @@ -298,16 +299,16 @@ CheckVLServer(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 @@ -593,6 +594,8 @@ afs_CheckServers(int adown, struct cell *acellp) memset(caps, 0, j * sizeof(Capabilities)); for (i = 0; i < j; i++) { + struct rx_connection *rxconn; + deltas[i] = 0; sa = addrs[i]; ts = sa->server; @@ -621,7 +624,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; @@ -629,9 +632,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; @@ -681,7 +684,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) @@ -799,7 +802,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)); @@ -1698,6 +1701,7 @@ afs_GetCapabilities(struct server *ts) struct vrequest treq; struct afs_conn *tc; struct unixuser *tu; + struct rx_connection *rxconn; afs_int32 code; if ( !ts || !ts->cell ) @@ -1711,17 +1715,18 @@ afs_GetCapabilities(struct server *ts) if ( !tu ) return; tc = afs_ConnBySA(ts->addr, ts->cell->fsport, ts->cell->cellNum, tu, 0, 1, - SHARED_LOCK); + SHARED_LOCK, + &rxconn); afs_PutUser(tu, SHARED_LOCK); if ( !tc ) return; /* InitCallBackStateN, triggered by our RPC, may need this */ ReleaseWriteLock(&afs_xserver); - code = RXAFS_GetCapabilities(tc->id, &caps); + code = RXAFS_GetCapabilities(rxconn, &caps); ObtainWriteLock(&afs_xserver, 723); /* we forced a conn above; important we mark it down if needed */ if ((code < 0) && (code != RXGEN_OPCODE)) { - afs_PutConn(tc, SHARED_LOCK); + afs_PutConn(tc, rxconn, SHARED_LOCK); afs_ServerDown(tc->srvr); ForceNewConnections(tc->srvr); /* multi homed clients */ } diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index d775b7c40..0f3eee486 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -396,6 +396,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. @@ -409,20 +410,20 @@ afs_FlushVCBs(afs_int32 lockit) for (safety3 = 0; safety3 < AFS_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; @@ -960,6 +961,7 @@ afs_FlushActiveVcaches(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); @@ -968,12 +970,12 @@ afs_FlushActiveVcaches(afs_int32 doflocks) afs_InitReq(&treq, afs_osi_credp); treq.flags |= O_NONBLOCK; - tc = afs_Conn(&tvc->f.fid, &treq, SHARED_LOCK); + tc = afs_Conn(&tvc->f.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->f.fid.Fid, &tsync); RX_AFS_GLOCK(); @@ -981,7 +983,7 @@ afs_FlushActiveVcaches(afs_int32 doflocks) } else code = -1; } while (afs_Analyze - (tc, code, &tvc->f.fid, &treq, + (tc, rxconn, code, &tvc->f.fid, &treq, AFS_STATS_FS_RPCIDX_EXTENDLOCK, SHARED_LOCK, NULL)); ReleaseWriteLock(&tvc->lock); @@ -1266,24 +1268,25 @@ afs_WriteVCache(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->f.m.Length)); do { - tc = afs_Conn(&avc->f.fid, areq, SHARED_LOCK); + tc = afs_Conn(&avc->f.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->f.fid.Fid, + RXAFS_StoreStatus(rxconn, (struct AFSFid *)&avc->f.fid.Fid, astatus, &OutStatus, &tsync); RX_AFS_GLOCK(); XSTATS_END_TIME; } else code = -1; } while (afs_Analyze - (tc, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STORESTATUS, + (tc, rxconn, code, &avc->f.fid, areq, AFS_STATS_FS_RPCIDX_STORESTATUS, SHARED_LOCK, NULL)); UpgradeSToWLock(&avc->lock, 20); @@ -1535,12 +1538,13 @@ afs_RemoteLookup(struct VenusFid *afid, struct vrequest *areq, afs_int32 code; afs_uint32 start; 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; @@ -1548,7 +1552,7 @@ afs_RemoteLookup(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(); @@ -1556,7 +1560,7 @@ afs_RemoteLookup(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; @@ -2316,9 +2320,10 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid, struct afs_conn *tc; struct AFSCallBack CallBack; struct AFSVolSync tsync; + 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; @@ -2326,7 +2331,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(); @@ -2335,7 +2340,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 248d48c74..93c85b17d 100644 --- a/src/afs/afs_volume.c +++ b/src/afs/afs_volume.c @@ -736,6 +736,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; @@ -760,34 +761,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; @@ -798,7 +799,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) { @@ -1110,6 +1111,7 @@ InstallUVolumeEntry(struct volume *av, struct uvldbentry *ve, int acell, bulkaddrs addrs; ListAddrByAttributes attrs; afsUUID uuid; + struct rx_connection *rxconn; memset(&attrs, 0, sizeof(attrs)); attrs.Mask = VLADDR_UUID; @@ -1119,11 +1121,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 { @@ -1135,7 +1138,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; -- 2.39.5