1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

Rewrite clvmd configuration code.

This commit is contained in:
Alasdair Kergon 2009-08-28 19:22:05 +00:00
parent 226e79e7b7
commit a946372e50
8 changed files with 2531 additions and 96 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.52 -
=================================
Rewrite clvmd configuration code to cope with all combinations of libs.
Fix global locking in PV reporting commands (2.02.49).
Fix pvcreate string termination in duplicate uuid warning message.
Fix pvcreate on a partition (2.02.51).

2255
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -325,7 +325,13 @@ AC_MSG_RESULT($REALTIME)
dnl -- Build cluster LVM daemon
AC_MSG_CHECKING(whether to build cluster LVM daemon)
AC_ARG_WITH(clvmd,
[ --with-clvmd=TYPE Build cluster LVM Daemon: cman/gulm/corosync/none/all
[ --with-clvmd=TYPE Build cluster LVM Daemon.
The following locking combinations are valid:
* cman,gulm (RHEL4 or equivalent)
* cman (RHEL5 or equivalent)
* cman,corosync,openais (or selection of them)
* all (autodetect)
* none (disable build)
[TYPE=none] ],
[ CLVMD="$withval" ],
[ CLVMD="none" ])
@ -339,17 +345,208 @@ if test x$CLVMD != xnone && test x$CLUSTER = xnone; then
CLUSTER=internal
fi
dnl -- define build types
if [[ `expr x"$CLVMD" : '.*gulm.*'` != 0 ]]; then
BUILDGULM=yes
fi
if [[ `expr x"$CLVMD" : '.*corosync.*'` != 0 ]]; then
BUILDCOROSYNC=yes
fi
if [[ `expr x"$CLVMD" : '.*openais.*'` != 0 ]]; then
BUILDOPENAIS=yes
fi
if [[ `expr x"$CLVMD" : '.*cman.*'` != 0 ]]; then
BUILDCMAN=yes
fi
dnl -- sanity check around user selection
if test x$BUILDGULM = xyes; then
if test x$BUILDCOROSYNC = xyes || \
test x$BUILDOPENAIS = xyes; then
AC_MSG_ERROR([requested clvmd configuration is not valid])
fi
fi
dnl -- Init pkg-config with dummy invokation:
dnl -- this is required because PKG_CHECK_MODULES macro is expanded
dnl -- to initialize the pkg-config environment only at the first invokation,
dnl -- that would be conditional in this configure.in.
if test x$CLVMD != xnone; then
PKG_CHECK_MODULES(PKGCONFIGINIT, pkgconfiginit, [],
[AC_MSG_RESULT([pkg-config initialized])])
fi
dnl -- define a soft bailout if we are autodetecting
soft_bailout() {
NOTFOUND=1
}
hard_bailout() {
AC_MSG_ERROR([bailing out])
}
dnl -- if clvmd=all then set soft_bailout (we don't want to error)
dnl -- and set all builds to yes. We need to do this here
dnl -- to skip the gulm + openais|corosync sanity check above.
if test x$CLVMD = xall; then
bailout=soft_bailout
BUILDGULM=yes
BUILDCMAN=yes
BUILDCOROSYNC=yes
BUILDOPENAIS=yes
else
bailout=hard_bailout
fi
dnl -- helper macro to check libs without adding them to LIBS
check_lib_no_libs() {
lib_no_libs_arg1=$1
shift
lib_no_libs_arg2=$1
shift
lib_no_libs_args=$@
AC_CHECK_LIB([$lib_no_libs_arg1],
[$lib_no_libs_arg2],,
[$bailout],
[$lib_no_libs_args])
LIBS=$ac_check_lib_save_LIBS
}
dnl -- Look for gulm libraries if required.
if test x$BUILDGULM = xyes; then
PKG_CHECK_MODULES(CCS, libccs, [HAVE_CCS=yes],
[NOTFOUND=0
AC_CHECK_HEADERS(ccs.h,,$bailout)
check_lib_no_libs ccs ccs_connect
if test $NOTFOUND = 0; then
AC_MSG_RESULT([no pkg for libccs, using -lccs])
CCS_LIBS="-lccs"
HAVE_CCS=yes
fi])
PKG_CHECK_MODULES(GULM, libgulm, [HAVE_GULM=yes],
[NOTFOUND=0
AC_CHECK_HEADERS(libgulm.h,,$bailout)
check_lib_no_libs gulm lg_core_login
if test $NOTFOUND = 0; then
AC_MSG_RESULT([no pkg for libgulm, using -lgulm])
GULM_LIBS="-lgulm"
HAVE_GULM=yes
fi])
fi
dnl -- Look for cman libraries if required.
if test x$BUILDCMAN = xyes; then
PKG_CHECK_MODULES(CMAN, libcman, [HAVE_CMAN=yes],
[NOTFOUND=0
AC_CHECK_HEADERS(libcman.h,,$bailout)
check_lib_no_libs cman cman_init
if test $NOTFOUND = 0; then
AC_MSG_RESULT([no pkg for libcman, using -lcman])
CMAN_LIBS="-lcman"
HAVE_CMAN=yes
fi])
CHECKCONFDB=yes
CHECKDLM=yes
fi
dnl -- Look for corosync that's required also for openais build
dnl -- only enough recent version of corosync ship pkg-config files.
dnl -- We can safely rely on that to detect the correct bits.
if test x$BUILDCOROSYNC = xyes || \
test x$BUILDOPENAIS = xyes; then
PKG_CHECK_MODULES(COROSYNC, corosync, [HAVE_COROSYNC=yes], $bailout)
CHECKCONFDB=yes
fi
dnl -- Look for corosync libraries if required.
if [[ "x$CLVMD" = xall -o `expr x"$CLVMD" : '.*corosync.*'` != 0 ]]; then
PKG_CHECK_MODULES(QUORUM, libquorum, [],
[AC_MSG_RESULT([no pkg for quorum library, using -lquorum]);
QUORUM_LIBS="-lquorum"])
PKG_CHECK_MODULES(CONFDB, libconfdb, [],
[AC_MSG_RESULT([no pkg for confdb library, using -lconfdb]);
CONFDB_LIBS="-lconfdb"])
PKG_CHECK_MODULES(CPG, libcpg, [],
[AC_MSG_RESULT([no pkg for libcpg library, using -lcpg]);
CPG_LIBS="-lcpg"])
if test x$BUILDCOROSYNC = xyes; then
PKG_CHECK_MODULES(QUORUM, libquorum, [HAVE_QUORUM=yes], $bailout)
CHECKCPG=yes
CHECKDLM=yes
fi
dnl -- Look for openais libraries if required.
if test x$BUILDOPENAIS = xyes; then
PKG_CHECK_MODULES(SALCK, libSaLck, [HAVE_SALCK=yes], $bailout)
CHECKCPG=yes
fi
dnl -- Below are checks for libraries common to more than one build.
dnl -- Check confdb library.
dnl -- mandatory for corosync build.
dnl -- optional for openais/cman build.
if test x$CHECKCONFDB = xyes; then
PKG_CHECK_MODULES(CONFDB, libconfdb,
[HAVE_CONFDB=yes],
[HAVE_CONFDB=no])
AC_CHECK_HEADERS(corosync/confdb.h,
[HAVE_CONFDB_H=yes],
[HAVE_CONFDB_H=no])
if test x$HAVE_CONFDB != xyes && \
test x$HAVE_CONFDB_H = xyes; then
check_lib_no_libs confdb confdb_initialize
AC_MSG_RESULT([no pkg for confdb, using -lconfdb])
CONFDB_LIBS="-lconfdb"
HAVE_CONFDB=yes
fi
if test x$BUILDCOROSYNC = xyes && \
test x$HAVE_CONFDB != xyes &&
test x$CLVMD != xall; then
AC_MSG_ERROR([bailing out... confdb library is required])
fi
fi
dnl -- Check cpg library.
if test x$CHECKCPG = xyes; then
PKG_CHECK_MODULES(CPG, libcpg, [HAVE_CPG=yes], $bailout)
fi
dnl -- Check dlm library.
if test x$CHECKDLM = xyes; then
PKG_CHECK_MODULES(DLM, libdlm, [HAVE_DLM=yes],
[NOTFOUND=0
AC_CHECK_HEADERS(libdlm.h,,$bailout)
check_lib_no_libs dlm dlm_lock -lpthread
if test $NOTFOUND = 0; then
AC_MSG_RESULT([no pkg for libdlm, using -ldlm])
DLM_LIBS="-ldlm -lpthread"
HAVE_DLM=yes
fi])
fi
dnl -- If we are autodetecting, we need to re-create
dnl -- the depedencies checks and set a proper CLVMD.
if test x$CLVMD = xall; then
if test x$HAVE_CCS = xyes && \
test x$HAVE_GULM = xyes; then
AC_MSG_RESULT([Enabling clvmd gulm backend])
NEWCLVMD="$NEWCLVMD,gulm"
fi
if test x$HAVE_CMAN = xyes && \
test x$HAVE_DLM = xyes; then
AC_MSG_RESULT([Enabling clvmd cman backend])
NEWCLVMD="$NEWCLVMD,cman"
fi
if test x$HAVE_COROSYNC = xyes && \
test x$HAVE_QUORUM = xyes && \
test x$HAVE_CPG = xyes && \
test x$HAVE_DLM = xyes && \
test x$HAVE_CONFDB = xyes; then
AC_MSG_RESULT([Enabling clvmd corosync backend])
NEWCLVMD="$NEWCLVMD,corosync"
fi
if test x$HAVE_COROSYNC = xyes && \
test x$HAVE_CPG = xyes && \
test x$HAVE_SALCK = xyes; then
AC_MSG_RESULT([Enabling clvmd openais backend])
NEWCLVMD="$NEWCLVMD,openais"
fi
CLVMD="$NEWCLVMD"
fi
################################################################################
@ -811,6 +1008,8 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[[()]]' '{print $2}'`
################################################################################
AC_SUBST(APPLIB)
AC_SUBST(BUILD_DMEVENTD)
AC_SUBST(CCS_CFLAGS)
AC_SUBST(CCS_LIBS)
AC_SUBST(CFLAGS)
AC_SUBST(CFLOW_CMD)
AC_SUBST(CLDFLAGS)
@ -819,6 +1018,8 @@ AC_SUBST(CLDWHOLEARCHIVE)
AC_SUBST(CLUSTER)
AC_SUBST(CLVMD)
AC_SUBST(CLOGD)
AC_SUBST(CMAN_CFLAGS)
AC_SUBST(CMAN_LIBS)
AC_SUBST(CMDLIB)
AC_SUBST(CONFDB_CFLAGS)
AC_SUBST(CONFDB_LIBS)
@ -829,6 +1030,8 @@ AC_SUBST(CPG_LIBS)
AC_SUBST(CSCOPE_CMD)
AC_SUBST(DEBUG)
AC_SUBST(DEVMAPPER)
AC_SUBST(DLM_CFLAGS)
AC_SUBST(DLM_LIBS)
AC_SUBST(DMEVENTD)
AC_SUBST(DM_COMPAT)
AC_SUBST(DM_DEVICE_GID)
@ -839,6 +1042,8 @@ AC_SUBST(DM_LIB_VERSION)
AC_SUBST(DM_LIB_PATCHLEVEL)
AC_SUBST(FSADM)
AC_SUBST(GROUP)
AC_SUBST(GULM_CFLAGS)
AC_SUBST(GULM_LIBS)
AC_SUBST(HAVE_LIBDL)
AC_SUBST(HAVE_REALTIME)
AC_SUBST(HAVE_SELINUX)
@ -865,6 +1070,8 @@ AC_SUBST(PKGCONFIG)
AC_SUBST(POOL)
AC_SUBST(QUORUM_CFLAGS)
AC_SUBST(QUORUM_LIBS)
AC_SUBST(SALCK_CFLAGS)
AC_SUBST(SALCK_LIBS)
AC_SUBST(SNAPSHOTS)
AC_SUBST(STATICDIR)
AC_SUBST(STATIC_LINK)

View File

@ -15,12 +15,22 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
QUORUM_LIBS = @QUORUM_LIBS@
QUORUM_CFLAGS = @QUORUM_CFLAGS@
CCS_LIBS = @CCS_LIBS@
CCS_CFLAGS = @CCS_CFLAGS@
CMAN_LIBS = @CMAN_LIBS@
CMAN_CFLAGS = @CMAN_CFLAGS@
CONFDB_LIBS = @CONFDB_LIBS@
CONFDB_CFLAGS = @CONFDB_CFLAGS@
CPG_LIBS = @CPG_LIBS@
CPG_CFLAGS = @CPG_CFLAGS@
DLM_LIBS = @DLM_LIBS@
DLM_CFLAGS = @DLM_CFLAGS@
GULM_LIBS = @GULM_LIBS@
GULM_CFLAGS = @GULM_CFLAGS@
QUORUM_LIBS = @QUORUM_LIBS@
QUORUM_CFLAGS = @QUORUM_CFLAGS@
SALCK_LIBS = @SALCK_LIBS@
SALCK_CFLAGS = @SALCK_CFLAGS@
SOURCES = \
clvmd-command.c \
@ -28,55 +38,35 @@ SOURCES = \
lvm-functions.c \
refresh_clvmd.c
ifneq (,$(findstring gulm,, "@CLVMD@,"))
GULM = yes
endif
ifneq (,$(findstring cman,, "@CLVMD@,"))
CMAN = yes
endif
ifneq (,$(findstring openais,, "@CLVMD@,"))
OPENAIS = yes
endif
ifneq (,$(findstring corosync,, "@CLVMD@,"))
COROSYNC = yes
endif
ifneq (,$(findstring all,, "@CLVMD@,"))
GULM = yes
CMAN = yes
OPENAIS = yes
COROSYNC = yes
endif
ifeq ("@DEBUG@", "yes")
DEFS += -DDEBUG
endif
ifeq ("$(GULM)", "yes")
ifneq (,$(findstring gulm,, "@CLVMD@,"))
SOURCES += clvmd-gulm.c tcp-comms.c
LMLIBS += -lccs -lgulm
LMLIBS += $(CCS_LIBS) $(GULM_LIBS)
CFLAGS += $(CCS_CFLAGS) $(GULM_CFLAGS)
DEFS += -DUSE_GULM
endif
ifeq ("$(CMAN)", "yes")
ifneq (,$(findstring cman,, "@CLVMD@,"))
SOURCES += clvmd-cman.c
LMLIBS += -ldlm -lcman
LMLIBS += $(CMAN_LIBS) $(CONFDB_LIBS) $(DLM_LIBS)
CFLAGS += $(CMAN_CFLAGS) $(CONFDB_CFLAGS) $(DLM_CFLAGS)
DEFS += -DUSE_CMAN
endif
ifeq ("$(OPENAIS)", "yes")
ifneq (,$(findstring openais,, "@CLVMD@,"))
SOURCES += clvmd-openais.c
LMLIBS += -lSaLck -lcpg
LMLIBS += $(CONFDB_LIBS) $(CPG_LIBS) $(SALCK_LIBS)
CFLAGS += $(CONFDB_CFLAGS) $(CPG_CFLAGS) $(SALCK_CFLAGS)
DEFS += -DUSE_OPENAIS
endif
ifeq ("$(COROSYNC)", "yes")
ifneq (,$(findstring corosync,, "@CLVMD@,"))
SOURCES += clvmd-corosync.c
LMLIBS += $(QUORUM_LIBS) $(CONFDB_LIBS) $(CPG_LIBS) -ldlm
CFLAGS += $(QUORUM_CFLAGS) $(CONFDB_CFLAGS) $(CPG_CFLAGS)
LMLIBS += $(CONFDB_LIBS) $(CPG_LIBS) $(DLM_LIBS) $(QUORUM_LIBS)
CFLAGS += $(CONFDB_CFLAGS) $(CPG_CFLAGS) $(DLM_CFLAGS) $(QUORUM_CFLAGS)
DEFS += -DUSE_COROSYNC
endif

View File

@ -1,6 +1,6 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
* Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@ -77,7 +77,7 @@ struct cluster_ops *init_cman_cluster(void);
#ifdef USE_OPENAIS
# include <openais/saAis.h>
# include <openais/totem/totem.h>
# include <corosync/totem/totem.h>
# define OPENAIS_CSID_LEN (sizeof(int))
# define OPENAIS_MAX_CLUSTER_MESSAGE MESSAGE_SIZE_MAX
# define OPENAIS_MAX_CLUSTER_MEMBER_NAME_LEN SA_MAX_NAME_LENGTH

View File

@ -55,13 +55,13 @@
/* Timeout value for several corosync calls */
#define LOCKSPACE_NAME "clvmd"
static void cpg_deliver_callback (cpg_handle_t handle,
static void corosync_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
void *msg,
size_t msg_len);
static void cpg_confchg_callback(cpg_handle_t handle,
static void corosync_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
@ -87,9 +87,9 @@ static dlm_lshandle_t *lockspace;
static struct cpg_name cpg_group_name;
/* Corosync callback structs */
cpg_callbacks_t cpg_callbacks = {
.cpg_deliver_fn = cpg_deliver_callback,
.cpg_confchg_fn = cpg_confchg_callback,
cpg_callbacks_t corosync_cpg_callbacks = {
.cpg_deliver_fn = corosync_cpg_deliver_callback,
.cpg_confchg_fn = corosync_cpg_confchg_callback,
};
quorum_callbacks_t quorum_callbacks = {
@ -205,7 +205,7 @@ static char *print_corosync_csid(const char *csid)
return buf;
}
static void cpg_deliver_callback (cpg_handle_t handle,
static void corosync_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
@ -225,7 +225,7 @@ static void cpg_deliver_callback (cpg_handle_t handle,
msg_len-COROSYNC_CSID_LEN, (char*)&nodeid);
}
static void cpg_confchg_callback(cpg_handle_t handle,
static void corosync_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
@ -294,7 +294,7 @@ static int _init_cluster(void)
node_hash = dm_hash_create(100);
err = cpg_initialize(&cpg_handle,
&cpg_callbacks);
&corosync_cpg_callbacks);
if (err != CS_OK) {
syslog(LOG_ERR, "Cannot initialise Corosync CPG service: %d",
err);

View File

@ -1,7 +1,7 @@
/******************************************************************************
*******************************************************************************
**
** Copyright (C) 2007 Red Hat, Inc. All rights reserved.
** Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved.
**
*******************************************************************************
******************************************************************************/
@ -41,7 +41,9 @@
#include <openais/saAis.h>
#include <openais/saLck.h>
#include <openais/cpg.h>
#include <corosync/corotypes.h>
#include <corosync/cpg.h>
#include "locking.h"
#include "lvm-logging.h"
@ -53,17 +55,18 @@
/* Timeout value for several openais calls */
#define TIMEOUT 10
static void cpg_deliver_callback (cpg_handle_t handle,
struct cpg_name *groupName,
static void openais_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
void *msg,
int msg_len);
static void cpg_confchg_callback(cpg_handle_t handle,
struct cpg_name *groupName,
struct cpg_address *member_list, int member_list_entries,
struct cpg_address *left_list, int left_list_entries,
struct cpg_address *joined_list, int joined_list_entries);
size_t msg_len);
static void openais_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
const struct cpg_address *joined_list, size_t joined_list_entries);
static void _cluster_closedown(void);
/* Hash list of nodes in the cluster */
@ -85,9 +88,9 @@ static SaLckHandleT lck_handle;
static struct cpg_name cpg_group_name;
/* Openais callback structs */
cpg_callbacks_t cpg_callbacks = {
.cpg_deliver_fn = cpg_deliver_callback,
.cpg_confchg_fn = cpg_confchg_callback,
cpg_callbacks_t openais_cpg_callbacks = {
.cpg_deliver_fn = openais_cpg_deliver_callback,
.cpg_confchg_fn = openais_cpg_confchg_callback,
};
struct node_info
@ -230,12 +233,12 @@ static int add_internal_client(int fd, fd_callback_t callback)
return 0;
}
static void cpg_deliver_callback (cpg_handle_t handle,
struct cpg_name *groupName,
static void openais_cpg_deliver_callback (cpg_handle_t handle,
const struct cpg_name *groupName,
uint32_t nodeid,
uint32_t pid,
void *msg,
int msg_len)
size_t msg_len)
{
int target_nodeid;
@ -250,11 +253,11 @@ static void cpg_deliver_callback (cpg_handle_t handle,
msg_len-OPENAIS_CSID_LEN, (char*)&nodeid);
}
static void cpg_confchg_callback(cpg_handle_t handle,
struct cpg_name *groupName,
struct cpg_address *member_list, int member_list_entries,
struct cpg_address *left_list, int left_list_entries,
struct cpg_address *joined_list, int joined_list_entries)
static void openais_cpg_confchg_callback(cpg_handle_t handle,
const struct cpg_name *groupName,
const struct cpg_address *member_list, size_t member_list_entries,
const struct cpg_address *left_list, size_t left_list_entries,
const struct cpg_address *joined_list, size_t joined_list_entries)
{
int i;
struct node_info *ninfo;
@ -330,7 +333,7 @@ static int _init_cluster(void)
lock_hash = dm_hash_create(10);
err = cpg_initialize(&cpg_handle,
&cpg_callbacks);
&openais_cpg_callbacks);
if (err != SA_AIS_OK) {
syslog(LOG_ERR, "Cannot initialise OpenAIS CPG service: %d",
err);
@ -342,7 +345,7 @@ static int _init_cluster(void)
NULL,
&ver);
if (err != SA_AIS_OK) {
cpg_initialize(&cpg_handle, &cpg_callbacks);
cpg_initialize(&cpg_handle, &openais_cpg_callbacks);
syslog(LOG_ERR, "Cannot initialise OpenAIS lock service: %d",
err);
DEBUGLOG("Cannot initialise OpenAIS lock service: %d\n\n", err);

View File

@ -45,6 +45,12 @@
/* Define to 1 if canonicalize_file_name is available. */
#undef HAVE_CANONICALIZE_FILE_NAME
/* Define to 1 if you have the <ccs.h> header file. */
#undef HAVE_CCS_H
/* Define to 1 if you have the <corosync/confdb.h> header file. */
#undef HAVE_COROSYNC_CONFDB_H
/* Define to 1 if you have the <ctype.h> header file. */
#undef HAVE_CTYPE_H
@ -90,12 +96,21 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <libcman.h> header file. */
#undef HAVE_LIBCMAN_H
/* Define to 1 if dynamic libraries are available. */
#undef HAVE_LIBDL
/* Define to 1 if you have the <libdlm.h> header file. */
#undef HAVE_LIBDLM_H
/* Define to 1 if you have the <libgen.h> header file. */
#undef HAVE_LIBGEN_H
/* Define to 1 if you have the <libgulm.h> header file. */
#undef HAVE_LIBGULM_H
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H