1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00
samba-mirror/ctdb/server/ipalloc.h
Martin Schwenke 429377a242 ctdb-ipalloc: Optimise check to see if IP is available on a node
Use a "bitmap" of available IPs for each IP address instead of walking
the list of available IP addresses.

For ctdb/tests/takeover/lcp2.030.sh, this improves the time taken on
my laptop from:

  real	0m11.997s
  user	0m11.960s
  sys	0m0.000s

to

  real	0m8.571s
  user	0m8.544s
  sys	0m0.000s

So, when assigning all 900 IP addresses the improvement is about 25%.

For the no-op case (where all IPs are already assigned to nodes), the
extra setup adds a small fraction of a second for 900 IPs.
Intermediate cases result in intermediate improvements.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-12-02 00:24:28 +01:00

69 lines
1.9 KiB
C

/*
CTDB IP takeover code
Copyright (C) Ronnie Sahlberg 2007
Copyright (C) Andrew Tridgell 2007
Copyright (C) Martin Schwenke 2015
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CTDB_IPALLOC_H__
#define __CTDB_IPALLOC_H__
#include <talloc.h>
#include "replace.h"
#include "system/network.h"
struct public_ip_list {
struct public_ip_list *next;
uint32_t pnn;
ctdb_sock_addr addr;
bool *available_on;
};
#define IP_KEYLEN 4
uint32_t *ip_key(ctdb_sock_addr *ip);
/* Flags used in IP allocation algorithms. */
enum ipalloc_algorithm {
IPALLOC_DETERMINISTIC,
IPALLOC_NONDETERMINISTIC,
IPALLOC_LCP2,
};
struct ipalloc_state;
struct ipalloc_state * ipalloc_state_init(TALLOC_CTX *mem_ctx,
uint32_t num_nodes,
enum ipalloc_algorithm algorithm,
bool no_ip_failback,
uint32_t *force_rebalance_nodes);
void ipalloc_set_node_flags(struct ipalloc_state *ipalloc_state,
struct ctdb_node_map *nodemap,
uint32_t *tval_noiptakeover,
uint32_t *tval_noiphostonalldisabled);
void ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
struct ctdb_public_ip_list *known_ips,
struct ctdb_public_ip_list *available_ips);
bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state);
struct public_ip_list *ipalloc(struct ipalloc_state *ipalloc_state);
#endif /* __CTDB_IPALLOC_H__ */