src/Makefile | 3
src/main.c | 16 ---
src/sanlock_internal.h | 3
src/watchdog.c | 208 -------------------------------------------------
src/watchdog.h | 2
5 files changed, 1 insertion(+), 231 deletions(-)
New commits:
commit ea7129df969f1f6eebcb6191f7e65d20d43bbdd9
Author: David Teigland <teigland(a)redhat.com>
Date: Tue Mar 15 16:34:27 2011 -0500
sanlock: remove wdtest
now that we're using libwdmd
diff --git a/src/Makefile b/src/Makefile
index 31df6d2..3cbd0e0 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -51,8 +51,7 @@ CFLAGS += -D_GNU_SOURCE -g \
-Wp,-D_FORTIFY_SOURCE=2 \
-fexceptions \
-fasynchronous-unwind-tables \
- -fdiagnostics-show-option \
- -DUSE_WDMD
+ -fdiagnostics-show-option
CMD_LDFLAGS = -lpthread -lrt -lblkid -lsanlock -lwdmd
diff --git a/src/main.c b/src/main.c
index 91c930c..9a15a9d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1805,10 +1805,6 @@ static int make_dirs(void)
if (rv < 0 && errno != EEXIST)
goto out;
- rv = mkdir(SANLK_WDTEST_DIR, 0777);
- if (rv < 0 && errno != EEXIST)
- goto out;
-
rv = 0;
out:
umask(old_umask);
@@ -2216,7 +2212,6 @@ static void print_usage(void)
printf(" daemon start daemon\n");
printf(" client send request to daemon (default type if none given)\n");
printf(" direct access storage directly (no coordination with daemon)\n");
- printf(" wdtest watchdog test for expired host_id lease\n");
printf("\n");
printf("client actions: ask daemon to:\n");
printf(" status send internal state\n");
@@ -2363,10 +2358,6 @@ static int read_command_line(int argc, char *argv[])
com.type = COM_CLIENT;
act = argv[2];
i = 3;
- } else if (!strcmp(arg1, "wdtest")) {
- com.type = COM_WDTEST;
- act = argv[2];
- i = 3;
} else {
com.type = COM_CLIENT;
act = argv[1];
@@ -2426,9 +2417,6 @@ static int read_command_line(int argc, char *argv[])
exit(EXIT_FAILURE);
}
break;
-
- case COM_WDTEST:
- break;
};
@@ -2747,10 +2735,6 @@ int main(int argc, char *argv[])
case COM_DIRECT:
rv = do_direct();
break;
-
- case COM_WDTEST:
- rv = do_wdtest();
- break;
};
out:
return rv;
diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h
index 493954f..bf47e3a 100644
--- a/src/sanlock_internal.h
+++ b/src/sanlock_internal.h
@@ -42,7 +42,6 @@
#define SANLK_RUN_DIR "/var/run/sanlock"
#define SANLK_LOG_DIR "/var/log"
-#define SANLK_WDTEST_DIR "/var/run/sanlock/wdtest"
#define SANLK_SOCKET_NAME "sanlock_sock"
#define SANLK_LOGFILE_NAME "sanlock.log"
#define SANLK_LOCKFILE_NAME "sanlock.pid"
@@ -126,7 +125,6 @@ struct space {
pthread_cond_t cond;
struct lease_status lease_status;
int wd_fd;
- char wdtest_path[PATH_MAX];
};
struct sm_header {
@@ -306,7 +304,6 @@ struct command_line {
#define COM_DAEMON 1
#define COM_CLIENT 2
#define COM_DIRECT 3
-#define COM_WDTEST 4
enum {
ACT_STATUS = 1,
diff --git a/src/watchdog.c b/src/watchdog.c
index e92ad74..9f16fa7 100644
--- a/src/watchdog.c
+++ b/src/watchdog.c
@@ -37,8 +37,6 @@
* after the pid goes ahead.
*/
-#ifdef USE_WDMD
-
#include "../wdmd/wdmd.h"
static int daemon_wdmd_con;
@@ -193,209 +191,3 @@ int setup_watchdog(void)
return -1;
}
-int do_wdtest(void)
-{
- return -1;
-}
-
-#else
-
-#define BUF_SIZE 128
-
-static int do_write(int fd, void *buf, size_t count)
-{
- int rv, off = 0;
-
- retry:
- rv = write(fd, (char *)buf + off, count);
- if (rv == -1 && errno == EINTR)
- goto retry;
- if (rv < 0) {
- return -1;
- }
-
- if (rv != count) {
- count -= rv;
- off += rv;
- goto retry;
- }
- return 0;
-}
-
-void update_watchdog_file(struct space *sp, uint64_t timestamp)
-{
- char buf[BUF_SIZE];
-
- if (!options.use_watchdog)
- return;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "renewal %llu expire %llu\n",
- (unsigned long long)timestamp,
- (unsigned long long)timestamp + to.host_id_renewal_fail_seconds);
-
- lseek(sp->wd_fd, 0, SEEK_SET);
-
- do_write(sp->wd_fd, buf, sizeof(buf));
-}
-
-int create_watchdog_file(struct space *sp, uint64_t timestamp)
-{
- char buf[BUF_SIZE];
- int rv, fd;
-
- if (!options.use_watchdog)
- return 0;
-
- snprintf(sp->wdtest_path, PATH_MAX, "%s/%s_hostid%llu",
- SANLK_WDTEST_DIR, sp->space_name,
- (unsigned long long)sp->host_id);
-
- /* If this open fails with EEXIST I don't think it's safe to unlink
- * watchdog_path and try again. If the daemon had failed while pid's
- * remained running, then the daemon is restarted (before watchdog
- * triggers) and we start renewing host_id again and get here. If we
- * were to unlink the wd file right here, and then the daemon failed
- * again, we'd possibly be left with pid's running that had been
- * connected to the previous daemon instance, and the watchdog file
- * unlinked, so the watchdog won't reset us.
- *
- * If the open fails with EEXIST we could open the existing file and go
- * on, although there's currently no mechanism to reattach to any
- * running pid's we're supposed to be supervising. */
-
- fd = open(sp->wdtest_path, O_WRONLY|O_CREAT|O_EXCL|O_NONBLOCK, 0666);
- if (fd < 0) {
- log_erros(sp, "create_watchdog_file open %s error %d",
- sp->wdtest_path, errno);
- return fd;
- }
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "renewal %llu expire %llu\n",
- (unsigned long long)timestamp,
- (unsigned long long)timestamp + to.host_id_renewal_fail_seconds);
-
- rv = do_write(fd, buf, sizeof(buf));
- if (rv < 0) {
- log_erros(sp, "create_watchdog_file write error %d", rv);
- close(fd);
- return rv;
- }
-
- sp->wd_fd = fd;
- return 0;
-}
-
-void unlink_watchdog_file(struct space *sp)
-{
- if (!options.use_watchdog)
- return;
-
- unlink(sp->wdtest_path);
-}
-
-void close_watchdog_file(struct space *sp)
-{
- close(sp->wd_fd);
-}
-
-void close_watchdog(void)
-{
-}
-
-int setup_watchdog(void)
-{
- DIR *d;
- struct dirent *de;
- int rv = 0;
-
- if (!options.use_watchdog)
- return 0;
-
- d = opendir(SANLK_WDTEST_DIR);
- if (!d)
- return 0;
-
- while ((de = readdir(d))) {
- if (de->d_name[0] == '.')
- continue;
-
- log_error("stale wdtest file: %s/%s",
- SANLK_WDTEST_DIR, de->d_name);
- rv = -1;
- }
- closedir(d);
-
- return rv;
-}
-
-int do_wdtest(void)
-{
- DIR *d;
- struct dirent *de;
- char path[PATH_MAX];
- char buf[BUF_SIZE];
- unsigned long long renewal = 0, expire = 0;
- time_t t;
- int fail_count = 0;
- int rv, fd;
-
- openlog("sanlock_wdtest", LOG_CONS | LOG_PID, LOG_USER);
-
- d = opendir(SANLK_WDTEST_DIR);
- if (!d)
- return 0;
-
- while ((de = readdir(d))) {
- if (de->d_name[0] == '.')
- continue;
-
- snprintf(path, PATH_MAX-1, "%s/%s",
- SANLK_WDTEST_DIR, de->d_name);
-
- fd = open(path, O_RDONLY|O_NONBLOCK, 0666);
- if (fd < 0) {
- syslog(LOG_ERR, "open error %s", path);
- continue;
- }
-
- memset(buf, 0, sizeof(buf));
- rv = read(fd, buf, sizeof(buf));
- if (rv < 0) {
- syslog(LOG_ERR, "read error %s", path);
- close(fd);
- continue;
- }
-
- close(fd);
-
- sscanf(buf, "renewal %llu expire %llu", &renewal, &expire);
-
- t = time(NULL);
-
- /* TODO: remove this line, just for debugging */
- syslog(LOG_ERR, "%s renewal %llu expire %llu now %llu",
- path,
- (unsigned long long)renewal,
- (unsigned long long)expire,
- (unsigned long long)t);
-
- if (t < expire)
- continue;
-
- syslog(LOG_CRIT, "%s test fail renewal %llu expire %llu now %llu",
- path,
- (unsigned long long)renewal,
- (unsigned long long)expire,
- (unsigned long long)t);
-
- fail_count++;
- }
- closedir(d);
-
- if (fail_count)
- return -1;
- return 0;
-}
-#endif
diff --git a/src/watchdog.h b/src/watchdog.h
index 4e05c55..7f8cb1f 100644
--- a/src/watchdog.h
+++ b/src/watchdog.h
@@ -17,6 +17,4 @@ void close_watchdog_file(struct space *sp);
int setup_watchdog(void);
void close_watchdog(void);
-int do_wdtest(void);
-
#endif