Skip to contentSkip to conversation

Clean up cluster lock mode and flags definition.

PATCH New Milan Broz 2 participants 2 messages Jun 4, 2010

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 Clean up cluster lock mode and flags definition.

Code is mixing up internal DLM and LVM definitions of lock modes and flags.

OpenAIS and singlenode locking do not depend on DLM but code currently cannot be compiled without libdlm.h!

LCK_* flags is LVM abstraction, used through all the code. Only low-level backend (clvmd-cmac etc) should use DLM definitions, also this code should do all needed conversions.

Because there are two DLM flags used in generic code (NOQUEUE, CONVERT) we define it similar way like lock modes. (So all needed binary-compatible flags are on one place in locking.h)

---
 daemons/clvmd/clvmd-command.c |    5 +--
 daemons/clvmd/clvmd-gulm.c    |    2 +-
 daemons/clvmd/clvmd-gulm.h    |    4 ---
 daemons/clvmd/lvm-functions.c |   42 +++++++++++++++++++---------------------
 lib/locking/locking.h         |    6 +++++
 5 files changed, 29 insertions(+), 30 deletions(-)
daemons/clvmd/clvmd-command.c +2 -3
index 83d03ef..b4e8a97 100644
@@ -69,7 +69,6 @@
 #include <unistd.h>
 #include <errno.h>
 #include <libdevmapper.h>
-#include <libdlm.h>
 
 #include "locking.h"
 #include "lvm-logging.h"
@@ -239,7 +238,7 @@ static int lock_vg(struct local_client *client)
 	/* 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) ? LCKF_NOQUEUE : 0, &lkid);
 	if (status)
 	    status = errno;
 	else
@@ -266,7 +265,7 @@ int do_pre_command(struct local_client *client)
 
 	switch (header->cmd) {
 	case CLVMD_CMD_TEST:
-		status = sync_lock("CLVMD_TEST", LKM_EXMODE, 0, &lockid);
+		status = sync_lock("CLVMD_TEST", LCK_EXCL, 0, &lockid);
 		client->bits.localsock.private = (void *)(long)lockid;
 		break;
 
daemons/clvmd/clvmd-gulm.c +1 -1
index 54dce4d..1f7977d 100644
@@ -738,7 +738,7 @@ static int _lock_resource(char *resource, int mode, int flags, int *lockid)
     pthread_mutex_lock(&lwait.mutex);
 
     /* This needs to be converted from DLM/LVM2 value for GULM */
-    if (flags & LKF_NOQUEUE) flags = lg_lock_flag_Try;
+    if (flags & LCKF_NOQUEUE) flags = lg_lock_flag_Try;
 
     dm_hash_insert(lock_hash, resource, &lwait);
     DEBUGLOG("lock_resource '%s', flags=%d, mode=%d\n", resource, flags, mode);
daemons/clvmd/clvmd-gulm.h +0 -4
index d4be46f..9416f5c 100644
@@ -1,7 +1,3 @@
-
-/* DLM constant that clvmd uses as a generic NONBLOCK lock flag */
-#define LKF_NOQUEUE 1
-
 extern int get_next_node_csid(void **context, char *csid);
 extern void add_down_node(char *csid);
 extern int gulm_fd(void);
daemons/clvmd/lvm-functions.c +20 -22

133 lines not on this page · raw message

lib/locking/locking.h +6 -0
index d904cf2..488d194 100644
@@ -73,6 +73,12 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 #define LCK_UNLOCK      0x00000006U	/* This is ours */
 
 /*
+ * Lock flags - these numbers are the same as DLM
+ */
+#define LCKF_NOQUEUE	0x00000001U	/* LKF$_NOQUEUE */
+#define LCKF_CONVERT	0x00000004U	/* LKF$_CONVERT */
+
+/*
  * Lock scope
  */
 #define LCK_SCOPE_MASK	0x00000008U
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 Clean up cluster lock mode and flags definition.

Quoted 6 lines · Milan Broz

Code is mixing up internal DLM and LVM definitions of lock modes and flags.

OpenAIS and singlenode locking do not depend on DLM but code currently cannot be compiled without libdlm.h!

Quoted 7 lines

LCK_* flags is LVM abstraction, used through all the code. Only low-level backend (clvmd-cmac etc) should use DLM definitions, also this code should do all needed conversions.

Because there are two DLM flags used in generic code (NOQUEUE, CONVERT) we define it similar way like lock modes. (So all needed binary-compatible flags are on one place in locking.h)

Thanks!

When I send the patch to fix this issue:

https://www.redhat.com/archives/lvm-devel/2010-May/msg00180.html

I change all references to use <linux/dlm.h> avoiding <libdlm.h>. I didn?t know we have the same definitions (with internal names) on locking.h.

With your fix I can continue compiling clvmd+openais without the need of libdlm and, now, without the need of patching the sources.

Thanks again!

Piter Punk