The branch, master has been updated
via 86cdaf5a2ee ctdb-scripts: Change default persistent DB for
statd_callout_helper
via 16df4de9542 ctdb-scripts: Support
CTDB_STATD_CALLOUT_SHARED_STORAGE=none
via 112c6b43bc9 ctdb-tests: Update statd-callout tests to handle both
modes
via 08310072aad ctdb-scripts: Support storing statd-callout state in
cluster filesystem
via 2e84621354a ctdb-scripts: Fix impending SM_NOTIFY versus record
deletion race
via c415208a49a ctdb-scripts: Factor out some statd-callout functions
via e6a85d128f7 ctdb-scripts: Improve update and listing code
via b8fe8a5fd27 ctdb-scripts: Drop TCP tuning comments from
statd_callout_helper
via b2084281a4a ctdb-scripts: Fix some bit-rotted comments and
whitespace
via e704eb580a5 ctdb-scripts: Use CTDB_NFS_SHARED_STATE_DIR in
nfs-ganesha-callout
from cb279144037 s4:rpc_server/netlogon: fix
dcesrv_netr_LogonSamLogon_base_call() for ServerAuthenticateKerberos()
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 86cdaf5a2eeb9252fe16dfa4d215065cf1c748c2
Author: Martin Schwenke <[email protected]>
Date: Tue Jun 25 11:06:19 2024 +1000
ctdb-scripts: Change default persistent DB for statd_callout_helper
This database isn't use throughout CTDB, so name the it more
specifically.
Note that this might cause locks to be lost during upgrade to the
first version containing this change.
For testing, a different name is chosen to exercise related
functionality.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
Autobuild-User(master): Amitay Isaacs <[email protected]>
Autobuild-Date(master): Fri Dec 13 15:01:10 UTC 2024 on atb-devel-224
commit 16df4de95426316904866c484c751b7b34efc181
Author: Martin Schwenke <[email protected]>
Date: Tue Apr 30 12:12:32 2024 +1000
ctdb-scripts: Support CTDB_STATD_CALLOUT_SHARED_STORAGE=none
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit 112c6b43bc9b59740284ee227830157c66b9d40c
Author: Martin Schwenke <[email protected]>
Date: Fri Jun 30 21:50:10 2023 +1000
ctdb-tests: Update statd-callout tests to handle both modes
Add support for shared_dir mode.
Instead of duplicating all of the tests, update them so they can be
wrapped. Created new tests for shared_dir mode that source the
"original" tests.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit 08310072aad7b80f180d42292cf7eeaa773dd1b8
Author: Martin Schwenke <[email protected]>
Date: Wed Jun 28 14:01:44 2023 +1000
ctdb-scripts: Support storing statd-callout state in cluster filesystem
CTDB_STATD_CALLOUT_SHARED_STORAGE is a new configuration variable
indicating where statd-callout should store its NFS client locking
data. See the update to ctdb-script.options(5) for details.
This adds back functionality that was removed in commit
12cc82623150ca4a83482f1b7165401cbdecd3de. The commit message doesn't
say why this was changed but it was most likely due to a cluster
filesystem hanging at inopportune times. Hence, this is re-added as a
non-default option. There are 2 justifications for re-adding it:
* The existing method (persistent_db) relies on dequeuing data during
the monitor event, which loses any queued data on node crash.
* NFS-Ganesha writes NFSv4 client locking data to a cluster
filesystem, by default. Something similar might as well exist for
NFSv3.
Note that this could create the files for sm-notify in add-client.
However, this would require an alternate implementation of
send_notifies() (or a change to the implementation for persistent_db
too). It seems better to leave add-client lightweight and do the work
in notify, since add-client is a more frequent operation.
Unconditionally create the state directory on startup. This is
currently implicitly created for persistent_db when the queue
directory is created. However, it isn't created anywhere else for
shared_dir, so do it in a common place.
In test mode, the shared storage location has a prefix added so files
are created within the test environment.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit 2e84621354a62329b71d00b511c477c63693378f
Author: Martin Schwenke <[email protected]>
Date: Wed Jun 5 09:32:21 2024 +1000
ctdb-scripts: Fix impending SM_NOTIFY versus record deletion race
SM_NOTIFYs are sent before client records are deleted. Theoretically,
this means new records resulting from lock reclaim can be deleted.
This doesn't actually happen at the moment because any new "records"
resulting from lock reclaim are entered into the queue directory and
only dequeued to the database during a later monitor event. Since a
monitor event can't collide with an ipreallocated event, no records
can be dequeeued into the database during the ipreallocated event, so
they can't be deleted by delete_records().
However, a subsequent commit will add direct writing of records into a
shared cluster filesystem directory. This means that add-client
events will cause records to be added directly to that directory so,
without a fix, the race will be able to occur.
So, delete records before sending SM_NOTIFYs. In theory, the script
could be killed before all SM_NOTIFYs are successfully sent, resulting
in loss of locks. However, given the overall lack of error checking,
there are other, more likely problems.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit c415208a49a136e2800787d9a7c860f1599a58d1
Author: Martin Schwenke <[email protected]>
Date: Tue Jun 27 13:37:56 2023 +1000
ctdb-scripts: Factor out some statd-callout functions
This captures all of the persistent database (currently ctdb.tdb)
implementation-specific details in functions. Alternate
implementations can now be easily added.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit e6a85d128f7ada419fc13ca72a295533674e7840
Author: Martin Schwenke <[email protected]>
Date: Wed Aug 2 13:23:58 2023 +1000
ctdb-scripts: Improve update and listing code
Drop the complexity associated with using awk to escape dots in IPv4
addresses to protect them from sed, and generate a grep -F filter
instead.
For listing, the pipeline is now longer, but the steps are now
clearer:
1. List DB records
2. Extract keys
3. Keep only keys machine hosted public IPs
4. Parse out server IP and client IP
5. Sort
Performance here isn't critical, so having clearer code is preferable.
Use temporary files to avoid command-line length limits.
Also, drop the cd to the queue directory during update.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit b8fe8a5fd277f60ccc07ac64dff067255aff4f11
Author: Martin Schwenke <[email protected]>
Date: Wed Oct 16 12:23:42 2024 +1100
ctdb-scripts: Drop TCP tuning comments from statd_callout_helper
Commits caad5dc38d790d76f6720b312c1557ec3151a084 and
f022df1d40c9c1e3e528f178204f404ee395d5c2 commented out these lines
back in 2007.
2 things are clear from the commit messages:
* These setting should not be required in the real world - they are:
mainly useful for avoiding ack-storms when doing very rapid
failover/failback during testing
* If they are needed, they are not specific to
statd_callout/statd_callout_helper
Let's remove these comments to avoid confusing people.
Reported-by: Ulrich Sibiller <[email protected]>
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit b2084281a4a61a699deb05a18a37fc150f051e67
Author: Martin Schwenke <[email protected]>
Date: Tue Nov 26 11:25:09 2024 +1100
ctdb-scripts: Fix some bit-rotted comments and whitespace
The top comment in the file is no longer true.
The comment about notifications doesn't really apply anymore since
upstream sm-notify is used and it does "the right thing".
shfmt wants to remove a space before a semicolon, so do that too.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
commit e704eb580a503098d0030b6d7e68d98bd11153ae
Author: Martin Schwenke <[email protected]>
Date: Thu Jul 6 08:20:37 2023 +1000
ctdb-scripts: Use CTDB_NFS_SHARED_STATE_DIR in nfs-ganesha-callout
Rename CTDB_NFS_STATE_MNT to CTDB_NFS_SHARED_STATE_DIR. It doesn't
have to be a mount but can be any directory in a cluster filesystem.
CTDB_NFS_SHARED_STATE_DIR will soon be used in statd_callout_helper,
so the variable name might as well be better.
With this change, it will still only be used by nfs-ganesha-callout,
which isn't yet supported (i.e. it still lives in doc/examples). The
rest of the comments below refer to behaviour changes in that script.
CTDB_NFS_SHARED_STATE_DIR is now mandatory when GPFS is used. This is
much saner that choosing the first GPFS filesystem - if the state
directory changes then connection metadata can be lost.
Drop CTDB_NFS_STATE_FS_TYPE. The filesystem type is now determined
from CTDB_NFS_SHARED_STATE_DIR and it is now checked against supported
filesystems. This will catch the case when the filesystem for the
specified directory has not been mounted and the filesystem for the
mountpoint (e.g. ext4) is not a supported filesystem for shared state.
A side-effect is that the filesystem containing
CTDB_NFS_SHARED_STATE_DIR must be mounted when nfs-ganesha-callout is
first run.
While touching this file, my shfmt pre-commit hook wants to insert a
trailing ;; into a case statement. Let's sneak that in here too.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
ctdb/config/functions | 7 +-
ctdb/doc/ctdb-script.options.5.xml | 101 +++++-
ctdb/doc/examples/config_migrate.sh | 3 +-
ctdb/doc/examples/nfs-ganesha-callout | 63 ++--
ctdb/failover/statd_callout.c | 75 ++++-
.../UNIT/eventscripts/scripts/statd-callout.sh | 72 +++-
ctdb/tests/UNIT/eventscripts/statd-callout.001.sh | 11 +-
ctdb/tests/UNIT/eventscripts/statd-callout.002.sh | 11 +-
ctdb/tests/UNIT/eventscripts/statd-callout.003.sh | 11 +-
ctdb/tests/UNIT/eventscripts/statd-callout.004.sh | 13 +-
ctdb/tests/UNIT/eventscripts/statd-callout.005.sh | 11 +-
ctdb/tests/UNIT/eventscripts/statd-callout.006.sh | 11 +-
ctdb/tests/UNIT/eventscripts/statd-callout.007.sh | 11 +-
ctdb/tests/UNIT/eventscripts/statd-callout.101.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.102.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.103.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.104.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.105.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.106.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.107.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.201.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.202.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.203.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.204.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.205.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.206.sh | 6 +
ctdb/tests/UNIT/eventscripts/statd-callout.207.sh | 6 +
ctdb/tools/statd_callout_helper | 364 ++++++++++++++++-----
28 files changed, 687 insertions(+), 161 deletions(-)
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.101.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.102.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.103.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.104.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.105.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.106.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.107.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.201.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.202.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.203.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.204.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.205.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.206.sh
create mode 100755 ctdb/tests/UNIT/eventscripts/statd-callout.207.sh
Changeset truncated at 500 lines:
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 1ca3cebbbca..1d80c61e5f2 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -1160,11 +1160,8 @@ nfs_callout_init()
export CTDB_NFS_CALLOUT_STATE_DIR="${_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
+ if [ -n "$CTDB_NFS_SHARED_STATE_DIR" ]; then
+ export CTDB_NFS_SHARED_STATE_DIR
fi
if [ -n "$CTDB_NFS_EXPORTS_FILE" ]; then
export CTDB_NFS_EXPORTS_FILE
diff --git a/ctdb/doc/ctdb-script.options.5.xml
b/ctdb/doc/ctdb-script.options.5.xml
index 9298f9f3498..ab141e5829b 100644
--- a/ctdb/doc/ctdb-script.options.5.xml
+++ b/ctdb/doc/ctdb-script.options.5.xml
@@ -975,6 +975,19 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ CTDB_NFS_SHARED_STATE_DIR=<parameter>DIRECTORY</parameter>
+ </term>
+ <listitem>
+ <para>
+ DIRECTORY where clustered NFS shared state will be
+ located. DIRECTORY should be in a cluster filesystem
+ that is shared between the nodes. No default.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term>
CTDB_NFS_SKIP_SHARE_CHECK=yes|no
@@ -1030,25 +1043,81 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
<varlistentry>
<term>
- CTDB_NFS_STATE_FS_TYPE=<parameter>TYPE</parameter>
+ CTDB_STATD_CALLOUT_SHARED_STORAGE=<parameter>LOCATION</parameter>
</term>
<listitem>
<para>
- The type of filesystem used for a clustered NFS' shared
- state. No default.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- CTDB_NFS_STATE_MNT=<parameter>DIR</parameter>
- </term>
- <listitem>
- <para>
- The directory where a clustered NFS' shared state will be
- located. No default.
- </para>
+ LOCATION where NFSv3 statd state will be stored. Valid
+ values are:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>
+ persistent_db<optional>:<parameter>TDB</parameter></optional>
+ </term>
+ <listitem>
+ <para>
+ Data is queued to local storage and then dequeued
+ to TDB during monitor events. This means there is
+ a window where locking state may be lost.
+ However, this works around performance limitations
+ in CTDB's persistent database handling.
+ </para>
+ <para>
+ If :TDB is omitted then TDB defaults to
+ <filename>ctdb_statd_callout.tdb</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+
shared_dir<optional>:<parameter>DIRECTORY</parameter></optional>
+ </term>
+ <listitem>
+ <para>
+ DIRECTORY is a directory in a cluster filesystem
+ that is shared between the nodes. If DIRECTORY is
+ relative (i.e. does not start with '/') then it is
+ appended to CTDB_NFS_SHARED_STATE_DIR. If
+ :DIRECTORY is omitted then DIRECTORY defaults to
+ <filename>statd</filename>.
+ </para>
+ <para>
+ Using a shared directory may result in performance
+ and/or stability problems. rpc.statd is
+ single-threaded and its HA callout is called
+ synchronously, causing any latency introduced by
+ the callout to be cumulative. Stability issues
+ are most likely if thousands of clients reclaim
+ locks after failover and use of the cluster
+ filesystem introduces too much additional
+ latency. Too much latency in in the HA callout
+ may cause rpc.statd to fail health monitoring.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ none
+ </term>
+ <listitem>
+ <para>
+ No cluster-aware handling of NFSv3 statd state is
+ done. NFSv3 lock reclaim will not occur and
+ applications that use locking over NFSv3 are
+ likely to lose or corrupt data.
+ </para>
+ <para>
+ This should be used with care and only in the case
+ where no applications are using POSIX locks in
+ NFSv3 mounts. It should probably be considered an
+ option to test the latency of
+ <filename>statd_callout</filename>, without
+ including any storage costs.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</listitem>
</varlistentry>
diff --git a/ctdb/doc/examples/config_migrate.sh
b/ctdb/doc/examples/config_migrate.sh
index 874e96c880f..5d1f7a2084b 100755
--- a/ctdb/doc/examples/config_migrate.sh
+++ b/ctdb/doc/examples/config_migrate.sh
@@ -255,8 +255,7 @@ CTDB_NFS_CHECKS_DIR
CTDB_NFS_SKIP_SHARE_CHECK
CTDB_RPCINFO_LOCALHOST
CTDB_RPCINFO_LOCALHOST6
-CTDB_NFS_STATE_FS_TYPE
-CTDB_NFS_STATE_MNT
+CTDB_NFS_SHARED_STATE_DIR
# 70.iscsi
CTDB_START_ISCSI_SCRIPTS
# 00.ctdb
diff --git a/ctdb/doc/examples/nfs-ganesha-callout
b/ctdb/doc/examples/nfs-ganesha-callout
index 74c3ad5c1f9..5acd2354a96 100755
--- a/ctdb/doc/examples/nfs-ganesha-callout
+++ b/ctdb/doc/examples/nfs-ganesha-callout
@@ -36,10 +36,40 @@
# Exit on 1st error
set -e
-# Filesystem type and mount point for the (typically clustered)
-# volume that will contain the NFS-Ganesha state.
-state_fs="${CTDB_NFS_STATE_FS_TYPE:-gpfs}"
-state_dir="${CTDB_NFS_STATE_MNT}" # No sane default.
+die()
+{
+ echo "$1"
+ exit 1
+}
+
+# Shared directory, typically on a cluster filesystem, that will
+# contain the NFS-Ganesha state
+if [ -z "$CTDB_NFS_SHARED_STATE_DIR" ]; then
+ die "$0: CTDB_NFS_SHARED_STATE_DIR is not set"
+fi
+
+if [ ! -d "$CTDB_NFS_SHARED_STATE_DIR" ]; then
+ t="$CTDB_NFS_SHARED_STATE_DIR" # Readability, below
+ die "$0: CTDB_NFS_SHARED_STATE_DIR=${t} not found"
+fi
+
+state_fs=$(findmnt -n --target "$CTDB_NFS_SHARED_STATE_DIR" -o FSTYPE)
+
+case "$state_fs" in
+glusterfs | gpfs)
+ :
+ ;;
+fuse.glusterfs)
+ state_fs="glusterfs"
+ ;;
+*)
+ d="$CTDB_NFS_SHARED_STATE_DIR"
+ die "$0: filesystem type \"${state_fs}\" is not supported for ${d}"
+ ;;
+esac
+
+# Always put NFS-Ganesha state in its own subdirectory
+state_dir="${CTDB_NFS_SHARED_STATE_DIR}/ganesha"
# Location of exports file
nfs_exports_file="${CTDB_NFS_EXPORTS_FILE:-/etc/ganesha/ganesha.conf}"
@@ -47,7 +77,6 @@
nfs_exports_file="${CTDB_NFS_EXPORTS_FILE:-/etc/ganesha/ganesha.conf}"
# To change the following, edit the default values below. Do not set
# these - they aren't configuration variables, just hooks for testing.
nfs_service="${CTDB_NFS_SERVICE:-nfs-ganesha}"
-ganesha_rec_subdir=${CTDB_GANESHA_REC_SUBDIR:-.ganesha}
procfs=${PROCFS_PATH:-/proc}
case "$state_fs" in
@@ -55,13 +84,9 @@ gpfs)
GANRECDIR="/var/lib/nfs/ganesha"
;;
glusterfs)
- if [ -z "${state_dir}" ]; then
- echo "CTDB_NFS_STATE_MNT not defined for GlusterFS"
- exit 1
- fi
host=$(hostname)
- NODESTATEDIR="$state_dir/nfs-ganesha/$host"
- GANSTATEDIR="$state_dir/nfs-ganesha/.noderefs"
+ NODESTATEDIR="${state_dir}/${host}"
+ GANSTATEDIR="${state_dir}/.noderefs"
NODESTATELN="$GANSTATEDIR/$host"
;;
esac
@@ -184,21 +209,10 @@ get_cluster_fs_state()
create_ganesha_recdirs()
{
- if ! _mounts=$(mount | grep "$state_fs"); then
- echo "Failed to find mounts of type $state_fs"
- exit 1
- fi
- if [ -z "$_mounts" ]; then
- echo "startup $state_fs not ready"
- exit 0
- fi
-
case "$state_fs" in
gpfs)
- _mntpt=$(echo "$_mounts" | sort | awk 'NR == 1 {print $3}')
- _link_dst="${_mntpt}/${ganesha_rec_subdir}"
- mkdir -vp "$_link_dst"
- check_ln "$_link_dst" "$GANRECDIR"
+ mkdir -vp "$state_dir"
+ check_ln "$state_dir" "$GANRECDIR"
;;
glusterfs)
[ -d /var/lib/nfs.backup ] ||
@@ -279,6 +293,7 @@ nfs_stats()
# unhelpful for avoiding an unhealthy service
echo "Not implemented" >&2
exit 1
+ ;;
esac
}
diff --git a/ctdb/failover/statd_callout.c b/ctdb/failover/statd_callout.c
index a02a624aedf..8064432b21f 100644
--- a/ctdb/failover/statd_callout.c
+++ b/ctdb/failover/statd_callout.c
@@ -35,11 +35,16 @@
* The first line is the mode. Currently supported modes are:
*
* persistent_db
+ * shared_dir
+ * none
*
- * In this mode, the file contains 2 subsequent lines of text:
+ * In persistent_db and shared_dir modes, the file contains 2
+ * subsequent lines of text:
*
* path: directory where files should be created
* ips_file: file containing node's currently assigned public IP addresses
+ *
+ * In none mode, there are no subsequent lines.
*/
#define CONFIG_FILE CTDB_VARDIR "/scripts/statd_callout.conf"
@@ -48,6 +53,8 @@ static const char *progname;
struct {
enum {
CTDB_SC_MODE_PERSISTENT_DB,
+ CTDB_SC_MODE_SHARED_DIR,
+ CTDB_SC_MODE_NONE,
} mode;
union {
struct {
@@ -87,10 +94,14 @@ static void free_config(void)
{
switch (config.mode) {
case CTDB_SC_MODE_PERSISTENT_DB:
+ case CTDB_SC_MODE_SHARED_DIR:
free(config.path);
config.path = NULL;
free(config.ips_file);
config.ips_file = NULL;
+ break;
+ case CTDB_SC_MODE_NONE:
+ break;
}
}
@@ -127,6 +138,10 @@ static void read_config(void)
}
if (strcmp(mode, "persistent_db") == 0) {
config.mode = CTDB_SC_MODE_PERSISTENT_DB;
+ } else if (strcmp(mode, "shared_dir") == 0) {
+ config.mode = CTDB_SC_MODE_SHARED_DIR;
+ } else if (strcmp(mode, "none") == 0) {
+ config.mode = CTDB_SC_MODE_NONE;
} else {
fprintf(stderr,
"%s: unknown mode=%s in %s\n",
@@ -140,6 +155,7 @@ static void read_config(void)
switch (config.mode) {
case CTDB_SC_MODE_PERSISTENT_DB:
+ case CTDB_SC_MODE_SHARED_DIR:
status = getline_strip(&config.path, &n, f);
if (!status) {
goto parse_error;
@@ -150,6 +166,8 @@ static void read_config(void)
goto parse_error;
}
+ break;
+ case CTDB_SC_MODE_NONE:
break;
}
@@ -288,6 +306,51 @@ static void del_client_persistent_db(const char *cip)
for_each_sip(del_client_persistent_db_line, cip);
}
+static void add_client_shared_dir_line(const char *sip, const char *cip)
+{
+ char path[PATH_MAX];
+ FILE *f;
+
+ make_path(path, sizeof(path), sip, cip);
+
+ f = fopen(path, "w");
+ if (f == NULL) {
+ fprintf(stderr,
+ "%s: unable to open for writing %s\n",
+ progname,
+ path);
+ exit(1);
+ }
+ fclose(f);
+}
+
+static void add_client_shared_dir(const char *cip)
+{
+ for_each_sip(add_client_shared_dir_line, cip);
+}
+
+static void del_client_shared_dir_line(const char *sip, const char *cip)
+{
+ char path[PATH_MAX];
+ int ret;
+
+ make_path(path, sizeof(path), sip, cip);
+
+ ret = unlink(path);
+ if (ret != 0) {
+ fprintf(stderr,
+ "%s: unable to remove %s\n",
+ progname,
+ path);
+ exit(1);
+ }
+}
+
+static void del_client_shared_dir(const char *cip)
+{
+ for_each_sip(del_client_shared_dir_line, cip);
+}
+
static void usage(void)
{
printf("usage: %s: { add-client | del-client } <client-ip>\n",
progname);
@@ -313,6 +376,11 @@ int main(int argc, const char *argv[])
case CTDB_SC_MODE_PERSISTENT_DB:
add_client_persistent_db(mon_name);
break;
+ case CTDB_SC_MODE_SHARED_DIR:
+ add_client_shared_dir(mon_name);
+ break;
+ case CTDB_SC_MODE_NONE:
+ break;
}
} else if (strcmp(event, "del-client") == 0) {
mon_name = argv[2];
@@ -320,6 +388,11 @@ int main(int argc, const char *argv[])
case CTDB_SC_MODE_PERSISTENT_DB:
del_client_persistent_db(mon_name);
break;
+ case CTDB_SC_MODE_SHARED_DIR:
+ del_client_shared_dir(mon_name);
+ break;
+ case CTDB_SC_MODE_NONE:
+ break;
}
} else {
usage();
diff --git a/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh
b/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh
index f27d83760e1..10912c5d3e5 100644
--- a/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh
+++ b/ctdb/tests/UNIT/eventscripts/scripts/statd-callout.sh
@@ -1,10 +1,28 @@
setup()
{
+ CTDB_STATD_CALLOUT_SHARED_STORAGE="$1"
+
setup_public_addresses
ctdb_set_pnn
setup_date "1234567890"
export FAKE_NFS_HOSTNAME="cluster1"
+
+ case "$CTDB_STATD_CALLOUT_SHARED_STORAGE" in
+ "" | persistent_db)
+ CTDB_STATD_CALLOUT_SHARED_STORAGE="persistent_db:statd_foo.tdb"
+ ;;
+ shared_dir)
+ export CTDB_NFS_SHARED_STATE_DIR="/clusterfs"
+ ;;
+ esac
+
+ export CTDB_STATD_CALLOUT_SHARED_STORAGE
+ statd_callout_mode="${CTDB_STATD_CALLOUT_SHARED_STORAGE%%:*}"
+ statd_callout_location="${CTDB_STATD_CALLOUT_SHARED_STORAGE#*:}"
+ if [ "$statd_callout_location" = "$CTDB_STATD_CALLOUT_SHARED_STORAGE"
]; then
+ statd_callout_location=""
+ fi
}
ctdb_catdb_format_pairs()
@@ -44,12 +62,64 @@ EOF
done |
ctdb_catdb_format_pairs | {
ok
- simple_test_command ctdb catdb ctdb.tdb
+ simple_test_command ctdb catdb "$statd_callout_location"
+ } || exit $?
+}
+
+check_shared_dir_statd_state()
+{
+ ctdb_get_my_public_addresses |
+ while read -r _ _sip _; do
+ for _cip; do
+ echo "statd-state@${_sip}@${_cip}"
+ done
+ done |
+ sort | {
+ ok
+ _dir="${CTDB_TEST_TMP_DIR}${statd_callout_location}"
+ mkdir -p "$_dir"
+ (cd "$_dir" && simple_test_command ls)
} || exit $?
}
+check_shared_storage_statd_state()
+{
+ case "$statd_callout_mode" in
+ persistent_db)
+ if [ -z "$statd_callout_location" ]; then
+ statd_callout_location="statd_foo.tdb"
+ fi
+ check_ctdb_tdb_statd_state "$@"
+ ;;
+ shared_dir)
+ if [ -z "$statd_callout_location" ]; then
+ statd_callout_location="statd"
+ fi
+ case "$statd_callout_location" in
+ /*)
+ :
+ ;;
+ *)
+ _t="$CTDB_NFS_SHARED_STATE_DIR"
+ statd_callout_location="${_t}/${statd_callout_location}"
+ ;;
+ esac
+ check_shared_dir_statd_state "$@"
+ ;;
+ none)
+ :
+ ;;
+ esac
+}
+
check_statd_callout_smnotify()
{
+ case "$statd_callout_mode" in
--
Samba Shared Repository