]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: Do not use separate array for srvAddrs
authorAndrew Deason <adeason@sinenomine.net>
Wed, 2 Nov 2011 21:55:49 +0000 (16:55 -0500)
committerDerrick Brashear <shadow@dementix.org>
Sat, 12 Nov 2011 14:55:52 +0000 (06:55 -0800)
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 <marc.c.dionne@gmail.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
src/afs/afs_prototypes.h
src/afs/afs_server.c
src/afs/afs_vcache.c

index 708ba8070f7467d5fa57a275eaaa7f721e378adf..945cfe568ed0109a8a35469b723c8b294df6ea3d 100644 (file)
@@ -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);
index 35151641d69f0c6851e4a38f7e55a2a4afb94f9d..ad28100f8dea263d152c7d072c9fd3d2f3863b79 100644 (file)
@@ -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*/
 
index d93ed553aa4efd157017a29c1201e4ef5eb6bf74..08d54f56c3fa1cdc7e0b82272164820e82ab7849 100644 (file)
@@ -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));
 }
 
 /*!