update to sanlock-2.7

This commit is contained in:
David Teigland 2013-03-06 14:15:54 -06:00
parent 9739cc73a6
commit 9581e6bc50
9 changed files with 10 additions and 505 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@
/sanlock-2.4.tar.gz
/sanlock-2.5.tar.gz
/sanlock-2.6.tar.gz
/sanlock-2.7.tar.gz

View File

@ -1,57 +0,0 @@
From 337c30353d650bd02bd1203b7859124926dfef71 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Mon, 5 Nov 2012 15:53:40 -0600
Subject: [PATCH] fix systemd service files
add [Unit] and disable the cgroup stuff to avoid
the set_scheduler failures
Signed-off-by: David Teigland <teigland@redhat.com>
---
init.d/fence_sanlockd.service | 1 +
init.d/sanlock.service | 2 ++
init.d/wdmd.service | 2 ++
3 files changed, 5 insertions(+)
diff --git a/init.d/fence_sanlockd.service b/init.d/fence_sanlockd.service
index 873da59..f2d655b 100644
--- a/init.d/fence_sanlockd.service
+++ b/init.d/fence_sanlockd.service
@@ -1,3 +1,4 @@
+[Unit]
Description=daemon for fence_sanlock agent
After=syslog.target wdmd.service sanlock.service
Before=corosync.service
diff --git a/init.d/sanlock.service b/init.d/sanlock.service
index ff4a3e7..f026fe0 100644
--- a/init.d/sanlock.service
+++ b/init.d/sanlock.service
@@ -1,8 +1,10 @@
+[Unit]
Description=Shared Storage Lease Manager
After=syslog.target wdmd.service
[Service]
Type=forking
+ControlGroup=cpu:/
ExecStart=/lib/systemd/systemd-sanlock start
ExecStop=/lib/systemd/systemd-sanlock stop
diff --git a/init.d/wdmd.service b/init.d/wdmd.service
index 88d00b6..efe46bf 100644
--- a/init.d/wdmd.service
+++ b/init.d/wdmd.service
@@ -1,8 +1,10 @@
+[Unit]
Description=Watchdog Multiplexing Daemon
After=syslog.target
[Service]
Type=forking
+ControlGroup=cpu:/
ExecStart=/lib/systemd/systemd-wdmd start
ExecStop=/lib/systemd/systemd-wdmd stop
--
1.7.10.1.362.g242cab3

View File

