Commit 073fc1a8 authored by Julian Anastasov's avatar Julian Anastasov Committed by David S. Miller

[IPVS]: The NQ scheduler must not return servers with weight 0.

parent 2d30c35b
...@@ -81,8 +81,8 @@ ip_vs_nq_dest_overhead(struct ip_vs_dest *dest) ...@@ -81,8 +81,8 @@ ip_vs_nq_dest_overhead(struct ip_vs_dest *dest)
static struct ip_vs_dest * static struct ip_vs_dest *
ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph) ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph)
{ {
struct ip_vs_dest *dest, *least; struct ip_vs_dest *dest, *least = NULL;
unsigned int loh, doh; unsigned int loh = 0, doh;
IP_VS_DBG(6, "ip_vs_nq_schedule(): Scheduling...\n"); IP_VS_DBG(6, "ip_vs_nq_schedule(): Scheduling...\n");
...@@ -99,27 +99,10 @@ ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph) ...@@ -99,27 +99,10 @@ ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* new connections. * new connections.
*/ */
list_for_each_entry(least, &svc->destinations, n_list) {
if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
atomic_read(&least->weight) > 0) {
loh = ip_vs_nq_dest_overhead(least);
/* return the server directly if it is idle */
if (atomic_read(&least->activeconns) == 0)
goto out;
goto nextstage;
}
}
return NULL;
/*
* Find the destination with the least load.
*/
nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) { list_for_each_entry(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD) if (dest->flags & IP_VS_DEST_F_OVERLOAD ||
!atomic_read(&dest->weight))
continue; continue;
doh = ip_vs_nq_dest_overhead(dest); doh = ip_vs_nq_dest_overhead(dest);
...@@ -127,16 +110,21 @@ ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph) ...@@ -127,16 +110,21 @@ ip_vs_nq_schedule(struct ip_vs_service *svc, struct iphdr *iph)
/* return the server directly if it is idle */ /* return the server directly if it is idle */
if (atomic_read(&dest->activeconns) == 0) { if (atomic_read(&dest->activeconns) == 0) {
least = dest; least = dest;
loh = doh;
goto out; goto out;
} }
if (loh * atomic_read(&dest->weight) > if (!least ||
doh * atomic_read(&least->weight)) { (loh * atomic_read(&dest->weight) >
doh * atomic_read(&least->weight))) {
least = dest; least = dest;
loh = doh; loh = doh;
} }
} }
if (!least)
return NULL;
out: out:
IP_VS_DBG(6, "NQ: server %u.%u.%u.%u:%u " IP_VS_DBG(6, "NQ: server %u.%u.%u.%u:%u "
"activeconns %d refcnt %d weight %d overhead %d\n", "activeconns %d refcnt %d weight %d overhead %d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment