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