@ -1,29 +0,0 @@
From c7e288e4609bb84167a2ccb56ac66567c71be557 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 6 Nov 2012 15:36:16 -0600
Subject: [PATCH 2/3] wdmd: use mode 775 for run dir
init script already creates it as 775,
so this isn't a big problem.
Signed-off-by: David Teigland <teigland@redhat.com>
---
wdmd/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/wdmd/main.c b/wdmd/main.c
index 482ab29..646a0ac 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -1185,7 +1185,7 @@ static int lockfile(void)
int fd, rv;
old_umask = umask(0022);
- rv = mkdir(WDMD_RUN_DIR, 0777);
+ rv = mkdir(WDMD_RUN_DIR, 0775);
if (rv < 0 && errno != EEXIST) {
umask(old_umask);
return rv;
--
1.7.10.1.362.g242cab3

View File

@ -1,26 +0,0 @@
From 917c64327acb0ae53ce605dc6b47a4a0f4983827 Mon Sep 17 00:00:00 2001
From: Federico Simoncelli <fsimonce@redhat.com>
Date: Tue, 13 Nov 2012 10:59:09 -0600
Subject: [PATCH 3/3] systemd: add wdmd dependency for sanlock
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
init.d/sanlock.service | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/init.d/sanlock.service b/init.d/sanlock.service
index f026fe0..64d9ced 100644
--- a/init.d/sanlock.service
+++ b/init.d/sanlock.service
@@ -1,6 +1,7 @@
[Unit]
Description=Shared Storage Lease Manager
-After=syslog.target wdmd.service
+After=syslog.target
+Wants=wdmd.service
[Service]
Type=forking
--
1.7.10.1.362.g242cab3

View File

@ -1,153 +0,0 @@
From 265cc664ff5ffd08dd3ce30396e8573b7baf1488 Mon Sep 17 00:00:00 2001
From: Federico Simoncelli <fsimonce@redhat.com>
Date: Tue, 20 Nov 2012 11:52:22 -0500
Subject: [PATCH] wdmd: make the watchdog device configurable
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
src/sysconfig.sanlock => init.d/sanlock.sysconfig | 0
wdmd/sysconfig.wdmd => init.d/wdmd.sysconfig | 3 +++
wdmd/main.c | 29 +++++++++++++----------
3 files changed, 20 insertions(+), 12 deletions(-)
rename src/sysconfig.sanlock => init.d/sanlock.sysconfig (100%)
rename wdmd/sysconfig.wdmd => init.d/wdmd.sysconfig (73%)
diff --git a/src/sysconfig.sanlock b/init.d/sanlock.sysconfig
similarity index 100%
rename from src/sysconfig.sanlock
rename to init.d/sanlock.sysconfig
diff --git a/wdmd/sysconfig.wdmd b/init.d/wdmd.sysconfig
similarity index 73%
rename from wdmd/sysconfig.wdmd
rename to init.d/wdmd.sysconfig
index 06a13db..1ef8564 100644
--- a/wdmd/sysconfig.wdmd
+++ b/init.d/wdmd.sysconfig
@@ -5,4 +5,7 @@
#
# To enable use of test scripts
#WDMDOPTS="-G sanlock -S 1"
+#
+# To select a specific watchdog device
+#WDMDOPTS="-G sanlock -w /dev/watchdog1"
diff --git a/wdmd/main.c b/wdmd/main.c
index 482ab29..ff2d57c 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -64,6 +64,7 @@ static int shm_fd;
static int allow_scripts;
static int kill_script_sec;
static char *scripts_dir = (char *)"/etc/wdmd.d";
+static char *watchdog_path = "/dev/watchdog";
struct script_status {
uint64_t start;
@@ -921,13 +922,13 @@ static int open_dev(void)
int fd;
if (dev_fd != -1) {
- log_error("/dev/watchdog already open fd %d", dev_fd);
+ log_error("watchdog already open fd %d", dev_fd);
return -1;
}
- fd = open("/dev/watchdog", O_WRONLY | O_CLOEXEC);
+ fd = open(watchdog_path, O_WRONLY | O_CLOEXEC);
if (fd < 0) {
- log_error("no /dev/watchdog, load a watchdog driver");
+ log_error("no %s, load a watchdog driver", watchdog_path);
return fd;
}
@@ -942,7 +943,7 @@ static void close_watchdog_unclean(void)
return;
}
- log_error("/dev/watchdog closed unclean");
+ log_error("%s closed unclean", watchdog_path);
close(dev_fd);
dev_fd = -1;
@@ -960,9 +961,9 @@ static void close_watchdog(void)
rv = write(dev_fd, "V", 1);
if (rv < 0)
- log_error("/dev/watchdog disarm write error %d", errno);
+ log_error("%s disarm write error %d", watchdog_path, errno);
else
- log_error("/dev/watchdog disarmed");
+ log_error("%s disarmed", watchdog_path);
close(dev_fd);
dev_fd = -1;
@@ -980,7 +981,7 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_GETTIMEOUT, &timeout);
if (rv < 0) {
- log_error("/dev/watchdog failed to report timeout");
+ log_error("%s failed to report timeout", watchdog_path);
close_watchdog();
return -1;
}
@@ -992,18 +993,18 @@ static int setup_watchdog(void)
rv = ioctl(dev_fd, WDIOC_SETTIMEOUT, &timeout);
if (rv < 0) {
- log_error("/dev/watchdog failed to set timeout");
+ log_error("%s failed to set timeout", watchdog_path);
close_watchdog();
return -1;
}
if (timeout != fire_timeout) {
- log_error("/dev/watchdog failed to set new timeout");
+ log_error("%s failed to set new timeout", watchdog_path);
close_watchdog();
return -1;
}
out:
- log_error("/dev/watchdog armed with fire_timeout %d", fire_timeout);
+ log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);
return 0;
}
@@ -1150,7 +1151,7 @@ static int test_loop(void)
if (dev_fd == -1) {
open_dev();
pet_watchdog();
- log_error("/dev/watchdog reopen");
+ log_error("%s reopen", watchdog_path);
} else {
pet_watchdog();
}
@@ -1326,6 +1327,7 @@ static void print_usage_and_exit(int status)
printf("-s <path> path to scripts dir (default %s)\n", scripts_dir);
printf("-k <num> kill unfinished scripts after num seconds (default %d)\n",
kill_script_sec);
+ printf("-w /dev/watchdog path to the watchdog device (default %s)\n", watchdog_path);
exit(status);
}
@@ -1358,7 +1360,7 @@ int main(int argc, char *argv[])
{0, 0, 0, 0 }
};
- c = getopt_long(argc, argv, "hdVDH:G:S:s:k:",
+ c = getopt_long(argc, argv, "hdVDH:G:S:s:k:w:",
long_options, &option_index);
if (c == -1)
break;
@@ -1391,6 +1393,9 @@ int main(int argc, char *argv[])
case 'k':
kill_script_sec = atoi(optarg);
break;
+ case 'w':
+ watchdog_path = strdup(optarg);
+ break;
}
}
--
1.7.11.7

