viced: Move host quota calculation
authorAndrew Deason <adeason@sinenomine.net>
Tue, 14 Aug 2012 22:25:44 +0000 (17:25 -0500)
committerDerrick Brashear <shadow@your-file-system.com>
Sun, 12 Jan 2014 19:37:07 +0000 (11:37 -0800)
Calculate this during initialization, not every time we want to use
it.

Change-Id: I931d2f3f0b4b99add682c098dd51f03c9942f5b4
Reviewed-on: http://gerrit.openafs.org/9710
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/viced/host.c
src/viced/host.h
src/viced/viced.c

index 33ff9c8..c24841c 100644 (file)
@@ -69,6 +69,7 @@ int rxcon_ident_key;
 int rxcon_client_key;
 
 static struct rx_securityClass *sc = NULL;
+static int h_quota_limit;
 
 /* arguments for PerHost_EnumerateClient enumeration */
 struct enumclient_args {
@@ -1606,18 +1607,8 @@ removeInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
 static int
 h_threadquota(int waiting)
 {
-    if (lwps > 64) {
-       if (waiting > 5)
-           return 1;
-    } else if (lwps > 32) {
-       if (waiting > 4)
-           return 1;
-    } else if (lwps > 16) {
-       if (waiting > 3)
-           return 1;
-    } else {
-       if (waiting > 2)
-           return 1;
+    if (waiting > h_quota_limit) {
+       return 1;
     }
     return 0;
 }
@@ -2185,8 +2176,11 @@ h_GetHost_r(struct rx_connection *tcon)
 
 /* not reentrant */
 void
-h_InitHostPackage(void)
+h_InitHostPackage(int hquota)
 {
+    opr_Assert(hquota > 0);
+    h_quota_limit = hquota;
+
     memset(&nulluuid, 0, sizeof(afsUUID));
     rxcon_ident_key = rx_KeyCreate((rx_destructor_t) free);
     rxcon_client_key = rx_KeyCreate((rx_destructor_t) 0);
index 8233869..06776a2 100644 (file)
@@ -225,7 +225,7 @@ extern void h_GetHostNetStats(afs_int32 * a_numHostsP, afs_int32 * a_sameNetOrSu
                  afs_int32 * a_diffSubnetP, afs_int32 * a_diffNetworkP);
 extern int h_NBLock_r(struct host *host);
 extern void h_DumpHosts(void);
-extern void h_InitHostPackage(void);
+extern void h_InitHostPackage(int hquota);
 extern void h_CheckHosts(void );
 extern void h_AddHostToAddrHashTable_r(afs_uint32 addr, afs_uint16 port, struct host * host);
 extern void h_AddHostToUuidHashTable_r(afsUUID * uuid, struct host * host);
index e47bcbc..5376074 100644 (file)
@@ -153,6 +153,7 @@ static int panic_timeout = 2 * 60;
 static int panic_timeout = 30 * 60;
 #endif
 
+static int host_thread_quota;
 int rxpackets = 150;           /* 100 */
 int nSmallVns = 400;           /* 200 */
 int large = 400;               /* 200 */
@@ -1433,6 +1434,16 @@ ParseArgs(int argc, char *argv[])
     if (auditFileName)
        osi_audit_file(auditFileName);
 
+    if (lwps > 64) {
+       host_thread_quota = 5;
+    } else if (lwps > 32) {
+       host_thread_quota = 4;
+    } else if (lwps > 16) {
+       host_thread_quota = 3;
+    } else {
+       host_thread_quota = 2;
+    }
+
     return (0);
 }                              /*ParseArgs */
 
@@ -2064,7 +2075,7 @@ main(int argc, char *argv[])
     }
 
     init_sys_error_to_et();    /* Set up error table translation */
-    h_InitHostPackage();       /* set up local cellname and realmname */
+    h_InitHostPackage(host_thread_quota); /* set up local cellname and realmname */
     InitCallBack(numberofcbs);
     ClearXStatValues();