1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

1938 Commits

Author SHA1 Message Date
Amitay Isaacs
e1fdfdd1c1 ctdb-recovery-helper: Write recovery records to a recovery file
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:15 +01:00
Amitay Isaacs
9058fe06df ctdb-recovery-helper: Re-factor function to retain records from recdb
Also, rename traverse function and traverse state for recdb_records
consistently.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:15 +01:00
Amitay Isaacs
a80ff09ed3 ctdb-recovery-helper: Create accessors for recdb structure fields
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:15 +01:00
Amitay Isaacs
70011a1bfb ctdb-recovery-helper: Rename pnn to dmaster in recdb_records()
This variable is used to set the dmaster value for each record in
recdb_traverse().

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:15 +01:00
Amitay Isaacs
5b926d882e ctdb-recovery-helper: Pass capabilities to database recovery functions
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:15 +01:00
Amitay Isaacs
5f43f92796 ctdb-recovery-helper: Factor out generic recv function
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:15 +01:00
Amitay Isaacs
95a15cde45 ctdb-daemon: Implement new controls DB_PULL and DB_PUSH_START/DB_PUSH_CONFIRM
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:15 +01:00
Amitay Isaacs
c41808e6d2 ctdb-tunables: Add new tunable RecBufferSizeLimit
This will be used to limit the size of record buffer sent in newer
controls for recovery and existing controls for vacuuming.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-25 03:26:14 +01:00
Martin Schwenke
e4f592539d ctdb-daemon: Replace an unsafe strcpy(3) call
Tweak another strncpy(3) call.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-03-22 00:23:20 +01:00
Martin Schwenke
0ffa5d8d9e ctdb-daemon: Validate length of new interface names
Interface names that are too long will be truncated by strncpy(3)
later on.  It is better to validate the length of each new interface
name to ensure it will be usable.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-03-22 00:23:20 +01:00
Volker Lendecke
deaab95b8d ctdb: Fix CID 1356313 Explicit null dereferenced
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-03-18 00:29:14 +01:00
Martin Schwenke
fa8bd41009 ctdb-tunables: Mark tunable DeferredRebalanceOnNodeAdd obsolete
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Mar 10 06:51:46 CET 2016 on sn-devel-144
2016-03-10 06:51:46 +01:00
Martin Schwenke
c9e69a4b2e ctdb-recoverd: Drop use of DeferredRebalanceOnNodeAdd tunable
If set, this was used to setup an IP takeover run on a timer after
certain updates to the public IP address configuration (e.g. "ctdb
addip").

However, "ctdb reloadips" completely manages public IP reconfiguration
and avoids the anomalies that DeferredRebalanceOnNodeAdd was
introduced to work around.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-03-10 03:34:19 +01:00
Martin Schwenke
aaa57fbcb3 ctdb-tools: Drop "ctdb rebalanceip"
This is undocumented and is not needed.  It was a workaround for
trying to ensure public IP addresses are properly rebalanced after
running "ctdb addip" on multiple nodes.  "ctdb reloadips" is a better
solution.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-03-10 03:34:19 +01:00
Amitay Isaacs
bd23b43bfe ctdb-tunables: Fix the implementation of LIST_TUNABLES control
Do not assume the first tunable is not obsolete.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-10 03:34:18 +01:00
Amitay Isaacs
700f39372a ctdb-recovery-helper: Get tunables first, so control timeout can be set
During the recovery process, the timeout value for sending all controls
is decided by RecoverTimeout tunable.  So in the recovery process,
first get the tunables, so the control timeout gets set correctly.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-10 03:34:18 +01:00
Amitay Isaacs
4a78200f43 ctdb-tunables: Mark tunable ReclockPingPeriod obsolete
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-10 03:34:18 +01:00
Amitay Isaacs
73ab0f9911 ctdb-tunables: Mark tunable MaxRedirectCount obsolete
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-10 03:34:18 +01:00
Amitay Isaacs
aa700deb64 ctdb-tunables: Add missing flags in the initializer
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-10 03:34:18 +01:00
Amitay Isaacs
ace23f0a81 ctdb-locking: Use real-time only for actual record or DB locking
Use real-time priority only for obtaining record and database locks.
Do not open databases with real-time priority as it can cause thundering
herd on fcntl lock while opening tdb database.  Also relinquish real-time
priority after the lock is obtained.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Mon Mar  7 11:29:00 CET 2016 on sn-devel-144
2016-03-07 11:29:00 +01:00
Amitay Isaacs
00b9e76904 ctdb-takeover: Inform clients when dropping all IP addresses
CTDB releases all IPs in following cases: starting up, shutting down,
node gets banned, node does not come out of recovery for a long time.
Always inform samba when CTDB releases IP addresses.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-07 08:14:21 +01:00
Amitay Isaacs
b8272d835d ctdb-takeover: Do not kill smbd processes on releasing IP
CTDB already notifies Samba with RELEASE_IP message.  Samba can take
appropriate action based on that.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-03-07 08:14:21 +01:00
Martin Schwenke
46edef25df ctdb-recovery: Limit scope of reclock latency statistics
It does not make sense to update this statistic for the timeout case,
since this could skew the statistic.  To keep it simple, just update
it for the usual case where there is lock contention, since this is
the usual case.  So the daemon statistic measures time to test the
lock and the corresponding recovery daemon statistic measures time to
take the lock.

Additionally, the recovery daemon will eventually use this code to
take the lock, and the method of updating the latency statistic will
need to be pushed further out to a configurable handler that depends
on the calling context.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Tue Feb 23 10:32:06 CET 2016 on sn-devel-144
2016-02-23 10:32:06 +01:00
Martin Schwenke
188019b877 ctdb-recovery: Negate the status when checking the recovery lock
Have 0 indicate that the lock was taken.  This allows non-zero values
to be used to indicate why the lock could not be taken.  EACCES means
lock contention.

For now use just EACCES to cover all failures, since
ctdb_recovery_lock() returns a bool and details of other errors will
be lost.  ctdb_recovery_lock() will undergo some big changes, so don't
try to fix this now.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-23 07:23:18 +01:00
Martin Schwenke
fad3f367b7 ctdb-recovery: Clean up status handling from recmode child
This currently returns an incorrect error when the expected number of
bytes are not read.  Separate out the different cases to clarify the
logic and avoid reporting the wrong error.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-23 07:23:18 +01:00
Martin Schwenke
b6c3918457 ctdb-recovery: Don't bother ensuring file descriptor is -1
This is already done before the destructor is assigned.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-23 07:23:18 +01:00
Martin Schwenke
531e6724ba ctdb-recovery: Don't store recmode in recovery mode state
The callbacks that use this value are only ever called if recovery
mode is being set to NORMAL.  So do not check if recmode is NORMAL
either.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-23 07:23:18 +01:00
Martin Schwenke
6695fa50ae ctdb: Use ctdb_wait_for_process_to_exit()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-23 07:23:18 +01:00
Martin Schwenke
4d6ec81299 ctdb-recovery: Drop redundant status send when setting recovery mode
The child process writes the status into the pipe before looping to
wait.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-23 07:23:18 +01:00
Martin Schwenke
3e2f2169a4 ctdb-recovery: Include lib/util/time.h instead of samba_util.h
Less is more...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-23 07:23:18 +01:00
Volker Lendecke
7b3fb853a4 ctdb: Fix CID 1353175 Logically dead code
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-02-16 16:41:18 +01:00
Volker Lendecke
e23ab7d408 ctdb: Fix CID 1353176 Logically dead code
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-02-16 16:41:18 +01:00
Martin Schwenke
2deba05c58 ctdb-ipalloc: Remove most uses of struct ctdb_public_ip_list_old
Where possible, this should no longer be used.

struct ctdb_public_ip_list is a fixed size structure and introduces an
extra level of indirection.  This means one level of indirection can
be dropped for known_public_ips and available_public_ips.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Feb 12 08:40:21 CET 2016 on sn-devel-144
2016-02-12 08:40:21 +01:00
Martin Schwenke
53752bcf29 ctdb-ipalloc: Use goto fail to avoid repetition
This is getting unreadable...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-02-12 05:32:16 +01:00
Amitay Isaacs
157e19b984 ctdb-recovery: Add a log message when marshalling recovery database fails
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-02-12 05:32:16 +01:00
Amitay Isaacs
d1f3b5d408 ctdb-daemon: Improve log message when REQ_DMASTER is received on non-lmaster
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-02-12 05:32:16 +01:00
Amitay Isaacs
19a411f839 ctdb-recovery: Create recovery databases in state dir
This matches the behaviour during serial database recovery.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Feb 11 08:01:14 CET 2016 on sn-devel-144
2016-02-11 08:01:14 +01:00
Amitay Isaacs
171fdc20b9 ctdb-recovery: Fix newlines in log messages
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Uri Simchoni <uri@samba.org>

Autobuild-User(master): Uri Simchoni <uri@samba.org>
Autobuild-Date(master): Tue Feb  9 22:28:08 CET 2016 on sn-devel-144
2016-02-09 22:28:08 +01:00
Amitay Isaacs
b71c2e4230 Revert "ctdb-daemon: Check packet generation against database generation"
This reverts commit 0ff90f4fac.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11707

The checks against database generation are not required since
the global generation is updated as part of updating vnnmap
before the actual database recovery.  This change was done in
5aab31a39a.

Checking only against the database generation is incomplete.  It can
cause CTDB to abort if the following sequence of events happen.

 - CTDB gets REQ_DMASTER packet (gen1)
   This packet processing gets deferred to get a record lock

 - CTDB goes into recovery, marks RECOVERY_ACTIVE
   CTDB recovery helper updates vnnmap (gen2)

 - CTDB processes REQ_DMASTER packet (gen1)
   The check against database generation (gen1) succeeds.
   The check for lmaster is now invalid because VNNMAP has changed.
   This will cause CTDB to abort due to protocol error.

Reverting the patch stops processing packets of older generation before
they get into call processing.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Feb  9 12:39:24 CET 2016 on sn-devel-144
2016-02-09 12:39:24 +01:00
Günther Deschner
1f6495b2f5 ctdb/server: fix gcc6 build warning.
ctdb/server/ipalloc_lcp2.c:264:29: warning: 'minimbl' may be used uninitialized
in this function [-Wmaybe-uninitialized]

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sun Feb  7 00:56:44 CET 2016 on sn-devel-144
2016-02-07 00:56:44 +01:00
Michael Adam
476672b647 dlist: remove unneeded type argument from DLIST_ADD_END()
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2016-02-06 21:48:17 +01:00
Martin Schwenke
6bbf7d8f09 ctdb: NAT gateway capability and control to set it are obsolete
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Jan 27 18:35:24 CET 2016 on sn-devel-144
2016-01-27 18:35:24 +01:00
Volker Lendecke
93e48df86c ctdb: Fix the O3 developer build
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2016-01-14 19:37:19 +01:00
Martin Schwenke
39bc356ccb ctdb-ipalloc: Document the steps involved in a takeover run
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Wed Jan 13 23:27:01 CET 2016 on sn-devel-144
2016-01-13 23:27:01 +01:00
Martin Schwenke
e320725f02 ctdb-ipalloc: Split IP allocation into its own build subsystem
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2016-01-13 20:18:20 +01:00
Martin Schwenke
18b0aeaae0 ctdb-ipalloc: Fix a memory leak
Commit cfa0ffe780 introduced a memory
leak.  Never assume...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:17 +01:00
Martin Schwenke
24160ee6a4 ctdb-daemon: Don't leak memory if not using recovery lock
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:17 +01:00
Martin Schwenke
56ce230de7 ctdb-recoverd: Fix some uninitialised memory issues
The first element of these structures is a 32-bit PNN.  On 64-bit
systems this field can be followed by 32-bits of padding.  When the
structures are copied this can cause uninitialised memory to be
copied.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:17 +01:00
Martin Schwenke
8f73ae03cc ctdb-daemon: Drop the "schedule for deletion" messages to DEBUG level
Thousands of these can be generated each second, rendering INFO level
debugging useless.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2016-01-12 19:16:17 +01:00
Martin Schwenke
fe918572cb ctdb-ipalloc: Rename top level IP allocation algorithm functions
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Dec  4 12:25:14 CET 2015 on sn-devel-104
2015-12-04 12:25:14 +01:00
Martin Schwenke
821aa24ffd ctdb-ipalloc: Rename ctdb_takeover_run_core() to ipalloc()
It just does IP allocation...

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
99abcc108c ctdb-ipalloc: Fold force_rebalance_candidates into IP allocation state
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
13aa583ea4 ctdb-ipalloc: Fold all IPs list into IP allocation state
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
fb66232155 ctdb-ipalloc: Tidy up some of the IP allocation functions
Shorter temporary variables for compactness/readability.  "tmp_ip" is
5 characters longer than "t".  In each for statement it is used 4
times, so costs 20 characters.  Save those extra characters so that
future edits will avoid going over 80 columns.

Tweak whitespace for readability, rewrap some code.

No functional changes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
5dcc1d7a69 ctdb-daemon: Don't delete connection information for released IP
As per the comment:

  If the IP address is hosted on this node then remove the connection.

  Otherwise this function has been called because the server IP
  address has been released to another node and the client has exited.
  This means that we should not delete the connection information.
  The takeover node processes connections too.

This doesn't matter at the moment, since the empty connection list for
an IP address that has been released will never be pushed to another
node.  However, it matters if the connection information is stored in
a real replicated database.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
4261d6e70a ctdb-daemon: Move VNN lookup out of ctdb_remove_tcp_connection()
In a subsequent commit ctdb_takeover_client_destructor_hook() needs to
know the VNN.  So just have both callers of
ctdb_remove_tcp_connection() do the lookup and pass in the VNN.

This should cause no change in behaviour.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
473f1a77e1 ctdb-daemon: Do not process tickle updates for hosted IP addresses
Tickle list updates are broadcast to all connected nodes and are
accepted even when received on the same node that sent them.  This
could actually lead to lost connection information when information
about new connections is received while an update is in-flight.

Instead, return early when the IP is hosted on the current node, since
it is the only one that could have sent the update.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
bd7c94d5ac ctdb-recoverd: Drop function unban_all_nodes()
It hasn't worked since commit cda5f02c7c
in 2009, which reworked the banning code.  Since then
ctdb_control_modflags() has contained a comment saying:

  /* we don't let other nodes modify our BANNED status */

Unbanning all nodes originally occurred here when the recovery master
role moved to a new node.  The logic could have been meant for the
case when the old recovery master was malfunctioning, so got banned.
If any other nodes had been banned by this recovery master then they
would be unbanned.  However, this would also unban the old recovery
master, which is probably suboptimal.  The logic would also trigger if
a node was banned for a good reason and then the recovery master was
stopped.  So, apart from doing nothing, the logic is too simplistic so
might as well be removed.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
ad6685847b ctdb-daemon: Drop handling of ban control sent to unexpected node
The banning code caters for the case where the node specified in the
bantime data is not the node receiving the control.  This never
happens.  There are 2 places where ctdb_ctrl_set_ban() is called: the
ctdb CLI tool and the recovery daemon.  Both pass the same node in the
bantime data that they are sending the control to.  There are no plans
to do anything more elaborate, so just delete the handling of this
special case.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-12-04 09:17:17 +01:00
Martin Schwenke
33084a1c2c ctdb-ipalloc: Drop unnecessary struct ctdb_ipflags
This can be easily decomposed into 2 separate arrays.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Nov 23 05:34:55 CET 2015 on sn-devel-104
2015-11-23 05:34:55 +01:00
Martin Schwenke
e73496d0dc ctdb-ipalloc: Move memory allocation into ipalloc_state_init()
This puts all of the memory allocation for ipalloc_state into its init
function.  This also simplifies the code because
set_ipflags_internal() can no longer fail because it no longer
allocates memory.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-23 02:31:11 +01:00
Martin Schwenke
47c5e5aa14 ctdb-ipalloc: Have set_ipflags_internal() set ipalloc_state->ipflags
This is cleaner than returning ipflags and assigning them into
ipalloc_state afterwards.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-23 02:31:10 +01:00
Martin Schwenke
dd163e26d9 ctdb-ipalloc: Fold IP flags into IP allocation state
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-23 02:31:10 +01:00
Martin Schwenke
22a930a045 ctdb-ipalloc: Use number of nodes from IP allocation state
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-23 02:31:10 +01:00
Martin Schwenke
13162419be ctdb-ipalloc: Allocate memory off IP allocation state
Instead of local or passed temporary contexts.

This has the side effect of making ipalloc_state available inside the
modified functions, making future use of ipalloc_state simpler.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-23 02:31:10 +01:00
Martin Schwenke
921e17d81e ctdb-ipalloc: Add error handling to IP allocation
The only likely failure is out of memory, so just return boolean
value.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-23 02:31:10 +01:00
Martin Schwenke
25c10936eb ctdb-ipalloc: Drop CTDB context argument from set_ipflags_internal()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-23 02:31:10 +01:00
Martin Schwenke
5b7bb6056b ctdb-ipalloc: ctdb_takeover_run_core() takes ipalloc_state
As do the functions called below it.  They no longer need a CTDB
context.

create_merged_ip_list() now takes both a CTDB context and an
ipalloc_state.

Drop ipalloc_state from CTDB context.  So the substitution in the
code is:

  ctdb->ipalloc_state  ->  ipalloc_state

Tweak the test code to match.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-20 01:36:32 +01:00
Martin Schwenke
5fba874a2e ctdb-ipalloc: Tidy up create_merged_ip_list()
Simplify with TALLOC_FREE() and fix some whitespace.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-20 01:36:32 +01:00
Martin Schwenke
837483c8d3 ctdb-ipalloc: Move IP list creation out to ctdb_takeover_run()
For various reasons create_merged_ip_list() needs a CTDB context.
This is difficult to resolve now for a few reasons, including:

* The ip_tree needs somewhere to live.

  It isn't very useful in its current form.  However, in the future
  real remote IP monitoring will probably be added back, so leave it
  around.

* It uses node flags from the ctdb_node structure.

  This could be changed by putting a node map into ipalloc_state
  and referencing that.

For now, it is easier to move it out to where there will be a CTDB
context available for the forseeable future.  ctdb_takeover_run() will
need one as long as the current client interface is used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-20 01:36:31 +01:00
Martin Schwenke
cc1637b17c ctdb-ipalloc: Add no_ip_failback to ipalloc_state
The IP allocation algorithms need the value of this tunable, so copy
it to avoid needing the CTDB context.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-20 01:36:31 +01:00
Martin Schwenke
47ddd62358 ctdb-ipalloc: New enum ipalloc_algorithm in ipalloc_state
Algorithm-related tunables from the CTDB context no longer need to be
accessed in the allocation logic.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-20 01:36:31 +01:00
Martin Schwenke
cfa0ffe780 ctdb-ipalloc: Move IP allocation state into its own struct
Most of the IP allocation code does not need a CTDB context.  However,
temporarily hang this off the CTDB context and make only the changes
relating to known/available IP address.  This makes those logic
changes obvious without burying them in function type changes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-20 01:36:31 +01:00
Martin Schwenke
d7739d8a7f ctdb-ipalloc: node_ip_coverage() doesn't need CTDB context
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-20 01:36:31 +01:00
Christof Schmitt
03b27bd139 ctdb: Use prctl_set_comment from lib/util
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-18 04:05:13 +01:00
Martin Schwenke
44bf7c2a12 ctdb-recoverd: Factor out recovery master validation
Starting to untangle cluster management, database recovery and public
IP allocation.  This is a non-trivial subset of the cluster management
code that runs in the recovery daemon on all nodes.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Mon Nov 16 11:47:45 CET 2015 on sn-devel-104
2015-11-16 11:47:44 +01:00
Martin Schwenke
e44957fc8b ctdb-recmaster: Update capabilities before calling first election
Capabilities are used when computing an election result so having them
up-to-date seems like a good idea.

Also update several instances of an ambiguous comment.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:12 +01:00
Martin Schwenke
c5e50a474b ctdb-recoverd: Move VNN map retrieval to where it is needed
The VNN map is only needed on the recovery master, so no need for all
recovery daemons to retrieve it.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:12 +01:00
Martin Schwenke
d1f996a50f ctdb-recoverd: Drop explicit check for recovery lock
This is already handled in update_recovery_lock(), which is called
immediately before.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:12 +01:00
Martin Schwenke
1499f3e301 ctdb-recoverd: Simplify using TALLOC_FREE()
The only non-obvious part here is dropping the setting of the nodemap
local variable to NULL.  If the following control succeeds then it is
set, otherwise return and it doesn't matter.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:12 +01:00
Martin Schwenke
050e64b647 ctdb-recoverd: Clarify that recmaster is being set on the current node
That is, using CTDB_CURRENT_NODE makes this more obvious.

Also fix incorrect error messages.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:12 +01:00
Martin Schwenke
0833e478c3 ctdb-recoverd: Do not sanity check recovery master with local daemon
Each recovery daemon knows who the recmaster is and is in sync with
its local daemon.  The recovery master is running this check so do not
bother checking with its local daemon - both agree that it is the
recovery master.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:12 +01:00
Martin Schwenke
d8decd0b1d ctdb-recoverd: Don't retrieve recovery master from local daemon
The recovery daemon already knows which node is the master.  This
relies on rec->recmaster being correctly initialised and correctly set
during elections.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:12 +01:00
Martin Schwenke
e90cab7073 ctdb-recoverd: Explicitly set initial recovery master to unknown
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
018077f3b0 ctdb-recoverd: Do not set recovery master during recovery
Recovery should not do cluster management functions.  Setting the
recovery master should only be done via an election.

Main loop will determine if recovery master is inconsistent across the
cluster and force an election if necessary.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
4b37cc7cf6 ctdb-recoverd: Have recovery daemon remember election result
The recovery daemon pushes knowledge of recovery master election
progress/result to local daemon.  It then retrieves that information
again.

Instead, have the recovery daemon reliably track election
progress/result in rec->recmaster so it doesn't need to be retrieved.
Be careful to maintain consistency by only doing this when the local
daemon has been updated.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
6f8837528f ctdb-recoverd: Clarify recovery master validation logic
There can be no holes in the nodemap.  Even if a node has been deleted
it will take a slot in the nodemap.  The only exception is that the
nodemap shrinks if nodes are deleted from the end.  That should never
include the master because a node should be shutdown before being
deleted, and an election should already have take place.

To avoid walking off the end of the nodemap nodes array just confirm
that the master node's PNN is a valid index into the array.  No need
to walk through the nodemap.

After this, in this section of the code j is now invalid.  So use the
master's PNN to index into the nodemap.  This is safe.

In the process, clean up some log messages to avoid saying "Force
reelection".  It's just an "election".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
9166c30a41 ctdb-daemon: Rename EventScriptTimeoutCount to MonitorTimeoutCount
This only applies to monitor events so renaming clarifies this.

Note that this change is not backward compatible.  Users with

  CTDB_SET_EventScriptTimeoutCount=<n>

in their configuration will get failures when starting CTDB but the
cause will be clearly logged.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
55ad4d80d4 ctdb-daemon: Move script timeout count into monitor state
It is only used by the monitoring code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
0d5db1c007 ctdb-daemon: Reset script timeout count in monitor code
This is the only place it is used.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
a33b50d07f ctdb-daemon: Do not bother printing script timeout count
It is only updated for monitor events, so it is meaningless here.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
bda2d9de2b ctdb-ipalloc: Don't consider runstates in the IP takeover code
Checking runstates is unnecessary now that nodes that are not RUNNING
will return no available IP addresses.  I have no idea why I didn't do
it this way originally.

Tweak the test code to cope with this.

Note that this is a backward-incompatible change.  If new and old
versions of CTDB are running together in a cluster and a new node
takes over as recovery master then old nodes will be able to host
public IP addresses before they are in RUNNING runstate.  This is
mitigated by the bias towards recovery master stability in elections.
If it is important that nodes do not host IPs until they are RUNNING
then do not restart nodes running the old version.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
9ea318847a ctdb-ipalloc: Check for available IPs, not runstate, in takeover run
The available IPs list is now only non-empty for nodes that are in
RUNNING runstate.  So, to avoid running the IP allocation algorithm
when there are no available available IPs, explicitly check for
available IPs rather than checking runstates.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Martin Schwenke
66574c9fda ctdb-ipalloc: A VNN can only host IPs if node is in RUNNING runstate
This will allow wonderful simplification (i.e. removal) of some of the
runstate checking in the takeover run code.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-16 08:42:11 +01:00
Amitay Isaacs
f50db5cba5 ctdb-server: Replace ctdb_logging.h with common/logging.h
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-16 00:46:15 +01:00
Amitay Isaacs
c170cdbc75 ctdb-logging: Move debug_extra definition to server/ctdb_logging.c
This variable is used for adding a prefix to log entries from various
child processes.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-16 00:46:14 +01:00
Amitay Isaacs
7dd2f1c35a ctdb-daemon: Move ctdb_fork.c to server
These functions are only used in the ctdb daemon code.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-16 00:46:14 +01:00
Amitay Isaacs
848da80152 ctdb-daemon: Move switch_from_server_to_client() to ctdb_daemon.c
This function can only called from ctdb daemon.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Michael Adam <obnox@samba.org>
2015-11-16 00:46:14 +01:00
Martin Schwenke
0886637a5e ctdb-recoverd: Reload remote IPs as part of takeover run
This is currently done before each IP takeover run, so just factor it
in.

ctdb_reload_remote_public_ips() becomes static.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>

Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Nov 12 09:28:45 CET 2015 on sn-devel-104
2015-11-12 09:28:45 +01:00
Martin Schwenke
8cdae3ade6 ctdb-recoverd: Move ctdb_reload_remote_public_ips() to ctdb_takeover.c
This will help to untangle known and available public IP lists from
the CTDB context.

verify_remote_ip_allocation() needs a forward declaration.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
2015-11-12 06:24:15 +01:00