Mark Fasheh
2015-Jan-28 22:12 UTC
[Ocfs2-devel] [PATCH 0/6] ocfs2-tools: userspace clustering updates
Hi, The following series of patches updates ocfs2-tools to work with the latest userspace clustering releases from SUSE. Kernel clustering (o2cb) functionality is not changed. The first 3 patches teach ocfs2-tools about the nocontrold feature which Goldwyn implemented last year. https://oss.oracle.com/pipermail/ocfs2-tools-devel/2014-February/004161.html The following 3 add on to that to allow ocfs2-tools to setup a cluster stack (if not already setup) based on the stack specified in the fs superblock. If the stack is not available the command will fail as it normally does. The last patch is just a small cleanup I added while I was testing these changes. Other than my own testing (to make sure nothing broke), these have been shipping in SUSE for over a year now. Thanks! --Mark
Mark Fasheh
2015-Jan-28 22:12 UTC
[Ocfs2-devel] [PATCH 1/6] Get cluster list info from corosync
From: Goldwyn Rodrigues <rgoldwyn at suse.de> Instead of getting the cluster list from controld, we get the list directly from Corosync's cmap. This introduces a new config flag BUILD_CMAP_SUPPORT, which translates to HAVE_CMAP defines for libo2cb. Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com> Signed-off-by: Mark Fasheh <mfasheh at suse.de> --- Config.make.in | 1 + configure.in | 19 +++++++++++++++++++ debugfs.ocfs2/Makefile | 3 +++ fsck.ocfs2/Makefile | 3 +++ libo2cb/Makefile | 5 +++++ libo2cb/o2cb_abi.c | 28 ++++++++++++++++++++++++++++ mkfs.ocfs2/Makefile | 3 +++ mount.ocfs2/Makefile | 3 +++ mounted.ocfs2/Makefile | 3 +++ o2cb_ctl/Makefile | 3 +++ ocfs2_hb_ctl/Makefile | 3 +++ tunefs.ocfs2/Makefile | 3 +++ 12 files changed, 77 insertions(+) diff --git a/Config.make.in b/Config.make.in index bf7c6fd..583a243 100644 --- a/Config.make.in +++ b/Config.make.in @@ -81,6 +81,7 @@ HAVE_COROSYNC = @HAVE_COROSYNC@ BUILD_OCFS2_CONTROLD = @BUILD_OCFS2_CONTROLD@ BUILD_PCMK_SUPPORT = @BUILD_PCMK_SUPPORT@ BUILD_CMAN_SUPPORT = @BUILD_CMAN_SUPPORT@ +BUILD_CMAP_SUPPORT = @BUILD_CMAP_SUPPORT@ BUILD_FSDLM_SUPPORT = @BUILD_FSDLM_SUPPORT@ CPG_LDFLAGS = @CPG_LDFLAGS@ AIS_LDFLAGS = @AIS_LDFLAGS@ diff --git a/configure.in b/configure.in index 2ac25c1..de44013 100644 --- a/configure.in +++ b/configure.in @@ -382,6 +382,25 @@ if test "x$cpg_found" = "xyes" -a "x$ckpt_found" = "xyes" -a "x$libdlmcontrol_fo fi AC_SUBST(BUILD_OCFS2_CONTROLD) +LIBCMAP_FOUND+AC_CHECK_HEADER(corosync/cmap.h, LIBCMAP_FOUND=yes, + [AC_MSG_WARN([corosync/cmap.h not found, cmap support will not be built. Older api will be used])]) +AC_SUBST(LIBCMAP_FOUND) + +fsdlm_found+if test "x$LIBCMAP_FOUND" = "xyes"; then + AC_CHECK_LIB(cmap, cmap_initialize, cmap_found=yes) + if test "x$cmap_found" = "xyes"; then + AC_MSG_WARN([libcmap not found, cmap support will not be built. Older api will be used]) + fi +fi + +BUILD_CMAP_SUPPORT+if test "x$cmap_found" = "xyes"; then + BUILD_CMAP_SUPPORT=yes +fi +AC_SUBST(BUILD_CMAP_SUPPORT) + BUILD_PCMK_SUPPORT if test "x$pcmk_found" = "xyes" -a "x$BUILD_OCFS2_CONTROLD" = "xyes"; then BUILD_PCMK_SUPPORT=yes diff --git a/debugfs.ocfs2/Makefile b/debugfs.ocfs2/Makefile index ca4c9a4..ff00e69 100644 --- a/debugfs.ocfs2/Makefile +++ b/debugfs.ocfs2/Makefile @@ -33,6 +33,9 @@ OBJS = $(subst .c,.o,$(CFILES)) LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2 LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif MANS = debugfs.ocfs2.8 diff --git a/fsck.ocfs2/Makefile b/fsck.ocfs2/Makefile index edc8dc5..c49940e 100644 --- a/fsck.ocfs2/Makefile +++ b/fsck.ocfs2/Makefile @@ -13,6 +13,9 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBTOOLS_INTERNAL_LIBS = -L$(TOPDIR)/libtools-internal -ltools-internal LIBTOOLS_INTERNAL_DEPS = $(TOPDIR)/libtools-internal/libtools-internal.a diff --git a/libo2cb/Makefile b/libo2cb/Makefile index 7728bb3..0ae177b 100644 --- a/libo2cb/Makefile +++ b/libo2cb/Makefile @@ -11,6 +11,11 @@ LIBRARIES = libo2cb.a CFLAGS += -fPIC +ifneq ($(BUILD_CMAP_SUPPORT),) +DEFINES += -DHAVE_CMAP +endif + + ifneq ($(OCFS2_DEBUG_EXE),) DEBUG_EXE_FILES = $(shell awk '/DEBUG_EXE/{if (k[FILENAME] == 0) {print FILENAME; k[FILENAME] = 1;}}' $(CFILES)) DEBUG_EXE_PROGRAMS = $(addprefix debug_,$(subst .c,,$(DEBUG_EXE_FILES))) diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c index cc50689..2d86c8e 100644 --- a/libo2cb/o2cb_abi.c +++ b/libo2cb/o2cb_abi.c @@ -37,6 +37,9 @@ #include <ctype.h> #include <linux/types.h> +#ifdef HAVE_CMAP +#include <corosync/cmap.h> +#endif #include "o2cb/o2cb.h" #include "o2cb/o2cb_client_proto.h" @@ -1962,6 +1965,30 @@ static errcode_t classic_list_clusters(char ***clusters) return o2cb_list_dir(path, clusters); } +#ifdef HAVE_CMAP +static errcode_t user_list_clusters(char ***clusters) +{ + cmap_handle_t handle; + char **list; + int rv; + + rv = cmap_initialize(&handle); + if (rv != CS_OK) + return O2CB_ET_SERVICE_UNAVAILABLE; + + /* We supply only one cluster_name */ + list = (char **)malloc(sizeof(char *) * 2); + rv = cmap_get_string(handle, "totem.cluster_name", &list[0]); + if (rv != CS_OK) { + free(list); + return O2CB_ET_INTERNAL_FAILURE; + } + + list[1] = NULL; + *clusters = list; + return 0; +} +#else static errcode_t user_list_clusters(char ***clusters) { errcode_t err = O2CB_ET_SERVICE_UNAVAILABLE; @@ -2011,6 +2038,7 @@ out: return err; } +#endif errcode_t o2cb_list_clusters(char ***clusters) { diff --git a/mkfs.ocfs2/Makefile b/mkfs.ocfs2/Makefile index 5631e01..ee246db 100644 --- a/mkfs.ocfs2/Makefile +++ b/mkfs.ocfs2/Makefile @@ -10,6 +10,9 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a diff --git a/mount.ocfs2/Makefile b/mount.ocfs2/Makefile index cf316bf..3715120 100644 --- a/mount.ocfs2/Makefile +++ b/mount.ocfs2/Makefile @@ -11,6 +11,9 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a DEFINES = -DVERSION=\"$(VERSION)\" diff --git a/mounted.ocfs2/Makefile b/mounted.ocfs2/Makefile index 8a574fb..21f3824 100644 --- a/mounted.ocfs2/Makefile +++ b/mounted.ocfs2/Makefile @@ -9,6 +9,9 @@ LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBTOOLS_INTERNAL_LIBS = -L$(TOPDIR)/libtools-internal -ltools-internal diff --git a/o2cb_ctl/Makefile b/o2cb_ctl/Makefile index 5efcab4..76ddef8 100644 --- a/o2cb_ctl/Makefile +++ b/o2cb_ctl/Makefile @@ -14,6 +14,9 @@ LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2 LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) diff --git a/ocfs2_hb_ctl/Makefile b/ocfs2_hb_ctl/Makefile index 10fd8b1..7049c11 100644 --- a/ocfs2_hb_ctl/Makefile +++ b/ocfs2_hb_ctl/Makefile @@ -11,6 +11,9 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a ifndef OCFS2_DYNAMIC_CTL diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile index 585a68c..35564e5 100644 --- a/tunefs.ocfs2/Makefile +++ b/tunefs.ocfs2/Makefile @@ -12,6 +12,9 @@ LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_CMAP_SUPPORT),) +LIBO2CB_LIBS += -lcmap +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a UNINST_LIBRARIES = libocfs2ne.a -- 2.1.2
Mark Fasheh
2015-Jan-28 22:12 UTC
[Ocfs2-devel] [PATCH 2/6] Don't use controld if kernel supports DLM callbacks
From: Goldwyn Rodrigues <rgoldwyn at suse.de> This requires dlm_lt libraries and they have been added wherever required. Note, we can possibly remove runtime load of dlm_lt and should use compile time options. We are detecting the presence of libdlm during compile time anyways. Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com> Signed-off-by: Mark Fasheh <mfasheh at suse.de> --- debugfs.ocfs2/Makefile | 3 +++ fsck.ocfs2/Makefile | 5 ++++- fswreck/Makefile | 4 ++++ libo2cb/Makefile | 3 +++ libo2cb/o2cb_abi.c | 38 ++++++++++++++++++++++++++++++++++++ libocfs2/Makefile | 4 ++++ listuuid/Makefile | 4 ++++ mkfs.ocfs2/Makefile | 3 +++ mount.ocfs2/Makefile | 5 ++++- mounted.ocfs2/Makefile | 5 ++++- o2cb_ctl/Makefile | 7 +++++-- o2image/Makefile | 4 ++++ ocfs2_controld/Makefile | 2 +- ocfs2_hb_ctl/Makefile | 5 ++++- ocfs2cdsl/Makefile | 4 ++++ ocfs2console/ocfs2interface/Makefile | 4 ++++ tunefs.ocfs2/Makefile | 5 ++++- 17 files changed, 97 insertions(+), 8 deletions(-) diff --git a/debugfs.ocfs2/Makefile b/debugfs.ocfs2/Makefile index ff00e69..3db7b60 100644 --- a/debugfs.ocfs2/Makefile +++ b/debugfs.ocfs2/Makefile @@ -33,6 +33,9 @@ OBJS = $(subst .c,.o,$(CFILES)) LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2 LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif diff --git a/fsck.ocfs2/Makefile b/fsck.ocfs2/Makefile index c49940e..051ed74 100644 --- a/fsck.ocfs2/Makefile +++ b/fsck.ocfs2/Makefile @@ -13,10 +13,13 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif -LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBTOOLS_INTERNAL_LIBS = -L$(TOPDIR)/libtools-internal -ltools-internal LIBTOOLS_INTERNAL_DEPS = $(TOPDIR)/libtools-internal/libtools-internal.a diff --git a/fswreck/Makefile b/fswreck/Makefile index ffbd6ea..9856e0d 100644 --- a/fswreck/Makefile +++ b/fswreck/Makefile @@ -41,7 +41,11 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb -ldlm_lt +else LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a dist-subdircreate: diff --git a/libo2cb/Makefile b/libo2cb/Makefile index 0ae177b..5f12b07 100644 --- a/libo2cb/Makefile +++ b/libo2cb/Makefile @@ -15,6 +15,9 @@ ifneq ($(BUILD_CMAP_SUPPORT),) DEFINES += -DHAVE_CMAP endif +ifneq ($(BUILD_FSDLM_SUPPORT),) +DEFINES += -DHAVE_FSDLM +endif ifneq ($(OCFS2_DEBUG_EXE),) DEBUG_EXE_FILES = $(shell awk '/DEBUG_EXE/{if (k[FILENAME] == 0) {print FILENAME; k[FILENAME] = 1;}}' $(CFILES)) diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c index 2d86c8e..2867fea 100644 --- a/libo2cb/o2cb_abi.c +++ b/libo2cb/o2cb_abi.c @@ -40,6 +40,9 @@ #ifdef HAVE_CMAP #include <corosync/cmap.h> #endif +#ifdef HAVE_FSDLM +#include <libdlm.h> +#endif #include "o2cb/o2cb.h" #include "o2cb/o2cb_client_proto.h" @@ -50,6 +53,7 @@ #define LOCKING_PROTOCOL_FILE "/sys/fs/ocfs2/max_locking_protocol" #define OCFS2_STACK_LABEL_LEN 4 #define CONTROL_DEVICE "/dev/misc/ocfs2_control" +#define DLM_RECOVER_CALLBACK "/sys/fs/ocfs2/dlm_recover_callback_support" static errcode_t o2cb_validate_cluster_name(struct o2cb_cluster_desc *desc); static errcode_t o2cb_validate_cluster_flags(struct o2cb_cluster_desc *desc, @@ -1384,6 +1388,26 @@ static errcode_t user_begin_group_join(struct o2cb_cluster_desc *cluster, char *argv[OCFS2_CONTROLD_MAXARGS + 1]; char buf[OCFS2_CONTROLD_MAXLINE]; +#ifdef HAVE_FSDLM + uint32_t maj, min, pat; + + if (strncmp(cluster->c_stack, OCFS2_PCMK_CLUSTER_STACK, OCFS2_STACK_LABEL_LEN)) + goto no_pcmk; + + rc = dlm_kernel_version(&maj, &min, &pat); + + if (rc < 0) + return O2CB_ET_SERVICE_UNAVAILABLE; + + if (read_single_line_file(DLM_RECOVER_CALLBACK, buf, 3) > 0) { + /* Controld is not required */ + if (maj < 6) + return O2CB_ET_INTERNAL_FAILURE; + return 0; + } +no_pcmk: +#endif + if (control_daemon_fd != -1) { /* fprintf(stderr, "Join already in progress!\n"); */ err = O2CB_ET_INTERNAL_FAILURE; @@ -1475,6 +1499,13 @@ static errcode_t user_complete_group_join(struct o2cb_cluster_desc *cluster, char *argv[OCFS2_CONTROLD_MAXARGS + 1]; char buf[OCFS2_CONTROLD_MAXLINE]; +#ifdef HAVE_FSDLM + if (read_single_line_file(DLM_RECOVER_CALLBACK, buf, 3) > 0) { + /* Controld is not required */ + return 0; + } +#endif + if (control_daemon_fd == -1) { /* fprintf(stderr, "Join not started!\n"); */ err = O2CB_ET_SERVICE_UNAVAILABLE; @@ -1545,6 +1576,13 @@ static errcode_t user_group_leave(struct o2cb_cluster_desc *cluster, char *argv[OCFS2_CONTROLD_MAXARGS + 1]; char buf[OCFS2_CONTROLD_MAXLINE]; +#ifdef HAVE_FSDLM + if (read_single_line_file(DLM_RECOVER_CALLBACK, buf, 3) > 0) { + /* Controld is not required */ + return 0; + } +#endif + if (control_daemon_fd != -1) { /* fprintf(stderr, "Join in progress!\n"); */ err = O2CB_ET_INTERNAL_FAILURE; diff --git a/libocfs2/Makefile b/libocfs2/Makefile index a4027c2..9ed420a 100644 --- a/libocfs2/Makefile +++ b/libocfs2/Makefile @@ -9,7 +9,11 @@ LIBRARIES = libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb -ldlm_lt +else LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a CFLAGS += -fPIC diff --git a/listuuid/Makefile b/listuuid/Makefile index 7f03b9c..2859724 100644 --- a/listuuid/Makefile +++ b/listuuid/Makefile @@ -10,7 +10,11 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb -ldlm_lt +else LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a UNINST_PROGRAMS = listuuid diff --git a/mkfs.ocfs2/Makefile b/mkfs.ocfs2/Makefile index ee246db..604c522 100644 --- a/mkfs.ocfs2/Makefile +++ b/mkfs.ocfs2/Makefile @@ -13,6 +13,9 @@ LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a diff --git a/mount.ocfs2/Makefile b/mount.ocfs2/Makefile index 3715120..73c3df8 100644 --- a/mount.ocfs2/Makefile +++ b/mount.ocfs2/Makefile @@ -11,10 +11,13 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif -LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a DEFINES = -DVERSION=\"$(VERSION)\" diff --git a/mounted.ocfs2/Makefile b/mounted.ocfs2/Makefile index 21f3824..a36ab29 100644 --- a/mounted.ocfs2/Makefile +++ b/mounted.ocfs2/Makefile @@ -9,10 +9,13 @@ LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif -LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBTOOLS_INTERNAL_LIBS = -L$(TOPDIR)/libtools-internal -ltools-internal LIBTOOLS_INTERNAL_DEPS = $(TOPDIR)/libtools-internal/libtools-internal.a diff --git a/o2cb_ctl/Makefile b/o2cb_ctl/Makefile index 76ddef8..21d25b9 100644 --- a/o2cb_ctl/Makefile +++ b/o2cb_ctl/Makefile @@ -13,11 +13,14 @@ LIBTOOLS_INTERNAL_DEPS = $(TOPDIR)/libtools-internal/libtools-internal.a LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2 LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a -LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif -LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a diff --git a/o2image/Makefile b/o2image/Makefile index b0d9511..3bc1b58 100644 --- a/o2image/Makefile +++ b/o2image/Makefile @@ -13,7 +13,11 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb -ldlm_lt +else LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a sbindir = $(root_sbindir) diff --git a/ocfs2_controld/Makefile b/ocfs2_controld/Makefile index f6ac203..ef842d4 100644 --- a/ocfs2_controld/Makefile +++ b/ocfs2_controld/Makefile @@ -18,7 +18,7 @@ PCMK_INCLUDES = -I/usr/include/pacemaker -I/usr/include/heartbeat/ $(GLIB_CFLAGS endif INCLUDES = -I$(TOPDIR)/include -I. $(PCMK_INCLUDES) -LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb -ldlm_lt LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2 LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a diff --git a/ocfs2_hb_ctl/Makefile b/ocfs2_hb_ctl/Makefile index 7049c11..b4d0490 100644 --- a/ocfs2_hb_ctl/Makefile +++ b/ocfs2_hb_ctl/Makefile @@ -11,10 +11,13 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif -LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a ifndef OCFS2_DYNAMIC_CTL LDFLAGS += -static diff --git a/ocfs2cdsl/Makefile b/ocfs2cdsl/Makefile index 391b553..f07bfaa 100644 --- a/ocfs2cdsl/Makefile +++ b/ocfs2cdsl/Makefile @@ -9,7 +9,11 @@ LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb -ldlm_lt +else LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +endif sbindir = $(root_sbindir) SBIN_PROGRAMS = ocfs2cdsl diff --git a/ocfs2console/ocfs2interface/Makefile b/ocfs2console/ocfs2interface/Makefile index 63fb56f..5409455 100644 --- a/ocfs2console/ocfs2interface/Makefile +++ b/ocfs2console/ocfs2interface/Makefile @@ -14,7 +14,11 @@ LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb -ldlm_lt +else LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +endif LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a ifdef HAVE_BLKID diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile index 35564e5..ba603b9 100644 --- a/tunefs.ocfs2/Makefile +++ b/tunefs.ocfs2/Makefile @@ -12,10 +12,13 @@ LIBO2DLM_LIBS = -L$(TOPDIR)/libo2dlm -lo2dlm $(DL_LIBS) LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb +LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a +ifneq ($(BUILD_FSDLM_SUPPORT),) +LIBO2CB_LIBS += -ldlm_lt +endif ifneq ($(BUILD_CMAP_SUPPORT),) LIBO2CB_LIBS += -lcmap endif -LIBO2CB_DEPS = $(TOPDIR)/libo2cb/libo2cb.a UNINST_LIBRARIES = libocfs2ne.a -- 2.1.2
Mark Fasheh
2015-Jan-28 22:12 UTC
[Ocfs2-devel] [PATCH 3/6] Auto setup cluster_stack based on what is on disk
From: Goldwyn Rodrigues <rgoldwyn at suse.de> This happens only the first time. mount.ocfs2 reads the stack from the filesystems superblock. If the stack is not setup, it will modprobe the modules and write the appropriate stack name to cluster_stack file. If it is already present, it tries to edit/re-write it, if different. If it fails, the mount fails. Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com> Signed-off-by: Mark Fasheh <mfasheh at suse.de> --- include/o2cb/o2cb.h | 1 + libo2cb/o2cb_abi.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++ mount.ocfs2/mount.ocfs2.c | 6 +++ 3 files changed, 113 insertions(+) diff --git a/include/o2cb/o2cb.h b/include/o2cb/o2cb.h index d512cf9..5ef9754 100644 --- a/include/o2cb/o2cb.h +++ b/include/o2cb/o2cb.h @@ -208,5 +208,6 @@ void o2cb_control_close(void); errcode_t o2cb_control_node_down(const char *uuid, unsigned int nodeid); errcode_t o2cb_get_hb_ctl_path(char *buf, int count); +errcode_t o2cb_setup_stack(char *stack_name); #endif /* _O2CB_H */ diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c index 2867fea..4414ff2 100644 --- a/libo2cb/o2cb_abi.c +++ b/libo2cb/o2cb_abi.c @@ -29,6 +29,7 @@ #include <sys/ioctl.h> #include <sys/ipc.h> #include <sys/sem.h> +#include <sys/wait.h> #include <dirent.h> #include <fcntl.h> #include <unistd.h> @@ -150,6 +151,22 @@ static ssize_t read_single_line_file(const char *file, char *line, return ret; } +static int write_single_line_file(char *filename, char *line, size_t count) +{ + ssize_t ret = 0; + FILE *f; + + f = fopen(filename, "w"); + if (f) { + if (fputs(line, f)) + ret = strlen(line); + fclose(f); + } else + ret = -errno; + + return ret; +} + static ssize_t read_stack_file(char *line, size_t count) { return read_single_line_file(CLUSTER_STACK_FILE, line, count); @@ -2582,3 +2599,92 @@ errcode_t o2cb_get_hb_ctl_path(char *buf, int count) return 0; } + +#define MODPROBE_COMMAND "/sbin/modprobe" +#define USER_KERNEL_MODULE "ocfs2_stack_user" +#define O2CB_KERNEL_MODULE "ocfs2_stack_o2cb" + +static int perform_modprobe(char *module_name) +{ + pid_t child; + int child_status; + + char *argv[3]; + + argv[0] = MODPROBE_COMMAND; + argv[1] = module_name; + argv[2] = NULL; + + child = fork(); + if (child == 0) { + execv(MODPROBE_COMMAND, argv); + /* If execv fails, we have a problem */ + return -EINVAL; + } else + wait(&child_status); + + return child_status; +} + +errcode_t o2cb_setup_stack(char *stack_name) +{ + char line[64]; + int modprobe_performed = 0, write_performed = 0; + errcode_t err = O2CB_ET_SERVICE_UNAVAILABLE; + int len; + +redo: + len = read_single_line_file(CLUSTER_STACK_FILE, line, sizeof(line)); + + if (len > 0) { + if (line[len - 1] == '\n') { + line[len - 1] = '\0'; + len--; + } + + if (len != OCFS2_STACK_LABEL_LEN) { + err = O2CB_ET_INTERNAL_FAILURE; + goto out; + } + + if (!strncmp(line, stack_name, OCFS2_STACK_LABEL_LEN)) { + err = 0; + goto out; + } + + if (!write_performed) { + len = write_single_line_file(CLUSTER_STACK_FILE, + stack_name, strlen(stack_name)); + if (len < 0) + goto out; + write_performed = 1; + goto redo; + } + + } else if (len == -ENOENT) { + if (!modprobe_performed) { + perform_modprobe("ocfs2"); + if ((!strncmp(stack_name, OCFS2_PCMK_CLUSTER_STACK, + OCFS2_STACK_LABEL_LEN)) || + (!strncmp(stack_name, OCFS2_CMAN_CLUSTER_STACK, + OCFS2_STACK_LABEL_LEN))) + perform_modprobe(USER_KERNEL_MODULE); + else if (!strncmp(stack_name, classic_stack.s_name, + OCFS2_STACK_LABEL_LEN)) + perform_modprobe(O2CB_KERNEL_MODULE); + + write_single_line_file(CLUSTER_STACK_FILE, stack_name, + OCFS2_STACK_LABEL_LEN); + write_performed = 1; + goto redo; + } else + err = O2CB_ET_INTERNAL_FAILURE; + } else { + err = O2CB_ET_INTERNAL_FAILURE; + goto out; + } + + err = 0; +out: + return err; +} diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c index 2fa2c2f..a1c8698 100644 --- a/mount.ocfs2/mount.ocfs2.c +++ b/mount.ocfs2/mount.ocfs2.c @@ -358,6 +358,12 @@ int main(int argc, char **argv) if (verbose) printf("device=%s\n", mo.dev); + ret = o2cb_setup_stack((char *)OCFS2_RAW_SB(fs->fs_super)->s_cluster_info.ci_stack); + if (ret) { + com_err(progname, ret, "while setting up stack\n"); + goto bail; + } + if (clustered) { ret = o2cb_init(); if (ret) { -- 2.1.2
Mark Fasheh
2015-Jan-28 22:12 UTC
[Ocfs2-devel] [PATCH 4/6] mkfs: Setup cluster_stack if not setup based on args
From: Goldwyn Rodrigues <rgoldwyn at suse.de> Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com> Signed-off-by: Mark Fasheh <mfasheh at suse.de> --- mkfs.ocfs2/check.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mkfs.ocfs2/check.c b/mkfs.ocfs2/check.c index f05dc72..79583bf 100644 --- a/mkfs.ocfs2/check.c +++ b/mkfs.ocfs2/check.c @@ -339,6 +339,15 @@ int ocfs2_check_volume(State *s) goto nolock; if (!s->force) { + if (s->cluster_stack) { + ret = o2cb_setup_stack(s->cluster_stack); + if (ret) { + com_err(s->progname, ret, + "while setting up stack\n"); + return -1; + } + } + ret = o2cb_init(); if (ret) { com_err(s->progname, ret, -- 2.1.2
Mark Fasheh
2015-Jan-28 22:12 UTC
[Ocfs2-devel] [PATCH 5/6] Auto setup o2cb stack as default if no stack is setup
From: Goldwyn Rodrigues <rgoldwyn at suse.de> Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.com> Signed-off-by: Mark Fasheh <mfasheh at suse.de> --- libo2cb/o2cb_abi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c index 4414ff2..fa1b1d2 100644 --- a/libo2cb/o2cb_abi.c +++ b/libo2cb/o2cb_abi.c @@ -177,7 +177,9 @@ static errcode_t determine_stack(void) ssize_t len; char line[100]; errcode_t err = O2CB_ET_SERVICE_UNAVAILABLE; + int setup_performed = 0; +redo: len = read_stack_file(line, sizeof(line)); if (len > 0) { if (line[len - 1] == '\n') { @@ -197,8 +199,11 @@ static errcode_t determine_stack(void) err = 0; } } else if (len == -ENOENT) { - current_stack = &classic_stack; - err = 0; + if (!setup_performed) { + o2cb_setup_stack(OCFS2_CLASSIC_CLUSTER_STACK); + setup_performed = 1; + goto redo; + } } return err; -- 2.1.2
Mark Fasheh
2015-Jan-28 22:12 UTC
[Ocfs2-devel] [PATCH 6/6] Add users guide (txt version) and o2cb README to DIST_FILES so they are included in the tarball output of 'make dist'.
Signed-off-by: Mark Fasheh <mfasheh at suse.de> --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 5bd380b..9519a4e 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ DIST_FILES = \ CREDITS \ MAINTAINERS \ README \ + README.O2CB \ Config.make.in \ Preamble.make \ Postamble.make \ @@ -79,6 +80,7 @@ DIST_FILES = \ vendor.guess \ Makepdfs \ documentation/samples/cluster.conf \ + documentation/users_guide.txt \ $(PKGCONFIG_SOURCES) \ $(DEBIAN_FILES) -- 2.1.2