[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH]: Remove the need of libdlm when using clvmd with OpenAIS



Hi,

I am compiling LVM with clustering support (clvmd) using
OpenAIS. The ./configure runs OK but, when doing the
compilation, I got a lot of errors about missing libdlm.h

clvmd-openais.c doesn't have any use of libdlm or libdlm
functions (the clvmd-cman.c and clvmd-corosync.c uses).

But the compilation stops because clvmd-command.c and
lvm-functions.c includes libdlm.h only to use some defined
constants, like LKM_EXMODE and LKF_NOQUEUE.

All these constants are defined on dlmconstants.h with
other names: LKM_EXMODE -> DLM_LOCK_EX.

This patch changes the constants found in clvmd-command.c
and lvm-functions.c to use the names in dlmconstants.h.
And to include linux/dlm.h instead libdlm.h.

With that, clvmd can compiles using OpenAIS locking
mechanism and without the need of libdlm (needed by the
other cluster managers).

I hope this patch are OK and can help other LVM users.

Thanks

Piter PUNK
diff -Naur orig/daemons/clvmd/clvmd-command.c new/daemons/clvmd/clvmd-command.c
--- orig/daemons/clvmd/clvmd-command.c	2010-04-30 11:51:58.000000000 -0300
+++ new/daemons/clvmd/clvmd-command.c	2010-05-20 16:26:30.151491344 -0300
@@ -69,7 +69,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <libdevmapper.h>
-#include <libdlm.h>
+#include <linux/dlm.h>
 
 #include "locking.h"
 #include "lvm-logging.h"
@@ -239,7 +239,7 @@
 	/* Read locks need to be PR; other modes get passed through */
 	if (lock_mode == LCK_READ)
 	    lock_mode = LCK_PREAD;
-	status = sync_lock(lockname, lock_mode, (lock_cmd & LCK_NONBLOCK) ? LKF_NOQUEUE : 0, &lkid);
+	status = sync_lock(lockname, lock_mode, (lock_cmd & LCK_NONBLOCK) ? DLM_LKF_NOQUEUE : 0, &lkid);
 	if (status)
 	    status = errno;
 	else
@@ -266,7 +266,7 @@
 
 	switch (header->cmd) {
 	case CLVMD_CMD_TEST:
-		status = sync_lock("CLVMD_TEST", LKM_EXMODE, 0, &lockid);
+		status = sync_lock("CLVMD_TEST", DLM_LOCK_EX, 0, &lockid);
 		client->bits.localsock.private = (void *)(long)lockid;
 		break;
 
diff -Naur orig/daemons/clvmd/lvm-functions.c new/daemons/clvmd/lvm-functions.c
--- orig/daemons/clvmd/lvm-functions.c	2010-04-20 11:07:38.000000000 -0300
+++ new/daemons/clvmd/lvm-functions.c	2010-05-20 16:29:32.693735791 -0300
@@ -35,7 +35,7 @@
 #include <syslog.h>
 #include <assert.h>
 #include <libdevmapper.h>
-#include <libdlm.h>
+#include <linux/dlm.h>
 
 #include "lvm-types.h"
 #include "clvm.h"
@@ -243,7 +243,7 @@
 	struct lv_info *lvi;
 
 	/* Mask off invalid options */
-	flags &= LKF_NOQUEUE | LKF_CONVERT;
+	flags &= DLM_LKF_NOQUEUE | DLM_LKF_CONVERT;
 
 	lvi = lookup_info(resource);
 
@@ -253,7 +253,7 @@
 	}
 
 	/* Only allow explicit conversions */