View File

@ -1,59 +0,0 @@
From e076556572ae9129807a0ae00bb63b7ff0a54807 Mon Sep 17 00:00:00 2001
From: Federico Simoncelli <fsimonce@redhat.com>
Date: Mon, 10 Dec 2012 17:33:58 +0100
Subject: [PATCH 5/6] wdmd: fix miscellaneous build warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixed warnings:
* wdmd: _FORTIFY_SOURCE requires compiling with optimization (-O)
* wdmd: initialization discards const qualifier from pointer target type
* ignoring return value of write
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>
---
wdmd/Makefile | 2 +-
wdmd/main.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/wdmd/Makefile b/wdmd/Makefile
index de6b035..bf871c5 100644
--- a/wdmd/Makefile
+++ b/wdmd/Makefile
@@ -21,7 +21,7 @@ LIB_SOURCE = client.c wdmd_sock.c
TEST_SOURCE = wdmd_client.c
-CFLAGS += -D_GNU_SOURCE -g \
+CFLAGS += -D_GNU_SOURCE -g -O2 \
-Wall \
-Wformat \
-Wformat-security \
diff --git a/wdmd/main.c b/wdmd/main.c
index ff2d57c..8a97f04 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -63,8 +63,8 @@ static int shm_fd;
static int allow_scripts;
static int kill_script_sec;
-static char *scripts_dir = (char *)"/etc/wdmd.d";
-static char *watchdog_path = "/dev/watchdog";
+static const char *scripts_dir = "/etc/wdmd.d";
+static const char *watchdog_path = "/dev/watchdog";
struct script_status {
uint64_t start;
@@ -1307,7 +1307,7 @@ static void print_debug_and_exit(void)
if (rv < 0)
exit(1);
- write(STDOUT_FILENO, debug_buf, strlen(debug_buf));
+ rv = write(STDOUT_FILENO, debug_buf, strlen(debug_buf));
exit(0);
}
--
1.7.11.7

View File

@ -1,164 +0,0 @@
From b154ab95212f2a882f9893000a184199baa8fb68 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 8 Jan 2013 14:23:14 -0600
Subject: [PATCH 6/6] wdmd: dynamically select working watchdog device
Some watchdog drivers enable both /dev/watchdog0 and
/dev/watchdog1. Sometimes, only one of them works,
and the working one is not consistent. So, we need
to test which works before deciding which to use.
Signed-off-by: David Teigland <teigland@redhat.com>
---
wdmd/main.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 82 insertions(+), 5 deletions(-)
diff --git a/wdmd/main.c b/wdmd/main.c
index 8a97f04..827d1bb 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -49,6 +49,8 @@
#define DEFAULT_SOCKET_GID 0
#define DEFAULT_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
+#define WDPATH_SIZE 64
+
static int test_interval = DEFAULT_TEST_INTERVAL;
static int fire_timeout = DEFAULT_FIRE_TIMEOUT;
static int high_priority = DEFAULT_HIGH_PRIORITY;
@@ -64,7 +66,9 @@ static int shm_fd;
static int allow_scripts;
static int kill_script_sec;
static const char *scripts_dir = "/etc/wdmd.d";
-static const char *watchdog_path = "/dev/watchdog";
+static char watchdog_path[WDPATH_SIZE];
+static char option_path[WDPATH_SIZE];
+static char saved_path[WDPATH_SIZE];
struct script_status {
uint64_t start;
@@ -928,7 +932,7 @@ static int open_dev(void)
fd = open(watchdog_path, O_WRONLY | O_CLOEXEC);
if (fd < 0) {
- log_error("no %s, load a watchdog driver", watchdog_path);
+ log_error("open %s error %d", watchdog_path, errno);
return fd;
}
@@ -969,10 +973,18 @@ static void close_watchdog(void)
dev_fd = -1;
}
-static int setup_watchdog(void)
+static int _setup_watchdog(char *path)
{
+ struct stat buf;
int rv, timeout;
+ strncpy(watchdog_path, path, WDPATH_SIZE);
+ watchdog_path[WDPATH_SIZE - 1] = '\0';
+
+ rv = stat(watchdog_path, &buf);
+ if (rv < 0)
+ return -1;
+
rv = open_dev();
if (rv < 0)
return -1;
@@ -1006,9 +1018,73 @@ static int setup_watchdog(void)
out:
log_error("%s armed with fire_timeout %d", watchdog_path, fire_timeout);
+ /* TODO: save watchdog_path in /var/run/wdmd/saved_path,
+ * and in startup read that file, copying it to saved_path */
+
return 0;
}
+/*
+ * Order of preference:
+ * . saved path (path used before daemon restart)
+ * . command line option (-w)
+ * . /dev/watchdog0
+ * . /dev/watchdog1
+ * . /dev/watchdog
+ */
+
+static int setup_watchdog(void)
+{
+ int rv;
+
+ if (!saved_path[0])
+ goto opt;
+
+ rv = _setup_watchdog(saved_path);
+ if (!rv)
+ return 0;
+
+ opt:
+ if (!option_path[0] || !strcmp(saved_path, option_path))
+ goto zero;
+
+ rv = _setup_watchdog(option_path);
+ if (!rv)
+ return 0;
+
+ zero:
+ if (!strcmp(saved_path, "/dev/watchdog0") ||
+ !strcmp(option_path, "/dev/watchdog0"))
+ goto one;
+
+ rv = _setup_watchdog((char *)"/dev/watchdog0");
+ if (!rv)
+ return 0;
+
+ one:
+ if (!strcmp(saved_path, "/dev/watchdog1") ||
+ !strcmp(option_path, "/dev/watchdog1"))
+ goto old;
+
+ rv = _setup_watchdog((char *)"/dev/watchdog1");
+ if (!rv)
+ return 0;
+
+ old:
+ if (!strcmp(saved_path, "/dev/watchdog") ||
+ !strcmp(option_path, "/dev/watchdog"))
+ goto out;
+
+ rv = _setup_watchdog((char *)"/dev/watchdog");
+ if (!rv)
+ return 0;
+
+ out:
+ log_error("no watchdog device, load a watchdog driver");
+ return -1;
+
+}
+
static void pet_watchdog(void)
{
int rv, unused;
@@ -1327,7 +1403,7 @@ static void print_usage_and_exit(int status)
printf("-s <path> path to scripts dir (default %s)\n", scripts_dir);
printf("-k <num> kill unfinished scripts after num seconds (default %d)\n",
kill_script_sec);
- printf("-w /dev/watchdog path to the watchdog device (default %s)\n", watchdog_path);
+ printf("-w /dev/watchdog path to the watchdog device to try first\n");
exit(status);
}
@@ -1394,7 +1470,8 @@ int main(int argc, char *argv[])
kill_script_sec = atoi(optarg);
break;
case 'w':
- watchdog_path = strdup(optarg);
+ snprintf(option_path, WDPATH_SIZE, "%s", optarg);
+ option_path[WDPATH_SIZE - 1] = '\0';
break;
}
}
--
1.7.11.7

