source: vendor/current/ctdb/server/ipalloc_deterministic.c

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 1.8 KB
Line 
1/*
2 ctdb ip takeover code
3
4 Copyright (C) Ronnie Sahlberg 2007
5 Copyright (C) Andrew Tridgell 2007
6 Copyright (C) Martin Schwenke 2011
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see <http://www.gnu.org/licenses/>.
20*/
21
22#include "replace.h"
23#include "system/network.h"
24
25#include "lib/util/debug.h"
26#include "common/logging.h"
27
28#include "server/ipalloc_private.h"
29
30bool ipalloc_deterministic(struct ipalloc_state *ipalloc_state)
31{
32 struct public_ip_list *t;
33 int i, numnodes;
34
35 numnodes = ipalloc_state->num;
36
37 DEBUG(DEBUG_NOTICE,("Deterministic IPs enabled. Resetting all ip allocations\n"));
38 /* Allocate IPs to nodes in a modulo fashion so that IPs will
39 * always be allocated the same way for a specific set of
40 * available/unavailable nodes.
41 */
42
43 for (i = 0, t = ipalloc_state->all_ips; t!= NULL; t = t->next, i++) {
44 t->pnn = i % numnodes;
45 }
46
47 /* IP failback doesn't make sense with deterministic
48 * IPs, since the modulo step above implicitly fails
49 * back IPs to their "home" node.
50 */
51 if (1 == ipalloc_state->no_ip_failback) {
52 DEBUG(DEBUG_WARNING, ("WARNING: 'NoIPFailback' set but ignored - incompatible with 'DeterministicIPs\n"));
53 }
54
55 unassign_unsuitable_ips(ipalloc_state);
56
57 basic_allocate_unassigned(ipalloc_state);
58
59 /* No failback here! */
60
61 return true;
62}
Note: See TracBrowser for help on using the repository browser.