OBS User unknown 2009-01-27 01:19:31 +00:00 committed by Git OBS Bridge
parent e765b22cb2
commit 7a5efa9688
3 changed files with 395 additions and 8 deletions

378
clvmd-openais-use-dlm.diff Normal file
View File

@ -0,0 +1,378 @@
Index: LVM2.2.02.39/daemons/clvmd/clvmd-openais.c
===================================================================
--- LVM2.2.02.39.orig/daemons/clvmd/clvmd-openais.c 2008-06-20 20:46:21.000000000 +0800
+++ LVM2.2.02.39/daemons/clvmd/clvmd-openais.c 2009-01-22 12:36:41.000000000 +0800
@@ -34,9 +34,9 @@
#include <syslog.h>
#include <assert.h>
#include <libdevmapper.h>
+#include <libdlm.h>
#include <openais/saAis.h>
-#include <openais/saLck.h>
#include <openais/cpg.h>
#include "list.h"
@@ -50,6 +50,8 @@
/* Timeout value for several openais calls */
#define TIMEOUT 10
+#define LOCKSPACE_NAME "clvmd"
+
static void cpg_deliver_callback (cpg_handle_t handle,
struct cpg_name *groupName,
uint32_t nodeid,
@@ -77,9 +79,15 @@
/* OpenAIS handles */
static cpg_handle_t cpg_handle;
-static SaLckHandleT lck_handle;
static struct cpg_name cpg_group_name;
+static dlm_lshandle_t *lockspace;
+
+struct lock_wait {
+ pthread_cond_t cond;
+ pthread_mutex_t mutex;
+ struct dlm_lksb lksb;
+};
/* Openais callback structs */
cpg_callbacks_t cpg_callbacks = {
@@ -93,13 +101,6 @@
int nodeid;
};
-struct lock_info
-{
- SaLckResourceHandleT res_handle;
- SaLckLockIdT lock_id;
- SaNameT lock_name;
-};
-
/* Set errno to something approximating the right value and return 0 or -1 */
static int ais_to_errno(SaAisErrorT err)
{
@@ -309,19 +310,9 @@
num_nodes = member_list_entries;
}
-static int lck_dispatch(struct local_client *client, char *buf, int len,
- const char *csid, struct local_client **new_client)
-{
- *new_client = NULL;
- saLckDispatch(lck_handle, SA_DISPATCH_ONE);
- return 1;
-}
-
static int _init_cluster(void)
{
SaAisErrorT err;
- SaVersionT ver = { 'B', 1, 1 };
- int select_fd;
node_hash = dm_hash_create(100);
lock_hash = dm_hash_create(10);
@@ -335,16 +326,14 @@
return ais_to_errno(err);
}
- err = saLckInitialize(&lck_handle,
- NULL,
- &ver);
- if (err != SA_AIS_OK) {
- cpg_initialize(&cpg_handle, &cpg_callbacks);
- syslog(LOG_ERR, "Cannot initialise OpenAIS lock service: %d",
- err);
- DEBUGLOG("Cannot initialise OpenAIS lock service: %d\n\n", err);
- return ais_to_errno(err);
+ /* Create a lockspace for LV & VG locks to live in */
+ lockspace = dlm_create_lockspace(LOCKSPACE_NAME, 0600);
+ if (!lockspace) {
+ syslog(LOG_ERR, "Unable to create lockspace for CLVM: %m");
+ return -1;
}
+ dlm_ls_pthread_init(lockspace);
+ DEBUGLOG("DLM initialisation complete\n");
/* Connect to the clvmd group */
strcpy((char *)cpg_group_name.value, "clvmd");
@@ -352,7 +341,7 @@
err = cpg_join(cpg_handle, &cpg_group_name);
if (err != SA_AIS_OK) {
cpg_finalize(cpg_handle);
- saLckFinalize(lck_handle);
+ dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
syslog(LOG_ERR, "Cannot join clvmd process group");
DEBUGLOG("Cannot join clvmd process group: %d\n", err);
return ais_to_errno(err);
@@ -362,15 +351,12 @@
&our_nodeid);
if (err != SA_AIS_OK) {
cpg_finalize(cpg_handle);
- saLckFinalize(lck_handle);
+ dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
syslog(LOG_ERR, "Cannot get local node id\n");
return ais_to_errno(err);
}
DEBUGLOG("Our local node id is %d\n", our_nodeid);
- saLckSelectionObjectGet(lck_handle, (SaSelectionObjectT *)&select_fd);
- add_internal_client(select_fd, lck_dispatch);
-
DEBUGLOG("Connected to OpenAIS\n");
return 0;
@@ -381,7 +367,7 @@
DEBUGLOG("cluster_closedown\n");
unlock_all();
- saLckFinalize(lck_handle);
+ dlm_release_lockspace(LOCKSPACE_NAME, lockspace, 1);
cpg_finalize(cpg_handle);
}
@@ -472,156 +458,82 @@
return somedown;
}
-/* Real locking */
-static int _lock_resource(char *resource, int mode, int flags, int *lockid)
-{
- struct lock_info *linfo;
- SaLckResourceHandleT res_handle;
- SaAisErrorT err;
- SaLckLockIdT lock_id;
- SaLckLockStatusT lockStatus;
+static void sync_ast_routine(void *arg)
+{
+ struct lock_wait *lwait = arg;
+
+ pthread_mutex_lock(&lwait->mutex);
+ pthread_cond_signal(&lwait->cond);
+ pthread_mutex_unlock(&lwait->mutex);
+}
- /* This needs to be converted from DLM/LVM2 value for OpenAIS LCK */
- if (flags & LCK_NONBLOCK) flags = SA_LCK_LOCK_NO_QUEUE;
+static int _sync_lock(const char *resource, int mode, int flags, int *lockid)
+{
+ int status;
+ struct lock_wait lwait;
- linfo = malloc(sizeof(struct lock_info));
- if (!linfo)
+ if (!lockid) {
+ errno = EINVAL;
return -1;
-
- DEBUGLOG("lock_resource '%s', flags=%d, mode=%d\n", resource, flags, mode);
-
- linfo->lock_name.length = strlen(resource)+1;
- strcpy((char *)linfo->lock_name.value, resource);
-
- err = saLckResourceOpen(lck_handle, &linfo->lock_name,
- SA_LCK_RESOURCE_CREATE, TIMEOUT, &res_handle);
- if (err != SA_AIS_OK)
- {
- DEBUGLOG("ResourceOpen returned %d\n", err);
- free(linfo);
- return ais_to_errno(err);
}
- err = saLckResourceLock(
- res_handle,
- &lock_id,
+ DEBUGLOG("sync_lock: '%s' mode:%d flags=%d\n", resource,mode,flags);
+ /* Conversions need the lockid in the LKSB */
+ if (flags & LKF_CONVERT)
+ lwait.lksb.sb_lkid = *lockid;
+
+ pthread_cond_init(&lwait.cond, NULL);
+ pthread_mutex_init(&lwait.mutex, NULL);
+ pthread_mutex_lock(&lwait.mutex);
+
+ status = dlm_ls_lock(lockspace,
mode,
+ &lwait.lksb,
flags,
- 0,
- SA_TIME_END,
- &lockStatus);
- if (err != SA_AIS_OK && lockStatus != SA_LCK_LOCK_GRANTED)
- {
- free(linfo);
- saLckResourceClose(res_handle);
- return ais_to_errno(err);
- }
-
- /* Wait for it to complete */
+ resource,
+ strlen(resource),
+ 0, sync_ast_routine, &lwait, NULL, NULL);
+ if (status)
+ return status;
- DEBUGLOG("lock_resource returning %d, lock_id=%llx\n", err,
- lock_id);
-
- linfo->lock_id = lock_id;
- linfo->res_handle = res_handle;
-
- dm_hash_insert(lock_hash, resource, linfo);
-
- return ais_to_errno(err);
-}
+ /* Wait for it to complete */
+ pthread_cond_wait(&lwait.cond, &lwait.mutex);
+ pthread_mutex_unlock(&lwait.mutex);
+ *lockid = lwait.lksb.sb_lkid;
-static int _unlock_resource(char *resource, int lockid)
-{
- SaAisErrorT err;
- struct lock_info *linfo;
-
- DEBUGLOG("unlock_resource %s\n", resource);
- linfo = dm_hash_lookup(lock_hash, resource);
- if (!linfo)
+ errno = lwait.lksb.sb_status;
+ DEBUGLOG("sync_lock: returning lkid %x\n", *lockid);
+ if (lwait.lksb.sb_status)
+ return -1;
+ else
return 0;
-
- DEBUGLOG("unlock_resource: lockid: %llx\n", linfo->lock_id);
- err = saLckResourceUnlock(linfo->lock_id, SA_TIME_END);
- if (err != SA_AIS_OK)
- {
- DEBUGLOG("Unlock returned %d\n", err);
- return ais_to_errno(err);
- }
-
- /* Release the resource */
- dm_hash_remove(lock_hash, resource);
- saLckResourceClose(linfo->res_handle);
- free(linfo);
-
- return ais_to_errno(err);
-}
-
-static int _sync_lock(const char *resource, int mode, int flags, int *lockid)
-{
- int status;
- char lock1[strlen(resource)+3];
- char lock2[strlen(resource)+3];
-
- snprintf(lock1, sizeof(lock1), "%s-1", resource);
- snprintf(lock2, sizeof(lock2), "%s-2", resource);
-
- switch (mode)
- {
- case LCK_EXCL:
- status = _lock_resource(lock1, SA_LCK_EX_LOCK_MODE, flags, lockid);
- if (status)
- goto out;
-
- /* If we can't get this lock too then bail out */
- status = _lock_resource(lock2, SA_LCK_EX_LOCK_MODE, LCK_NONBLOCK,
- lockid);
- if (status == SA_LCK_LOCK_NOT_QUEUED)
- {
- _unlock_resource(lock1, *lockid);
- status = -1;
- errno = EAGAIN;
- }
- break;
-
- case LCK_PREAD:
- case LCK_READ:
- status = _lock_resource(lock1, SA_LCK_PR_LOCK_MODE, flags, lockid);
- if (status)
- goto out;
- _unlock_resource(lock2, *lockid);
- break;
-
- case LCK_WRITE:
- status = _lock_resource(lock2, SA_LCK_EX_LOCK_MODE, flags, lockid);
- if (status)
- goto out;
- _unlock_resource(lock1, *lockid);
- break;
-
- default:
- status = -1;
- errno = EINVAL;
- break;
- }
-out:
- *lockid = mode;
- return status;
}
static int _sync_unlock(const char *resource, int lockid)
{
int status = 0;
- char lock1[strlen(resource)+3];
- char lock2[strlen(resource)+3];
+ struct lock_wait lwait;
- snprintf(lock1, sizeof(lock1), "%s-1", resource);
- snprintf(lock2, sizeof(lock2), "%s-2", resource);
+ DEBUGLOG("sync_unlock: '%s' lkid:%x\n", resource, lockid);
- _unlock_resource(lock1, lockid);
- _unlock_resource(lock2, lockid);
+ pthread_cond_init(&lwait.cond, NULL);
+ pthread_mutex_init(&lwait.mutex, NULL);
+ pthread_mutex_lock(&lwait.mutex);
- return status;
+ status = dlm_ls_unlock(lockspace, lockid, 0, &lwait.lksb, &lwait);
+
+ if (status)
+ return status;
+ /* Wait for it to complete */
+ pthread_cond_wait(&lwait.cond, &lwait.mutex);
+ pthread_mutex_unlock(&lwait.mutex);
+
+ errno = lwait.lksb.sb_status;
+ if (lwait.lksb.sb_status != EUNLOCK)
+ return -1;
+ else
+ return 0;
}
/* We are always quorate ! */
Index: LVM2.2.02.39/daemons/clvmd/Makefile.in
===================================================================
--- LVM2.2.02.39.orig/daemons/clvmd/Makefile.in 2009-01-22 12:26:13.000000000 +0800
+++ LVM2.2.02.39/daemons/clvmd/Makefile.in 2009-01-22 12:27:34.000000000 +0800
@@ -59,7 +59,7 @@
ifeq ("$(OPENAIS)", "yes")
SOURCES += clvmd-openais.c
- LMLIBS += -lSaLck -lcpg
+ LMLIBS += -ldlm -lcpg
DEFS += -DUSE_OPENAIS
endif
Index: LVM2.2.02.39/daemons/clvmd/clvm.h
===================================================================
--- LVM2.2.02.39.orig/daemons/clvmd/clvm.h 2009-01-22 12:26:13.000000000 +0800
+++ LVM2.2.02.39/daemons/clvmd/clvm.h 2009-01-22 12:35:08.000000000 +0800
@@ -79,6 +79,7 @@
/* Locking flags - these match the ones
* in dlm.h
*/
+#ifndef LKF_NOQUEUE
#define LKF_NOQUEUE (0x00000001)
#define LKF_CANCEL (0x00000002)
#define LKF_CONVERT (0x00000004)
@@ -94,3 +95,4 @@
#define LKF_HEADQUE (0x00001000)
#define LKF_NOORDER (0x00002000)
#endif
+#endif

View File

@ -1,7 +1,12 @@
-------------------------------------------------------------------
Thu Jan 22 13:00:26 CST 2009 - xwhu@suse.de
- bnc#464851, use dlm instead of openais lck
-------------------------------------------------------------------
Wed Jan 21 15:23:31 CET 2009 - ro@suse.de
- do not require a specific package release from subpackage
- do not require a specific package release from subpackage
(bnc#467704)
-------------------------------------------------------------------

View File

@ -18,7 +18,7 @@
Name: lvm2
BuildRequires: device-mapper-devel libopenais-devel readline-devel
BuildRequires: device-mapper-devel libdlm-devel libopenais-devel readline-devel
BuildRequires: libselinux-devel
License: GPL v2 or later; LGPL v2.1 or later
Group: System/Base
@ -28,7 +28,7 @@ Obsoletes: lvm
PreReq: %fillup_prereq %insserv_prereq
AutoReqProv: on
Version: 2.02.39
Release: 11
Release: 14
Summary: LVM2 Tools
Source: LVM2.%{version}.tar.bz2
Source1: lvm.conf
@ -51,6 +51,7 @@ Patch12: enable-clvmd.patch
Patch13: pipe_buff-definition.diff
Patch14: lvm-pv-create-link.diff
Patch15: dmeventd-link-libcmd.diff
Patch16: clvmd-openais-use-dlm.diff
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Not a real replacement but we drop evms
Provides: evms = 2.5.5 evms-gui = 2.5.5 evms-devel = 2.5.5 evms-ha = 2.5.5
@ -87,6 +88,7 @@ A daemon for using LVM2 Logival Volumes in a clustered environment.
%patch13
%patch14 -p1
%patch15 -p1
%patch16 -p1
%build
CFLAGS="$RPM_OPT_FLAGS" MODPROBE_CMD=/sbin/modprobe \
@ -263,10 +265,12 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man8/vgsplit.8.gz
%changelog
* Thu Jan 22 2009 xwhu@suse.de
- bnc#464851, use dlm instead of openais lck
* Wed Jan 21 2009 ro@suse.de
- do not require a specific package release from subpackage
(bnc#467704)
* Thu Dec 04 2008 xwhu@suse.de
* Wed Dec 03 2008 xwhu@suse.de
- Add OCF script for clvmd
* Wed Nov 12 2008 xwhu@suse.de
- bnc#443677. dmeventd DSOs are linked against liblvm2cmd
@ -309,13 +313,13 @@ rm -rf $RPM_BUILD_ROOT
- enabled SELinux support [Fate#303662]
* Fri Aug 22 2008 xwhu@suse.de
- Remove the -p option for fillup_and_insserv
* Wed Aug 13 2008 xwhu@suse.de
* Tue Aug 12 2008 xwhu@suse.de
- Add Should-Stop to boot.lvm
* Thu Jul 31 2008 xwhu@suse.de
- repack LVM2.2.02.38.tar.bz2 into bz2 format
* Wed Jul 23 2008 hare@suse.de
- Include mkinitrd scriptlets.
* Fri Jun 27 2008 xwhu@suse.de
* Thu Jun 26 2008 xwhu@suse.de
- update to 2.02.38
Fix tracking of validity of PVs with no mdas in lvmcache.
Fix return values for reporting commands when run with no PVs, LVs, or VGs.
@ -351,7 +355,7 @@ rm -rf $RPM_BUILD_ROOT
- Split clvmd into a separate package (bnc#384708)
* Wed Apr 23 2008 xwhu@suse.de
- Change async lock primitives to sync
* Wed Apr 23 2008 xwhu@suse.de
* Tue Apr 22 2008 xwhu@suse.de
- Fix build aginst beta
definition of PIPE_BUF is missing
* Tue Apr 22 2008 xwhu@suse.de
@ -750,7 +754,7 @@ rm -rf $RPM_BUILD_ROOT
- accept additional devices (IDE->64, iseries/vd->8, #39114)
* Thu Apr 01 2004 fehr@suse.de
- update to new version 2.00.09 (fixes #34657 and #36877)
* Tue Mar 02 2004 ro@suse.de
* Mon Mar 01 2004 ro@suse.de
- boot.lvm: root-fs is mounted-rw by boot.rootfsck
* Thu Feb 26 2004 fehr@suse.de
- skip cdroms and device with zero size on probing