cluster: master - cman: Make cman-notifyd use corosync reload callbacks
by Christine Caulfield
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 01af75d8f464e4c2d4a38c12e9a18c9b3d0008f4
Parent: 8bdfd5ba128867b1ebd021fd34e51ce16beae56a
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Tue Mar 16 10:01:51 2010 +0000
Committer: Christine Caulfield <ccaulfie(a)redhat.com>
CommitterDate: Tue Mar 16 10:01:51 2010 +0000
cman: Make cman-notifyd use corosync reload callbacks
Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com>
---
cman/notifyd/main.c | 90 ++++++++++++++++++++++-----------------------------
1 files changed, 39 insertions(+), 51 deletions(-)
diff --git a/cman/notifyd/main.c b/cman/notifyd/main.c
index 5c57b51..0668e59 100644
--- a/cman/notifyd/main.c
+++ b/cman/notifyd/main.c
@@ -51,12 +51,10 @@ static void quorum_notification_callback (
uint32_t view_list_entries,
uint32_t *view_list);
-static void confdb_object_create_callback (
+static void confdb_reload_callback (
confdb_handle_t handle,
- hdb_handle_t parent_object_handle,
- hdb_handle_t object_handle,
- const void *name_pt,
- size_t name_len);
+ confdb_reload_type_t type);
+
static corosync_cfg_callbacks_t cfg_callbacks =
{
@@ -71,7 +69,7 @@ static quorum_callbacks_t quorum_callbacks =
static confdb_callbacks_t confdb_callbacks =
{
- .confdb_object_create_change_notify_fn = confdb_object_create_callback
+ .confdb_reload_notify_fn = confdb_reload_callback
};
@@ -256,7 +254,7 @@ static void init_logging(int reconf)
logt_conf("cmannotifyd", mode, syslog_facility, syslog_priority, logfile_priority, logfile);
}
-static void dispatch_notification(const char *str, int *quorum)
+static void dispatch_notification(const char *str, uint32_t quorum)
{
char *envp[MAX_ARGS];
char *argv[MAX_ARGS];
@@ -275,7 +273,7 @@ static void dispatch_notification(const char *str, int *quorum)
envp[envptr++] = strdup(scratch);
if (quorum) {
- snprintf(scratch, sizeof(scratch), "CMAN_NOTIFICATION_QUORUM=%d", *quorum);
+ snprintf(scratch, sizeof(scratch), "CMAN_NOTIFICATION_QUORUM=%d", quorum);
envp[envptr++] = strdup(scratch);
}
@@ -347,15 +345,12 @@ static void quorum_notification_callback(quorum_handle_t handle,
dispatch_notification("CMAN_REASON_STATECHANGE", quorate);
}
-static void confdb_object_create_callback(confdb_handle_t handle,
- hdb_handle_t parent_object_handle,
- hdb_handle_t object_handle,
- const void *name_pt,
- size_t name_len)
+static void confdb_reload_callback (
+ confdb_handle_t handle,
+ confdb_reload_type_t type)
{
- logt_print(LOG_DEBUG,
- "Received a config update notification\n");
- init_logging(1);
+ logt_print(LOG_DEBUG,
+ "Received a config reload notification, type=%d\n", type);
dispatch_notification("CMAN_REASON_CONFIG_UPDATE", 0);
}
@@ -364,23 +359,23 @@ static void byebye_corosync(void)
if (cfg_handle)
{
corosync_cfg_finalize(cfg_handle);
- cfg_handle = NULL;
+ cfg_handle = 0LL;
}
if (quorum_handle)
{
quorum_finalize(quorum_handle);
- quorum_handle = NULL;
+ quorum_handle = 0LL;
}
if (confdb_handle)
{
confdb_finalize(confdb_handle);
- confdb_handle = NULL;
+ confdb_handle = 0LL;
}
}
static void setup_corosync(int forever)
{
- int init = 0, active = 0;
+ int init = 0;
cs_error_t cs_err;
retry_init:
@@ -402,7 +397,7 @@ retry_init:
cs_err = confdb_initialize(&confdb_handle, &confdb_callbacks);
if (cs_err != CS_OK)
goto init_fail;
- // TODO track changes
+ cs_err = confdb_track_changes(confdb_handle, OBJECT_PARENT_HANDLE, CONFDB_TRACK_DEPTH_ONE);
}
goto out_ok;
@@ -420,7 +415,7 @@ init_fail:
out:
byebye_corosync();
out_ok:
- exit(EXIT_SUCCESS);
+ return;
}
static void loop(void)
@@ -446,45 +441,38 @@ static void loop(void)
goto out;
if (select_result == -1) {
- logt_print(LOG_CRIT, "Unable to select on cman_fd: %s\n", strerror(errno));
+ logt_print(LOG_CRIT, "Unable to select on corosync fds: %s\n", strerror(errno));
byebye_corosync();
- exit(EXIT_FAILURE);
+ logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
+ setup_corosync(1);
+ logt_print(LOG_DEBUG, "corosync is back..\n");
}
if (FD_ISSET(cfg_fd, &read_fds)) {
- cs_result = CS_OK;
- while (cs_result == CS_OK) {
- cs_result = corosync_cfg_dispatch(cfg_handle, CS_DISPATCH_ONE);
- if (cs_result != CS_OK) {
- byebye_corosync();
- logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
- setup_corosync(1);
- logt_print(LOG_DEBUG, "corosync is back..\n");
- }
+ cs_result = corosync_cfg_dispatch(cfg_handle, CS_DISPATCH_ONE);
+ if (cs_result != CS_OK) {
+ byebye_corosync();
+ logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
+ setup_corosync(1);
+ logt_print(LOG_DEBUG, "corosync is back..\n");
}
}
if (FD_ISSET(confdb_fd, &read_fds)) {
- cs_result = CS_OK;
- while (cs_result == CS_OK) {
- cs_result = confdb_dispatch(confdb_handle, CS_DISPATCH_ONE);
- if (cs_result != CS_OK) {
- byebye_corosync();
- logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
- setup_corosync(1);
- logt_print(LOG_DEBUG, "corosync is back..\n");
- }
+ cs_result = confdb_dispatch(confdb_handle, CS_DISPATCH_ONE);
+ if (cs_result != CS_OK) {
+ byebye_corosync();
+ logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
+ setup_corosync(1);
+ logt_print(LOG_DEBUG, "corosync is back..\n");
}
}
if (FD_ISSET(quorum_fd, &read_fds)) {
- cs_result = CS_OK;
- while (cs_result == CS_OK) {
- cs_result = quorum_dispatch(quorum_handle, CS_DISPATCH_ONE);
- if (cs_result != CS_OK) {
- byebye_corosync();
- logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
- setup_corosync(1);
- logt_print(LOG_DEBUG, "corosync is back..\n");
- }
+ cs_result = quorum_dispatch(quorum_handle, CS_DISPATCH_ONE);
+ if (cs_result != CS_OK) {
+ byebye_corosync();
+ logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
+ setup_corosync(1);
+ logt_print(LOG_DEBUG, "corosync is back..\n");
}
}
} while (select_result && !daemon_quit);
14 years, 1 month
cluster: RHEL54 - Bug in GFS locking code leads to dos
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 565fc69b92c16e00385008e55339e0434e86edd6
Parent: a7cca219bb0d1c8551e3a90094c78c0fdec51fbd
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Mar 11 11:35:01 2010 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Mar 11 11:46:08 2010 -0600
Bug in GFS locking code leads to dos
This patch fixes the bug described in bug 570863.
Without the patch, a program may be written that uses
locking commands to crash the system.
rhbz#571297
---
gfs-kernel/src/gfs/ops_file.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gfs-kernel/src/gfs/ops_file.c b/gfs-kernel/src/gfs/ops_file.c
index bd68583..cbf9d2d 100644
--- a/gfs-kernel/src/gfs/ops_file.c
+++ b/gfs-kernel/src/gfs/ops_file.c
@@ -1652,7 +1652,8 @@ gfs_lock(struct file *file, int cmd, struct file_lock *fl)
if (!(fl->fl_flags & FL_POSIX))
return -ENOLCK;
- if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
+ if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
+ fl->fl_type != F_UNLCK)
return -ENOLCK;
if (cmd == F_CANCELLK) {
14 years, 1 month
cluster: RHEL48 - Bug in GFS locking code leads to dos
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 19bb0c8920a245c58f1a96d8e37387f7d83d1f17
Parent: 35f94eace1e0b3b1c4b9da50d26ba8a1fdbf0716
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Mar 11 11:35:01 2010 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Mar 11 11:43:51 2010 -0600
Bug in GFS locking code leads to dos
This patch fixes the bug described in bug 570863.
Without the patch, a program may be written that uses
locking commands to crash the system.
rhbz#571299
---
gfs-kernel/src/gfs/ops_file.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gfs-kernel/src/gfs/ops_file.c b/gfs-kernel/src/gfs/ops_file.c
index 4d263ee..46cfec2 100644
--- a/gfs-kernel/src/gfs/ops_file.c
+++ b/gfs-kernel/src/gfs/ops_file.c
@@ -1625,7 +1625,8 @@ gfs_lock(struct file *file, int cmd, struct file_lock *fl)
if (!(fl->fl_flags & FL_POSIX))
return -ENOLCK;
- if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
+ if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
+ fl->fl_type != F_UNLCK)
return -ENOLCK;
if (sdp->sd_args.ar_localflocks) {
14 years, 1 month
cluster: RHEL4 - Bug in GFS locking code leads to dos
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: abf96e2fbe89852fa67e9c5120a0cbe4b9d8d090
Parent: 2d0323010f7110452625bc71c9898459a2ca7e85
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Mar 11 11:35:01 2010 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Mar 11 11:41:09 2010 -0600
Bug in GFS locking code leads to dos
This patch fixes the bug described in bug 570863.
Without the patch, a program may be written that uses
locking commands to crash the system.
rhbz#571298
---
gfs-kernel/src/gfs/ops_file.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gfs-kernel/src/gfs/ops_file.c b/gfs-kernel/src/gfs/ops_file.c
index 4d263ee..46cfec2 100644
--- a/gfs-kernel/src/gfs/ops_file.c
+++ b/gfs-kernel/src/gfs/ops_file.c
@@ -1625,7 +1625,8 @@ gfs_lock(struct file *file, int cmd, struct file_lock *fl)
if (!(fl->fl_flags & FL_POSIX))
return -ENOLCK;
- if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
+ if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
+ fl->fl_type != F_UNLCK)
return -ENOLCK;
if (sdp->sd_args.ar_localflocks) {
14 years, 1 month
cluster: RHEL55 - Bug in GFS locking code leads to dos
by Bob Peterson
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: e685b407d5fa266bc99563932b2336aff2489363
Parent: 92c3ba0359d38829318d3d6d93d32c1baee06c03
Author: Bob Peterson <rpeterso(a)redhat.com>
AuthorDate: Thu Mar 11 11:35:01 2010 -0600
Committer: Bob Peterson <rpeterso(a)redhat.com>
CommitterDate: Thu Mar 11 11:35:01 2010 -0600
Bug in GFS locking code leads to dos
This patch fixes the bug described in bug 570863.
Without the patch, a program may be written that uses
locking commands to crash the system.
rhbz#571298
---
gfs-kernel/src/gfs/ops_file.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gfs-kernel/src/gfs/ops_file.c b/gfs-kernel/src/gfs/ops_file.c
index 440fbf6..150f328 100644
--- a/gfs-kernel/src/gfs/ops_file.c
+++ b/gfs-kernel/src/gfs/ops_file.c
@@ -1653,7 +1653,8 @@ gfs_lock(struct file *file, int cmd, struct file_lock *fl)
if (!(fl->fl_flags & FL_POSIX))
return -ENOLCK;
- if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
+ if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID &&
+ fl->fl_type != F_UNLCK)
return -ENOLCK;
if (cmd == F_CANCELLK) {
14 years, 1 month
cluster: master - cman: Make cman_notifyd use corosync calls rather than libcman
by Christine Caulfield
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 8bdfd5ba128867b1ebd021fd34e51ce16beae56a
Parent: f3f55aa3460c18d91d8ad21e7d5fc62c30619a42
Author: Christine Caulfield <ccaulfie(a)redhat.com>
AuthorDate: Thu Mar 11 10:25:58 2010 +0000
Committer: Christine Caulfield <ccaulfie(a)redhat.com>
CommitterDate: Thu Mar 11 10:25:58 2010 +0000
cman: Make cman_notifyd use corosync calls rather than libcman
This is currently incomplete as it doesn't handle configuration updates,
which might need some additions to the confdb library
Signed-off-by: Christine Caulfield <ccaulfie(a)redhat.com>
---
cman/notifyd/Makefile.am | 9 ++-
cman/notifyd/main.c | 252 +++++++++++++++++++++++++++++++---------------
2 files changed, 178 insertions(+), 83 deletions(-)
diff --git a/cman/notifyd/Makefile.am b/cman/notifyd/Makefile.am
index edf66e6..5c80177 100644
--- a/cman/notifyd/Makefile.am
+++ b/cman/notifyd/Makefile.am
@@ -13,11 +13,16 @@ cmannotifyd_SOURCES = main.c
cmannotifyd_CPPFLAGS = -D_GNU_SOURCE \
-I$(top_srcdir)/common/liblogthread/ \
-I$(top_srcdir)/config/libs/libccsconfdb/ \
- -I$(top_srcdir)/cman/services/cman/lib/
+ $(cfg_CFLAGS) \
+ $(quorum_CFLAGS) \
+ $(confdb_CFLAGS)
+
cmannotifyd_LDADD = $(top_builddir)/common/liblogthread/liblogthread.la \
$(top_builddir)/config/libs/libccsconfdb/libccs.la \
- $(top_builddir)/cman/services/cman/lib/libcman.la
+ $(cfg_LIBS) \
+ $(quorum_LIBS) \
+ $(confdb_LIBS)
$(notifyscript): $(notifyscript).in
cat $^ | sed \
diff --git a/cman/notifyd/main.c b/cman/notifyd/main.c
index 83e27f5..5c57b51 100644
--- a/cman/notifyd/main.c
+++ b/cman/notifyd/main.c
@@ -14,18 +14,20 @@
#include <sys/wait.h>
#include <sys/select.h>
-#include "libcman.h"
-#include "ccs.h"
+#include <corosync/cfg.h>
+#include <corosync/quorum.h>
+#include <corosync/confdb.h>
#include "liblogthread.h"
+#include "ccs.h"
#include "copyright.cf"
int debug = 0;
int daemonize = 1;
int daemon_quit = 0;
-cman_handle_t cman_handle;
int rr = 0;
+
#define LOCKFILE_NAME CLUSTERVARRUN "/cmannotifyd.pid"
#define OPTION_STRING "hdfVr"
@@ -34,6 +36,46 @@ int rr = 0;
#define MAX_ARGS 128
#endif
+static corosync_cfg_handle_t cfg_handle;
+static quorum_handle_t quorum_handle;
+static confdb_handle_t confdb_handle;
+
+static void corosync_cfg_shutdown_callback (
+ corosync_cfg_handle_t cfg_handle,
+ corosync_cfg_shutdown_flags_t flags);
+
+static void quorum_notification_callback (
+ quorum_handle_t handle,
+ uint32_t quorate,
+ uint64_t ring_seq,
+ uint32_t view_list_entries,
+ uint32_t *view_list);
+
+static void confdb_object_create_callback (
+ confdb_handle_t handle,
+ hdb_handle_t parent_object_handle,
+ hdb_handle_t object_handle,
+ const void *name_pt,
+ size_t name_len);
+
+static corosync_cfg_callbacks_t cfg_callbacks =
+{
+ .corosync_cfg_state_track_callback = NULL,
+ .corosync_cfg_shutdown_callback = corosync_cfg_shutdown_callback
+};
+
+static quorum_callbacks_t quorum_callbacks =
+{
+ .quorum_notify_fn = quorum_notification_callback
+};
+
+static confdb_callbacks_t confdb_callbacks =
+{
+ .confdb_object_create_change_notify_fn = confdb_object_create_callback
+};
+
+
+
static void print_usage(void)
{
printf("Usage:\n\n");
@@ -283,125 +325,173 @@ out:
exit(EXIT_FAILURE);
}
-static void cman_callback(cman_handle_t ch, void *private, int reason, int arg)
+static void corosync_cfg_shutdown_callback(corosync_cfg_handle_t handle,
+ corosync_cfg_shutdown_flags_t flags)
{
- const char *str = NULL;
-
- switch (reason) {
- case CMAN_REASON_TRY_SHUTDOWN:
- logt_print(LOG_DEBUG, "Received a cman shutdown request\n");
- cman_replyto_shutdown(ch, 1); /* allow cman to shutdown */
- str = "CMAN_REASON_TRY_SHUTDOWN";
- dispatch_notification(str, 0);
- break;
- case CMAN_REASON_STATECHANGE:
- logt_print(LOG_DEBUG,
- "Received a cman statechange notification\n");
- str = "CMAN_REASON_STATECHANGE";
- dispatch_notification(str, &arg);
- break;
- case CMAN_REASON_CONFIG_UPDATE:
- logt_print(LOG_DEBUG,
- "Received a cman config update notification\n");
- init_logging(1);
- str = "CMAN_REASON_CONFIG_UPDATE";
- dispatch_notification(str, 0);
- break;
- }
+ logt_print(LOG_DEBUG, "Received a CFG shutdown request\n");
+
+ corosync_cfg_replyto_shutdown(handle, COROSYNC_CFG_SHUTDOWN_FLAG_YES);
+
+ dispatch_notification("CMAN_REASON_TRY_SHUTDOWN", 0);
}
-static void byebye_cman(void)
+
+static void quorum_notification_callback(quorum_handle_t handle,
+ uint32_t quorate,
+ uint64_t ring_seq,
+ uint32_t view_list_entries,
+ uint32_t *view_list)
{
- if (!cman_handle)
- return;
+ logt_print(LOG_DEBUG,
+ "Received a quorum notification\n");
+ dispatch_notification("CMAN_REASON_STATECHANGE", quorate);
+}
- cman_finish(cman_handle);
- cman_handle = NULL;
+static void confdb_object_create_callback(confdb_handle_t handle,
+ hdb_handle_t parent_object_handle,
+ hdb_handle_t object_handle,
+ const void *name_pt,
+ size_t name_len)
+{
+ logt_print(LOG_DEBUG,
+ "Received a config update notification\n");
+ init_logging(1);
+ dispatch_notification("CMAN_REASON_CONFIG_UPDATE", 0);
}
-static void setup_cman(int forever)
+static void byebye_corosync(void)
+{
+ if (cfg_handle)
+ {
+ corosync_cfg_finalize(cfg_handle);
+ cfg_handle = NULL;
+ }
+ if (quorum_handle)
+ {
+ quorum_finalize(quorum_handle);
+ quorum_handle = NULL;
+ }
+ if (confdb_handle)
+ {
+ confdb_finalize(confdb_handle);
+ confdb_handle = NULL;
+ }
+}
+
+static void setup_corosync(int forever)
{
int init = 0, active = 0;
+ cs_error_t cs_err;
retry_init:
- cman_handle = cman_init(NULL);
- if (!cman_handle) {
- if ((init++ < 5) || (forever)) {
- if (daemon_quit)
- goto out;
-
- sleep(1);
- goto retry_init;
- }
- logt_print(LOG_CRIT, "cman_init error %d\n", errno);
- exit(EXIT_FAILURE);
- }
-retry_active:
- if (!cman_is_active(cman_handle)) {
- if ((active++ < 5) || (forever)) {
- if (daemon_quit)
- goto out;
+ if (!cfg_handle) {
+ cs_err = corosync_cfg_initialize(&cfg_handle, &cfg_callbacks);
+ if (cs_err != CS_OK)
+ goto init_fail;
+ }
- sleep(1);
- goto retry_active;
- }
- logt_print(LOG_CRIT, "cman_is_active error %d\n", errno);
- cman_finish(cman_handle);
- exit(EXIT_FAILURE);
+ if (!quorum_handle) {
+ cs_err = quorum_initialize(&quorum_handle, &quorum_callbacks);
+ if (cs_err != CS_OK)
+ goto init_fail;
+ cs_err = quorum_trackstart(quorum_handle, CS_TRACK_CHANGES);
}
- if (cman_start_notification(cman_handle, cman_callback) < 0) {
- logt_print(LOG_CRIT, "cman_start_notification error %d\n", errno);
- cman_finish(cman_handle);
- exit(EXIT_FAILURE);
+ if (!confdb_handle) {
+ cs_err = confdb_initialize(&confdb_handle, &confdb_callbacks);
+ if (cs_err != CS_OK)
+ goto init_fail;
+ // TODO track changes
}
+ goto out_ok;
- return;
+init_fail:
+ if ((init++ < 5) || (forever)) {
+ if (daemon_quit)
+ goto out;
+
+ sleep(1);
+ goto retry_init;
+ }
+ logt_print(LOG_CRIT, "corosync_init error %d\n", errno);
+ exit(EXIT_FAILURE);
out:
- byebye_cman();
+ byebye_corosync();
+out_ok:
exit(EXIT_SUCCESS);
}
static void loop(void)
{
- int cd_result, se_result;
+ cs_error_t cs_result;
+ int select_result;
fd_set read_fds;
- int cman_fd;
+ int cfg_fd;
+ int quorum_fd;
+ int confdb_fd;
do {
FD_ZERO (&read_fds);
- cman_fd = cman_get_fd(cman_handle);
- FD_SET (cman_fd, &read_fds);
- se_result = select((cman_fd + 1), &read_fds, 0, 0, 0);
+ corosync_cfg_fd_get(cfg_handle, &cfg_fd);
+ confdb_fd_get(confdb_handle, &confdb_fd);
+ quorum_fd_get(quorum_handle, &quorum_fd);
+ FD_SET (cfg_fd, &read_fds);
+ FD_SET (confdb_fd, &read_fds);
+ FD_SET (quorum_fd, &read_fds);
+ select_result = select(FD_SETSIZE, &read_fds, 0, 0, 0);
if (daemon_quit)
goto out;
- if (se_result == -1) {
+ if (select_result == -1) {
logt_print(LOG_CRIT, "Unable to select on cman_fd: %s\n", strerror(errno));
- byebye_cman();
+ byebye_corosync();
exit(EXIT_FAILURE);
}
- if (FD_ISSET(cman_fd, &read_fds)) {
- cd_result = 1;
- while (cd_result > 0) {
- cd_result = cman_dispatch(cman_handle, CMAN_DISPATCH_ONE);
- if (cd_result == -1 && errno == EHOSTDOWN) {
- byebye_cman();
- logt_print(LOG_DEBUG, "waiting for cman to reappear..\n");
- setup_cman(1);
- logt_print(LOG_DEBUG, "cman is back..\n");
+ if (FD_ISSET(cfg_fd, &read_fds)) {
+ cs_result = CS_OK;
+ while (cs_result == CS_OK) {
+ cs_result = corosync_cfg_dispatch(cfg_handle, CS_DISPATCH_ONE);
+ if (cs_result != CS_OK) {
+ byebye_corosync();
+ logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
+ setup_corosync(1);
+ logt_print(LOG_DEBUG, "corosync is back..\n");
+ }
+ }
+ }
+ if (FD_ISSET(confdb_fd, &read_fds)) {
+ cs_result = CS_OK;
+ while (cs_result == CS_OK) {
+ cs_result = confdb_dispatch(confdb_handle, CS_DISPATCH_ONE);
+ if (cs_result != CS_OK) {
+ byebye_corosync();
+ logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
+ setup_corosync(1);
+ logt_print(LOG_DEBUG, "corosync is back..\n");
+ }
+ }
+ }
+ if (FD_ISSET(quorum_fd, &read_fds)) {
+ cs_result = CS_OK;
+ while (cs_result == CS_OK) {
+ cs_result = quorum_dispatch(quorum_handle, CS_DISPATCH_ONE);
+ if (cs_result != CS_OK) {
+ byebye_corosync();
+ logt_print(LOG_DEBUG, "waiting for corosync to reappear..\n");
+ setup_corosync(1);
+ logt_print(LOG_DEBUG, "corosync is back..\n");
}
}
}
- } while (se_result && !daemon_quit);
+ } while (select_result && !daemon_quit);
out:
logt_print(LOG_DEBUG, "shutting down...\n");
- byebye_cman();
+ byebye_corosync();
}
int main(int argc, char **argv)
@@ -421,7 +511,7 @@ int main(int argc, char **argv)
if (rr)
set_scheduler();
- setup_cman(0);
+ setup_corosync(0);
loop();
return 0;
14 years, 1 month
cluster: RHEL4 - rgmanager: Kill correct PIDs during force_unmount
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 2d0323010f7110452625bc71c9898459a2ca7e85
Parent: 69f42e4e36aadfba659a7843303b99bf9064b9f1
Author: Shane Bradley <sbradley(a)redhat.com>
AuthorDate: Mon Feb 15 16:16:55 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Fri Feb 19 09:46:09 2010 -0500
rgmanager: Kill correct PIDs during force_unmount
When stopping a service that contains a filesystem resource that is
managed by fs.sh, on a stop operation it can kill a process that is
not located on that mount point.
There was a couple of scenarios that would kill a process that was
not on that mount point when it was stopped:
These processes should not have been killed:
$ less /tmp/media/demo1/tmp.txt
$ less /tmp/test\ /media/demo1/tmp.txt
These processes was and should have been killed:
$ less /media/demo1/tmp.txt
Resolves: rhbz#555901
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/resources/fs.sh | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/rgmanager/src/resources/fs.sh b/rgmanager/src/resources/fs.sh
index 5b3a3bc..46a5189 100755
--- a/rgmanager/src/resources/fs.sh
+++ b/rgmanager/src/resources/fs.sh
@@ -690,6 +690,7 @@ killMountProcesses()
typeset have_lsof=""
typeset have_fuser=""
typeset try
+ typeset command pid user line
if [ $# -ne 1 ]; then
ocf_log err \
@@ -726,30 +727,30 @@ killMountProcesses()
#
# Use lsof to free up mount point
#
- while read command pid user
+ while read line
do
- if [ -z "$pid" ]; then
+ path=$(echo $line | awk '{for (i=9;i<NF+1;i++) {printf "%s ",$i};}')
+ #if [ -z $(echo $path | grep -E "$mp(/| |$)") ]
+ if [ -z $(echo $path | grep -E "^$mp/.*") ]; then
continue
fi
-
+ command=$(echo $line | awk '{print $1}')
+ pid=$(echo $line | awk '{print $2}')
+ user=$(echo $line | awk '{print $3}')
if [ $try -eq 1 ]; then
- ocf_log warn \
- "killing process $pid ($user $command $mp)"
+ ocf_log warn "killing process $pid ($user $command $mp)"
elif [ $try -eq 3 ]; then
- ocf_log crit \
- "Could not clean up mountpoint $mp"
- ret=$FAIL
+ ocf_log crit "Could not clean up mountpoint $mp"
+ ret=$FAIL
fi
-
if [ $try -gt 1 ]; then
kill -9 $pid
else
kill -TERM $pid
fi
- done < <(lsof -bn 2>/dev/null | \
- grep -E "$mp(/.*|)\$" | \
- awk '{print $1,$2,$3}' | \
- sort -u -k 1,3)
+ done< <(lsof -bn 2>/dev/null | \
+ grep -E " $mp(/| |$)" | \
+ sort -u -k 1,3)
elif [ -n "$have_fuser" ]; then
#
# Use fuser to free up mount point
14 years, 1 month
cluster: RHEL4 - magma-plugins: Handle other errors from dlm_lock
by Lon Hohberger
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 69f42e4e36aadfba659a7843303b99bf9064b9f1
Parent: 41adf63ed2763528207b0b4267b955a47a30e12e
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue Feb 16 16:33:19 2010 -0500
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Tue Feb 16 16:48:42 2010 -0500
magma-plugins: Handle other errors from dlm_lock
If writing to the dlm lockspace file descriptor failed
due to delivery of a signal, libdlm and magma-plugins were
passing EINTR back up back up to the caller instead of
retrying the lock or unlock request like they should have.
Additionally, when any error except EAGAIN occurred, we
were overwriting errno with the value of lksb->sb_status,
which was always EINPROG (65539), causing the caller to
have an incorrect errno value.
Resolves: rhbz#294491
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
magma-plugins/sm/sm.c | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/magma-plugins/sm/sm.c b/magma-plugins/sm/sm.c
index 666bb4f..3503d16 100644
--- a/magma-plugins/sm/sm.c
+++ b/magma-plugins/sm/sm.c
@@ -36,7 +36,7 @@
#include <sys/select.h>
#include <sys/stat.h>
-#define MODULE_DESCRIPTION "CMAN/SM Plugin v1.1.7.6"
+#define MODULE_DESCRIPTION "CMAN/SM Plugin v1.1.7.7"
#define MODULE_AUTHOR "Lon Hohberger"
#define DLM_LS_NAME "Magma"
@@ -571,12 +571,18 @@ _dlm_lock(sm_priv_t *p, int mode, struct dlm_lksb *lksb, int options,
int ret;
/* Ok, we have the NL lock. Now convert it. */
- ret = dlm_ls_lock(p->ls, mode, lksb, options,
+ /* Check for EINTR returned from write() in libdlm.c */
+ do {
+ ret = dlm_ls_lock(p->ls, mode, lksb, options,
resource, strlen(resource), 0, ast_function,
lksb, NULL, NULL);
- if (ret < 0)
- return -1;
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ return -1;
+ }
+ } while (0);
while (lksb->sb_status == EINPROG) {
if (wait_for_dlm_event(p->ls) < 0) {
@@ -645,13 +651,18 @@ _dlm_unlock(sm_priv_t *p, struct dlm_lksb *lksb)
{
int ret;
- ret = dlm_ls_unlock(p->ls, lksb->sb_lkid, 0, lksb, NULL);
+ /* Check for EINTR returned from write() in libdlm.c */
+ do {
+ ret = dlm_ls_unlock(p->ls, lksb->sb_lkid, 0, lksb, NULL);
- if (ret != 0)
- return ret;
+ if (ret < 0) {
+ if (errno == EINTR)
+ continue;
+ return -1;
+ }
+ } while (0);
/* lksb->sb_status should be EINPROG at this point */
-
while (lksb->sb_status == EINPROG) {
if (wait_for_dlm_event(p->ls) < 0) {
if (lksb->sb_status == EINPROG)
@@ -799,7 +810,7 @@ sm_lock(cluster_plugin_t *self,
the CLK_CONVERT flag, then assume it's a previous lksb with
a held lock. */
if ((flags & CLK_CONVERT) && *lockpp) {
- lksb = (struct lksb *)(*lockpp);
+ lksb = (struct dlm_lksb *)(*lockpp);
options |= LKF_CONVERT;
} else {
lksb = malloc(sz);
@@ -838,8 +849,17 @@ sm_lock(cluster_plugin_t *self,
errno = EAGAIN;
return -1;
default:
- fprintf(stderr, "_dlm_lock: %d / %d\n", ret, errno);
- ret = lksb->sb_status;
+ /* Other error conditions: Pass back to caller.
+ * Note that 'ret' is still the indicator for a
+ * successful call to dlm_ls_lock. So, in the
+ * successful case, we want to pass the
+ * lock state back, otherwise errno in the event
+ * of a failed call. */
+ if (ret == 0) {
+ ret = lksb->sb_status;
+ } else {
+ ret = errno;
+ }
free(lksb);
errno = ret;
return -1;
14 years, 1 month
cluster: RHEL55 - rgmanager: Fix multiple event processing w/ EVENT_USER
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 92c3ba0359d38829318d3d6d93d32c1baee06c03
Parent: 3bf0a8ed29906b0043929b8866655222a0e70789
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Tue Oct 6 16:00:47 2009 -0400
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Mar 10 14:23:11 2010 +0100
rgmanager: Fix multiple event processing w/ EVENT_USER
We were trying to send responses to each event, which
could cause a crash.
Resolves: bz527239
Signed-off-by: Lon Hohberger <lhh(a)redhat.com>
---
rgmanager/src/daemons/slang_event.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/rgmanager/src/daemons/slang_event.c b/rgmanager/src/daemons/slang_event.c
index d410a40..8a5493c 100644
--- a/rgmanager/src/daemons/slang_event.c
+++ b/rgmanager/src/daemons/slang_event.c
@@ -1155,7 +1155,7 @@ S_service_event(const char *file, const char *script, char *name,
int
S_user_event(const char *file, const char *script, char *name,
- int request, int arg1, int arg2, int target, msgctx_t *ctx)
+ int request, int arg1, int arg2, int target, msgctx_t **ctx)
{
int ret = RG_SUCCESS;
@@ -1179,20 +1179,21 @@ S_user_event(const char *file, const char *script, char *name,
/* XXX Send response code to caller - that 0 should be the
new service owner, if there is one */
- if (ctx) {
+ if (*ctx) {
if (_user_return > 0) {
/* sl_start_service() squashes return code and
node ID into one value. <0 = error, >0 =
success, return-value == node id running
service */
- send_ret(ctx, name, 0, request, _user_return);
+ send_ret(*ctx, name, 0, request, _user_return);
} else {
/* return value < 0 ... pass directly back;
don't transpose */
- send_ret(ctx, name, _user_return, request, 0);
+ send_ret(*ctx, name, _user_return, request, 0);
}
- msg_close(ctx);
- msg_free_ctx(ctx);
+ msg_close(*ctx);
+ msg_free_ctx(*ctx);
+ *ctx = NULL;
}
_user_return = 0;
return ret;
@@ -1232,7 +1233,7 @@ slang_do_script(event_t *pattern, event_t *ev)
ev->ev.user.u_arg1,
ev->ev.user.u_arg2,
ev->ev.user.u_target,
- ev->ev.user.u_ctx);
+ &ev->ev.user.u_ctx);
break;
default:
break;
14 years, 1 month
cluster: RHEL55 - init: change default run options
by Fabio M. Di Nitto
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 3bf0a8ed29906b0043929b8866655222a0e70789
Parent: 1181c15ba197897c551b8830868b850a35e29104
Author: Fabio M. Di Nitto <fdinitto(a)redhat.com>
AuthorDate: Wed Mar 10 14:19:41 2010 +0100
Committer: Fabio M. Di Nitto <fdinitto(a)redhat.com>
CommitterDate: Wed Mar 10 14:19:41 2010 +0100
init: change default run options
from RHEL5.5 distcvs
Signed-off-by: Fabio M. Di Nitto <fdinitto(a)redhat.com>
---
rgmanager/init.d/rgmanager | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/rgmanager/init.d/rgmanager b/rgmanager/init.d/rgmanager
index c4e3429..842467b 100755
--- a/rgmanager/init.d/rgmanager
+++ b/rgmanager/init.d/rgmanager
@@ -7,7 +7,7 @@
# any later version.
#
# description: Starts and stops Red Hat Service (resource group) Manager
-# chkconfig: 2345 99 01
+# chkconfig: - 99 01
#
# Source function library
14 years, 1 month