forked from pool/ocfs2-tools
c8700c5230
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/ocfs2-tools?expand=0&rev=8
188 lines
5.0 KiB
Diff
188 lines
5.0 KiB
Diff
---
|
|
ocfs2_controld/ckpt.c | 2 -
|
|
ocfs2_controld/main.c | 53 ++++++++++++++++++++++++++++++++++------
|
|
ocfs2_controld/mount.c | 2 +
|
|
ocfs2_controld/ocfs2_controld.h | 1
|
|
ocfs2_controld/pacemaker.c | 2 -
|
|
5 files changed, 51 insertions(+), 9 deletions(-)
|
|
|
|
Index: ocfs2_controld/ckpt.c
|
|
===================================================================
|
|
--- a/ocfs2_controld/ckpt.c.orig
|
|
+++ b/ocfs2_controld/ckpt.c
|
|
@@ -381,7 +381,7 @@ static int call_section_read(struct ckpt
|
|
|
|
/* -ENOENT is a clean error for the caller to handle */
|
|
if (rc == -ENOENT) {
|
|
- log_debug("Checkpoint \"%.*s\" does not have a "
|
|
+ log_error("Checkpoint \"%.*s\" does not have a "
|
|
"section named \"%s\"",
|
|
handle->ch_name.length,
|
|
handle->ch_name.value, name);
|
|
Index: ocfs2_controld/main.c
|
|
===================================================================
|
|
--- a/ocfs2_controld/main.c.orig
|
|
+++ b/ocfs2_controld/main.c
|
|
@@ -73,7 +73,7 @@ static int time_to_die = 0;
|
|
static int sigpipe_write_fd;
|
|
|
|
char *prog_name;
|
|
-int daemon_debug_opt;
|
|
+int daemon_debug_opt = 0;
|
|
char daemon_debug_buf[1024];
|
|
char dump_buf[DUMP_SIZE];
|
|
int dump_point;
|
|
@@ -994,8 +994,7 @@ static void lockfile(void)
|
|
fd = open(LOCKFILE_NAME, O_CREAT|O_WRONLY,
|
|
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
|
|
if (fd < 0) {
|
|
- fprintf(stderr, "cannot open/create lock file %s\n",
|
|
- LOCKFILE_NAME);
|
|
+ log_error("cannot open/create lock file %s", LOCKFILE_NAME);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
@@ -1006,13 +1005,13 @@ static void lockfile(void)
|
|
|
|
error = fcntl(fd, F_SETLK, &lock);
|
|
if (error) {
|
|
- fprintf(stderr, "ocfs2_controld is already running\n");
|
|
+ log_error("ocfs2_controld is already running");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
error = ftruncate(fd, 0);
|
|
if (error) {
|
|
- fprintf(stderr, "cannot clear lock file %s\n", LOCKFILE_NAME);
|
|
+ log_error("cannot clear lock file %s", LOCKFILE_NAME);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
@@ -1020,7 +1019,7 @@ static void lockfile(void)
|
|
|
|
error = write(fd, buf, strlen(buf));
|
|
if (error <= 0) {
|
|
- fprintf(stderr, "cannot write lock file %s\n", LOCKFILE_NAME);
|
|
+ log_error("cannot write lock file %s", LOCKFILE_NAME);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
}
|
|
@@ -1030,13 +1029,13 @@ static void daemonize(void)
|
|
int fd;
|
|
pid_t pid = fork();
|
|
if (pid < 0) {
|
|
+ log_error("main: cannot fork");
|
|
perror("main: cannot fork");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
if (pid)
|
|
exit(EXIT_SUCCESS);
|
|
setsid();
|
|
- chdir("/");
|
|
umask(0);
|
|
close(0);
|
|
close(1);
|
|
@@ -1107,6 +1106,7 @@ static void decode_arguments(int argc, c
|
|
break;
|
|
|
|
default:
|
|
+ log_error("unknown option: %c\n", optchar);
|
|
fprintf(stderr, "unknown option: %c\n", optchar);
|
|
exit(EXIT_FAILURE);
|
|
break;
|
|
@@ -1144,12 +1144,53 @@ static void set_scheduler(void)
|
|
}
|
|
}
|
|
|
|
+#include <sys/time.h>
|
|
+#include <sys/resource.h>
|
|
+
|
|
+static int
|
|
+hack_enable_coredumps(void)
|
|
+{
|
|
+ int rc;
|
|
+ struct rlimit rlim;
|
|
+ int doenable = 1;
|
|
+
|
|
+ if ((rc = getrlimit(RLIMIT_CORE, &rlim)) < 0) {
|
|
+ int errsave = errno;
|
|
+ log_error("Cannot get current core limit value. %d", errsave);
|
|
+ errno = errsave;
|
|
+ return rc;
|
|
+ }
|
|
+ if (rlim.rlim_max == 0 && geteuid() == 0) {
|
|
+ rlim.rlim_max = RLIM_INFINITY;
|
|
+ }
|
|
+
|
|
+ rlim.rlim_cur = (doenable ? rlim.rlim_max : 0);
|
|
+
|
|
+ if (doenable && rlim.rlim_max == 0) {
|
|
+ log_error("Not possible to enable core dumps (rlim_max is 0)");
|
|
+ }
|
|
+
|
|
+ if ((rc = setrlimit(RLIMIT_CORE, &rlim)) < 0) {
|
|
+ int errsave = errno;
|
|
+ log_error("Unable to enable core dumps: %d", errsave);
|
|
+ errno = errsave;
|
|
+ return rc;
|
|
+ }
|
|
+ chdir("/var/lib/openais");
|
|
+ log_debug("Core dumps enabled: /var/lib/openais");
|
|
+ return 0;
|
|
+}
|
|
+
|
|
int main(int argc, char **argv)
|
|
{
|
|
errcode_t err;
|
|
prog_name = argv[0];
|
|
const char *stack = NULL;
|
|
|
|
+ decode_arguments(argc, argv);
|
|
+
|
|
+ hack_enable_coredumps();
|
|
+
|
|
init_mounts();
|
|
|
|
initialize_o2cb_error_table();
|
|
@@ -1165,13 +1206,11 @@ int main(int argc, char **argv)
|
|
return 1;
|
|
}
|
|
if (strcmp(stack, stackname)) {
|
|
- fprintf(stderr, "%s: This daemon supports the \"%s\" stack, but the \"%s\" stack is in use\n",
|
|
- prog_name, stackname, stack);
|
|
+ log_error("%s: This daemon supports the \"%s\" stack, but the \"%s\" stack is in use",
|
|
+ prog_name, stackname, stack);
|
|
return 1;
|
|
}
|
|
|
|
- decode_arguments(argc, argv);
|
|
-
|
|
if (!daemon_debug_opt)
|
|
daemonize();
|
|
|
|
Index: ocfs2_controld/mount.c
|
|
===================================================================
|
|
--- a/ocfs2_controld/mount.c.orig
|
|
+++ b/ocfs2_controld/mount.c
|
|
@@ -176,6 +176,8 @@ static void notify_mount_client(struct m
|
|
else
|
|
mg->mg_mount_notified = 1;
|
|
|
|
+ log_debug("Notified client: %d", mg->mg_mount_notified);
|
|
+
|
|
/*
|
|
* XXX If we failed to notify the client, what can we do? I'm
|
|
* guessing that our main loop will get POLLHUP and we'll clean
|
|
Index: ocfs2_controld/ocfs2_controld.h
|
|
===================================================================
|
|
--- a/ocfs2_controld/ocfs2_controld.h.orig
|
|
+++ b/ocfs2_controld/ocfs2_controld.h
|
|
@@ -60,6 +60,7 @@ do { \
|
|
#define log_error(fmt, args...) \
|
|
do { \
|
|
log_debug(fmt, ##args); \
|
|
+ fprintf(stderr, fmt "\n", ##args); \
|
|
syslog(LOG_ERR, fmt, ##args); \
|
|
} while (0)
|
|
|