re-import sources as agreed with the maintainer

This commit is contained in:
Adam Samalik 2023-07-10 13:18:00 +02:00
parent ab2e22588f
commit 0f3b005d29
11 changed files with 1298 additions and 1 deletions

13
.gitignore vendored
View File

@ -1,2 +1,13 @@
SOURCES/dlm-4.1.0.tar.gz
/dlm-3.99.0.tar.gz
/dlm-3.99.1.tar.gz
/dlm-3.99.2.tar.gz
/dlm-3.99.3.tar.gz
/dlm-3.99.4.tar.gz
/dlm-3.99.5.tar.gz
/dlm-4.0.0.tar.gz
/dlm-4.0.1.tar.gz
/dlm-4.0.4.tar.gz
/dlm-4.0.5.tar.gz
/dlm-4.0.6.tar.gz
/dlm-4.0.9.tar.gz
/dlm-4.1.0.tar.gz

View File

@ -0,0 +1,28 @@
From 2eefc91150a3292c2be82f4139207e06b4c4bba4 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 10 Jun 2016 13:13:48 -0500
Subject: [PATCH] dlm_controld: libsystemd broke itself
---
dlm_controld/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 13d6339ab263..cf556c9d72b8 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -62,9 +62,9 @@ LIB_CFLAGS += $(BIN_CFLAGS)
LIB_LDFLAGS += -Wl,-z,relro -pie
ifeq ($(USE_SD_NOTIFY),yes)
- BIN_CFLAGS += $(shell pkg-config --cflags libsystemd-daemon) \
+ BIN_CFLAGS += $(shell pkg-config --cflags libsystemd) \
-DUSE_SD_NOTIFY
- BIN_LDFLAGS += $(shell pkg-config --libs libsystemd-daemon)
+ BIN_LDFLAGS += $(shell pkg-config --libs libsystemd)
endif
all: $(LIB_TARGET) $(BIN_TARGET)
--
1.8.3.1

View File

