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

[IPVS]: Use list_for_each_entry_continue in some schedulers.

parent 073fc1a8
......@@ -458,10 +458,11 @@ __ip_vs_wlc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* The server with weight=0 is quiesced and will not receive any
* new connection.
*/
list_for_each_entry(least, &svc->destinations, n_list) {
if (least->flags & IP_VS_DEST_F_OVERLOAD)
list_for_each_entry(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
if (atomic_read(&least->weight) > 0) {
if (atomic_read(&dest->weight) > 0) {
least = dest;
loh = atomic_read(&least->activeconns) * 50
+ atomic_read(&least->inactconns);
goto nextstage;
......@@ -473,7 +474,7 @@ __ip_vs_wlc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* Find the destination with the least load.
*/
nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) {
list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
......
......@@ -711,11 +711,12 @@ __ip_vs_wlc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* The server with weight=0 is quiesced and will not receive any
* new connection.
*/
list_for_each_entry(least, &svc->destinations, n_list) {
if (least->flags & IP_VS_DEST_F_OVERLOAD)
list_for_each_entry(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
if (atomic_read(&least->weight) > 0) {
if (atomic_read(&dest->weight) > 0) {
least = dest;
loh = atomic_read(&least->activeconns) * 50
+ atomic_read(&least->inactconns);
goto nextstage;
......@@ -727,7 +728,7 @@ __ip_vs_wlc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* Find the destination with the least load.
*/
nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) {
list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
......
......@@ -65,8 +65,8 @@ ip_vs_lc_dest_overhead(struct ip_vs_dest *dest)
static struct ip_vs_dest *
ip_vs_lc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
{
struct ip_vs_dest *dest, *least;
unsigned int loh, doh;
struct ip_vs_dest *dest, *least = NULL;
unsigned int loh = 0, doh;
IP_VS_DBG(6, "ip_vs_lc_schedule(): Scheduling...\n");
......@@ -79,31 +79,18 @@ ip_vs_lc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* served, but no new connection is assigned to the server.
*/
list_for_each_entry(least, &svc->destinations, n_list) {
if (least->flags & IP_VS_DEST_F_OVERLOAD)
continue;
if (atomic_read(&least->weight) > 0) {
loh = ip_vs_lc_dest_overhead(least);
goto nextstage;
}
}
return NULL;
/*
* Find the destination with the least load.
*/
nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) {
if ((dest->flags & IP_VS_DEST_F_OVERLOAD) ||
atomic_read(&dest->weight) == 0)
continue;
doh = ip_vs_lc_dest_overhead(dest);
if (doh < loh) {
if (!least || doh < loh) {
least = dest;
loh = doh;
}
}
if (least)
IP_VS_DBG(6, "LC: server %u.%u.%u.%u:%u activeconns %d inactconns %d\n",
NIPQUAD(least->addr), ntohs(least->port),
atomic_read(&least->activeconns),
......
......@@ -103,9 +103,10 @@ ip_vs_sed_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* new connections.
*/
list_for_each_entry(least, &svc->destinations, n_list) {
if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
atomic_read(&least->weight) > 0) {
list_for_each_entry(dest, &svc->destinations, n_list) {
if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
atomic_read(&dest->weight) > 0) {
least = dest;
loh = ip_vs_sed_dest_overhead(least);
goto nextstage;
}
......@@ -116,7 +117,7 @@ ip_vs_sed_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* Find the destination with the least load.
*/
nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) {
list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
doh = ip_vs_sed_dest_overhead(dest);
......
......@@ -91,9 +91,10 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* new connections.
*/
list_for_each_entry(least, &svc->destinations, n_list) {
if (!(least->flags & IP_VS_DEST_F_OVERLOAD) &&
atomic_read(&least->weight) > 0) {
list_for_each_entry(dest, &svc->destinations, n_list) {
if (!(dest->flags & IP_VS_DEST_F_OVERLOAD) &&
atomic_read(&dest->weight) > 0) {
least = dest;
loh = ip_vs_wlc_dest_overhead(least);
goto nextstage;
}
......@@ -104,7 +105,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
* Find the destination with the least load.
*/
nextstage:
list_for_each_entry(dest, &svc->destinations, n_list) {
list_for_each_entry_continue(dest, &svc->destinations, n_list) {
if (dest->flags & IP_VS_DEST_F_OVERLOAD)
continue;
doh = ip_vs_wlc_dest_overhead(dest);
......
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