src/main.c
by David Teigland
src/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit 4502c270ce11a9b4cff15a31804d7aa200b600d4
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jan 24 14:09:55 2013 -0600
sanlock: shutdown or rem_lockspace should SIGKILL
rem_lockspace (without UNUSED) or shutdown (with force)
clear any pids using the lockspace. They should go
directly to using SIGKILL instead of attempting to use a
killpath.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/main.c b/src/main.c
index 90436a5..3444f0c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -615,7 +615,9 @@ static void kill_pids(struct space *sp)
in_grace = now < (last_success + id_renewal_fail_seconds + kill_grace_seconds);
- if ((kill_grace_seconds > 0) && in_grace && cl->killpath[0]) {
+ if (sp->external_remove || (external_shutdown > 1)) {
+ sig = SIGKILL;
+ } else if ((kill_grace_seconds > 0) && in_grace && cl->killpath[0]) {
sig = SIGRUNPATH;
} else if (in_grace) {
sig = SIGTERM;
10 years, 8 months
fence_sanlock/fence_sanlock.8
by David Teigland
fence_sanlock/fence_sanlock.8 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 30ed09ab2b5e04049f0687dc1d11cb6d9aae8ccc
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Dec 13 14:18:22 2012 -0600
fence_sanlock: fix man page name of path arg
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/fence_sanlock/fence_sanlock.8 b/fence_sanlock/fence_sanlock.8
index 3c1d472..d9e41be 100644
--- a/fence_sanlock/fence_sanlock.8
+++ b/fence_sanlock/fence_sanlock.8
@@ -191,7 +191,7 @@ Example cluster.conf configuration for fence_sanlock:
</unfence>
</clusternode>
-<fencedevice name="wd" agent="fence_sanlock" device="/dev/fence/leases"/>
+<fencedevice name="wd" agent="fence_sanlock" path="/dev/fence/leases"/>
.fi
.SH SEE ALSO
10 years, 8 months
wdmd/main.c
by David Teigland
wdmd/main.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 82 insertions(+), 5 deletions(-)
New commits:
commit df0db196dfe27dbbaec156351faed44b3466083a
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Jan 8 14:23:14 2013 -0600
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(a)redhat.com>
diff --git a/wdmd/main.c b/wdmd/main.c
index 126524c..529b563 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;
@@ -1329,7 +1405,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);
}
@@ -1396,7 +1472,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;
}
}
10 years, 8 months
src/client.c src/main.c src/sanlock_admin.h
by David Teigland
src/client.c | 21 ++++++++++++---------
src/main.c | 23 ++++++++++++-----------
src/sanlock_admin.h | 6 ++----
3 files changed, 26 insertions(+), 24 deletions(-)
New commits:
commit 1c6186c3df0f0cf097fdf0b637003ba5b5ced632
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Jan 8 16:03:42 2013 -0600
sanlock: make get_lockspaces allocate space for data
Change get_lockspaces api so the client lib will
allocate memory for the lockspace data and return
it to the caller who will free it.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/client.c b/src/client.c
index ec2953f..5c78354 100644
--- a/src/client.c
+++ b/src/client.c
@@ -163,10 +163,10 @@ int sanlock_rem_lockspace(struct sanlk_lockspace *ls, uint32_t flags)
return cmd_lockspace(SM_CMD_REM_LOCKSPACE, ls, flags, 0);
}
-int sanlock_get_lockspaces(struct sanlk_lockspace *lss, int lss_size,
- int *lss_count, uint32_t flags)
+int sanlock_get_lockspaces(struct sanlk_lockspace **lss, int *lss_count,
+ uint32_t flags)
{
- struct sanlk_lockspace *ls;
+ struct sanlk_lockspace *lsbuf, *ls;
struct sm_header h;
int rv, fd, i, ret, recv_count;
@@ -202,30 +202,33 @@ int sanlock_get_lockspaces(struct sanlk_lockspace *lss, int lss_size,
*lss_count = h.data2;
recv_count = h.data2;
- if (recv_count * sizeof(struct sanlk_lockspace) > lss_size) {
- recv_count = lss_size / sizeof(struct sanlk_lockspace);
- rv = -ENOBUFS;
- }
-
if (!lss)
goto out;
- ls = lss;
+ lsbuf = malloc(recv_count * sizeof(struct sanlk_lockspace));
+ if (!lsbuf)
+ goto out;
+
+ ls = lsbuf;
for (i = 0; i < recv_count; i++) {
ret = recv(fd, ls, sizeof(struct sanlk_lockspace), MSG_WAITALL);
if (ret < 0) {
rv = -errno;
+ free(lsbuf);
goto out;
}
if (ret != sizeof(struct sanlk_lockspace)) {
rv = -1;
+ free(lsbuf);
goto out;
}
ls++;
}
+
+ *lss = lsbuf;
out:
close(fd);
return rv;
diff --git a/src/main.c b/src/main.c
index 0291e22..90436a5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2145,10 +2145,9 @@ static int do_client(void)
{
struct sanlk_resource **res_args = NULL;
struct sanlk_resource *res;
- struct sanlk_lockspace *ls;
+ struct sanlk_lockspace *lss, *ls;
char *res_state = NULL;
char *res_str = NULL;
- char *buf;
uint32_t io_timeout = 0;
int i, fd, count;
int rv = 0;
@@ -2173,21 +2172,23 @@ static int do_client(void)
break;
case ACT_GETS:
- buf = malloc(ONEMB);
- if (!buf)
- break;
- memset(buf, 0, ONEMB);
- ls = (struct sanlk_lockspace *)buf;
+ lss = NULL;
- rv = sanlock_get_lockspaces(ls, ONEMB, &count, 0);
+ rv = sanlock_get_lockspaces(&lss, &count, 0);
if (rv < 0)
log_tool("gets error %d", rv);
- if (rv < 0 && rv != -ENOBUFS && rv != -ENOSPC) {
- free(buf);
+ if (rv < 0 && rv != -ENOSPC) {
+ if (lss)
+ free(lss);
break;
}
+ if (!lss)
+ break;
+
+ ls = lss;
+
for (i = 0; i < count; i++) {
log_tool("s %.48s:%llu:%s:%llu %s",
ls->name,
@@ -2198,7 +2199,7 @@ static int do_client(void)
ls++;
}
- free(buf);
+ free(lss);
break;
case ACT_LOG_DUMP:
diff --git a/src/sanlock_admin.h b/src/sanlock_admin.h
index dadd034..5d3d5af 100644
--- a/src/sanlock_admin.h
+++ b/src/sanlock_admin.h
@@ -67,14 +67,12 @@ int sanlock_rem_lockspace(struct sanlk_lockspace *ls, uint32_t flags);
* 0: all lockspaces copied out, lss_count set to number
* -ENOSPC: sanlock internal buffer ran out of space
* (lss_count set to number that would have been copied)
- * -ENOBUFS: lss_size too small
- * (lss_count set to number that would have been copied)
*
* sanlk_lockspace.flags set to SANLK_LSF_
*/
-int sanlock_get_lockspaces(struct sanlk_lockspace *lss, int lss_size,
- int *lss_count, uint32_t flags);
+int sanlock_get_lockspaces(struct sanlk_lockspace **lss, int *lss_count,
+ uint32_t flags);
/*
* Returns the alignment in bytes required by sanlock_init()
10 years, 8 months
src/client.c
by David Teigland
src/client.c | 3 +++
1 file changed, 3 insertions(+)
New commits:
commit c653a6f587a3e317abe7ef7df7aaa2b162bc8b34
Author: David Teigland <teigland(a)redhat.com>
Date: Thu Jan 3 14:06:23 2013 -0600
sanlock: get_lockspaces count only
Accept null lss to get only the count.
Signed-off-by: David Teigland <teigland(a)redhat.com>
diff --git a/src/client.c b/src/client.c
index 5b4d81b..ec2953f 100644
--- a/src/client.c
+++ b/src/client.c
@@ -207,6 +207,9 @@ int sanlock_get_lockspaces(struct sanlk_lockspace *lss, int lss_size,
rv = -ENOBUFS;
}
+ if (!lss)
+ goto out;
+
ls = lss;
for (i = 0; i < recv_count; i++) {
10 years, 8 months