@ -0,0 +1,199 @@
From 2e893b981b19430aeca983dd63fb3ac0979d0b35 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 9 Sep 2020 17:16:59 -0500
Subject: [PATCH] dlm_controld: use new quorum api to detect missed failures
If a node failed and then quickly rejoined before corosync
detected the original failure, the quorum callback from
corosync would not include an indication that the node had
ever failed. This meant there would be no removal and
readdition of the node's configfs settings in the kernel,
and the failed network connections may never be cleared.
The new quorum nodelist callback does include an indication
of a node that has left and rejoined. This patch keeps track
of nodeids that have left and rejoined through that callback
between sequential occurances of the standard quorum callback.
When the standard quorum callback is removing and adding
configfs settings for nodes that have been removed or added,
it will also now look at the list of nodes that have left
and rejoined, and do configfs removal and addition for those.
---
dlm_controld/member.c | 106 +++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 91 insertions(+), 15 deletions(-)
diff --git a/dlm_controld/member.c b/dlm_controld/member.c
index 1d5bfa3d9166..d567c114b259 100644
--- a/dlm_controld/member.c
+++ b/dlm_controld/member.c
@@ -20,6 +20,8 @@ static int old_node_count;
static uint32_t quorum_nodes[MAX_NODES];
static int quorum_node_count;
static struct list_head cluster_nodes;
+static uint32_t leavejoin_nodes[MAX_NODES];
+static int leavejoin_count;
struct node_cluster {
struct list_head list;
@@ -103,15 +105,51 @@ int is_cluster_member(uint32_t nodeid)
return is_member(quorum_nodes, quorum_node_count, nodeid);
}
-static void quorum_callback(quorum_handle_t h, uint32_t quorate,
- uint64_t ring_seq, uint32_t node_list_entries,
- uint32_t *node_list)
+static int is_leavejoin_node(uint32_t nodeid)
+{
+ return is_member(leavejoin_nodes, leavejoin_count, nodeid);
+}
+
+static void quorum_nodelist_callback(quorum_handle_t cbhandle, struct quorum_ring_id ring_id,
+ uint32_t member_list_entries, const uint32_t *member_list,
+ uint32_t joined_list_entries, const uint32_t *joined_list,
+ uint32_t left_list_entries, const uint32_t *left_list)
+{
+ uint64_t ring_seq = ring_id.seq;
+ int i, j;
+
+ for (i = 0; i < left_list_entries; i++) {
+ log_debug("cluster left_list %u seq %llu",
+ left_list[i], (unsigned long long)ring_seq);
+ }
+
+ for (j = 0; j < joined_list_entries; j++) {
+ log_debug("cluster joined_list %u seq %llu",
+ joined_list[j], (unsigned long long)ring_seq);
+ }
+
+ for (i = 0; i < left_list_entries; i++) {
+ for (j = 0; j < joined_list_entries; j++) {
+ if (joined_list[j] == left_list[i]) {
+ log_debug("cluster node %d left and joined", joined_list[j]);
+ if (!is_leavejoin_node(joined_list[j]))
+ leavejoin_nodes[leavejoin_count++] = joined_list[j];
+ }
+ }
+ }
+}
+
+static void quorum_callback(quorum_handle_t cbhandle, uint32_t quorate,
+ struct quorum_ring_id ring_id, uint32_t node_list_entries,
+ const uint32_t *node_list)
{
corosync_cfg_node_address_t addrs[MAX_NODE_ADDRESSES];
corosync_cfg_node_address_t *addrptr = addrs;
const struct node_config *nc;
cs_error_t err;
int i, j, num_addrs;
+ uint32_t nodeid;
+ uint64_t ring_seq = ring_id.seq;
uint64_t now = monotime();
if (!cluster_joined_monotime) {
@@ -142,15 +180,55 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
if (!is_cluster_member(old_nodes[i])) {
log_debug("cluster node %u removed seq %llu",
old_nodes[i], (unsigned long long)cluster_ringid_seq);
+
rem_cluster_node(old_nodes[i], now);
del_configfs_node(old_nodes[i]);
}
}
+ for (i = 0; i < leavejoin_count; i++) {
+ nodeid = leavejoin_nodes[i];
+
+ log_debug("cluster node %u leavejoin seq %llu",
+ nodeid, (unsigned long long)cluster_ringid_seq);
+
+ /* remove */
+
+ rem_cluster_node(nodeid, now);
+ del_configfs_node(nodeid);
+
+ /* add */
+
+ add_cluster_node(nodeid, now);
+
+ fence_delay_begin = now;
+
+ err = corosync_cfg_get_node_addrs(ch, nodeid,
+ MAX_NODE_ADDRESSES,
+ &num_addrs, addrs);
+ if (err != CS_OK) {
+ log_error("corosync_cfg_get_node_addrs failed nodeid %u", nodeid);
+ continue;
+ }
+
+ nc = node_config_get(nodeid);
+
+ for (j = 0; j < num_addrs; j++) {
+ add_configfs_node(nodeid,
+ addrptr[j].address,
+ addrptr[j].address_length,
+ (nodeid == our_nodeid),
+ nc->mark);
+ }
+ }
+
for (i = 0; i < quorum_node_count; i++) {
+ if (is_leavejoin_node(quorum_nodes[i]))
+ continue;
if (!is_old_member(quorum_nodes[i])) {
log_debug("cluster node %u added seq %llu",
quorum_nodes[i], (unsigned long long)cluster_ringid_seq);
+
add_cluster_node(quorum_nodes[i], now);
fence_delay_begin = now;
@@ -176,12 +254,10 @@ static void quorum_callback(quorum_handle_t h, uint32_t quorate,
}
}
}
-}
-static quorum_callbacks_t quorum_callbacks =
-{
- .quorum_notify_fn = quorum_callback,
-};
+ memset(leavejoin_nodes, 0, sizeof(leavejoin_nodes));
+ leavejoin_count = 0;
+}
void process_cluster(int ci)
{
@@ -208,23 +284,23 @@ void update_cluster(void)
int setup_cluster(void)
{
+ quorum_model_v1_data_t model_data;
cs_error_t err;
int fd;
- uint32_t quorum_type;
+ uint32_t quorum_type = 0;
INIT_LIST_HEAD(&cluster_nodes);
- err = quorum_initialize(&qh, &quorum_callbacks, &quorum_type);
+ memset(&model_data, 0, sizeof(model_data));
+ model_data.quorum_notify_fn = quorum_callback;
+ model_data.nodelist_notify_fn = quorum_nodelist_callback;
+
+ err = quorum_model_initialize(&qh, QUORUM_MODEL_V1, (quorum_model_data_t *)&model_data, &quorum_type, NULL);
if (err != CS_OK) {
log_error("quorum init error %d", err);
return -1;
}
- if (quorum_type == QUORUM_FREE) {
- log_error("no quorum provider configured in corosync, unable to operate");
- goto fail;
- }
-
err = quorum_fd_get(qh, &fd);
if (err != CS_OK) {
log_error("quorum fd_get error %d", err);
--
2.7.5

View File

@ -0,0 +1,41 @@
From 3a5d91435a557932b2ff674ec8e7c22e880da42f Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 24 Mar 2018 08:55:06 +0000
Subject: [PATCH] New location of major() and minor() macros for glibc 2.27.
glibc 2.27 moves the major() and minor() macros to the
<sys/sysmacros.h> header file.
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
dlm_controld/dlm_daemon.h | 1 +
libdlm/libdlm.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h
index 6cb0f11c1335..731818c53c9b 100644
--- a/dlm_controld/dlm_daemon.h
+++ b/dlm_controld/dlm_daemon.h
@@ -40,6 +40,7 @@
#include <sched.h>
#include <signal.h>
#include <dirent.h>
+#include <sys/sysmacros.h>
#include <corosync/cpg.h>
diff --git a/libdlm/libdlm.c b/libdlm/libdlm.c
index a9e6195579aa..ebfba4576fa8 100644
--- a/libdlm/libdlm.c
+++ b/libdlm/libdlm.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <dirent.h>
#include <linux/major.h>
+#include <sys/sysmacros.h>
#ifdef HAVE_SELINUX
#include <selinux/selinux.h>
#endif
--
2.7.5

View File

@ -0,0 +1,217 @@
From db875a3d07f9f6a633951ed886cec80b91efea43 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 2 Oct 2018 11:22:39 -0500
Subject: [PATCH] update makefile gcc flags
---
dlm_controld/Makefile | 41 ++++++++++++++---------------------------
dlm_tool/Makefile | 44 ++++++++++++++++----------------------------
fence/Makefile | 46 +++++++++++++++++-----------------------------
libdlm/Makefile | 6 +++++-
4 files changed, 52 insertions(+), 85 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index cf556c9d72b8..85c2db12883a 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -31,35 +31,22 @@ BIN_SOURCE = action.c \
rbtree.c
LIB_SOURCE = lib.c
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
- -Wall \
- -Wformat \
- -Wformat-security \
- -Wmissing-prototypes \
- -Wnested-externs \
- -Wpointer-arith \
- -Wextra -Wshadow \
- -Wcast-align \
- -Wwrite-strings \
- -Waggregate-return \
- -Wstrict-prototypes \
- -Winline \
- -Wredundant-decls \
- -Wno-sign-compare \
- -Wno-unused-parameter \
- -Wp,-D_FORTIFY_SOURCE=2 \
- -fexceptions \
- -fasynchronous-unwind-tables \
- -fdiagnostics-show-option \
-
-BIN_CFLAGS += -fPIE -DPIE
+CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
+ -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs \
+ -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings \
+ -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls \
+ -Wno-sign-compare -Wno-unused-parameter -Wp,-D_FORTIFY_SOURCE=2 \
+ -fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option \
+ -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong \
+ -fstack-clash-protection -Wl,-z,now
+
+BIN_CFLAGS += $(CFLAGS) -fPIE -DPIE
BIN_CFLAGS += -I../include -I../libdlm
+LIB_CFLAGS += $(CFLAGS) -fPIC
-BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
+BIN_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -pie
BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum
-
-LIB_CFLAGS += $(BIN_CFLAGS)
-LIB_LDFLAGS += -Wl,-z,relro -pie
+LIB_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -pie
ifeq ($(USE_SD_NOTIFY),yes)
BIN_CFLAGS += $(shell pkg-config --cflags libsystemd) \
@@ -73,7 +60,7 @@ $(BIN_TARGET): $(BIN_SOURCE)
$(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
$(LIB_TARGET): $(LIB_SOURCE)
- $(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_SMAJOR)
+ $(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR)
ln -sf $(LIB_TARGET) $(LIB_SO)
ln -sf $(LIB_TARGET) $(LIB_SMAJOR)
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index c16d8f537225..80d7725791f3 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -8,38 +8,26 @@ MAN_TARGET = dlm_tool.8
BIN_SOURCE = main.c
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
- -Wall \
- -Wformat \
- -Wformat-security \
- -Wmissing-prototypes \
- -Wnested-externs \
- -Wpointer-arith \
- -Wextra -Wshadow \
- -Wcast-align \
- -Wwrite-strings \
- -Waggregate-return \
- -Wstrict-prototypes \
- -Winline \
- -Wredundant-decls \
- -Wno-sign-compare \
- -Wno-unused-parameter \
- -Wp,-D_FORTIFY_SOURCE=2 \
- -fexceptions \
- -fasynchronous-unwind-tables \
- -fdiagnostics-show-option \
-
-BIN_CFLAGS += -fPIE -DPIE
-BIN_CFLAGS += -I../include -I../libdlm -I../dlm_controld
-
-BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
-BIN_LDFLAGS += -L../libdlm -L../dlm_controld
-BIN_LDFLAGS += -lpthread -ldlm -ldlmcontrol
+CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
+ -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs \
+ -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings \
+ -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls \
+ -Wno-sign-compare -Wno-unused-parameter -Wp,-D_FORTIFY_SOURCE=2 \
+ -fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option \
+ -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong \
+ -fstack-clash-protection -Wl,-z,now
+
+CFLAGS += -fPIE -DPIE
+CFLAGS += -I../include -I../libdlm -I../dlm_controld
+
+LDFLAGS += -Wl,-z,relro -pie
+LDFLAGS += -L../libdlm -L../dlm_controld
+LDFLAGS += -lpthread -ldlm -ldlmcontrol
all: $(BIN_TARGET)
$(BIN_TARGET): $(BIN_SOURCE)
- $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@
+ $(CC) $(BIN_SOURCE) $(CFLAGS) $(LDFLAGS) -o $@
clean:
rm -f *.o *.so *.so.* $(BIN_TARGET)
diff --git a/fence/Makefile b/fence/Makefile
index 77bf0fd15be8..b927879eb141 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -8,39 +8,27 @@ MAN_TARGET = dlm_stonith.8
BIN_SOURCE = stonith_helper.c
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
- -Wall \
- -Wformat \
- -Wformat-security \
- -Wmissing-prototypes \
- -Wnested-externs \
- -Wpointer-arith \
- -Wextra -Wshadow \
- -Wcast-align \
- -Wwrite-strings \
- -Waggregate-return \
- -Wstrict-prototypes \
- -Winline \
- -Wredundant-decls \
- -Wno-sign-compare \
- -Wno-unused-parameter \
- -Wp,-D_FORTIFY_SOURCE=2 \
- -fexceptions \
- -fasynchronous-unwind-tables \
- -fdiagnostics-show-option \
-
-BIN_CFLAGS += -fPIE -DPIE
-BIN_CFLAGS += `xml2-config --cflags`
-BIN_CFLAGS += -I../include
-
-BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
-BIN_LDFLAGS += `xml2-config --libs`
-BIN_LDFLAGS += -ldl
+CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
+ -Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs \
+ -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings \
+ -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls \
+ -Wno-sign-compare -Wno-unused-parameter -Wp,-D_FORTIFY_SOURCE=2 \
+ -fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option \
+ -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong \
+ -fstack-clash-protection -Wl,-z,now
+
+CFLAGS += -fPIE -DPIE
+CFLAGS += `xml2-config --cflags`
+CFLAGS += -I../include
+
+LDFLAGS += -Wl,-z,relro -pie
+LDFLAGS += `xml2-config --libs`
+LDFLAGS += -ldl
all: $(BIN_TARGET)
$(BIN_TARGET): $(BIN_SOURCE)
- $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
+ $(CC) $(BIN_SOURCE) $(CFLAGS) $(LDFLAGS) -o $@ -L.
clean:
rm -f *.o *.so *.so.* $(BIN_TARGET)
diff --git a/libdlm/Makefile b/libdlm/Makefile
index 336c22e7edb4..ab32761912b3 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -72,10 +72,14 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-Wno-sign-compare \
-Wno-unused-parameter \
-Wp,-D_FORTIFY_SOURCE=2 \
+ -Wp,-D_GLIBCXX_ASSERTIONS \
+ -fstack-protector-strong \
+ -fstack-clash-protection \
-fexceptions \
-fasynchronous-unwind-tables \
-fdiagnostics-show-option \
- -fPIC
+ -fPIC \
+ -Wl,-z,now
LIB_CFLAGS += $(CFLAGS) -D_REENTRANT
LLT_CFLAGS += $(CFLAGS)
--
2.7.5

View File

@ -0,0 +1,28 @@
From 58f1d500b6da18d62eef35b5f55a030ce8b9b0ce Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 14 Jan 2019 15:47:07 -0600
Subject: [PATCH] dlm_controld: ignore unwanted uevent strings
---
dlm_controld/main.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlm_controld/main.c b/dlm_controld/main.c
index 40816aae3b24..ca1349bae241 100644
--- a/dlm_controld/main.c
+++ b/dlm_controld/main.c
@@ -350,7 +350,10 @@ static void process_uevent(int ci)
act = argv[0];
sys = argv[2];
- if ((strlen(sys) != strlen("dlm")) || strcmp(sys, "dlm"))
+ if (!act || !sys || !argv[3])
+ return;
+
+ if (strncmp(sys, "dlm", 3))
return;
log_debug("kernel: %s %s", act, argv[3]);
--
2.7.5

View File

@ -0,0 +1,362 @@
/*
* Copyright (c) 2011 David Teigland
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License V2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/* gcc dlm_seq_async.c -ldlm -o dlm_seq_async */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <signal.h>
#include <syslog.h>
#include <sys/time.h>
#include <asm/types.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include "libdlm.h"
#define DEFAULT_NUM_R 1000
#define DEFAULT_NUM_LPR 1
static dlm_lshandle_t *dh;
static int openclose = 0;
static int quiet = 0;
static int verbose = 0;
static int opt_convert = 0;
static int opt_unlock = 0;
static int opt_async = 0;
static int opt_delay = 0;
static unsigned int num_r = DEFAULT_NUM_R;
static unsigned int num_lpr = DEFAULT_NUM_LPR;
static unsigned int num_iter = 1;
static unsigned int iter = 0;
static uint32_t *lkids;
static struct dlm_lksb lksb;
static unsigned int cb_count;
static int libdlm_fd;
#define log_debug(fmt, args...) \
do { \
if (!quiet) \
printf(fmt "\n", ##args); \
} while (0)
#define log_error(fmt, args...) \
do { \
printf("ERROR " fmt "\n", ##args); \
exit(-1); \
} while (0)
static void astfn(void *arg)
{
int status = lksb.sb_status;
cb_count++;
printf("astfn %x status %d count %u\n", lksb.sb_lkid, status, cb_count);
if (!status)
return;
if (status == EUNLOCK)
return;
}
static void seq(int acquire, int convert, int unlock, int mode)
{
char name[DLM_RESNAME_MAXLEN];
uint32_t lkid;
int i, j, rv;
for (i = 0; i < num_r; i++) {
snprintf(name, sizeof(name), "seq.%08d", i);
for (j = 0; j < num_lpr; j++) {
memset(&lksb, 0, sizeof(lksb));
if (acquire) {
printf("acquire %s %d\n", name, mode);
rv = dlm_ls_lockx(dh, mode, &lksb, 0,
name, strlen(name), 0,
astfn, &lksb, NULL,
NULL, NULL);
}
if (convert) {
lksb.sb_lkid = lkids[(i * num_lpr) + j];
printf("convert %s %x %d\n", name, lksb.sb_lkid, mode);
rv = dlm_ls_lockx(dh, mode, &lksb, LKF_CONVERT,
name, strlen(name), 0,
astfn, &lksb, NULL,
NULL, NULL);
}
if (unlock) {
lkid = lkids[(i * num_lpr) + j];
printf("unlock %s %x\n", name, lkid);
rv = dlm_ls_unlock(dh, lkid, 0, &lksb, &lksb);
}
if (rv) {
log_error("dlm op %d %d %d %d,%d error %d",
acquire, convert, unlock, i, j, rv);
return;
}
if (acquire && lkids)
lkids[(i * num_lpr) + j] = lksb.sb_lkid;
}
}
cb_count = 0;
while (1) {
rv = dlm_dispatch(libdlm_fd);
if (rv < 0) {
printf("dlm_dispatch error %d %d\n", rv, errno);
}
if (cb_count == (num_r * num_lpr))
break;
}
}
static void print_usage(void)
{
printf("dlm_seq [options]\n");
printf("Options:\n");
printf("\n");
printf(" -i <n> Iterations (0 no limit), default 1)\n");
printf(" -r <n> The number of resources, default %d\n", DEFAULT_NUM_R);
printf(" -l <n> The number of locks per resource, default %d\n", DEFAULT_NUM_LPR);
printf(" -c Convert locks after acquiring them all\n");
printf(" -u Unlock locks after acquire/convert\n");
printf(" -s Same resource names in each iteration\n");
printf(" -d <us> Delay us between consecutive seq\n");
printf(" -o Open/close existing lockspace\n");
printf(" -v Verbose output\n");
printf(" -q Quiet output\n");
}
static void decode_arguments(int argc, char **argv)
{
int cont = 1;
int optchar;
while (cont) {
optchar = getopt(argc, argv, "i:r:l:cuvqohad:s");
switch (optchar) {
case 'i':
num_iter = atoi(optarg);
break;
case 'r':
num_r = atoi(optarg);
break;
case 'l':
num_lpr = atoi(optarg);
break;
case 'c':
opt_convert = 1;
break;
case 'u':
opt_unlock = 1;
break;
case 'd':
opt_delay = atoi(optarg);
break;
case 'o':
openclose = 1;
break;
case 'v':
verbose = 1;
break;
case 'q':
quiet = 1;
break;
case 'h':
print_usage();
exit(EXIT_SUCCESS);
break;
case 'V':
printf("%s (built %s %s)\n", argv[0], __DATE__, __TIME__);
exit(EXIT_SUCCESS);
break;
case ':':
case '?':
fprintf(stderr, "Please use '-h' for usage.\n");
exit(EXIT_FAILURE);
break;
case EOF:
cont = 0;
break;
default:
fprintf(stderr, "unknown option: %c\n", optchar);
exit(EXIT_FAILURE);
break;
};
}
}
void _acquire(int mode)
{
seq(1, 0, 0, mode);
if (opt_delay)
usleep(opt_delay);
}
void _convert(int mode)
{
seq(0, 1, 0, mode);
if (opt_delay)
usleep(opt_delay);
}
void _unlock(void)
{
seq(0, 0, 1, 0);
if (opt_delay)
usleep(opt_delay);
}
int main(int argc, char *argv[])
{
int rv, quit = 0;
decode_arguments(argc, argv);
printf("%d resources, %d locks per resource\n", num_r, num_lpr);
if (openclose) {
log_debug("dlm_open_lockspace...");
dh = dlm_open_lockspace("dlm_seq");
if (!dh) {
log_error("dlm_open_lockspace error %lu %d",
(unsigned long)dh, errno);
return -ENOTCONN;
}
} else {
log_debug("dlm_new_lockspace...");
dh = dlm_new_lockspace("dlm_seq", 0600, 0);
if (!dh) {
log_error("dlm_new_lockspace error %lu %d",
(unsigned long)dh, errno);
return -ENOTCONN;
}
}
libdlm_fd = dlm_ls_get_fd(dh);
if (libdlm_fd < 0) {
log_error("dlm_ls_get fd error %d %d", libdlm_fd, errno);
goto done;
}
lkids = malloc(sizeof(uint32_t) * (num_r * num_lpr));
if (!lkids) {
log_error("no mem");
goto done;
}
while (1) {
_acquire(LKM_EXMODE);
_convert(LKM_PRMODE);
_unlock();
_acquire(LKM_EXMODE);
_unlock();
_acquire(LKM_EXMODE);
_convert(LKM_NLMODE);
_convert(LKM_EXMODE);
_unlock();
_acquire(LKM_PRMODE);
_convert(LKM_EXMODE);
_unlock();
_acquire(LKM_PRMODE);
_unlock();
_acquire(LKM_PRMODE);
_convert(LKM_NLMODE);
_convert(LKM_PRMODE);
_unlock();
_acquire(LKM_NLMODE);
_convert(LKM_PRMODE);
_unlock();
_acquire(LKM_NLMODE);
_unlock();
_acquire(LKM_NLMODE);
_convert(LKM_EXMODE);
_convert(LKM_NLMODE);
_unlock();
iter++;
if (!num_iter)
continue;
if (iter == num_iter)
break;
}
free(lkids);
done:
if (openclose) {
log_debug("dlm_close_lockspace");
rv = dlm_close_lockspace(dh);
if (rv < 0)
log_error("dlm_close_lockspace error %d %d",
rv, errno);
} else {
log_debug("dlm_release_lockspace");
rv = dlm_release_lockspace("dlm_seq", dh, 1);
if (rv < 0)
log_error("dlm_release_lockspace error %d %d",
rv, errno);
}
return 0;
}

View File

@ -0,0 +1,327 @@
/*
* Copyright (c) 2011 David Teigland
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License V2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it would be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/* gcc dlm_seq_sync.c -ldlm_lt -o dlm_seq_sync */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <signal.h>
#include <syslog.h>
#include <sys/time.h>
#include <asm/types.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/un.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include "libdlm.h"
#define DEFAULT_NUM_R 1000
#define DEFAULT_NUM_LPR 1
static dlm_lshandle_t *dh;
static int openclose = 0;
static int quiet = 0;
static int verbose = 0;
static int opt_convert = 0;
static int opt_unlock = 0;
static int opt_delay = 0;
static unsigned int num_r = DEFAULT_NUM_R;
static unsigned int num_lpr = DEFAULT_NUM_LPR;
static unsigned int num_iter = 1;
static unsigned int iter = 0;
static uint32_t *lkids;
static struct dlm_lksb lksb;
static unsigned int cb_count;
#define log_debug(fmt, args...) \
do { \
if (!quiet) \
printf(fmt "\n", ##args); \
} while (0)
#define log_error(fmt, args...) \
do { \
printf("ERROR " fmt "\n", ##args); \
exit(-1); \
} while (0)
static void seq(int acquire, int convert, int unlock, int mode)
{
char name[DLM_RESNAME_MAXLEN];
uint32_t lkid;
int i, j, rv;
for (i = 0; i < num_r; i++) {
snprintf(name, sizeof(name), "seq.%08d", i);
for (j = 0; j < num_lpr; j++) {
memset(&lksb, 0, sizeof(lksb));
if (acquire) {
printf("acquire %s %d\n", name, mode);
rv = dlm_ls_lock_wait(dh, mode, &lksb, 0,
name, strlen(name),
0, NULL, NULL, NULL);
}
if (convert) {
lksb.sb_lkid = lkids[(i * num_lpr) + j];
printf("convert %s %x %d\n", name, lksb.sb_lkid, mode);
rv = dlm_ls_lock_wait(dh, mode, &lksb,
LKF_CONVERT,
name, strlen(name),
0, NULL, NULL, NULL);
}
if (unlock) {
lkid = lkids[(i * num_lpr) + j];
printf("unlock %s %x\n", name, lkid);
rv = dlm_ls_unlock_wait(dh, lkid, 0, &lksb);
}
if (rv) {
log_error("dlm op %d %d %d %d,%d error %d",
acquire, convert, unlock, i, j, rv);
exit(EXIT_FAILURE);
}
if (acquire && lkids)
lkids[(i * num_lpr) + j] = lksb.sb_lkid;
}
}
}
static void print_usage(void)
{
printf("dlm_seq [options]\n");
printf("Options:\n");
printf("\n");
printf(" -i <n> Iterations (0 no limit), default 1)\n");
printf(" -r <n> The number of resources, default %d\n", DEFAULT_NUM_R);
printf(" -l <n> The number of locks per resource, default %d\n", DEFAULT_NUM_LPR);
printf(" -c Convert locks after acquiring them all\n");
printf(" -u Unlock locks after acquire/convert\n");
printf(" -s Same resource names in each iteration\n");
printf(" -d <us> Delay us between consecutive seq\n");
printf(" -o Open/close existing lockspace\n");
printf(" -v Verbose output\n");
printf(" -q Quiet output\n");
}
static void decode_arguments(int argc, char **argv)
{
int cont = 1;
int optchar;
while (cont) {
optchar = getopt(argc, argv, "i:r:l:cuvqohad:s");
switch (optchar) {
case 'i':
num_iter = atoi(optarg);
break;
case 'r':
num_r = atoi(optarg);
break;
case 'l':
num_lpr = atoi(optarg);
break;
case 'c':
opt_convert = 1;
break;
case 'u':
opt_unlock = 1;
break;
case 'd':
opt_delay = atoi(optarg);
break;
case 'o':
openclose = 1;
break;
case 'v':
verbose = 1;
break;
case 'q':
quiet = 1;
break;
case 'h':
print_usage();
exit(EXIT_SUCCESS);
break;
case 'V':
printf("%s (built %s %s)\n", argv[0], __DATE__, __TIME__);
exit(EXIT_SUCCESS);
break;
case ':':
case '?':
fprintf(stderr, "Please use '-h' for usage.\n");
exit(EXIT_FAILURE);
break;
case EOF:
cont = 0;
break;
default:
fprintf(stderr, "unknown option: %c\n", optchar);
exit(EXIT_FAILURE);
break;
};
}
}
void _acquire(int mode)
{
seq(1, 0, 0, mode);
if (opt_delay)
usleep(opt_delay);
}
void _convert(int mode)
{
seq(0, 1, 0, mode);
if (opt_delay)
usleep(opt_delay);
}
void _unlock(void)
{
seq(0, 0, 1, 0);
if (opt_delay)
usleep(opt_delay);
}
int main(int argc, char *argv[])
{
int rv, quit = 0;
decode_arguments(argc, argv);
printf("%d resources, %d locks per resource\n", num_r, num_lpr);
if (openclose) {
log_debug("dlm_open_lockspace...");
dh = dlm_open_lockspace("dlm_seq");
if (!dh) {
log_error("dlm_open_lockspace error %lu %d",
(unsigned long)dh, errno);
return -ENOTCONN;
}
} else {
log_debug("dlm_new_lockspace...");
dh = dlm_new_lockspace("dlm_seq", 0600, 0);
if (!dh) {
log_error("dlm_new_lockspace error %lu %d",
(unsigned long)dh, errno);
return -ENOTCONN;
}
}
lkids = malloc(sizeof(uint32_t) * (num_r * num_lpr));
if (!lkids) {
log_error("no mem");
goto done;
}
while (1) {
_acquire(LKM_EXMODE);
_convert(LKM_PRMODE);
_unlock();
_acquire(LKM_EXMODE);
_unlock();
_acquire(LKM_EXMODE);
_convert(LKM_NLMODE);
_convert(LKM_EXMODE);
_unlock();
_acquire(LKM_PRMODE);
_convert(LKM_EXMODE);
_unlock();
_acquire(LKM_PRMODE);
_unlock();
_acquire(LKM_PRMODE);
_convert(LKM_NLMODE);
_convert(LKM_PRMODE);
_unlock();
_acquire(LKM_NLMODE);
_convert(LKM_PRMODE);
_unlock();
_acquire(LKM_NLMODE);
_unlock();
_acquire(LKM_NLMODE);
_convert(LKM_EXMODE);
_convert(LKM_NLMODE);
_unlock();
iter++;
if (!num_iter)
continue;
if (iter == num_iter)
break;
}
free(lkids);
done:
if (openclose) {
log_debug("dlm_close_lockspace");
rv = dlm_close_lockspace(dh);
if (rv < 0)
log_error("dlm_close_lockspace error %d %d",
rv, errno);
} else {
log_debug("dlm_release_lockspace");
rv = dlm_release_lockspace("dlm_seq", dh, 1);
if (rv < 0)
log_error("dlm_release_lockspace error %d %d",
rv, errno);
}
return 0;
}

50
tests/scripts/run_tests.sh Executable file
View File

@ -0,0 +1,50 @@
#!/bin/bash
set -x
COROSYNC_NODE=$(hostname)
sed -e "s/@LOCAL_NODE@/$COROSYNC_NODE/" test-corosync-conf > /etc/corosync/corosync.conf
modprobe configfs
mount -t configfs none /sys/kernel/config
modprobe dlm
ls /sys/kernel/config
ls /sys/kernel/config/dlm
mkdir /var/log/cluster
systemctl start corosync
sleep 2
corosync-quorumtool
sleep 2
tail -8 /var/log/cluster/corosync.conf
mkdir /var/log/dlm_controld
dlm_controld --log_debug --debug_logfile --enable_fencing 0 --enable_quorum_lockspace 0 --enable_quorum_fencing 0 --enable_startup_fencing 0
sleep 2
tail -8 /var/log/dlm_controld/dlm_controld.log
ls /sys/kernel/config/dlm
dlm_tool status
gcc dlm_seq_async.c -ldlm -o dlm_seq_async
gcc dlm_seq_sync.c -ldlm_lt -o dlm_seq_sync
./dlm_seq_sync -i 100 -d 10000 -c -u -v -r 10 -i 10
[ $? -ne 0 ] && echo "dlm_seq_sync error" >&2 && exit 1
./dlm_seq_async -i 100 -d 10000 -c -u -v -r 10 -i 10
[ $? -ne 0 ] && echo "dlm_seq_async error" >&2 && exit 1
pkill dlm_controld
sleep 2
corosync-cfgtool -H

View File

@ -0,0 +1,20 @@
totem {
version: 2
secauth: off
cluster_name: test
}
nodelist {
node {
ring0_addr: @LOCAL_NODE@
nodeid: 1
}
}
quorum {
provider: corosync_votequorum
}
logging {
to_logfile: yes
logfile: /var/log/cluster/corosync.log
to_syslog: yes
}

14
tests/tests.yml Normal file
View File

@ -0,0 +1,14 @@
- hosts: localhost
roles:
- role: standard-test-basic # this is a standard test role, it takes care of the test environment, logging, archiving results..
tags:
- classic
tests:
- simple:
dir: scripts
run: ./run_tests.sh
required_packages:
- dlm
- dlm-devel
- corosync
- gcc