Compare commits

...

No commits in common. "c8" and "c9s" have entirely different histories.
c8 ... c9s

14 changed files with 1105 additions and 36 deletions

View File

@ -1 +1 @@
821112426f474123d090c570153d67468c4e0c11 SOURCES/dlm-4.1.0.tar.gz
9239bf86ecd26fd532528fbcd64712d79e389ff3 dlm-4.2.0.tar.gz

15
.gitignore vendored
View File

@ -1 +1,14 @@
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.1.tar.gz
/dlm-4.2.0.tar.gz

View File

@ -0,0 +1,70 @@
From 4cfb7b21a88f0ae32d97ea4cbb0c7419b88f397d Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo@redhat.com>
Date: Wed, 12 Oct 2022 12:44:03 -0400
Subject: [PATCH] Revert "treewide: add -fcf-protection=full to CFLAGS"
This reverts commit 215aedf1fdff58c62fe596284948590965acc85c.
---
dlm_controld/Makefile | 2 +-
dlm_tool/Makefile | 2 +-
fence/Makefile | 2 +-
libdlm/Makefile | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index ec8c360cc853..9cf7152f60ab 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -43,7 +43,7 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-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 -fcf-protection=full
+ -fstack-clash-protection
BIN_CFLAGS += $(CFLAGS) -fPIE -DPIE
BIN_CFLAGS += -I../include -I../libdlm
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index 57629c731771..1c3d61d5c860 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -15,7 +15,7 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-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 -fcf-protection=full
+ -fstack-clash-protection
CFLAGS += -fPIE -DPIE
CFLAGS += -I../include -I../libdlm -I../dlm_controld
diff --git a/fence/Makefile b/fence/Makefile
index 446f4eaac9f9..ee4dfb886d4c 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -15,7 +15,7 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-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 -fcf-protection=full
+ -fstack-clash-protection
CFLAGS += -fPIE -DPIE
CFLAGS += -I../include
diff --git a/libdlm/Makefile b/libdlm/Makefile
index 823fdaa94073..5069ccf1f7f9 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -80,8 +80,8 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-fdiagnostics-show-option \
-fPIC
-LIB_CFLAGS += $(CFLAGS) -D_REENTRANT -fcf-protection=full
-LLT_CFLAGS += $(CFLAGS) -fcf-protection=full
+LIB_CFLAGS += $(CFLAGS) -D_REENTRANT
+LLT_CFLAGS += $(CFLAGS)
LIB_LDFLAGS += $(LDFLAGS) -lpthread -Wl,-z,now
LLT_LDFLAGS += $(LDFLAGS) -Wl,-z,now
--
2.7.5

View File

@ -0,0 +1,48 @@
From 4f6e9461edb571577eebb712e676eec4c7edd5ec Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 8 Feb 2022 09:54:06 -0600
Subject: [PATCH 1/5] dlm_controld: fix printf args in log messages
Fix log message arg types in two recent commits:
dcc945a9d40b90a7b13d7f826f2726f35921f95b
"dlm_controld: use uint64_t for cluster ringid"
b0222892f0b82ff680d4b3f9ac4250f47300d897
"dlm_controld: add support for per nodeid configuration"
---
dlm_controld/cpg.c | 2 +-
dlm_controld/node_config.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlm_controld/cpg.c b/dlm_controld/cpg.c
index f3365ee4cd77..b9f9a16b8ae0 100644
--- a/dlm_controld/cpg.c
+++ b/dlm_controld/cpg.c
@@ -450,7 +450,7 @@ static int check_ringid_done(struct lockspace *ls)
but that's probably not guaranteed.) */
if (ls->cpg_ringid_wait) {
- log_group(ls, "check_ringid wait cluster %u cpg %llu:%llu",
+ log_group(ls, "check_ringid wait cluster %llu cpg %u:%llu",
(unsigned long long)cluster_ringid_seq,
ls->cpg_ringid.nodeid,
(unsigned long long)ls->cpg_ringid.seq);
diff --git a/dlm_controld/node_config.c b/dlm_controld/node_config.c
index fe794be72f22..9845e8988e8c 100644
--- a/dlm_controld/node_config.c
+++ b/dlm_controld/node_config.c
@@ -58,8 +58,8 @@ int node_config_init(const char *path)
}
nc[nodeid].mark = mark;
- log_debug("parsed node config id=%d mark=%" PRIu32,
- nodeid, mark);
+ log_debug("parsed node config id=%d mark=%llu",
+ nodeid, (unsigned long long)mark);
}
}
--
2.7.5

View File