View File

@ -1,6 +1,6 @@
Name: sanlock
Version: 2.6
Release: 8%{?dist}
Version: 2.7
Release: 1%{?dist}
Summary: A shared disk lock manager
Group: System Environment/Base
@ -17,15 +17,9 @@ ExclusiveArch: x86_64
Requires: %{name}-lib = %{version}-%{release}
Requires(pre): /usr/sbin/groupadd
Requires(pre): /usr/sbin/useradd
Source0: https://fedorahosted.org/releases/s/a/sanlock/%{name}-%{version}.tar.gz
Patch0: 0001-fix-systemd-service-files.patch
Patch1: 0002-wdmd-use-mode-775-for-run-dir.patch
Patch2: 0003-systemd-add-wdmd-dependency-for-sanlock.patch
Patch3: 0004-wdmd-make-the-watchdog-device-configurable.patch
Patch4: 0005-wdmd-fix-miscellaneous-build-warnings.patch
Patch5: 0006-wdmd-dynamically-select-working-watchdog-device.patch
Source0: http://git.fedorahosted.org/cgit/sanlock.git/snapshot/%{name}-%{version}.tar.gz
#Patch0: foo.patch
%description
sanlock uses disk paxos to manage leases on shared storage.
@ -34,12 +28,7 @@ access to the shared disks.
%prep
%setup -q
%patch0 -p1 -b .0001-fix-systemd-service-files
%patch1 -p1 -b .0002-wdmd-use-mode-775-for-run-dir
%patch2 -p1 -b .0003-systemd-add-wdmd-dependency-for-sanlock
%patch3 -p1 -b .0004-wdmd-make-the-watchdog-device-configurable
%patch4 -p1 -b .0005-wdmd-fix-miscellaneous-build-warnings
%patch5 -p1 -b .0006-wdmd-dynamically-select-working-watchdog-device
#%patch0 -p1 -b .0001-foo.patch
%build
# upstream does not require configure
@ -268,6 +257,9 @@ if [ $1 -ge 1 ] ; then
fi
%changelog
* Wed Mar 06 2013 David Teigland <teigland@redhat.com> - 2.7-1
- Update to sanlock-2.7
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.6-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

View File

@ -1 +1 @@
c488b1914e0996246e3572a359093d7d sanlock-2.6.tar.gz
682323103d06666e4d83274b597a7b27 sanlock-2.7.tar.gz