mirror of
https://github.com/samba-team/samba.git
synced 2025-02-26 21:57:41 +03:00
ctdb-ipalloc: Optimise check to see if IPs can be hosted
Add an early return if there are no known IP addresses. Also add an extra comment for clarification. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12254 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
dfc3b8855d
commit
fed251726f
@ -245,12 +245,14 @@ bool ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
|
|||||||
bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state)
|
bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
bool have_ips = false;
|
||||||
|
|
||||||
for (i=0; i < ipalloc_state->num; i++) {
|
for (i=0; i < ipalloc_state->num; i++) {
|
||||||
struct ctdb_public_ip_list *ips =
|
struct ctdb_public_ip_list *ips =
|
||||||
ipalloc_state->known_public_ips;
|
ipalloc_state->known_public_ips;
|
||||||
if (ips[i].num != 0) {
|
if (ips[i].num != 0) {
|
||||||
int j;
|
int j;
|
||||||
|
have_ips = true;
|
||||||
/* Succeed if an address is hosted on node i */
|
/* Succeed if an address is hosted on node i */
|
||||||
for (j=0; j < ips[i].num; j++) {
|
for (j=0; j < ips[i].num; j++) {
|
||||||
if (ips[i].ip[j].pnn == i) {
|
if (ips[i].ip[j].pnn == i) {
|
||||||
@ -260,6 +262,14 @@ bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! have_ips) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* At this point there are known addresses but none are
|
||||||
|
* hosted. Need to check if cluster can now host some
|
||||||
|
* addresses.
|
||||||
|
*/
|
||||||
for (i=0; i < ipalloc_state->num; i++) {
|
for (i=0; i < ipalloc_state->num; i++) {
|
||||||
if (ipalloc_state->available_public_ips[i].num != 0) {
|
if (ipalloc_state->available_public_ips[i].num != 0) {
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user