-	if (lvi && !(flags & LKF_CONVERT)) {
+	if (lvi && !(flags & DLM_LKF_CONVERT)) {
 		errno = EBUSY;
 		return -1;
 	}
@@ -276,7 +276,7 @@
 			return -1;
 
 		lvi->lock_mode = mode;
-		status = sync_lock(resource, mode, flags & ~LKF_CONVERT, &lvi->lock_id);
+		status = sync_lock(resource, mode, flags & ~DLM_LKF_CONVERT, &lvi->lock_id);
 		saved_errno = errno;
 		if (status) {
 			free(lvi);
@@ -346,9 +346,9 @@
 		return 0;	/* Success, we did nothing! */
 
 	/* Do we need to activate exclusively? */
-	if ((activate_lv == 2) || (mode == LKM_EXMODE)) {
+	if ((activate_lv == 2) || (mode == DLM_LOCK_EX)) {
 		exclusive = 1;
-		mode = LKM_EXMODE;
+		mode = DLM_LOCK_EX;
 	}
 
 	/*
@@ -357,7 +357,7 @@
 	 * of exclusive lock to shared one during activation.
 	 */
 	if (lock_flags & LCK_CLUSTER_VG) {
-		status = hold_lock(resource, mode, LKF_NOQUEUE | (lock_flags & LCK_CONVERT?LKF_CONVERT:0));
+		status = hold_lock(resource, mode, DLM_LKF_NOQUEUE | (lock_flags & LCK_CONVERT?DLM_LKF_CONVERT:0));
 		if (status) {
 			/* Return an LVM-sensible error for this.
 			 * Forcing EIO makes the upper level return this text
@@ -465,12 +465,12 @@
 
 	mode = get_current_lock(resource);
 	switch (mode) {
-		case LKM_NLMODE: type = "NL"; break;
-		case LKM_CRMODE: type = "CR"; break;
-		case LKM_CWMODE: type = "CW"; break;
-		case LKM_PRMODE: type = "PR"; break;
-		case LKM_PWMODE: type = "PW"; break;
-		case LKM_EXMODE: type = "EX"; break;
+		case DLM_LOCK_NL: type = "NL"; break;
+		case DLM_LOCK_CR: type = "CR"; break;
+		case DLM_LOCK_CW: type = "CW"; break;
+		case DLM_LOCK_PR: type = "PR"; break;
+		case DLM_LOCK_PW: type = "PW"; break;
+		case DLM_LOCK_EX: type = "EX"; break;
 	}
 
 	DEBUGLOG("do_lock_query: resource '%s', mode %i (%s)\n", resource, mode, type ?: "?");
@@ -511,7 +511,7 @@
 
 	switch (command & LCK_MASK) {
 	case LCK_LV_EXCLUSIVE:
-		status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
+		status = do_activate_lv(resource, lock_flags, DLM_LOCK_EX);
 		break;
 
 	case LCK_LV_SUSPEND:
@@ -528,7 +528,7 @@
 		break;
 
 	case LCK_LV_ACTIVATE:
-		status = do_activate_lv(resource, lock_flags, LKM_CRMODE);
+		status = do_activate_lv(resource, lock_flags, DLM_LOCK_CR);
 		break;
 
 	case LCK_LV_DEACTIVATE:
@@ -560,14 +560,14 @@
 	/* Nearly all the stuff happens cluster-wide. Apart from SUSPEND. Here we get the
 	   lock out on this node (because we are the node modifying the metadata)
 	   before suspending cluster-wide.
-	   LKF_CONVERT is used always, local node is going to modify metadata
+	   DLM_LKF_CONVERT is used always, local node is going to modify metadata
 	 */
 	if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_SUSPEND &&
 	    (lock_flags & LCK_CLUSTER_VG)) {
 		DEBUGLOG("pre_lock_lv: resource '%s', cmd = %s, flags = %s\n",
 			 resource, decode_locking_cmd(command), decode_flags(lock_flags));
 
-		if (hold_lock(resource, LKM_PWMODE, LKF_NOQUEUE | LKF_CONVERT))
+		if (hold_lock(resource, DLM_LOCK_PW, DLM_LKF_NOQUEUE | DLM_LKF_CONVERT))
 			return errno;
 	}
 	return 0;
@@ -590,7 +590,7 @@
 
 		/* If the lock state is PW then restore it to what it was */
 		oldmode = get_current_lock(resource);
-		if (oldmode == LKM_PWMODE) {
+		if (oldmode == DLM_LOCK_PW) {
 			struct lvinfo lvi;
 
 			pthread_mutex_lock(&lvm_lock);
@@ -600,7 +600,7 @@
 				return EIO;
 
 			if (lvi.exists) {
-				if (hold_lock(resource, LKM_CRMODE, LKF_CONVERT))
+				if (hold_lock(resource, DLM_LOCK_CR, DLM_LKF_CONVERT))
 					return errno;
 			} else {
 				if (hold_unlock(resource))
@@ -792,15 +792,15 @@
 				memcpy(&uuid[58], &lv[32], 6);
 				uuid[64] = '\0';
 
-				lock_mode = LKM_CRMODE;
+				lock_mode = DLM_LOCK_CR;
 
 				/* Look for this lock in the list of EX locks
 				   we were passed on the command-line */
 				if (was_ex_lock(uuid, argv))
-					lock_mode = LKM_EXMODE;
+					lock_mode = DLM_LOCK_EX;
 
 				DEBUGLOG("getting initial lock for %s\n", uuid);
-				hold_lock(uuid, lock_mode, LKF_NOQUEUE);
+				hold_lock(uuid, lock_mode, DLM_LKF_NOQUEUE);
 			}
 		}
 	}

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]