1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00
Commit Graph

2671 Commits

Author SHA1 Message Date
Martin Schwenke
d39a1cc1d4 ctdb-server: Use ctdb_connection_same() to simplify
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Volker Lendecke
1b1fd5c228 ctdb: Don't leak a pointer on talloc_realloc failure
We should not directly overwrite the pointer we are realloc'ing

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-11-06 23:03:42 +00:00
Volker Lendecke
e080add68a ctdb: Save a few lines with talloc_zero()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-11-06 23:03:42 +00:00
Martin Schwenke
762f5f5ca6 ctdb-server: Remove duplicate logic
Initialise the pointer to NULL and fall through to let
talloc_realloc() do the allocation.  talloc_realloc() does the right
thing with a NULL pointer...

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
5af8627feb ctdb-server: Handle pre-existing connection first
This is cheap when tcparray is NULL and let's the code that now
follows be simplified.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
9838b4d0d6 ctdb-server: Drop an unnecessary variable
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
f4a8f84328 ctdb-server: Drop a log message to DEBUG level
This is harmless, so it doesn't generally need to be logged.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
3c19c8df77 ctdb-server: Clean up connection tracking functions
Apply README.Coding, modernise logging, pre-render connection as a
string for logging, switch terminology from "tickle" to "connection",
tidy up comments.

No changes in functionality.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
9a2249c990 ctdb-server: Use find_public_ip_vnn() in a couple of extra places
Reorder code to use early returns, modernise debug.

Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Oct  8 06:42:04 UTC 2024 on atb-devel-224
2024-10-08 06:42:04 +00:00
Martin Schwenke
2167261b0e ctdb-server: Clean up find_public_ip_vnn()
Fix the comment (NULL versus -1), apply some README.Coding.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
d268c605c1 ctdb-daemon: Ensure CTDB_BASE is set, don't fetch it
Uses of CTDB_BASE in the subsequent code are now handled by the path
module, so there is no point getting the value of CTDB_BASE.  Instead,
check that the attempt to set it worked, noting that:

  [...] if overwrite is zero, then the value of name is not
  changed (and setenv() returns a success status).

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
b6151faf45 ctdb-daemon: Use path_etcdir_append() to construct some paths
No need to use CTDB_BASE directly.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
3b613a085b ctdb-daemon: Replace remaining uses of CTDB_NO_MEMORY() in this file
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
01cc3f0784 ctdb-daemon: Clean up error handling and debug
Add some missing error handling and error messages.

Remove a use of CTDB_NO_MEMORY(), which then renders the caller's use
of ctdb_errstr() pointless, so remove that too.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
3429ba764c ctdb-daemon: Use ctdb_vnn_address_string() in old-style debugging
Modernise the debug macros along the way.

These are done separately because they will require a little more
patience to review.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
c17e629a8a ctdb-daemon: Add ctdb_vnn_address_string() and use in trivial places
Define a static function to return the string.  This clearly doesn't
need a ctdb_ prefix, but it matches ctdb_vnn_iface_string(), so
doesn't look out of place.

Use it in the places where review is trivial.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
766e6d35c4 ctdb-daemon: Store public address string in VNN
These are currently converted to strings constantly in log messages
and other places.  This clutters the code and probably has a minor
performance impact.

Add a new string field to the VNN structure.  Populate it when a
public address is added and the VNN structure is allocated.  This is
consistent with how node addresses are handled.

Don't use it yet, or this commit becomes huge.

A short-term goal is that each VNN public address will be converted to
a string only once.  A longer-term goal is to reduce use of
ctdb_addr_to_str().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
ef3d9c227f ctdb-daemon: Fix a comment
The word "no" was accidentally dropped in commit
1e47a1b3f6.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
7b4447b4d3 ctdb-daemon: Drop unused arguments
Unused since commit a10545ab6b.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
46f6b50f7a ctdb-daemon: Improve error handling when releasing all IPs
Currently, event failures are completely ignored in favour of checking
if the IP is on an interface.  This misses the case where event
scripts up to and including 10.interface succeed, but something later
fails.  When that occurs, count is incremented, so the failure is
counted as a success in the summary that is logged.

Fail when releaseip fails even though 10.interface succeeded in
releasing the IP.  This may result in the IP address coming back, but
that's a different problem.

Underlying this is a design question about when releaseip is
successful.  Should releaseip be a distinct operation, with subsequent
reconfigurations considered separately?

Update logging to clearly identify each of the 3 possible errors.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
5af2f09a1f ctdb-server: Optimise local IP verification
It is more efficient calling ctdb_sys_local_ip_check() inside a loop
compared to calling ctdb_sys_have_ip().  There is a chance that this
is premature optimisation... but it sure is easy.  Fall back to
checking with bind().

