The branch, master has been updated via c620bf5 ctdb-daemon: Reset push_started flag once DB_PUSH_CONFIRM is done via ecb7472 ctdb-recoverd: Avoid duplicate recoverd event in parallel recovery via 3d3c152 ctdb-system: Remove duplicate functions via a4ac97d6 ctdb-daemon: Use lib/util functions instead of redefinitions via 95c2cd1 lib/util: Add a generic definition for set_close_on_exec via e1e1442 ctdb-tests: Re-use set_blocking instead of re-definition via 3031732 ctdb-tests: Re-use async accept wrapper from async_req via 48d1fd8 ctdb-scripts: Add eventscript 06.nfs via 6096233 ctdb-scripts: Move NFS callout-related code to functions file from 6888c17 build: Address may be used uninitialized in this function on Ubuntu 10.04
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit c620bf5debd57a4a5d7f893a2b6383098ff7a919 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Jun 8 15:04:52 2016 +1000 ctdb-daemon: Reset push_started flag once DB_PUSH_CONFIRM is done Once DB_PUSH_START is processed as part of recovery, push_started flag tracks if there are multiple attempts to send DB_PUSH_START. In DB_PUSH_CONFIRM, once the record count is confirmed, all information related to DB_PUSH should be reset. However, The push_started flag was not reset when the push_state was reset. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> Autobuild-User(master): Amitay Isaacs <ami...@samba.org> Autobuild-Date(master): Wed Jun 8 14:31:52 CEST 2016 on sn-devel-144 commit ecb74721e78942e66aaf2d2f88f141305e311328 Author: Amitay Isaacs <ami...@gmail.com> Date: Wed Jun 8 14:15:22 2016 +1000 ctdb-recoverd: Avoid duplicate recoverd event in parallel recovery BUG: https://bugzilla.samba.org/show_bug.cgi?id=11956 In do_recovery, after the recovery and takeover is complete, recoverd event is triggered. When the parallel database recovery was separated, ctdb_recovery_helper implemented sending END_RECOVERY control which causes recoverd event to be triggered. So when there is parallel database recovery, recoverd event is triggered twice. Instead move the call to run_recovered_eventscript() explicitly in the serial recovery code path. This avoids the duplication trigger of recoverd event. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 3d3c15232bf7bf337127414d0c0cc639cc290710 Author: Amitay Isaacs <ami...@gmail.com> Date: Fri May 27 13:32:28 2016 +1000 ctdb-system: Remove duplicate functions Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit a4ac97d6c073c30c0fdefb8ae7c31d6fa6b29924 Author: Amitay Isaacs <ami...@gmail.com> Date: Fri May 27 13:50:06 2016 +1000 ctdb-daemon: Use lib/util functions instead of redefinitions Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 95c2cd10d7918aad5b97ca2bde86a8811189b54c Author: Amitay Isaacs <ami...@gmail.com> Date: Fri May 27 13:43:33 2016 +1000 lib/util: Add a generic definition for set_close_on_exec Avoid changing function names to smb_set_close_on_exec in ctdb. Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit e1e14420a63bf766fdd05a1560dfe09f7cda4df6 Author: Amitay Isaacs <ami...@gmail.com> Date: Fri May 27 12:52:12 2016 +1000 ctdb-tests: Re-use set_blocking instead of re-definition Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 30317325041b18031cb02519f7195a3cbbe0fb25 Author: Amitay Isaacs <ami...@gmail.com> Date: Fri May 27 12:38:20 2016 +1000 ctdb-tests: Re-use async accept wrapper from async_req Signed-off-by: Amitay Isaacs <ami...@gmail.com> Reviewed-by: Martin Schwenke <mar...@meltin.net> commit 48d1fd8299663cddabf63cb1d33a8c032d9b9b87 Author: Martin Schwenke <mar...@meltin.net> Date: Mon Jun 6 14:03:47 2016 +1000 ctdb-scripts: Add eventscript 06.nfs This generates takeip-pre and releaseip-pre call-out events. One use is to put NFS into grace before an IP is assigned to an interface. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> commit 6096233919528e2337fa9d3269caaf0a86becf9b Author: Martin Schwenke <mar...@meltin.net> Date: Mon Jun 6 13:56:55 2016 +1000 ctdb-scripts: Move NFS callout-related code to functions file A second NFS eventscript may be required, so make this code available to it. The initialisation code can't be evaluated in the functions file because service_state_dir isn't yet setup, so put it in a function and call it with other initialisation code. Signed-off-by: Martin Schwenke <mar...@meltin.net> Reviewed-by: Amitay Isaacs <ami...@gmail.com> ----------------------------------------------------------------------- Summary of changes: ctdb/client/ctdb_client.c | 4 +- ctdb/common/comm.c | 19 ++------ ctdb/common/system.h | 2 - ctdb/common/system_aix.c | 5 ++- ctdb/common/system_freebsd.c | 3 +- ctdb/common/system_gnu.c | 3 +- ctdb/common/system_kfreebsd.c | 3 +- ctdb/common/system_linux.c | 5 ++- ctdb/common/system_util.c | 33 -------------- ctdb/config/events.d/06.nfs | 39 ++++++++++++++++ ctdb/config/events.d/60.nfs | 59 +------------------------ ctdb/config/functions | 63 ++++++++++++++++++++++++++ ctdb/config/nfs-linux-kernel-callout | 2 +- ctdb/doc/examples/nfs-ganesha-callout | 2 +- ctdb/packaging/RPM/ctdb.spec.in | 1 + ctdb/server/ctdb_cluster_mutex.c | 1 + ctdb/server/ctdb_daemon.c | 5 ++- ctdb/server/ctdb_event_helper.c | 2 + ctdb/server/ctdb_logging.c | 1 + ctdb/server/ctdb_recover.c | 1 + ctdb/server/ctdb_recoverd.c | 18 ++++---- ctdb/tcp/tcp_connect.c | 5 ++- ctdb/tests/src/comm_server_test.c | 81 ++-------------------------------- ctdb/tests/src/ctdb_porting_tests.c | 5 ++- ctdb/tests/src/fake_ctdbd.c | 83 +---------------------------------- ctdb/tests/src/pkt_read_test.c | 19 ++------ ctdb/tests/src/pkt_write_test.c | 19 ++------ ctdb/utils/pmda/pmda_ctdb.c | 3 +- ctdb/wscript | 7 ++- lib/util/blocking.h | 2 + 30 files changed, 170 insertions(+), 325 deletions(-) create mode 100755 ctdb/config/events.d/06.nfs Changeset truncated at 500 lines: diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 4ed8f0a..7e98499 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -294,9 +294,9 @@ int ctdb_socket_connect(struct ctdb_context *ctdb) return -1; } - set_nonblocking(ctdb->daemon.sd); + set_blocking(ctdb->daemon.sd, false); set_close_on_exec(ctdb->daemon.sd); - + ctdb->daemon.queue = ctdb_queue_setup(ctdb, ctdb, ctdb->daemon.sd, CTDB_DS_ALIGNMENT, ctdb_client_read_cb, ctdb, "to-ctdbd"); diff --git a/ctdb/common/comm.c b/ctdb/common/comm.c index 1bbb460..7f370da 100644 --- a/ctdb/common/comm.c +++ b/ctdb/common/comm.c @@ -24,26 +24,13 @@ #include <talloc.h> #include <tdb.h> +#include "lib/util/blocking.h" #include "lib/util/tevent_unix.h" #include "pkt_read.h" #include "pkt_write.h" #include "comm.h" -static bool set_nonblocking(int fd) -{ - int v; - - v = fcntl(fd, F_GETFL, 0); - if (v == -1) { - return false; - } - if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) { - return false; - } - return true; -} - /* * Communication endpoint around a socket */ @@ -78,6 +65,7 @@ int comm_setup(TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd, struct comm_context **result) { struct comm_context *comm; + int ret; if (fd < 0) { return EINVAL; @@ -88,7 +76,8 @@ int comm_setup(TALLOC_CTX *mem_ctx, struct tevent_context *ev, int fd, } /* Socket queue relies on non-blocking sockets. */ - if (!set_nonblocking(fd)) { + ret = set_blocking(fd, false); + if (ret == -1) { return EIO; } diff --git a/ctdb/common/system.h b/ctdb/common/system.h index 2b469dc..2007814 100644 --- a/ctdb/common/system.h +++ b/ctdb/common/system.h @@ -47,8 +47,6 @@ int ctdb_get_peer_pid(const int fd, pid_t *peer_pid); bool set_scheduler(void); void reset_scheduler(void); -void set_nonblocking(int fd); -void set_close_on_exec(int fd); bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin); bool parse_ip(const char *addr, const char *ifaces, unsigned port, diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c index de69b9e..48cd781 100644 --- a/ctdb/common/system_aix.c +++ b/ctdb/common/system_aix.c @@ -25,6 +25,7 @@ #include "system/wait.h" #include "lib/util/debug.h" +#include "lib/util/blocking.h" #include "protocol/protocol.h" @@ -65,7 +66,7 @@ int ctdb_sys_open_sending_socket(void) return -1; } - set_nonblocking(s); + set_blocking(s, false); set_close_on_exec(s); return s; @@ -142,7 +143,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, return -1; } - set_nonblocking(s); + set_blocking(s, false); set_close_on_exec(s); memset(&ip4pkt, 0, sizeof(ip4pkt)); diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c index 3845019..a03b97a 100644 --- a/ctdb/common/system_freebsd.c +++ b/ctdb/common/system_freebsd.c @@ -30,6 +30,7 @@ #include "system/wait.h" #include "lib/util/debug.h" +#include "lib/util/blocking.h" #include "protocol/protocol.h" @@ -179,7 +180,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, return -1; } - set_nonblocking(s); + set_blocking(s, false); set_close_on_exec(s); ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c index 70361d7..09c4ffe 100644 --- a/ctdb/common/system_gnu.c +++ b/ctdb/common/system_gnu.c @@ -29,6 +29,7 @@ #include "system/wait.h" #include "lib/util/debug.h" +#include "lib/util/blocking.h" #include "protocol/protocol.h" @@ -177,7 +178,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, return -1; } - set_nonblocking(s); + set_blocking(s, false); set_close_on_exec(s); ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip)); diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c index 9b5c9ce..56f7c1c 100644 --- a/ctdb/common/system_kfreebsd.c +++ b/ctdb/common/system_kfreebsd.c @@ -29,6 +29,7 @@ #include "system/wait.h" #include "lib/util/debug.h" +#include "lib/util/blocking.h" #include "protocol/protocol.h" @@ -177,7 +178,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, return -1; } - set_nonblocking(s); + set_blocking(s, false); set_close_on_exec(s); ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip)); diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c index 2dca174..ef78df8 100644 --- a/ctdb/common/system_linux.c +++ b/ctdb/common/system_linux.c @@ -24,6 +24,7 @@ #include "system/wait.h" #include "lib/util/debug.h" +#include "lib/util/blocking.h" #include "protocol/protocol.h" @@ -385,7 +386,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest, return -1; } - set_nonblocking(s); + set_blocking(s, false); set_close_on_exec(s); ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, @@ -468,7 +469,7 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data) DEBUG(DEBUG_DEBUG, (__location__ " Created RAW SOCKET FD:%d for tcp tickle\n", s)); - set_nonblocking(s); + set_blocking(s, false); set_close_on_exec(s); return s; diff --git a/ctdb/common/system_util.c b/ctdb/common/system_util.c index 4d56fd3..91bd72e 100644 --- a/ctdb/common/system_util.c +++ b/ctdb/common/system_util.c @@ -120,39 +120,6 @@ void reset_scheduler(void) #endif } -void set_nonblocking(int fd) -{ - int v; - - v = fcntl(fd, F_GETFL, 0); - if (v == -1) { - DEBUG(DEBUG_WARNING, ("Failed to get file status flags - %s\n", - strerror(errno))); - return; - } - if (fcntl(fd, F_SETFL, v | O_NONBLOCK) == -1) { - DEBUG(DEBUG_WARNING, ("Failed to set non_blocking on fd - %s\n", - strerror(errno))); - } -} - -void set_close_on_exec(int fd) -{ - int v; - - v = fcntl(fd, F_GETFD, 0); - if (v == -1) { - DEBUG(DEBUG_WARNING, ("Failed to get file descriptor flags - %s\n", - strerror(errno))); - return; - } - if (fcntl(fd, F_SETFD, v | FD_CLOEXEC) != 0) { - DEBUG(DEBUG_WARNING, ("Failed to set close_on_exec on fd - %s\n", - strerror(errno))); - } -} - - bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin) { sin->sin_family = AF_INET; diff --git a/ctdb/config/events.d/06.nfs b/ctdb/config/events.d/06.nfs new file mode 100755 index 0000000..2a069f3 --- /dev/null +++ b/ctdb/config/events.d/06.nfs @@ -0,0 +1,39 @@ +#!/bin/sh +# script to manage nfs in a clustered environment + +[ -n "$CTDB_BASE" ] || \ + export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD") + +. $CTDB_BASE/functions + +service_name="nfs" +loadconfig +ctdb_setup_service_state_dir + +###################################################################### + +nfs_callout_pre () +{ + _event="$1" + shift + + nfs_callout "${_event}-pre" "$@" +} + +###################################################################### + +nfs_callout_init + +ctdb_start_stop_service + +is_ctdb_managed_service || exit 0 + +case "$1" in +takeip) + nfs_callout_pre "$@" + ;; + +releaseip) + nfs_callout_pre "$@" + ;; +esac diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs index 57cfbff..eb12ad6 100755 --- a/ctdb/config/events.d/60.nfs +++ b/ctdb/config/events.d/60.nfs @@ -12,63 +12,6 @@ ctdb_setup_service_state_dir ###################################################################### -if [ -z "$CTDB_NFS_CALLOUT" ] ; then - CTDB_NFS_CALLOUT="${CTDB_BASE}/nfs-linux-kernel-callout" -fi -# Always export, for statd callout -export CTDB_NFS_CALLOUT - -# If the callout wants to use this then it must create it -export CTDB_NFS_CALLOUT_STATE_DIR="${service_state_dir}/callout-state" - -# Export, if set, for use by clustered NFS callouts -if [ -n "$CTDB_NFS_STATE_FS_TYPE" ] ; then - export CTDB_NFS_STATE_FS_TYPE -fi -if [ -n "$CTDB_NFS_STATE_MNT" ] ; then - export CTDB_NFS_STATE_MNT -fi - -nfs_callout_cache="${service_state_dir}/nfs_callout_cache" -nfs_callout_cache_callout="${nfs_callout_cache}/CTDB_NFS_CALLOUT" -nfs_callout_cache_ops="${nfs_callout_cache}/ops" - -nfs_callout_register () -{ - mkdir -p "$nfs_callout_cache_ops" - rm -f "$nfs_callout_cache_ops"/* - - echo "$CTDB_NFS_CALLOUT" >"$nfs_callout_cache_callout" - - _t=$(eval "$CTDB_NFS_CALLOUT" "register") - if [ -n "$_t" ] ; then - echo "$_t" | - while IFS="" read _op ; do - touch "${nfs_callout_cache_ops}/${_op}" - done - else - touch "${nfs_callout_cache_ops}/ALL" - fi -} - -nfs_callout () -{ - # Re-run registration if $CTDB_NFS_CALLOUT has changed - _prev="" - if [ -r "$nfs_callout_cache_callout" ] ; then - read _prev <"$nfs_callout_cache_callout" - fi - if [ "$CTDB_NFS_CALLOUT" != "$_prev" ] ; then - nfs_callout_register - fi - - # Run the operation if it is registered... - if [ -e "${nfs_callout_cache_ops}/${1}" ] || \ - [ -e "${nfs_callout_cache_ops}/ALL" ]; then - eval "$CTDB_NFS_CALLOUT" "$@" - fi -} - service_reconfigure () { # Restart lock manager, notify clients @@ -294,6 +237,8 @@ nfs_update_lock_info () ###################################################################### +nfs_callout_init + ctdb_start_stop_service is_ctdb_managed_service || exit 0 diff --git a/ctdb/config/functions b/ctdb/config/functions index 33efa51..b2a0735 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -1164,6 +1164,69 @@ if ! type mktemp >/dev/null 2>&1 ; then } fi +###################################################################### +# NFS callout handling + +nfs_callout_init () +{ + if [ -z "$CTDB_NFS_CALLOUT" ] ; then + CTDB_NFS_CALLOUT="${CTDB_BASE}/nfs-linux-kernel-callout" + fi + # Always export, for statd callout + export CTDB_NFS_CALLOUT + + # If the callout wants to use this then it must create it + export CTDB_NFS_CALLOUT_STATE_DIR="${service_state_dir}/callout-state" + + # Export, if set, for use by clustered NFS callouts + if [ -n "$CTDB_NFS_STATE_FS_TYPE" ] ; then + export CTDB_NFS_STATE_FS_TYPE + fi + if [ -n "$CTDB_NFS_STATE_MNT" ] ; then + export CTDB_NFS_STATE_MNT + fi + + nfs_callout_cache="${service_state_dir}/nfs_callout_cache" + nfs_callout_cache_callout="${nfs_callout_cache}/CTDB_NFS_CALLOUT" + nfs_callout_cache_ops="${nfs_callout_cache}/ops" +} + +nfs_callout_register () +{ + mkdir -p "$nfs_callout_cache_ops" + rm -f "$nfs_callout_cache_ops"/* + + echo "$CTDB_NFS_CALLOUT" >"$nfs_callout_cache_callout" + + _t=$(eval "$CTDB_NFS_CALLOUT" "register") + if [ -n "$_t" ] ; then + echo "$_t" | + while IFS="" read _op ; do + touch "${nfs_callout_cache_ops}/${_op}" + done + else + touch "${nfs_callout_cache_ops}/ALL" + fi +} + +nfs_callout () +{ + # Re-run registration if $CTDB_NFS_CALLOUT has changed + _prev="" + if [ -r "$nfs_callout_cache_callout" ] ; then + read _prev <"$nfs_callout_cache_callout" + fi + if [ "$CTDB_NFS_CALLOUT" != "$_prev" ] ; then + nfs_callout_register + fi + + # Run the operation if it is registered... + if [ -e "${nfs_callout_cache_ops}/${1}" ] || \ + [ -e "${nfs_callout_cache_ops}/ALL" ]; then + eval "$CTDB_NFS_CALLOUT" "$@" + fi +} + ######################################################## # tickle handling ######################################################## diff --git a/ctdb/config/nfs-linux-kernel-callout b/ctdb/config/nfs-linux-kernel-callout index 22151a6..3b457be 100755 --- a/ctdb/config/nfs-linux-kernel-callout +++ b/ctdb/config/nfs-linux-kernel-callout @@ -242,7 +242,7 @@ case "$1" in register) nfs_register ;; - monitor-pre|releaseip|takeip) + monitor-pre|releaseip|takeip|releaseip-pre|takeip-pre) # Not required/implemented : ;; diff --git a/ctdb/doc/examples/nfs-ganesha-callout b/ctdb/doc/examples/nfs-ganesha-callout index 34794c1..3e12b36 100755 --- a/ctdb/doc/examples/nfs-ganesha-callout +++ b/ctdb/doc/examples/nfs-ganesha-callout @@ -335,7 +335,7 @@ case "$action" in takeip) nfs_takeip "$@" ;; monitor-list-shares) nfs_monitor_list_shares ;; register) nfs_register ;; - monitor-pre|monitor-post) + monitor-pre|monitor-post|releaseip-pre|takeip-pre) # Not required/implemented : ;; diff --git a/ctdb/packaging/RPM/ctdb.spec.in b/ctdb/packaging/RPM/ctdb.spec.in index 3bc9beb..b7c881e 100644 --- a/ctdb/packaging/RPM/ctdb.spec.in +++ b/ctdb/packaging/RPM/ctdb.spec.in @@ -171,6 +171,7 @@ rm -rf $RPM_BUILD_ROOT %{_sysconfdir}/ctdb/events.d/00.ctdb %{_sysconfdir}/ctdb/events.d/01.reclock %{_sysconfdir}/ctdb/events.d/05.system +%{_sysconfdir}/ctdb/events.d/06.nfs %{_sysconfdir}/ctdb/events.d/10.interface %{_sysconfdir}/ctdb/events.d/10.external %{_sysconfdir}/ctdb/events.d/13.per_ip_routing diff --git a/ctdb/server/ctdb_cluster_mutex.c b/ctdb/server/ctdb_cluster_mutex.c index fa70a00..3448491 100644 --- a/ctdb/server/ctdb_cluster_mutex.c +++ b/ctdb/server/ctdb_cluster_mutex.c @@ -28,6 +28,7 @@ #include "lib/util/time.h" #include "lib/util/strv.h" #include "lib/util/strv_util.h" +#include "lib/util/blocking.h" #include "ctdb_private.h" #include "common/common.h" diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 321b86e..0f17b0f 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -33,6 +33,7 @@ #include "lib/util/dlinklist.h" #include "lib/util/debug.h" #include "lib/util/samba_util.h" -- Samba Shared Repository