@ -0,0 +1,36 @@
From c745ac4ce06df71b13c5901aa2e6c3772f3661dd Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo@redhat.com>
Date: Thu, 2 Dec 2021 13:27:26 -0500
Subject: [PATCH 2/5] stonith_helper: Don't link dlm_stonith against libxml2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Took it from the debian patches. There is no need to link against
libxml2 for the stonith_helper tool.
Reported-by: Ferenc Wágner <wferi@debian.org>
---
fence/Makefile | 2 --
1 file changed, 2 deletions(-)
diff --git a/fence/Makefile b/fence/Makefile
index 2b080468eaa0..547f7ba946ff 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -18,12 +18,10 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-fstack-clash-protection -Wl,-z,now
CFLAGS += -fPIE -DPIE
-CFLAGS += `xml2-config --cflags`
CFLAGS += -I../include
CFLAGS += $(shell pkg-config --cflags pacemaker-fencing)
LDFLAGS += -Wl,-z,relro -Wl,-z,defs -pie
-LDFLAGS += `xml2-config --libs`
LDFLAGS += -ldl
all: $(BIN_TARGET)
--
2.7.5

View File

@ -0,0 +1,106 @@
From 681b54fd40b7a5e5c960bbd3e8aedca0fd4db575 Mon Sep 17 00:00:00 2001
From: Alexander Aring <aahringo@redhat.com>
Date: Tue, 8 Feb 2022 14:42:53 -0500
Subject: [PATCH 3/5] treewide: do always -Wl,-z,now in LDFLAGS
This patch reverts commit 7bb5570a ("treewide: try to resolve symbols at
linking time") because the recommended way to avoid security related
issues is always to use -Wl,-z,now.
This is solving the following annocheck failure:
https://sourceware.org/annobin/annobin.html/Test-bind-now.html
---
dlm_controld/Makefile | 6 +++---
dlm_tool/Makefile | 4 ++--
fence/Makefile | 4 ++--
libdlm/Makefile | 7 +++----
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index 8cfc97e6909a..a92fdebe2cba 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -43,15 +43,15 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-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
+ -fstack-clash-protection
BIN_CFLAGS += $(CFLAGS) -fPIE -DPIE
BIN_CFLAGS += -I../include -I../libdlm
LIB_CFLAGS += $(CFLAGS) -fPIC
-BIN_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -Wl,-z,defs -pie
+BIN_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -Wl,-z,now -pie
BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum -luuid
-LIB_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -Wl,-z,defs -pie
+LIB_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -Wl,-z,now -pie
PKG_CONFIG ?= pkg-config
ifeq ($(USE_SD_NOTIFY),yes)
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index 7b42638c0e4a..1c3d61d5c860 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -15,12 +15,12 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-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
+ -fstack-clash-protection
CFLAGS += -fPIE -DPIE
CFLAGS += -I../include -I../libdlm -I../dlm_controld
-LDFLAGS += -Wl,-z,relro -Wl,-z,defs -pie
+LDFLAGS += -Wl,-z,relro -Wl,-z,now -pie
LDFLAGS += -L../libdlm -L../dlm_controld
LDFLAGS += -lpthread -ldlm -ldlmcontrol
diff --git a/fence/Makefile b/fence/Makefile
index 547f7ba946ff..ee4dfb886d4c 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -15,13 +15,13 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-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
+ -fstack-clash-protection
CFLAGS += -fPIE -DPIE
CFLAGS += -I../include
CFLAGS += $(shell pkg-config --cflags pacemaker-fencing)
-LDFLAGS += -Wl,-z,relro -Wl,-z,defs -pie
+LDFLAGS += -Wl,-z,relro -Wl,-z,now -pie
LDFLAGS += -ldl
all: $(BIN_TARGET)
diff --git a/libdlm/Makefile b/libdlm/Makefile
index 313c2a08f17e..5069ccf1f7f9 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -78,14 +78,13 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-fexceptions \
-fasynchronous-unwind-tables \
-fdiagnostics-show-option \
- -fPIC \
- -Wl,-z,now
+ -fPIC
LIB_CFLAGS += $(CFLAGS) -D_REENTRANT
LLT_CFLAGS += $(CFLAGS)
-LIB_LDFLAGS += $(LDFLAGS) -lpthread -Wl,-z,defs
-LLT_LDFLAGS += $(LDFLAGS) -Wl,-z,defs
+LIB_LDFLAGS += $(LDFLAGS) -lpthread -Wl,-z,now
+LLT_LDFLAGS += $(LDFLAGS) -Wl,-z,now
all: $(LIB_TARGET) $(LLT_TARGET) $(LIB_PC) $(LLT_PC)
--
2.7.5

View File

@ -1,27 +1,28 @@
Name: dlm
Version: 4.1.0
Release: 1%{?dist}
Version: 4.2.0
Release: 2%{?dist}
License: GPLv2 and GPLv2+ and LGPLv2+
# For a breakdown of the licensing, see README.license
Group: System Environment/Kernel
Summary: dlm control daemon and tool
URL: https://pagure.io/dlm
BuildRequires: gcc
BuildRequires: glibc-kernheaders
BuildRequires: corosynclib-devel >= 1.99.9
BuildRequires: corosynclib-devel >= 3.1.0
BuildRequires: pacemaker-libs-devel >= 1.1.7
BuildRequires: libxml2-devel
BuildRequires: systemd-units
BuildRequires: systemd-devel
BuildRequires: make
Source0: https://releases.pagure.org/dlm/%{name}-%{version}.tar.gz
# Patch0: 0001-foo.patch
Patch0: 0001-Revert-treewide-add-fcf-protection-full-to-CFLAGS.patch
%if 0%{?rhel} && 0%{?rhel} <= 7
ExclusiveArch: i686 x86_64
%endif
Requires: %{name}-lib = %{version}-%{release}
Requires: corosync >= 1.99.9
Requires: corosync >= 3.1.0
%{?fedora:Requires: kernel-modules-extra}
Requires(post): systemd-units
Requires(preun): systemd-units
@ -33,13 +34,13 @@ The kernel dlm requires a user daemon to control membership.
%prep
%setup -q
# %patch0 -p1 -b .0001-foo.patch
%patch0 -p1 -b .backup0
%build
# upstream does not require configure
# upstream does not support _smp_mflags
CFLAGS+=$RPM_OPT_FLAGS make
CFLAGS+=$RPM_OPT_FLAGS make -C fence
CFLAGS=$RPM_OPT_FLAGS make
CFLAGS=$RPM_OPT_FLAGS make -C fence
%install
rm -rf $RPM_BUILD_ROOT
@ -59,7 +60,6 @@ install -Dm 0644 init/dlm.sysconfig %{buildroot}/etc/sysconfig/dlm
%systemd_postun_with_restart dlm.service
%files
%defattr(-,root,root,-)
%doc README.license
%{_unitdir}/dlm.service
%{_sbindir}/dlm_controld
@ -72,25 +72,20 @@ install -Dm 0644 init/dlm.sysconfig %{buildroot}/etc/sysconfig/dlm
%package lib
Summary: Library for %{name}
Group: System Environment/Libraries
Conflicts: clusterlib
%description lib
The %{name}-lib package contains the libraries needed to use the dlm
from userland applications.
%post lib -p /sbin/ldconfig
%postun lib -p /sbin/ldconfig
%ldconfig_scriptlets lib
%files lib
%defattr(-,root,root,-)
%{_prefix}/lib/udev/rules.d/*-dlm.rules
/usr/lib/udev/rules.d/*-dlm.rules
%{_libdir}/libdlm*.so.*
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
Requires: %{name}-lib = %{version}-%{release}
Conflicts: clusterlib-devel
@ -99,35 +94,56 @@ The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.
%files devel
%defattr(-,root,root,-)
%{_libdir}/libdlm*.so
%{_includedir}/libdlm*.h
%{_libdir}/pkgconfig/*.pc
%changelog
* Wed Jan 13 2021 David Teigland <teigland@redhat.com> - 4.1.0-1
- update to 4.1.0
* Fri Oct 14 2022 David Teigland <teigland@redhat.com> - 4.2.0-2
- rebuild with tests
* Wed Jan 06 2021 David Teigland <teigland@redhat.com> - 4.0.9-4
- dlm_controld: use new quorum api to detect missed failures
* Wed Oct 12 2022 David Teigland <teigland@redhat.com> - 4.2.0-1
- new upstream version
* Wed Jun 12 2019 David Teigland <teigland@redhat.com> - 4.0.9-3
- kick gating system
* Tue Feb 15 2022 David Teigland <teigland@redhat.com> - 4.1.1-2
- compiler warnings and makefile flags
* Wed Jun 12 2019 David Teigland <teigland@redhat.com> - 4.0.9-2
- try to kick gating system
* Mon Nov 15 2021 David Teigland <teigland@redhat.com> - 4.1.1-1
- new upstream version
* Tue Jun 11 2019 David Teigland <teigland@redhat.com> - 4.0.9-1
- update to 4.0.9
* Wed Aug 25 2021 David Teigland <teigland@redhat.com> - 4.0.9-7
- fix pacemaker header
* Wed Jan 23 2019 David Teigland <teigland@redhat.com> - 4.0.6-10
- dlm_controld: ignore unwanted uevent strings
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 4.0.9-6
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Tue Oct 02 2018 David Teigland <teigland@redhat.com> - 4.0.6-9
- update makefile gcc flags
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 4.0.9-5
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Thu Aug 09 2018 David Teigland <teigland@redhat.com> - 4.0.6-8
- Work around glibc regression for major/minor header
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.9-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.9-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Wed Jul 31 2019 David Teigland <teigland@redhat.com> - 4.0.9-1
- New upstream realease
* Wed Jul 24 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.6-11
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.6-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.6-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Sat Mar 24 2018 Richard W.M. Jones <rjones@redhat.com> - 4.0.6-8
- Fixes for glibc 2.27, required for riscv64.
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 4.0.6-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-8
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} # this is the testcase identifier, which OSCI pipeline uses

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (dlm-4.2.0.tar.gz) = b437373d292a6020c47bec2d2c3d630460332d2f0158033d719d156e3a6bead9bd37452ef7679da2cbac5d96a9d056a7daff203e45ddfe6dab47cc230abf48b9

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;
}

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