I think these checks really exist because of the weirdness fixed by
commit 4b4e4d8870.  However, we might as
well do what we can.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
a15167aafe ctdb-server: Add some local variables
Improve readability by not repeating the complex expression now
assigned to addr.  ctdb_sys_have_ip() is called in both arms of the
if/else, so call it once when declaring the new variable.

Modernise debug macros while touching lines.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Volker Lendecke
25a222225d ctdb: Use str_list_add_printf() in lock_helper_args()
Saves lines, str_list_add_printf takes care of NULL checks

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sun Sep 22 10:44:59 UTC 2024 on atb-devel-224
2024-09-22 10:44:59 +00:00
Volker Lendecke
83716809a8 ctdb: Change the ctdb_vfork_exec prototype to const char*const*
I could not find out how to cast a char ** to const char ** without
warning. This transfers fine to the execv call as well.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-09-22 09:36:36 +00:00
Volker Lendecke
65b3081f4b ctdb: Use str_list_add_printf() in debug_locks_args()
Saves lines, str_list_add_printf takes care of NULL checks

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2024-09-20 17:13:37 +00:00
Volker Lendecke
2fa0eabe64 ctdb: Make ctdb_lock_timeout_handler() easier to understand
Don't hide the real action inside an if-branch

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
2024-09-20 17:13:37 +00:00
Volker Lendecke
3cc3329420 ctdb: Add a NULL check to convert_node_map_to_list()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jennifer Sutton <jsutton@samba.org>
2024-08-27 07:19:32 +00:00
Martin Schwenke
f36f03172a ctdb-daemon: Remove a use of ctdb_errstr()
Code to setup the transport is about to be cleaned up, including
removing uses of ctdb_set_error(), so avoid logging a NULL pointer or
some other old error.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-08-20 13:06:33 +00:00
John Mulligan
ac926a506d ctdb-conf: add boolean arg for verbosity when loading config
In a future commit we will add support for loading the config file from
the `ctdb` command line tool. Prior to this change the config file load
func always called D_NOTICE that causes the command to emit new text and
thus break all the tests that rely on the specific test output (not to
mention something users could notice). This change plumbs a new
`verbose` argument into some of the config file loading functions.
Generally, all existing functions will have verbose set to true to match
the existing behavior. Future callers of this function can set it to
false in order to avoid emitting the extra text.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-08-06 00:43:36 +00:00
John Mulligan
a0e8304ccf ctdb-server: rename ctdb_load_nodes_file to ctdb_load_nodes
Rename ctdb_load_nodes_file to ctdb_load_nodes as it can now load nodes
from more than a regular file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-08-06 00:43:36 +00:00
John Mulligan
7e7cb91806 ctdb-server: rename nodes_file field to nodes_source
Rename the `struct ctdb_context` field nodes_file to nodes_source to
better match that the field may indicate something other than a true
file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-08-06 00:43:36 +00:00
John Mulligan
dc65e7082d ctdb-server: use the new "nodes list" configuration option
Use the new "nodes list" configuration option. Executing the given path
if the path is prefixed by a `!`. The use case is to decouple the nodes
file from the shared storage, especially in the case where the shared
storage is provided by a vfs module.

For an example, imagine a script that runs `curl` on a URL for a
highly-available web server where the URL provides the content
of the nodes file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-08-06 00:43:36 +00:00
Martin Schwenke
ead5a3111f ctdb-daemon: Use ctdb_parse_node_address() in ctdbd
While here, fix a trivial memory leak (ctdbd will exit anyway if this
function fails).

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Jul 23 12:39:18 UTC 2024 on atb-devel-224
2024-07-23 12:39:18 +00:00
Martin Schwenke
181cc097ef ctdb-daemon: Use ctdb_read_nodes() in ctdbd
ctdb_control_getnodesfile() calls ctdb_read_nodes(), which returns a
struct ctdb_node_map rather than the old version, so update associated
marshalling.  While here modernise a debug message and wrap the
function arguments.

For ctdb_load_nodes_file() to use ctdb_read_nodes(), tweak
convert_node_map_to_list() to also use the modern node map structure.

