[sanlock] 05/05: release 3.9.1
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 90156f382c2508cc7dc4dc32f8247d3e1291b318
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jan 22 13:05:08 2024 -0600
release 3.9.1
---
VERSION | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/VERSION b/VERSION
index a5c4c76..6bd1074 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.9.0
+3.9.1
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months
[sanlock] 04/05: wdmd: rename native service
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 74e5f3a7cf34fe694e07f31c1a2a24c8ad58b761
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jan 22 12:56:00 2024 -0600
wdmd: rename native service
---
init.d/{wdmd.service.native => wdmd.service} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/init.d/wdmd.service.native b/init.d/wdmd.service
similarity index 100%
rename from init.d/wdmd.service.native
rename to init.d/wdmd.service
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months
[sanlock] 03/05: wdmd: remove old init based service
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 4bdee6c74910a87296070ade77cf26a039274039
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jan 22 12:55:24 2024 -0600
wdmd: remove old init based service
---
init.d/wdmd.service | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/init.d/wdmd.service b/init.d/wdmd.service
deleted file mode 100644
index 7994fb3..0000000
--- a/init.d/wdmd.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Watchdog Multiplexing Daemon
-After=syslog.target
-
-[Service]
-Type=forking
-ExecStart=/usr/lib/systemd/systemd-wdmd start
-ExecStop=/usr/lib/systemd/systemd-wdmd stop
-
-[Install]
-WantedBy=multi-user.target
-
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months
[sanlock] 02/05: wdmd: use real name of systemd-wdmd helper script
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 44239df9b6ca582f459e9bced297026f73973c51
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jan 22 12:44:45 2024 -0600
wdmd: use real name of systemd-wdmd helper script
---
init.d/{wdmd => systemd-wdmd} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/init.d/wdmd b/init.d/systemd-wdmd
similarity index 100%
rename from init.d/wdmd
rename to init.d/systemd-wdmd
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months
[sanlock] 01/05: wdmd.service: /usr/lib instead of /lib
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit c56521cc44278c168f637feaafd1e92f9d1a6b3d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jan 22 12:43:40 2024 -0600
wdmd.service: /usr/lib instead of /lib
---
init.d/wdmd.service | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/init.d/wdmd.service b/init.d/wdmd.service
index 7e6d973..7994fb3 100644
--- a/init.d/wdmd.service
+++ b/init.d/wdmd.service
@@ -4,8 +4,8 @@ After=syslog.target
[Service]
Type=forking
-ExecStart=/lib/systemd/systemd-wdmd start
-ExecStop=/lib/systemd/systemd-wdmd stop
+ExecStart=/usr/lib/systemd/systemd-wdmd start
+ExecStop=/usr/lib/systemd/systemd-wdmd stop
[Install]
WantedBy=multi-user.target
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months
[sanlock] 05/05: sanlock: include startup message in syslog
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit a5bbe3fb867fe9c83b8027c6ee1b01d470b61e5f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 11 16:08:05 2024 -0600
sanlock: include startup message in syslog
---
src/main.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/main.c b/src/main.c
index 59e96a0..403e358 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1821,12 +1821,17 @@ static int do_daemon(void)
uname(&nodename);
- if (com.io_timeout != DEFAULT_IO_TIMEOUT || com.watchdog_fire_timeout != DEFAULT_WATCHDOG_FIRE_TIMEOUT)
+ if (com.io_timeout != DEFAULT_IO_TIMEOUT || com.watchdog_fire_timeout != DEFAULT_WATCHDOG_FIRE_TIMEOUT) {
log_warn("sanlock daemon started %s host %s (%s) io_timeout %u watchdog_fire_timeout %u",
VERSION, our_host_name_global, nodename.nodename, com.io_timeout, com.watchdog_fire_timeout);
- else
+ syslog(LOG_INFO, "sanlock daemon started %s host %s (%s) io_timeout %u watchdog_fire_timeout %u",
+ VERSION, our_host_name_global, nodename.nodename, com.io_timeout, com.watchdog_fire_timeout);
+ } else {
log_warn("sanlock daemon started %s host %s (%s)",
VERSION, our_host_name_global, nodename.nodename);
+ syslog(LOG_INFO, "sanlock daemon started %s host %s (%s)",
+ VERSION, our_host_name_global, nodename.nodename);
+ }
setup_priority();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months, 2 weeks
[sanlock] 04/05: wdmd: improve log levels and messages
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 9c2cbe5ad53905d0792ead3ed5affc84b20e5a22
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 11 15:27:34 2024 -0600
wdmd: improve log levels and messages
---
wdmd/main.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/wdmd/main.c b/wdmd/main.c
index bbb4356..38a99f3 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -75,6 +75,7 @@ static int test_loop_enable;
static int dev_fd = -1;
static int shm_fd;
static int itco; /* watchdog_identity is "iTCO_wdt" */
+static int daemon_setup_done;
static int allow_scripts;
static int kill_script_sec;
@@ -131,6 +132,12 @@ do { \
syslog(LOG_ERR, fmt, ##args); \
} while (0)
+#define log_info(fmt, args...) \
+do { \
+ log_debug(fmt, ##args); \
+ syslog(LOG_INFO, fmt, ##args); \
+} while (0)
+
#define log_script(i) \
log_error("script %.64s last_result %d start %llu run %u fail %u good %u kill %u long %u", \
scripts[i].name, scripts[i].last_result, \
@@ -404,8 +411,8 @@ static void close_watchdog(void)
rv = write(dev_fd, "V", 1);
if (rv < 0)
log_error("%s disarm write error %d", watchdog_path, errno);
- else
- log_error("%s disarmed", watchdog_path);
+ else if (daemon_setup_done)
+ log_info("%s disarmed", watchdog_path);
close(dev_fd);
dev_fd = -1;
@@ -2020,8 +2027,7 @@ static int lockfile(void)
rv = fcntl(fd, F_SETLK, &lock);
if (rv < 0) {
- log_error("lockfile setlk error %s: %s",
- lockfile_path, strerror(errno));
+ log_error("daemon already running (lockfile %s %d)", lockfile_path, errno);
goto fail;
}
@@ -2058,19 +2064,19 @@ static void setup_priority(void)
rv = mlockall(MCL_CURRENT | MCL_FUTURE);
if (rv < 0) {
- log_error("mlockall failed");
+ log_info("mlockall failed");
}
rv = sched_get_priority_max(SCHED_RR);
if (rv < 0) {
- log_error("could not get max scheduler priority err %d", errno);
+ log_info("could not get max scheduler priority err %d", errno);
return;
}
sched_param.sched_priority = rv;
rv = sched_setscheduler(0, SCHED_RR|SCHED_RESET_ON_FORK, &sched_param);
if (rv < 0) {
- log_error("could not set RR|RESET_ON_FORK priority %d err %d",
+ log_info("could not set RR|RESET_ON_FORK priority %d err %d",
sched_param.sched_priority, errno);
}
}
@@ -2081,7 +2087,7 @@ static int group_to_gid(char *arg)
gr = getgrnam(arg);
if (gr == NULL) {
- log_error("group '%s' not found, using socket gid: %i", arg, DEFAULT_SOCKET_GID);
+ log_info("group '%s' not found, using socket gid: %i", arg, DEFAULT_SOCKET_GID);
return DEFAULT_SOCKET_GID;
}
@@ -2296,8 +2302,10 @@ int main(int argc, char *argv[])
/* Sets watchdog_identity and itco */
setup_identity(watchdog_path);
- log_error("wdmd started S%d H%d G%d using %s \"%s\"", allow_scripts, high_priority,
- socket_gid, watchdog_path, watchdog_identity[0] ? watchdog_identity : "unknown");
+ log_info("wdmd started S%d H%d G%d using %s \"%s\"", allow_scripts, high_priority,
+ socket_gid, watchdog_path, watchdog_identity[0] ? watchdog_identity : "unknown");
+
+ daemon_setup_done = 1;
rv = test_loop();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months, 2 weeks
[sanlock] 03/05: sanlock: save client_id in token and report in
status and use in -C
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit f135fb266e9122cec31527b2a60f253801916ee9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jan 8 16:50:43 2024 -0600
sanlock: save client_id in token and report in status and use in -C
When one process uses multiple registered connections there was no
way to see the association between tokens/resources and client
connections (client_id's) from the 'sanlock status -D' output.
The ci (client_id) is now reported for resources in in status -D.
A new option -C <client_id> is added for 'sanlock client release'
(and others) to use in place of -p <pid>. It was not possible
to release specific resources from the command line with -p when
a single process had multiple client connections.
---
src/cmd.c | 15 ++++----
src/main.c | 92 +++++++++++++++++++++++++++++++++++++-------------
src/resource.c | 10 +++---
src/sanlock.8 | 3 ++
src/sanlock_internal.h | 2 ++
src/sanlock_resource.h | 10 ++++++
6 files changed, 98 insertions(+), 34 deletions(-)
diff --git a/src/cmd.c b/src/cmd.c
index 64ee409..dda9ab8 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -404,6 +404,7 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca, uint32_t cmd)
token->host_generation = spi.host_generation;
token->space_id = spi.space_id;
token->pid = cl_pid;
+ token->client_id = cl_ci;
token->io_timeout = spi.io_timeout;
token->sector_size = spi.sector_size; /* starting hint, may be changed */
token->align_size = spi.align_size; /* starting hint, may be changed */
@@ -2435,7 +2436,7 @@ static int print_state_lockspace(struct space *sp, char *str, const char *list_n
}
static int print_state_resource(struct resource *r, char *str, const char *list_name,
- uint32_t token_id)
+ int client_id, uint32_t token_id)
{
memset(str, 0, SANLK_STATE_MAXSTR);
@@ -2447,7 +2448,8 @@ static int print_state_resource(struct resource *r, char *str, const char *list_
"lver=%llu "
"reused=%u "
"res_id=%u "
- "token_id=%u",
+ "token_id=%u "
+ "ci=%d",
list_name,
r->flags,
r->sector_size,
@@ -2455,7 +2457,8 @@ static int print_state_resource(struct resource *r, char *str, const char *list_
(unsigned long long)r->leader.lver,
r->reused,
r->res_id,
- token_id);
+ token_id,
+ client_id);
return strlen(str) + 1;
}
@@ -2575,10 +2578,10 @@ static void send_state_lockspace(int fd, struct space *sp, const char *list_name
}
void send_state_resource(int fd, struct resource *r, const char *list_name,
- int pid, uint32_t token_id);
+ int pid, int client_id, uint32_t token_id);
void send_state_resource(int fd, struct resource *r, const char *list_name,
- int pid, uint32_t token_id)
+ int pid, int client_id, uint32_t token_id)
{
struct sanlk_state st;
char str[SANLK_STATE_MAXSTR];
@@ -2592,7 +2595,7 @@ void send_state_resource(int fd, struct resource *r, const char *list_name,
st.data64 = r->leader.lver;
memcpy(st.name, r->r.name, NAME_ID_SIZE);
- str_len = print_state_resource(r, str, list_name, token_id);
+ str_len = print_state_resource(r, str, list_name, client_id, token_id);
st.str_len = str_len;
diff --git a/src/main.c b/src/main.c
index 96ad50a..59e96a0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1100,7 +1100,8 @@ static void process_cmd_thread_registered(int ci_in, struct sm_header *h_recv)
struct cmd_args *ca;
struct client *cl;
int result = 0;
- int rv, i, ci_target;
+ int for_pid = -1, for_client_id = -1;
+ int rv, i, ci_target = -1;
ca = malloc(sizeof(struct cmd_args));
if (!ca) {
@@ -1109,31 +1110,43 @@ static void process_cmd_thread_registered(int ci_in, struct sm_header *h_recv)
}
if (h_recv->data2 != -1) {
- /* lease for another registered client with pid specified by data2 */
- ci_target = -1;
+ /* lease for another registered client with pid or client_id specified by data2 */
+
+ if (h_recv->cmd_flags & SANLK_FOR_CLIENT_ID)
+ for_client_id = h_recv->data2;
+ else
+ for_pid = h_recv->data2;
for (i = 0; i < client_size; i++) {
cl = &client[i];
pthread_mutex_lock(&cl->mutex);
- if (cl->pid != h_recv->data2) {
- pthread_mutex_unlock(&cl->mutex);
- continue;
+
+ if (for_pid > -1) {
+ if (cl->pid != for_pid) {
+ pthread_mutex_unlock(&cl->mutex);
+ continue;
+ }
+ } else if (for_client_id > -1) {
+ if (i != for_client_id) {
+ pthread_mutex_unlock(&cl->mutex);
+ continue;
+ }
}
+
ci_target = i;
break;
}
if (ci_target < 0) {
if (h_recv->cmd != SM_CMD_INQUIRE) {
- /* inquire can be used to check if a pid exists */
- log_error("cmd %d target pid %d not found",
- h_recv->cmd, h_recv->data2);
+ /* inquire can be used to check if a pid or client_id exists */
+ log_debug("cmd %d target %d not found", h_recv->cmd, h_recv->data2);
}
result = -ESRCH;
goto fail;
}
- log_client(ci_in, client[ci_in].fd, "process reg cmd %u target pid %d ci %d",
- h_recv->cmd, h_recv->data2, ci_target);
+ log_client(ci_in, client[ci_in].fd, "process reg cmd %u for target ci %d pid %d",
+ h_recv->cmd, ci_target, client[ci_target].pid);
} else {
/* lease for this registered client */
@@ -2170,10 +2183,10 @@ static void print_usage(void)
printf("sanlock client inq_lockspace -s LOCKSPACE\n");
printf("sanlock client rem_lockspace -s LOCKSPACE\n");
printf("sanlock client command -r RESOURCE -c <path> <args>\n");
- printf("sanlock client acquire -r RESOURCE -p <pid>\n");
- printf("sanlock client convert -r RESOURCE -p <pid>\n");
- printf("sanlock client release -r RESOURCE -p <pid>\n");
- printf("sanlock client inquire -p <pid>\n");
+ printf("sanlock client acquire -r RESOURCE -p|-C <id>\n");
+ printf("sanlock client convert -r RESOURCE -p|-C <id>\n");
+ printf("sanlock client release -r RESOURCE -p|-C <id>\n");
+ printf("sanlock client inquire -p|-C <id>\n");
printf("sanlock client request -r RESOURCE -f <force_mode>\n");
printf("sanlock client examine -r RESOURCE | -s LOCKSPACE\n");
printf("sanlock client format -x RINDEX [-Z 512|4096 -A 1M|2M|4M|8M]\n");
@@ -2486,6 +2499,9 @@ static int read_command_line(int argc, char *argv[])
case 'p':
com.pid = atoi(optionarg);
break;
+ case 'C':
+ com.cid = atoi(optionarg);
+ break;
case 'd':
com.he_data = strtoull(optionarg, NULL, 0);
break;
@@ -3198,6 +3214,7 @@ static int do_client(void)
char *res_state = NULL;
uint32_t flags = 0;
uint32_t config_cmd = 0;
+ int id = -1;
int i, fd;
int rv = 0;
@@ -3296,20 +3313,41 @@ static int do_client(void)
break;
case ACT_ACQUIRE:
- log_tool("acquire pid %d", com.pid);
+ if (com.pid > -1) {
+ log_tool("acquire pid %d", com.pid);
+ id = com.pid;
+ } else if (com.cid > -1) {
+ log_tool("acquire client_id %d", com.cid);
+ id = com.cid;
+ flags |= SANLK_FOR_CLIENT_ID;
+ }
flags |= com.orphan ? SANLK_ACQUIRE_ORPHAN : 0;
- rv = sanlock_acquire(-1, com.pid, flags, com.res_count, com.res_args, NULL);
+ rv = sanlock_acquire(-1, id, flags, com.res_count, com.res_args, NULL);
log_tool("acquire done %d", rv);
break;
case ACT_CONVERT:
- log_tool("convert pid %d", com.pid);
- rv = sanlock_convert(-1, com.pid, 0, com.res_args[0]);
+ if (com.pid > -1) {
+ log_tool("convert pid %d", com.pid);
+ id = com.pid;
+ } else if (com.cid > -1) {
+ log_tool("convert client_id %d", com.cid);
+ id = com.cid;
+ flags |= SANLK_FOR_CLIENT_ID;
+ }
+ rv = sanlock_convert(-1, id, flags, com.res_args[0]);
log_tool("convert done %d", rv);
break;
case ACT_RELEASE:
- log_tool("release pid %d", com.pid);
+ if (com.pid > -1) {
+ log_tool("release pid %d", com.pid);
+ id = com.pid;
+ } else if (com.cid > -1) {
+ log_tool("release client_id %d", com.cid);
+ id = com.cid;
+ flags |= SANLK_FOR_CLIENT_ID;
+ }
/*
* Odd case to specify: release all orphan resources for the named lockspace.
* Uses -s lockspace_name instead of using -r, but the function takes a
@@ -3328,13 +3366,20 @@ static int do_client(void)
}
flags |= com.orphan ? SANLK_REL_ORPHAN : 0;
flags |= com.all ? SANLK_REL_ALL: 0;
- rv = sanlock_release(-1, com.pid, flags, com.res_count, com.res_args);
+ rv = sanlock_release(-1, id, flags, com.res_count, com.res_args);
log_tool("release done %d", rv);
break;
case ACT_INQUIRE:
- log_tool("inquire pid %d", com.pid);
- rv = sanlock_inquire(-1, com.pid, 0, &com.res_count, &res_state);
+ if (com.pid > -1) {
+ log_tool("inquire pid %d", com.pid);
+ id = com.pid;
+ } else if (com.cid > -1) {
+ log_tool("inquire client_id %d", com.cid);
+ id = com.cid;
+ flags |= SANLK_FOR_CLIENT_ID;
+ }
+ rv = sanlock_inquire(-1, id, flags, &com.res_count, &res_state);
log_tool("inquire done %d res_count %d", rv, com.res_count);
if (rv < 0)
break;
@@ -3954,6 +3999,7 @@ int main(int argc, char *argv[])
com.write_init_io_timeout = DEFAULT_WRITE_INIT_IO_TIMEOUT;
com.aio_arg = DEFAULT_USE_AIO;
com.pid = -1;
+ com.cid = -1;
com.sh_retries = DEFAULT_SH_RETRIES;
com.quiet_fail = DEFAULT_QUIET_FAIL;
com.renewal_read_extend_sec_set = 0;
diff --git a/src/resource.c b/src/resource.c
index c1c49f9..cad8af5 100644
--- a/src/resource.c
+++ b/src/resource.c
@@ -35,7 +35,7 @@
#include "helper.h"
/* from cmd.c */
-void send_state_resource(int fd, struct resource *r, const char *list_name, int pid, uint32_t token_id);
+void send_state_resource(int fd, struct resource *r, const char *list_name, int pid, int client_id, uint32_t token_id);
/* from main.c */
int get_rand(int a, int b);
@@ -138,19 +138,19 @@ void send_state_resources(int fd)
pthread_mutex_lock(&resource_mutex);
list_for_each_entry(r, &resources_held, list) {
list_for_each_entry(token, &r->tokens, list)
- send_state_resource(fd, r, "held", token->pid, token->token_id);
+ send_state_resource(fd, r, "held", token->pid, token->client_id, token->token_id);
}
list_for_each_entry(r, &resources_add, list) {
list_for_each_entry(token, &r->tokens, list)
- send_state_resource(fd, r, "add", token->pid, token->token_id);
+ send_state_resource(fd, r, "add", token->pid, token->client_id, token->token_id);
}
list_for_each_entry(r, &resources_rem, list)
- send_state_resource(fd, r, "rem", r->pid, 0);
+ send_state_resource(fd, r, "rem", r->pid, 0, 0);
list_for_each_entry(r, &resources_orphan, list)
- send_state_resource(fd, r, "orphan", r->pid, 0);
+ send_state_resource(fd, r, "orphan", r->pid, 0, 0);
pthread_mutex_unlock(&resource_mutex);
}
diff --git a/src/sanlock.8 b/src/sanlock.8
index 5295bf5..6466689 100644
--- a/src/sanlock.8
+++ b/src/sanlock.8
@@ -726,6 +726,7 @@ Tell the sanlock daemon to acquire or release the specified resource lease
for the given pid. The pid must be registered with the sanlock daemon.
acquire can optionally take a versioned RESOURCE string RESOURCE:lver,
where lver is the version of the lease that must be acquired, or fail.
+Use -C in place of -p to specify client_id.
.BR "sanlock client convert -r" " RESOURCE " \
\fB-p\fP " " \fIpid\fP
@@ -735,12 +736,14 @@ lease for the given pid. If the existing mode is exclusive (default),
the mode of the lease can be converted to shared with RESOURCE:SH. If the
existing mode is shared, the mode of the lease can be converted to
exclusive with RESOURCE (no :SH suffix).
+Use -C in place of -p to specify client_id.
.BI "sanlock client inquire -p" " pid"
Print the resource leases held the given pid. The format is a versioned
RESOURCE string "RESOURCE:lver" where lver is the version of the lease
held.
+Use -C in place of -p to specify client_id.
.BR "sanlock client request -r" " RESOURCE " \
\fB-f\fP " " \fIforce_mode\fP
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 3e06e4f..a8ffdf5 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -105,6 +105,7 @@ struct token {
struct list_head list; /* resource->tokens */
struct resource *resource;
int pid;
+ int client_id;
uint32_t flags; /* be careful to avoid using this from different threads */
uint32_t token_id;
uint32_t res_id;
@@ -378,6 +379,7 @@ struct command_line {
char *gname; /* -G */
int gid; /* -G */
int pid; /* -p */
+ int cid; /* -C */
char sort_arg;
uint64_t host_id; /* -i */
uint64_t host_generation; /* -g */
diff --git a/src/sanlock_resource.h b/src/sanlock_resource.h
index 48e4489..ed27130 100644
--- a/src/sanlock_resource.h
+++ b/src/sanlock_resource.h
@@ -31,6 +31,8 @@
/* killpath flags */
#define SANLK_KILLPATH_PID 0x00000001
+#define SANLK_FOR_CLIENT_ID 0x00000010
+
/*
* acquire flags
*
@@ -57,6 +59,7 @@
#define SANLK_ACQUIRE_ORPHAN 0x00000002
#define SANLK_ACQUIRE_ORPHAN_ONLY 0x00000004
#define SANLK_ACQUIRE_OWNER_NOWAIT 0x00000008
+/* SANLK_FOR_CLIENT_ID 0x00000010 defined above */
/*
* release flags
@@ -87,6 +90,7 @@
#define SANLK_REL_ALL 0x00000001
#define SANLK_REL_RENAME 0x00000002
#define SANLK_REL_ORPHAN 0x00000004
+/* SANLK_FOR_CLIENT_ID 0x00000010 defined above */
/*
* convert flags
@@ -96,6 +100,12 @@
*/
#define SANLK_CONVERT_OWNER_NOWAIT 0x00000008 /* NB: value must match SANLK_ACQUIRE_OWNER_NOWAIT */
+/* SANLK_FOR_CLIENT_ID 0x00000010 defined above */
+
+/*
+ * inquire flags
+ */
+/* SANLK_FOR_CLIENT_ID 0x00000010 defined above */
/*
* request flags
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months, 2 weeks
[sanlock] 02/05: wdmd: remove unused init script code from helper
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit bf5b1dd00ca6c9c8b49011af0d673752ff124697
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jan 10 17:05:09 2024 -0600
wdmd: remove unused init script code from helper
Leave the watchdog-check function that's called from the
systemd service to load the softdog module if no watchdog
is enabled.
---
init.d/wdmd | 127 ++++--------------------------------------------------------
1 file changed, 7 insertions(+), 120 deletions(-)
diff --git a/init.d/wdmd b/init.d/wdmd
index b6a2a79..0016097 100644
--- a/init.d/wdmd
+++ b/init.d/wdmd
@@ -1,35 +1,10 @@
#!/bin/bash
#
# wdmd - watchdog multiplexing daemon
+# helper to load the softdog module if a watchdog is not enabled
#
-# chkconfig: 2345 97 03
-# description: starts and stops wdmd daemon
-#
-
-
-### BEGIN INIT INFO
-# Provides: wdmd
-# Required-Start: $time $syslog
-# Required-Stop: $syslog
-# Should-Start:
-# Should-Stop:
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: starts and stops wdmd daemon
-# Description: starts and stops wdmd daemon
-### END INIT INFO
-
-. /etc/rc.d/init.d/functions
-
-prog="wdmd"
-runfile="/run/$prog/$prog.pid"
-lockfile="/var/lock/subsys/$prog"
-exec="/usr/sbin/$prog"
-
-WDMDGROUP="sanlock"
-WDMDOPTS="-G $WDMDGROUP"
-[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+exec="/usr/sbin/wdmd"
watchdog_probe() {
$exec --probe > /dev/null 2>&1
@@ -43,113 +18,25 @@ watchdog_check() {
if [ $retval -ne 0 ]; then
echo -n $"Loading the softdog kernel module: "
- modprobe softdog && udevadm settle
+ modprobe softdog
watchdog_probe
retval=$?
if [ $retval -ne 0 ]; then
- failure; echo
+ echo "failed"
return 1
fi
- success; echo
- fi
-}
-
-start() {
- watchdog_check
-
- [ -x $exec ] || exit 5
-
- if [ ! -d /run/$prog ]; then
- install -d -g $WDMDGROUP -m 775 /run/$prog
- [ -x /sbin/restorecon ] && restorecon /run/$prog
- fi
-
- echo -n $"Starting $prog: "
- daemon $prog $WDMDOPTS
- retval=$?
- echo
- [ $retval -eq 0 ] && touch $lockfile
- return $retval
-}
-
-stop() {
- PID=$(pidofproc -p $runfile $prog)
-
- echo -n $"Sending stop signal $prog ($PID): "
- killproc -p $runfile $prog -TERM
- retval=$?
- echo
-
- if [ $retval -ne 0 ]; then
- return $retval
+ echo "success"
+ return 0
fi
-
- echo -n $"Waiting for $prog ($PID) to stop:"
-
- timeout=10
- while checkpid $PID; do
- sleep 1
- timeout=$((timeout - 1))
- if [ "$timeout" -le 0 ]; then
- failure; echo
- return 1
- fi
- done
-
- success; echo
- rm -f $lockfile
- return $retval
-}
-
-restart() {
- rh_status_q && stop
- start
-}
-
-reload() {
- restart
-}
-
-rh_status() {
- status $prog
-}
-
-rh_status_q() {
- rh_status >/dev/null 2>&1
}
case "$1" in
- start)
- rh_status_q && exit 0
- $1
- ;;
- stop)
- rh_status_q || exit 0
- $1
- ;;
- restart)
- $1
- ;;
- reload)
- rh_status_q || exit 7
- $1
- ;;
watchdog-check)
watchdog_check
;;
- force-reload)
- force_reload
- ;;
- status)
- rh_status
- ;;
- condrestart|try-restart)
- rh_status_q || exit 0
- restart
- ;;
*)
- echo $"Usage $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+ echo $"Usage $0 watchdog-check"
exit 2
esac
exit $?
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months, 2 weeks
[sanlock] 01/05: wdmd: fix timing for iTCO_wdt
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit b04d58c76001f3b78be147324f976daef14a7e0b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jan 10 16:46:35 2024 -0600
wdmd: fix timing for iTCO_wdt
iTCO_wdt does not fire until two successive timeouts, so the
values for set/get need to be adjusted by a factor of 2 to
make the watchdog fire at the correct time.
---
wdmd/main.c | 425 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 400 insertions(+), 25 deletions(-)
diff --git a/wdmd/main.c b/wdmd/main.c
index 3c60b4e..bbb4356 100644
--- a/wdmd/main.c
+++ b/wdmd/main.c
@@ -31,6 +31,7 @@
#include <sys/un.h>
#include <sys/stat.h>
#include <sys/mman.h>
+#include <sys/time.h>
#include <sys/signalfd.h>
#include <linux/watchdog.h>
@@ -55,6 +56,7 @@
#define DEFAULT_SOCKET_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
#define WDPATH_SIZE 64
+#define WD_ID_SIZE 64
static int standard_test_interval = DEFAULT_TEST_INTERVAL;
static int test_interval= DEFAULT_TEST_INTERVAL;
@@ -72,6 +74,7 @@ static char lockfile_path[PATH_MAX];
static int test_loop_enable;
static int dev_fd = -1;
static int shm_fd;
+static int itco; /* watchdog_identity is "iTCO_wdt" */
static int allow_scripts;
static int kill_script_sec;
@@ -79,6 +82,7 @@ static const char *scripts_dir = "/etc/wdmd.d";
static char watchdog_path[WDPATH_SIZE];
static char option_path[WDPATH_SIZE];
static char saved_path[WDPATH_SIZE];
+static char watchdog_identity[WD_ID_SIZE];
struct script_status {
uint64_t start;
@@ -115,11 +119,10 @@ static int client_size = 0;
static struct client *client = NULL;
static struct pollfd *pollfd = NULL;
-
#define log_debug(fmt, args...) \
do { \
if (daemon_debug) \
- fprintf(stderr, "%llu " fmt "\n", (unsigned long long)time(NULL), ##args); \
+ fprintf(stderr, "%llu %s " fmt "\n", (unsigned long long)time(NULL), time_str(), ##args); \
} while (0)
#define log_error(fmt, args...) \
@@ -146,6 +149,19 @@ static uint64_t monotime(void)
return ts.tv_sec;
}
+char time_str_buf[128];
+
+static char *time_str(void)
+{
+ struct timeval cur_time;
+ struct tm time_info;
+
+ gettimeofday(&cur_time, NULL);
+ localtime_r(&cur_time.tv_sec, &time_info);
+ strftime(time_str_buf, sizeof(time_str_buf), "%Y-%m-%d %H:%M:%S ", &time_info);
+ return time_str_buf;
+}
+
/*
* test clients
*/
@@ -282,12 +298,13 @@ static void dump_debug(int fd)
now = monotime();
memset(line, 0, sizeof(line));
- snprintf(line, 255, "wdmd %d socket_gid %d high_priority %d now %llu last_keepalive %llu last_closeunclean %llu allow_scripts %d kill_script_sec %d fire_timeout %d\n",
+ snprintf(line, 255, "wdmd %d socket_gid %d high_priority %d now %llu last_keepalive %llu last_closeunclean %llu allow_scripts %d kill_script_sec %d fire_timeout %d identity \"%s\"\n",
getpid(), socket_gid, high_priority,
(unsigned long long)now,
(unsigned long long)last_keepalive,
(unsigned long long)last_closeunclean,
- allow_scripts, kill_script_sec, fire_timeout);
+ allow_scripts, kill_script_sec, fire_timeout,
+ watchdog_identity);
line_len = strlen(line);
strncat(debug_buf, line, LINE_SIZE);
@@ -416,11 +433,93 @@ static void pet_watchdog(void)
log_debug("keepalive %d", rv);
}
+static int _open_watchdog_itco(struct wdmd_header *h)
+{
+ int get_timeout_itco, get_timeout_real, set_timeout_itco, set_timeout_real;
+ int rv;
+
+ /* Don't check dev_fd for -1 because dev_fd will be closed
+ and set to -1 prior to timeout in close_watchdog_unclean(). */
+
+ if (test_loop_enable)
+ return 0;
+
+ if (!h->fire_timeout)
+ return -1;
+
+ rv = open_dev();
+ if (rv < 0)
+ return -1;
+
+ get_timeout_real = 0;
+ get_timeout_itco = 0;
+
+ rv = ioctl(dev_fd, WDIOC_GETTIMEOUT, &get_timeout_itco);
+ if (rv < 0) {
+ log_error("open_watchdog gettimeout error %d", errno);
+ close_watchdog();
+ return -1;
+ }
+
+ get_timeout_real = get_timeout_itco * 2;
+
+ if (get_timeout_real == h->fire_timeout) {
+ /* success, requested value matches the default value */
+ fire_timeout = get_timeout_real;
+ _init_test_interval();
+ log_error("%s open with timeout %d", watchdog_path, get_timeout_real);
+ pet_watchdog();
+ test_loop_enable = 1;
+ return 0;
+ }
+
+ set_timeout_real = h->fire_timeout;
+ set_timeout_itco = set_timeout_real / 2;
+
+ rv = ioctl(dev_fd, WDIOC_SETTIMEOUT, &set_timeout_itco);
+ if (rv < 0) {
+ log_error("open_watchdog settimeout %d error %d", set_timeout_real, errno);
+ close_watchdog();
+ return -1;
+ }
+
+ get_timeout_real = 0;
+ get_timeout_itco = 0;
+
+ rv = ioctl(dev_fd, WDIOC_GETTIMEOUT, &get_timeout_itco);
+ if (rv < 0) {
+ log_error("open_watchdog gettimeout check error %d", errno);
+ close_watchdog();
+ return -1;
+ }
+
+ get_timeout_real = get_timeout_itco * 2;
+
+ if (get_timeout_real == set_timeout_real) {
+ /* success setting a custom timeout */
+ fire_timeout = get_timeout_real;
+ _init_test_interval();
+ log_error("%s open with timeout %d", watchdog_path, get_timeout_real);
+ pet_watchdog();
+ test_loop_enable = 1;
+ return 0;
+ }
+
+ /* failed to set a custom timeout */
+ log_error("open_watchdog gettimeout value real %d itco %d expect real %d",
+ get_timeout_real, get_timeout_itco, set_timeout_real);
+ close_watchdog();
+ return -1;
+}
+
static int _open_watchdog(struct wdmd_header *h)
{
int get_timeout, set_timeout;
int rv;
+ if (itco)
+ return _open_watchdog_itco(h);
+
/* Don't check dev_fd for -1 because dev_fd will be closed
and set to -1 prior to timeout in close_watchdog_unclean(). */
@@ -1112,6 +1211,49 @@ static int test_scripts(void)
return fail_count;
}
+static int setup_identity(char *wdpath)
+{
+ char sysfs_path[PATH_MAX] = { 0 };
+ char *base, *p;
+ int fd, rv;
+
+ /*
+ * This function will be called multiple times when probing
+ * different watchdog paths for one that works.
+ */
+ itco = 0;
+ memset(watchdog_identity, 0, sizeof(watchdog_identity));
+
+ /*
+ * $ cat /sys/class/watchdog/watchdog0/identity
+ * iTCO_wdt
+ */
+ if (!(base = basename(wdpath)))
+ return -1;
+
+ snprintf(sysfs_path, PATH_MAX-1, "/sys/class/watchdog/%s/identity", base);
+
+ if ((fd = open(sysfs_path, O_RDONLY)) < 0)
+ return -1;
+
+ rv = read(fd, watchdog_identity, WD_ID_SIZE-1);
+
+ close(fd);
+
+ if (rv <= 0)
+ return -1;
+
+ if ((p = strchr(watchdog_identity, '\n')))
+ *p = '\0';
+
+ log_debug("%s %s %s", wdpath, sysfs_path, watchdog_identity);
+
+ if (!strcmp(watchdog_identity, "iTCO_wdt"))
+ itco = 1;
+
+ return 0;
+}
+
static int _setup_watchdog(char *path)
{
struct stat buf;
@@ -1148,6 +1290,7 @@ static int _setup_watchdog(char *path)
}
/*
+ * Success: returns 0 with watchdog_path set.
* Order of preference:
* . saved path (path used before daemon restart)
* . command line option (-w)
@@ -1208,11 +1351,133 @@ static int setup_watchdog(void)
}
+/*
+ * iTCO_wdt actual firing timeout is double the value used in get/set!
+ * https://bugzilla.kernel.org/show_bug.cgi?id=213809
+ */
+static int _try_timeout_itco(const char *path)
+{
+ struct stat buf;
+ int try_timeout_real, try_timeout_itco, get_timeout_real, get_timeout_itco, set_timeout_real, set_timeout_itco;
+ int unused, fd, err, rv, rv2;
+
+ rv = stat(path, &buf);
+ if (rv < 0) {
+ fprintf(stderr, "%s stat error %d\n", path, errno);
+ return -1;
+ }
+
+ fd = open(path, O_WRONLY | O_CLOEXEC);
+ if (fd < 0) {
+ fprintf(stderr, "%s open error %d\n", path, errno);
+ return fd;
+ }
+
+ printf("%s %s open fd %d\n", time_str(), path, fd);
+
+ get_timeout_real = 0;
+ get_timeout_itco = 0;
+
+ rv = ioctl(fd, WDIOC_GETTIMEOUT, &get_timeout_itco);
+ if (rv < 0) {
+ fprintf(stderr, "%s gettimeout error %d\n", path, errno);
+ rv = -1;
+ goto out;
+ }
+
+ get_timeout_real = get_timeout_itco * 2;
+
+ printf("%s %s gettimeout real %d itco %d\n", time_str(), path, get_timeout_real, get_timeout_itco);
+
+ if (get_timeout_real == try_timeout)
+ goto keepalive;
+
+ try_timeout_real = try_timeout;
+ try_timeout_itco = try_timeout_real / 2;
+ set_timeout_real = try_timeout;
+ set_timeout_itco = set_timeout_real / 2;
+
+ rv = ioctl(fd, WDIOC_SETTIMEOUT, &set_timeout_itco);
+ if (rv < 0) {
+ fprintf(stderr, "%s settimeout real %d itco %d error %d\n", path, set_timeout_real, set_timeout_itco, errno);
+ rv = -1;
+ goto out;
+ }
+
+ set_timeout_real = set_timeout_itco * 2;
+
+ printf("%s %s settimeout real %d itco %d result real %d itco %d\n", time_str(), path,
+ try_timeout_real, try_timeout_itco, set_timeout_real, set_timeout_itco);
+
+ if (set_timeout_itco != try_timeout_itco) {
+ fprintf(stderr, "%s settimeout real %d itco %d failed\n", path, try_timeout_real, try_timeout_itco);
+ rv = -1;
+ goto out;
+ }
+
+ get_timeout_real = 0;
+ get_timeout_itco = 0;
+
+ rv = ioctl(fd, WDIOC_GETTIMEOUT, &get_timeout_itco);
+ if (rv < 0) {
+ fprintf(stderr, "%s gettimeout error %d\n", path, errno);
+ rv = -1;
+ goto out;
+ }
+
+ get_timeout_real = get_timeout_itco * 2;
+
+ printf("%s %s gettimeout real %d itco %d\n", time_str(), path, get_timeout_real, get_timeout_itco);
+
+ keepalive:
+
+ rv = ioctl(fd, WDIOC_KEEPALIVE, &unused);
+ if (rv < 0) {
+ fprintf(stderr, "%s keepalive error %d\n", path, errno);
+ rv = -1;
+ goto out;
+ }
+
+ printf("%s %s keepalive fd %d result %d\n", time_str(), path, fd, rv);
+
+ if (forcefire) {
+ int sleep_sec = 0;
+ int i;
+ setbuf(stdout, NULL);
+ printf("%s waiting for watchdog to reset machine:\n", time_str());
+ for (i = 1; i < get_timeout_real + 5; i++) {
+ sleep(1);
+ sleep_sec++;
+ if (sleep_sec >= get_timeout_real+1)
+ printf("%s %d %s failed to fire after timeout %d seconds\n", time_str(), i, path, get_timeout_real);
+ else
+ printf("%s %d\n", time_str(), i);
+ }
+ }
+
+ rv = 0;
+ out:
+ err = write(fd, "V", 1);
+ if (err < 0) {
+ fprintf(stderr, "trytimeout failed to disarm %s error %d %d\n", path, err, errno);
+ openlog("wdmd", LOG_CONS | LOG_PID, LOG_DAEMON);
+ syslog(LOG_ERR, "trytimeout failed to disarm %s error %d %d\n", path, err, errno);
+ }
+
+ printf("%s %s disarm write V fd %d result %d\n", time_str(), path, fd, rv);
+
+ rv2 = close(fd);
+
+ printf("%s %s close fd %d result %d\n", time_str(), path, fd, rv2);
+
+ return rv;
+}
+
static int _try_timeout(const char *path)
{
struct stat buf;
int get_timeout, set_timeout;
- int unused, fd, err, rv;
+ int unused, fd, err, rv, rv2;
rv = stat(path, &buf);
if (rv < 0) {
@@ -1226,6 +1491,8 @@ static int _try_timeout(const char *path)
return fd;
}
+ printf("%s %s open fd %d\n", time_str(), path, fd);
+
get_timeout = 0;
rv = ioctl(fd, WDIOC_GETTIMEOUT, &get_timeout);
@@ -1235,7 +1502,10 @@ static int _try_timeout(const char *path)
goto out;
}
- printf("%s gettimeout %d\n", path, get_timeout);
+ printf("%s %s gettimeout %d\n", time_str(), path, get_timeout);
+
+ if (get_timeout == try_timeout)
+ goto keepalive;
set_timeout = try_timeout;
@@ -1246,7 +1516,7 @@ static int _try_timeout(const char *path)
goto out;
}
- printf("%s settimeout %d result %d\n", path, try_timeout, set_timeout);
+ printf("%s %s settimeout %d result %d\n", time_str(), path, try_timeout, set_timeout);
if (set_timeout != try_timeout) {
fprintf(stderr, "%s settimeout %d failed\n", path, try_timeout);
@@ -1263,7 +1533,9 @@ static int _try_timeout(const char *path)
goto out;
}
- printf("%s gettimeout %d\n", path, get_timeout);
+ printf("%s %s gettimeout %d\n", time_str(), path, get_timeout);
+
+ keepalive:
rv = ioctl(fd, WDIOC_KEEPALIVE, &unused);
if (rv < 0) {
@@ -1272,22 +1544,20 @@ static int _try_timeout(const char *path)
goto out;
}
+ printf("%s %s keepalive fd %d result %d\n", time_str(), path, fd, rv);
+
if (forcefire) {
int sleep_sec = 0;
int i;
setbuf(stdout, NULL);
- printf("waiting for watchdog to reset machine:\n");
+ printf("%s waiting for watchdog to reset machine:\n", time_str());
for (i = 1; i < get_timeout + 5; i++) {
sleep(1);
sleep_sec++;
- if (sleep_sec == get_timeout+1) {
- printf("\n");
- printf("%d %s failed to fire after timeout %d seconds\n", i, path, get_timeout);
- } else if (sleep_sec > get_timeout+1) {
- printf("%d %s failed to fire after timeout %d seconds\n", i, path, get_timeout);
- } else {
- printf("%d ", i);
- }
+ if (sleep_sec >= get_timeout+1)
+ printf("%s %d %s failed to fire after timeout %d seconds\n", time_str(), i, path, get_timeout);
+ else
+ printf("%s %d\n", time_str(), i);
}
}
@@ -1300,6 +1570,79 @@ static int _try_timeout(const char *path)
syslog(LOG_ERR, "trytimeout failed to disarm %s error %d %d\n", path, err, errno);
}
+ printf("%s %s disarm write V fd %d result %d\n", time_str(), path, fd, rv);
+
+ rv2 = close(fd);
+
+ printf("%s %s close fd %d result %d\n", time_str(), path, fd, rv2);
+
+ return rv;
+}
+
+static int _probe_dev_itco(const char *path)
+{
+ struct stat buf;
+ int fd, err, rv, timeout_real, timeout_itco;
+
+ rv = stat(path, &buf);
+ if (rv < 0) {
+ fprintf(stderr, "error %d stat %s\n", errno, path);
+ return -1;
+ }
+
+ fd = open(path, O_WRONLY | O_CLOEXEC);
+ if (fd < 0) {
+ fprintf(stderr, "error %d open %s\n", errno, path);
+ return fd;
+ }
+
+ timeout_real = 0;
+ timeout_itco = 0;
+
+ rv = ioctl(fd, WDIOC_GETTIMEOUT, &timeout_itco);
+ if (rv < 0) {
+ fprintf(stderr, "error %d ioctl gettimeout %s\n", errno, path);
+ rv = -1;
+ goto out;
+ }
+
+ timeout_real = timeout_itco * 2;
+
+ if (timeout_real == fire_timeout) {
+ printf("%s\n", path);
+ rv = 0;
+ goto out;
+ }
+
+ timeout_real = fire_timeout;
+ timeout_itco = timeout_real / 2;
+
+ rv = ioctl(fd, WDIOC_SETTIMEOUT, &timeout_itco);
+ if (rv < 0) {
+ fprintf(stderr, "error %d ioctl settimeout %s\n", errno, path);
+ rv = -1;
+ goto out;
+ }
+
+ timeout_real = timeout_itco * 2;
+
+ if (timeout_real != fire_timeout) {
+ fprintf(stderr, "error %d invalid timeout %s\n", errno, path);
+ rv = -1;
+ goto out;
+ }
+
+ printf("%s\n", path);
+ rv = 0;
+
+ out:
+ err = write(fd, "V", 1);
+ if (err < 0) {
+ fprintf(stderr, "probe failed to disarm %s error %d %d\n", path, err, errno);
+ openlog("wdmd", LOG_CONS | LOG_PID, LOG_DAEMON);
+ syslog(LOG_ERR, "probe failed to disarm %s error %d %d\n", path, err, errno);
+ }
+
close(fd);
return rv;
}
@@ -1366,14 +1709,37 @@ static int _probe_dev(const char *path)
return rv;
}
-static int probe_dev(const char *path)
+static int probe_dev(const char *wdpath)
{
- if (try_timeout)
- return _try_timeout(path);
- else
- return _probe_dev(path);
+ char *path = (char *)wdpath;
+
+ setup_identity(path); /* sets itco=1 if iTCO_wdt */
+
+ if (try_timeout) {
+ /*
+ * Used to test support for a given timeout with: wdmd -t <secs>
+ * or to test firing for a given timeout with: wdmd -F -t <secs>
+ */
+ if (itco)
+ return _try_timeout_itco(path);
+ else
+ return _try_timeout(path);
+ } else {
+ /*
+ * Used to print on stdout just the path of the watchdog device
+ * that wdmd would use with: wdmd -p
+ */
+ if (itco)
+ return _probe_dev_itco(path);
+ else
+ return _probe_dev(path);
+ }
}
+/*
+ * Confusingly, this is the top level function for both
+ * wdmd -t (test timeout) and wdmd -p (print functional watchdog device).
+ */
static int probe_watchdog(void)
{
int rv;
@@ -1861,6 +2227,11 @@ int main(int argc, char *argv[])
}
}
+ if (forcefire && !do_probe) {
+ fprintf(stderr, "Use force fire (-F) with a timeout (-t).\n");
+ exit(EXIT_FAILURE);
+ }
+
if (do_probe) {
rv = setup_shm();
if (rv < 0) {
@@ -1891,9 +2262,6 @@ int main(int argc, char *argv[])
openlog("wdmd", LOG_CONS | LOG_PID, LOG_DAEMON);
- log_error("wdmd started S%d H%d G%d", allow_scripts, high_priority,
- socket_gid);
-
setup_priority();
rv = lockfile();
@@ -1920,10 +2288,17 @@ int main(int argc, char *argv[])
if (rv < 0)
goto out_files;
+ /* Sets watchdog_path */
rv = setup_watchdog();
if (rv < 0)
goto out_clients;
+ /* Sets watchdog_identity and itco */
+ setup_identity(watchdog_path);
+
+ log_error("wdmd started S%d H%d G%d using %s \"%s\"", allow_scripts, high_priority,
+ socket_gid, watchdog_path, watchdog_identity[0] ? watchdog_identity : "unknown");
+
rv = test_loop();
close_watchdog();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 months, 2 weeks