From: Andrew Deason Date: Wed, 2 Nov 2011 21:55:49 +0000 (-0500) Subject: afs: Do not use separate array for srvAddrs X-Git-Tag: upstream/1.8.0_pre1^2~3048 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=f199ac666195771a02e3ebb040c6e5fe47c58c58;p=packages%2Fo%2Fopenafs.git afs: Do not use separate array for srvAddrs The array of srvAddr structs we use in afs_LoopServers have indices unrelated to the indices of conns, rxconns, etc. Several places were assuming that addr[i] corresponded to conn[i], which is not necessarily true. So instead, do not use the separate addr array (except when populating the conn and rxconn arrays), and just get the srvAddr structure by going through the relevant conn[i]. Change-Id: Ib60126811f51943bfc81ab7c48d7f247f00f1cad Reviewed-on: http://gerrit.openafs.org/5790 Reviewed-by: Marc Dionne Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h index 708ba8070..945cfe568 100644 --- a/src/afs/afs_prototypes.h +++ b/src/afs/afs_prototypes.h @@ -869,14 +869,10 @@ extern afs_int32 afs_ServerDown(struct srvAddr *sa); extern void afs_CountServers(void); extern void afs_CheckServers(int adown, struct cell *acellp); extern void afs_LoopServers(int adown, struct cell *acellp, int vlalso, - void (*func1) (struct rx_connection **rxconns, - int nconns, int nservers, - struct afs_conn **conns, - struct srvAddr **addrs), - void (*func2) (struct rx_connection **rxconns, - int nconns, int nservers, - struct afs_conn **conns, - struct srvAddr **addrs)); + void (*func1) (int nconns, struct rx_connection **rxconns, + struct afs_conn **conns), + void (*func2) (int nconns, struct rx_connection **rxconns, + struct afs_conn **conns)); extern unsigned int afs_random(void); extern int afs_randomMod15(void); extern int afs_randomMod127(void); diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 35151641d..ad28100f8 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -552,19 +552,19 @@ CkSrv_MarkUpDown(struct afs_conn **conns, int nconns, afs_int32 *results) } void -CkSrv_GetCaps(struct rx_connection **rxconns, int nconns, int nservers, - struct afs_conn **conns, struct srvAddr **addrs) +CkSrv_GetCaps(int nconns, struct rx_connection **rxconns, + struct afs_conn **conns) { Capabilities *caps; afs_int32 *results; afs_int32 i; struct server *ts; - caps = afs_osi_Alloc(nservers * sizeof (Capabilities)); + caps = afs_osi_Alloc(nconns * sizeof (Capabilities)); osi_Assert(caps != NULL); - memset(caps, 0, nservers * sizeof(Capabilities)); + memset(caps, 0, nconns * sizeof(Capabilities)); - results = afs_osi_Alloc(nservers * sizeof (afs_int32)); + results = afs_osi_Alloc(nconns * sizeof (afs_int32)); osi_Assert(results != NULL); AFS_GUNLOCK(); @@ -576,7 +576,7 @@ CkSrv_GetCaps(struct rx_connection **rxconns, int nconns, int nservers, AFS_GLOCK(); for ( i = 0 ; i < nconns ; i++ ) { - ts = addrs[i]->server; + ts = conns[i]->parent->srvr->server; if ( !ts ) continue; ts->capabilities = 0; @@ -597,8 +597,8 @@ CkSrv_GetCaps(struct rx_connection **rxconns, int nconns, int nservers, } CkSrv_MarkUpDown(conns, nconns, results); - afs_osi_Free(caps, nservers * sizeof(Capabilities)); - afs_osi_Free(results, nservers * sizeof(afs_int32)); + afs_osi_Free(caps, nconns * sizeof(Capabilities)); + afs_osi_Free(results, nconns * sizeof(afs_int32)); } /* check down servers (if adown), or running servers (if !adown) */ @@ -613,12 +613,10 @@ afs_CheckServers(int adown, struct cell *acellp) * AFS_LS_ALL - check all */ void afs_LoopServers(int adown, struct cell *acellp, int vlalso, - void (*func1) (struct rx_connection **rxconns, int nconns, - int nservers, struct afs_conn **conns, - struct srvAddr **addrs), - void (*func2) (struct rx_connection **rxconns, int nconns, - int nservers, struct afs_conn **conns, - struct srvAddr **addrs)) + void (*func1) (int nservers, struct rx_connection **rxconns, + struct afs_conn **conns), + void (*func2) (int nservers, struct rx_connection **rxconns, + struct afs_conn **conns)) { struct vrequest treq; struct server *ts; @@ -632,7 +630,7 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, struct afs_conn **conns; int nconns; struct rx_connection **rxconns; - afs_int32 *conntimer, *results; + afs_int32 *conntimer; AFS_STATCNT(afs_CheckServers); @@ -680,8 +678,6 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, osi_Assert(rxconns != NULL); conntimer = afs_osi_Alloc(j * sizeof (afs_int32)); osi_Assert(conntimer != NULL); - results = afs_osi_Alloc(j * sizeof (afs_int32)); - osi_Assert(results != NULL); for (i = 0; i < j; i++) { struct rx_connection *rxconn; @@ -731,10 +727,13 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, } } /* Outer loop over addrs */ - (*func1)(rxconns, nconns, j, conns, addrs); + afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs)); + addrs = NULL; + + (*func1)(nconns, rxconns, conns); if (func2) { - (*func2)(rxconns, nconns, j, conns, addrs); + (*func2)(nconns, rxconns, conns); } for (i = 0; i < nconns; i++) { @@ -743,11 +742,9 @@ afs_LoopServers(int adown, struct cell *acellp, int vlalso, afs_PutConn(conns[i], rxconns[i], SHARED_LOCK); /* done with it now */ } - afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs)); afs_osi_Free(conns, j * sizeof(struct afs_conn *)); afs_osi_Free(rxconns, j * sizeof(struct rx_connection *)); afs_osi_Free(conntimer, j * sizeof(afs_int32)); - afs_osi_Free(results, j * sizeof(afs_int32)); } /*afs_CheckServers*/ diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index d93ed553a..08d54f56c 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -350,13 +350,13 @@ afs_FreeCBR(struct afs_cbr *asp) } static void -FlushAllVCBs(struct rx_connection **rxconns, int nconns, int nservers, - struct afs_conn **conns, struct srvAddr **addrs) +FlushAllVCBs(int nconns, struct rx_connection **rxconns, + struct afs_conn **conns) { afs_int32 *results; afs_int32 i; - results = afs_osi_Alloc(nservers * sizeof (afs_int32)); + results = afs_osi_Alloc(nconns * sizeof (afs_int32)); osi_Assert(results != NULL); AFS_GUNLOCK(); @@ -375,11 +375,11 @@ FlushAllVCBs(struct rx_connection **rxconns, int nconns, int nservers, for ( i = 0 ; i < nconns ; i++ ) { if (results[i] == 0) { /* Unchain all of them */ - while (addrs[i]->server->cbrs) - afs_FreeCBR(addrs[i]->server->cbrs); + while (conns[i]->parent->srvr->server->cbrs) + afs_FreeCBR(conns[i]->parent->srvr->server->cbrs); } } - afs_osi_Free(results, nservers * sizeof(afs_int32)); + afs_osi_Free(results, nconns * sizeof(afs_int32)); } /*!