Remove unused copy of ctdb_read_nodes_file().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-07-23 11:37:34 +00:00
Martin Schwenke
11c4b25331 ctdb-conf: Rename config loading to not be daemon-specific
We might end up using it elsewhere.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-06-28 18:43:52 +05:30
Martin Schwenke
52e5e92693 ctdb-conf: Move all conf files to new conf/ subdirectory
Leave common/conf.[ch] where they are to make this commit
comprehensible.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-06-28 18:43:52 +05:30
Volker Lendecke
7e621b1b53 ctdb: Modernize a few DEBUGs
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Apr 17 00:54:55 UTC 2024 on atb-devel-224
2024-04-17 00:54:55 +00:00
Volker Lendecke
0baae61e42 lib: Give lib/util/util_file.c its own header file
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
2024-04-16 23:51:45 +00:00
Volker Lendecke
a3e186b617 lib: Remove timeval_until()
We have the same function in tevent, no need to duplicate code.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-03-22 05:03:35 +00:00
Volker Lendecke
78208d4fe4 ctdb: Remove an unnecessary cast
nl->srvid is uint64_t, as is the srvid parameter of ctdb_daemon_send_message()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Mar 13 08:43:16 UTC 2024 on atb-devel-224
2024-03-13 08:43:16 +00:00
Vinit Agnihotri
7dacbcd0ec ctdb: send a CTDB_SRVID_START_IPREALLOCATE message after CTDB_EVENT_START_IPREALLOCATE
Event scripts run the "start_ipreallocate" hook in order to notice
that some ip addresses in the cluster potentially changed.

CTDB_SRVID_START_IPREALLOCATE gives C code a chance to get notified as well
once the event scripts are finished.

Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
2483a2ae20 ctdb-takeover: Use CTDB_CONTROL_START_IPREALLOCATE
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
b7cc56d22d ctdb-server: Implement CTDB_CONTROL_START_IPREALLOCATE
Trigger a "startipreallocate" event, but only if in RUNNING runstate.
"startipreallocate" is intended to allow an NFS server to be put into
grace on all nodes before any locks are released as part of releaseip
during failover.  If node A is leader and initiates a takeover run
then node B may be connected/active but may not have completed
startup.  In this case, the attempt to put NFS-Ganesha into grace on
node B will fail, startipreallocate will fail, and the node will be
banned.

Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Vinit Agnihotri
d97e642ba8 ctdb-daemon: Implement startipreallocate event
Signed-off-by: Vinit Agnihotri <vagnihotri@ddn.com>
Reviewed-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Martin Schwenke
9f68656b47 ctdb-daemon: Use ctdb_event_to_string()
ctdb_eventscript_call_names() will be dropped so the mapping between
events and strings is only maintained in one place.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-03-06 06:05:38 +00:00
Stefan Metzmacher
b1d0d5d514 ctdb: send a CTDB_SRVID_IPREALLOCATED message after CTDB_EVENT_IPREALLOCATED
Event scripts run the "ipreallocated" hook in order to notice that some ip addresses
in the cluster potentially changed.

CTDB_SRVID_IPREALLOCATED gives C code a chance to get notified as well once the event
scripts are finished.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-01-04 11:39:36 +00:00
Martin Schwenke
4b7329f158 ctdb-server: Drop unnecessary copy of destination address
Modernise debug while touching the code.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Fri Dec 15 12:09:21 UTC 2023 on atb-devel-224
2023-12-15 12:09:21 +00:00
Martin Schwenke
8fc3872557 ctdb-daemon: Use ctdb_connection_to_buf() to simplify
The one case that is no longer handled specially is when the
destination address is IPv4 loopback.  This may previously have been
used to avoid flooding the logs when testing.  However, that seems
unnecessary - if testing with 127.0.0.1 then make it a public address.

Modernise debug while touching the code.

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

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
037e8e449d ctdb: add/implement CTDB_CONTROL_TCP_CLIENT_PASSED
With multichannel a tcp connection is registered first with
a temporary smbd process, that calls CTDB_CONTROL_TCP_CLIENT
first and then passes the tcp connection to the longterm smbd
that already handles all connections belonging to the specific
client_guid. That smbd process calls CTDB_CONTROL_TCP_CLIENT
again, but the 'tickle' information is already there.
When the temporary smbd process exists/disconnects from ctdb
or calls CTDB_CONTROL_TCP_CLIENT_DISCONNECTED, the 'tickle'
information is removed, while the longterm smbd process
still serves the tcp connection.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00
Stefan Metzmacher
c6602b686b ctdb: add/implement CTDB_CONTROL_TCP_CLIENT_DISCONNECTED
With multichannel a ctdb connection from smbd may hold multiple
tcp connections, which can be disconnected before the smbd
process terminates the whole ctdb connection, so we a
way to remove undo 'CTDB_CONTROL_TCP_CLIENT' again.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2023-12-15 11:06:34 +00:00