diff --git a/0002-wdmd-make-the-watchdog-device-configurable.patch b/0002-wdmd-make-the-watchdog-device-configurable.patch new file mode 100644 index 0000000..4cbdfe8 --- /dev/null +++ b/0002-wdmd-make-the-watchdog-device-configurable.patch @@ -0,0 +1,153 @@ +From 265cc664ff5ffd08dd3ce30396e8573b7baf1488 Mon Sep 17 00:00:00 2001 +From: Federico Simoncelli +Date: Tue, 20 Nov 2012 11:52:22 -0500 +Subject: [PATCH] wdmd: make the watchdog device configurable + +Signed-off-by: Federico Simoncelli +--- + 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 to scripts dir (default %s)\n", scripts_dir); + printf("-k 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 + diff --git a/sanlock.spec b/sanlock.spec index 7e0a82c..a606156 100644 --- a/sanlock.spec +++ b/sanlock.spec @@ -1,6 +1,6 @@ Name: sanlock Version: 2.6 -Release: 3%{?dist} +Release: 4%{?dist} Summary: A shared disk lock manager Group: System Environment/Base @@ -17,6 +17,7 @@ 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-make-the-watchdog-device-configurable.patch %description sanlock uses disk paxos to manage leases on shared storage. @@ -25,7 +26,8 @@ access to the shared disks. %prep %setup -q -%patch0 -p1 -b .0001-fix-systemd-service-files.patch +%patch0 -p1 -b .0001-fix-systemd-service-files +%patch1 -p1 -b .0002-wdmd-make-the-watchdog-device-configurable %build # upstream does not require configure @@ -66,10 +68,10 @@ install -D -m 755 init.d/fence_sanlockd $RPM_BUILD_ROOT/%{_initddir}/fence_sanlo install -Dm 0644 src/logrotate.sanlock \ $RPM_BUILD_ROOT/etc/logrotate.d/sanlock -install -Dm 0644 src/sysconfig.sanlock \ +install -D -m 0644 init.d/sanlock.sysconfig \ $RPM_BUILD_ROOT/etc/sysconfig/sanlock -install -Dm 0644 wdmd/sysconfig.wdmd \ +install -D -m 0644 init.d/wdmd.sysconfig \ $RPM_BUILD_ROOT/etc/sysconfig/wdmd install -dm 0755 $RPM_BUILD_ROOT/etc/wdmd.d @@ -255,6 +257,9 @@ if [ $1 -ge 1 ] ; then fi %changelog +* Wed Jan 2 2013 Federico Simoncelli 2.6-4 +- wdmd: make the watchdog device configurable + * Mon Nov 05 2012 David Teigland - 2.6-3 - fix systemd service files and install them on rhel7