|
|
@ -758,6 +758,7 @@ static char *set_quota(char *arg) |
|
|
|
pool = add_url(); |
|
|
|
pool = add_url(); |
|
|
|
setup_url(pool, url); |
|
|
|
setup_url(pool, url); |
|
|
|
pool->quota = quota; |
|
|
|
pool->quota = quota; |
|
|
|
|
|
|
|
applog(LOG_INFO, "Setting pool %d to quota %d", pool->pool_no, pool->quota); |
|
|
|
|
|
|
|
|
|
|
|
return NULL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
@ -1184,7 +1185,7 @@ static struct opt_table opt_config_table[] = { |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
OPT_WITHOUT_ARG("--load-balance", |
|
|
|
OPT_WITHOUT_ARG("--load-balance", |
|
|
|
set_loadbalance, &pool_strategy, |
|
|
|
set_loadbalance, &pool_strategy, |
|
|
|
"Change multipool strategy from failover to efficiency based balance"), |
|
|
|
"Change multipool strategy from failover to quota based balance"), |
|
|
|
OPT_WITH_ARG("--log|-l", |
|
|
|
OPT_WITH_ARG("--log|-l", |
|
|
|
set_int_0_to_9999, opt_show_intval, &opt_log_interval, |
|
|
|
set_int_0_to_9999, opt_show_intval, &opt_log_interval, |
|
|
|
"Interval in seconds between log output"), |
|
|
|
"Interval in seconds between log output"), |
|
|
@ -2814,12 +2815,16 @@ static struct pool *select_balanced(struct pool *cp) |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Select any active pool in a rotating fashion when loadbalance is chosen */ |
|
|
|
static struct pool *priority_pool(int choice); |
|
|
|
|
|
|
|
static bool pool_unusable(struct pool *pool); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Select any active pool in a rotating fashion when loadbalance is chosen if
|
|
|
|
|
|
|
|
* it has any quota left. */ |
|
|
|
static inline struct pool *select_pool(bool lagging) |
|
|
|
static inline struct pool *select_pool(bool lagging) |
|
|
|
{ |
|
|
|
{ |
|
|
|
static int rotating_pool = 0; |
|
|
|
static int rotating_pool = 0; |
|
|
|
struct pool *pool, *cp; |
|
|
|
struct pool *pool, *cp; |
|
|
|
int tested; |
|
|
|
int tested, i; |
|
|
|
|
|
|
|
|
|
|
|
cp = current_pool(); |
|
|
|
cp = current_pool(); |
|
|
|
|
|
|
|
|
|
|
@ -2834,17 +2839,37 @@ static inline struct pool *select_pool(bool lagging) |
|
|
|
/* Try to find the first pool in the rotation that is usable */ |
|
|
|
/* Try to find the first pool in the rotation that is usable */ |
|
|
|
tested = 0; |
|
|
|
tested = 0; |
|
|
|
while (!pool && tested++ < total_pools) { |
|
|
|
while (!pool && tested++ < total_pools) { |
|
|
|
if (++rotating_pool >= total_pools) |
|
|
|
|
|
|
|
rotating_pool = 0; |
|
|
|
|
|
|
|
pool = pools[rotating_pool]; |
|
|
|
pool = pools[rotating_pool]; |
|
|
|
|
|
|
|
if (pool->quota_used++ >= pool->quota) { |
|
|
|
|
|
|
|
pool->quota_used = 0; |
|
|
|
|
|
|
|
pool = NULL; |
|
|
|
|
|
|
|
if (++rotating_pool >= total_pools) |
|
|
|
|
|
|
|
rotating_pool = 0; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
if (!pool_unworkable(pool)) |
|
|
|
if (!pool_unworkable(pool)) |
|
|
|
break; |
|
|
|
break; |
|
|
|
pool = NULL; |
|
|
|
pool = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* If there are no alive pools with quota, choose according to
|
|
|
|
|
|
|
|
* priority. */ |
|
|
|
|
|
|
|
if (!pool) { |
|
|
|
|
|
|
|
for (i = 0; i < total_pools; i++) { |
|
|
|
|
|
|
|
struct pool *tp = priority_pool(i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!pool_unusable(tp)) { |
|
|
|
|
|
|
|
pool = tp; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* If still nothing is usable, use the current pool */ |
|
|
|
/* If still nothing is usable, use the current pool */ |
|
|
|
if (!pool) |
|
|
|
if (!pool) |
|
|
|
pool = cp; |
|
|
|
pool = cp; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "Selecting pool %d for work", pool->pool_no); |
|
|
|
return pool; |
|
|
|
return pool; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3573,7 +3598,7 @@ void switch_pools(struct pool *selected) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (pool_strategy) { |
|
|
|
switch (pool_strategy) { |
|
|
|
/* Both of these set to the master pool */ |
|
|
|
/* All of these set to the master pool */ |
|
|
|
case POOL_BALANCE: |
|
|
|
case POOL_BALANCE: |
|
|
|
case POOL_FAILOVER: |
|
|
|
case POOL_FAILOVER: |
|
|
|
case POOL_LOADBALANCE: |
|
|
|
case POOL_LOADBALANCE: |
|
|
|