[Cluster-devel] [PATCH] dlm: Allow 64-bit request when CONFIG_COMPAT is on
Even if kernel is compiled for 32-bit ABI compatibility it still should able to process 64-bit dlm_write_request struct. The regression was introduced by: b75bc91 dlm: check the maximum size of a request from user Signed-off-by: Jacek Konieczny jaj...@jajcus.net --- fs/dlm/user.c | 4 1 file changed, 4 deletions(-) diff --git a/fs/dlm/user.c b/fs/dlm/user.c index 7ff4985..d08a156 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c @@ -503,11 +503,7 @@ static ssize_t device_write(struct file *file, const char __user *buf, #endif return -EINVAL; -#ifdef CONFIG_COMPAT - if (count sizeof(struct dlm_write_request32) + DLM_RESNAME_MAXLEN) -#else if (count sizeof(struct dlm_write_request) + DLM_RESNAME_MAXLEN) -#endif return -EINVAL; kbuf = kzalloc(count + 1, GFP_NOFS); -- 1.8.0.1
[Cluster-devel] [PATCH] dlm_stonith_{off, reboot} aliases for fence helper
Not so pretty hack to allow rebooting instead of halting the node fenced by dlm_stonith. 'dlm_stonith_reboot' can be now used instead of 'dlm_stonith' in the dlm.conf file to request node reboot. 'dlm_stonith_off' alias is also provided to explicitly request power-off. Signed-off-by: Jacek Konieczny jaj...@jajcus.net --- fence/Makefile | 10 +- fence/stonith_helper.c |8 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/fence/Makefile b/fence/Makefile index b4c59dd..2f24677 100644 --- a/fence/Makefile +++ b/fence/Makefile @@ -6,6 +6,8 @@ BINDIR=$(PREFIX)/sbin BIN_TARGET = dlm_stonith #MAN_TARGET = dlm_stonith.8 +SYMLINKS = dlm_stonith_off dlm_stonith_reboot + BIN_SOURCE = stonith_helper.c BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \ @@ -37,11 +39,14 @@ BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie BIN_LDFLAGS += `xml2-config --libs` BIN_LDFLAGS += -ldl -all: $(BIN_TARGET) +all: $(BIN_TARGET) $(SYMLINKS) $(BIN_TARGET): $(BIN_SOURCE) $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L. +$(SYMLINKS): $(BIN_TARGET) + for link in $(SYMLINKS) ; do ln -sf $(BIN_TARGET) $$link ; done + clean: rm -f *.o *.so *.so.* $(BIN_TARGET) @@ -53,5 +58,8 @@ install: all $(INSTALL) -d $(DESTDIR)/$(BINDIR) $(INSTALL) -d $(DESTDIR)/$(MANDIR)/man8 $(INSTALL) -c -m 755 $(BIN_TARGET) $(DESTDIR)/$(BINDIR) + for link in $(SYMLINKS) ; do \ + ln -sf $(BIN_TARGET) $(DESTDIR)/$(BINDIR)/$$link ; \ + done # $(INSTALL) -m 644 $(MAN_TARGET) $(DESTDIR)/$(MANDIR)/man8/ diff --git a/fence/stonith_helper.c b/fence/stonith_helper.c index 5b384c1..73a2245 100644 --- a/fence/stonith_helper.c +++ b/fence/stonith_helper.c @@ -16,6 +16,7 @@ int nodeid; uint64_t fail_time; +int turn_off = 1; #define MAX_ARG_LEN 1024 @@ -26,6 +27,11 @@ static int get_options(int argc, char *argv[]) char val[MAX_ARG_LEN]; char c; int rv; + int arg0_l; + + arg0_l = strlen(argv[0]); + if (arg0_l7 !strcmp(argv[0] + arg0_l - 7, _reboot)) turn_off = 0; + else if (arg0_l4 !strcmp(argv[0] + arg0_l - 4, _off)) turn_off = 1; if (argc 1) { while ((c = getopt(argc, argv, n:t:)) != -1) { @@ -77,7 +83,7 @@ int main(int argc, char *argv[]) if (t = fail_time) return 0; - rv = stonith_api_kick_helper(nodeid, 300, 1); + rv = stonith_api_kick_helper(nodeid, 300, turn_off); if (rv) { fprintf(stderr, kick_helper error %d nodeid %d\n, rv, nodeid); openlog(stonith_helper, LOG_CONS | LOG_PID, LOG_DAEMON); -- 1.7.7.4
Re: [Cluster-devel] cluster4 dlm dlm_stonith ??? should it really fence by turning node off?
My workaround for the missing functionality (or wrong default): [PATCH] dlm_stonith_{off,reboot} aliases for fence helper Greets, Jacek
Re: [Cluster-devel] [PATCH] dlm_stonith_{off, reboot} aliases for fence helper
On Mon, Nov 05, 2012 at 02:30:33PM -0500, David Teigland wrote: On Mon, Nov 05, 2012 at 07:05:22PM +0100, Jacek Konieczny wrote: - rv = stonith_api_kick_helper(nodeid, 300, 1); + rv = stonith_api_kick_helper(nodeid, 300, turn_off); I'd like it to be reboot, but seeing the arg as bool off I figured the opposite would be on ... if you're saying that the opposite of off is actually reboot, then I'll just make it 0. If it is 'off' by mistake and not for any better reason, then I think this will be the best – to make this '0' by default. I have verified the Pacemaker sources twice – 'off=0' means 'reboot'. Effort to make this configurable may be postponed until anybody is interested in fencing by power-off. Greets, Jacek
[Cluster-devel] cluster4 dlm dlm_stonith – should it really fence by turning node off?
Hello, The dlm_stonith fencing helper is really convenient when Pacemaker is in use. Though, it doesn't quite work as I would expect – when fencing is needed it requests a node to be turned off instead of rebooting. And it doesn't handle unfencing – so automatic recovery is not possible (rebooted node could join the cluster cleanly later, provided quorum handling is properly configured in the cluster stack). Preferably this behaviour should be configurable. I have hacked a work-around by (ab)using argv[0] – when 'dlm_stonith' is called as 'dlm_stonith_reboot' the node would be rebooted instead of halting – this works for me well-enough, but I don't think this is the right solution. Any ideas how to solve that properly? An argument for the helper to be included in the config file? Or, maybe, just change the default behaviour? Greets, Jacek
[Cluster-devel] [PATCH 1/2] --foreground option added to dlm_controld
Foreground is the preferred way to run services from systemd and it is easier to provide startup notification this way. Signed-off-by: Jacek Konieczny jaj...@jajcus.net --- dlm_controld/dlm_controld.8 |3 +++ dlm_controld/dlm_daemon.h |1 + dlm_controld/main.c |7 ++- 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/dlm_controld/dlm_controld.8 b/dlm_controld/dlm_controld.8 index 262ef8a..c9011fd 100644 --- a/dlm_controld/dlm_controld.8 +++ b/dlm_controld/dlm_controld.8 @@ -23,6 +23,9 @@ For default settings, see dlm_controld -h. .B --daemon_debug | -D enable debugging to stderr and don't fork +.B --foreground +don't fork + .B --log_debug | -K enable kernel dlm debugging messages diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h index 916ee58..377f28d 100644 --- a/dlm_controld/dlm_daemon.h +++ b/dlm_controld/dlm_daemon.h @@ -109,6 +109,7 @@ enum { enable_quorum_lockspace_ind, help_ind, version_ind, +foreground_ind, dlm_options_max, }; diff --git a/dlm_controld/main.c b/dlm_controld/main.c index fd469f9..deda60c 100644 --- a/dlm_controld/main.c +++ b/dlm_controld/main.c @@ -1245,6 +1245,11 @@ static void set_opt_defaults(void) 0, NULL, enable debugging to stderr and don't fork); + set_opt_default(foreground_ind, + foreground, '\0', no_arg, + 0, NULL, + don't fork); + set_opt_default(log_debug_ind, log_debug, 'K', no_arg, 0, NULL, @@ -1562,7 +1567,7 @@ int main(int argc, char **argv) INIT_LIST_HEAD(fs_register_list); init_daemon(); - if (!opt(daemon_debug_ind)) { + if (!opt(daemon_debug_ind) !opt(foreground_ind)) { if (daemon(0, 0) 0) { perror(daemon error); exit(EXIT_FAILURE); -- 1.7.7.4
[Cluster-devel] cluster4 dlm: startup notification for systemd
Hello, The two patches: [PATCH 1/2] --foreground option added to dlm_controld [PATCH 2/2] Startup notification by sd_notify() add startup notification for the systemd service unit. This way startup of services depending on DLM can be properly serialized. Currently dlm_controld forks immediately and the parent exits befor the DLM subsystem is properly initialized. If clvmd is started next, it will fail with some cryptic error messages (like 'dlm: no local IP address has been set'). With the startup notification clvmd startup can be delayed until dlm_controld reports it is ready. Similar thing could be implemented with forking and no external dependency, – but that is a bit more complicated, as requires communication between the parent and child process or moving the initialization code before fork(). sd_notify() could also be used to provide status information during the start-up phase too, but I am not familiar enough with what is happening there to provide reasonable status messages. Greets, Jacek
[Cluster-devel] [PATCH 2/2] Startup notification by sd_notify()
Implements simple start-up status notification via the sd_notify(3) function from the libsystemd-daemon library. This allows proper service startup serialization by the init daemon – services depending on DLM will be started after dlm_controld completes the initialization. As this pulls additional dependency, the feature my by disabled on compile time by calling 'make' with 'USE_SD_NOTIFY=no'. Signed-off-by: Jacek Konieczny jaj...@jajcus.net --- dlm_controld/Makefile |8 dlm_controld/main.c |8 init/dlm.service |5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile index f42a913..13d6339 100644 --- a/dlm_controld/Makefile +++ b/dlm_controld/Makefile @@ -6,6 +6,8 @@ LIBDIR=$(PREFIX)/$(LIBNUM) HDRDIR=$(PREFIX)/include MANDIR=$(PREFIX)/share/man +USE_SD_NOTIFY=yes + BIN_TARGET = dlm_controld LIB_NAME = libdlmcontrol @@ -59,6 +61,12 @@ BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum LIB_CFLAGS += $(BIN_CFLAGS) LIB_LDFLAGS += -Wl,-z,relro -pie +ifeq ($(USE_SD_NOTIFY),yes) + BIN_CFLAGS += $(shell pkg-config --cflags libsystemd-daemon) \ + -DUSE_SD_NOTIFY + BIN_LDFLAGS += $(shell pkg-config --libs libsystemd-daemon) +endif + all: $(LIB_TARGET) $(BIN_TARGET) $(BIN_TARGET): $(BIN_SOURCE) diff --git a/dlm_controld/main.c b/dlm_controld/main.c index deda60c..d1fdb2a 100644 --- a/dlm_controld/main.c +++ b/dlm_controld/main.c @@ -14,6 +14,10 @@ #include linux/genetlink.h #include linux/dlm_netlink.h +#ifdef USE_SD_NOTIFY +#include systemd/sd-daemon.h +#endif + #include copyright.cf #include version.cf @@ -1012,6 +1016,10 @@ static void loop(void) plock_fd = rv; plock_ci = client_add(rv, process_plocks, NULL); +#ifdef USE_SD_NOTIFY + sd_notify(0, READY=1); +#endif + for (;;) { rv = poll(pollfd, client_maxi + 1, poll_timeout); if (rv == -1 errno == EINTR) { diff --git a/init/dlm.service b/init/dlm.service index 3c4e53e..f068c63 100644 --- a/init/dlm.service +++ b/init/dlm.service @@ -3,10 +3,11 @@ Description=dlm control daemon After=syslog.target network.target corosync.service sys-kernel-config.mount [Service] -Type=forking +Type=notify +NotifyAccess=main EnvironmentFile=/etc/sysconfig/dlm ExecStartPre=/sbin/modprobe dlm -ExecStart=/usr/sbin/dlm_controld $DLM_CONTROLD_OPTS +ExecStart=/usr/sbin/dlm_controld --foreground $DLM_CONTROLD_OPTS #ExecStopPost=/sbin/modprobe -r dlm [Install] -- 1.7.7.4
[Cluster-devel] DLM patches from PLD Linux
Hello, These are three of the patches I have applied to dlm when packaging it for PLD Linux. I think they could be applied upstream. Greets, Jacek
[Cluster-devel] [PATCH 2/3] Run dlm.service after sys-kernel-config.mount
dlm_controld requires configfs mounted. systemd can take care for that, but it does it better if the order is set in the unit file. Signed-off-by: Jacek Konieczny jaj...@jajcus.net --- init/dlm.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/dlm.service b/init/dlm.service index d7cf9c7..3c4e53e 100644 --- a/init/dlm.service +++ b/init/dlm.service @@ -1,6 +1,6 @@ [Unit] Description=dlm control daemon -After=syslog.target network.target corosync.service +After=syslog.target network.target corosync.service sys-kernel-config.mount [Service] Type=forking -- 1.7.12.4
[Cluster-devel] [PATCH 3/3] Do not crash uncleanly on SIGINT and SIGHUP
Unclean shut-down of dlm_controld may trigger a node fencing, this should not be triggered by mistake. SIGINT is the natural way to stop dlm_controld started on a terminal with '-D' for debugging – let this work like SIGTERM. SIGHUP is often used for config reload. dlm_controld doesn't support that, but when someone tries this by mistake, this is not a reason to crash. Signed-off-by: Jacek Konieczny jaj...@jajcus.net --- dlm_controld/main.c | 9 + 1 file changed, 9 insertions(+) diff --git a/dlm_controld/main.c b/dlm_controld/main.c index 6eafa49..fd469f9 100644 --- a/dlm_controld/main.c +++ b/dlm_controld/main.c @@ -1582,6 +1582,15 @@ int main(int argc, char **argv) rv = sigaction(SIGTERM, act, NULL); if (rv 0) return -rv; + rv = sigaction(SIGINT, act, NULL); + if (rv 0) + return -rv; + + memset(act, 0, sizeof(act)); + act.sa_handler = SIG_IGN; + rv = sigaction(SIGHUP, act, NULL); + if (rv 0) + return -rv; memset(act, 0, sizeof(act)); act.sa_handler = sigchld_handler; -- 1.7.12.4
[Cluster-devel] [PATCH 1/3] Fix linking order
Objects should generally be listed before the libraries they require. DLM building fails for me without these changes. Signed-off-by: Jacek Konieczny jaj...@jajcus.net --- dlm_controld/Makefile | 4 ++-- dlm_tool/Makefile | 2 +- fence/Makefile| 2 +- libdlm/Makefile | 8 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile index d279b0d..f42a913 100644 --- a/dlm_controld/Makefile +++ b/dlm_controld/Makefile @@ -62,10 +62,10 @@ LIB_LDFLAGS += -Wl,-z,relro -pie all: $(LIB_TARGET) $(BIN_TARGET) $(BIN_TARGET): $(BIN_SOURCE) - $(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $(BIN_SOURCE) -o $@ -L. + $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L. $(LIB_TARGET): $(LIB_SOURCE) - $(CC) $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_SMAJOR) $^ + $(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_SMAJOR) ln -sf $(LIB_TARGET) $(LIB_SO) ln -sf $(LIB_TARGET) $(LIB_SMAJOR) diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile index fe43677..c16d8f5 100644 --- a/dlm_tool/Makefile +++ b/dlm_tool/Makefile @@ -39,7 +39,7 @@ BIN_LDFLAGS += -lpthread -ldlm -ldlmcontrol all: $(BIN_TARGET) $(BIN_TARGET): $(BIN_SOURCE) - $(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $(BIN_SOURCE) -o $@ + $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ clean: rm -f *.o *.so *.so.* $(BIN_TARGET) diff --git a/fence/Makefile b/fence/Makefile index 0f1a29c..b4c59dd 100644 --- a/fence/Makefile +++ b/fence/Makefile @@ -40,7 +40,7 @@ BIN_LDFLAGS += -ldl all: $(BIN_TARGET) $(BIN_TARGET): $(BIN_SOURCE) - $(CC) $(BIN_CFLAGS) $(BIN_LDFLAGS) $(BIN_SOURCE) -o $@ -L. + $(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L. clean: rm -f *.o *.so *.so.* $(BIN_TARGET) diff --git a/libdlm/Makefile b/libdlm/Makefile index 565a600..76d3504 100644 --- a/libdlm/Makefile +++ b/libdlm/Makefile @@ -86,18 +86,18 @@ LLT_LDFLAGS += $(LDFLAGS) all: $(LIB_TARGET) $(LLT_TARGET) $(LIB_PC) $(LLT_PC) $(LIB_O): $(SOURCE) - $(CC) $(LIB_CFLAGS) -c -o $@ $ + $(CC) $ $(LIB_CFLAGS) -c -o $@ $(LLT_O): $(SOURCE) - $(CC) $(LLT_CFLAGS) -c -o $@ $ + $(CC) $ $(LLT_CFLAGS) -c -o $@ $(LIB_TARGET): $(LIB_O) - $(CC) $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR) $^ + $(CC) $^ $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR) ln -sf $(LIB_TARGET) $(LIB_SO) ln -sf $(LIB_TARGET) $(LIB_SMAJOR) $(LLT_TARGET): $(LLT_O) - $(CC) $(LLT_LDFLAGS) -shared -o $@ -Wl,-soname=$(LLT_SMAJOR) $^ + $(CC) $^ $(LLT_LDFLAGS) -shared -o $@ -Wl,-soname=$(LLT_SMAJOR) ln -sf $(LLT_TARGET) $(LLT_SO) ln -sf $(LLT_TARGET) $(LLT_SMAJOR) -- 1.7.12.4