From cc31b2bd3f16a6a4ef36421569ab178937603ace Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Wed, 9 Dec 2009 18:42:02 +0000 Subject: [PATCH] Get rid of magic masks in cluster locking code - clvmd part. - do_command and lock_vg expect flags (no change here) Bug fixes: - lock_vg should check for NONBLOCK on lock_cmd, flags have this bit masked-out - do_pre/post_command expect do not mask flag at all, this causes that the code inside is never run! (see following patches, these functions expect plain command without flags) --- WHATS_NEW | 1 + daemons/clvmd/clvmd-command.c | 6 +++--- daemons/clvmd/lvm-functions.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index ea5cd2a55..c13e3d1cc 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.57 - ==================================== + Replace magic masks in cluster locking code by defined masks. Remove log volume from metadata if initial deactivation fails. Give better error message for pvmove when all data is skipped. Fix memory lock imbalance in lv_suspend if already suspended. diff --git a/daemons/clvmd/clvmd-command.c b/daemons/clvmd/clvmd-command.c index 2266a2be9..2612a0e1e 100644 --- a/daemons/clvmd/clvmd-command.c +++ b/daemons/clvmd/clvmd-command.c @@ -132,7 +132,7 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen, case CLVMD_CMD_LOCK_LV: /* This is the biggie */ - lock_cmd = args[0] & 0x3F; + lock_cmd = args[0] & (LCK_NONBLOCK | LCK_HOLD | LCK_SCOPE_MASK | LCK_TYPE_MASK); lock_flags = args[1]; lockname = &args[2]; status = do_lock_lv(lock_cmd, lock_flags, lockname); @@ -214,7 +214,7 @@ static int lock_vg(struct local_client *client) client->bits.localsock.private = (void *)lock_hash; } - lock_cmd = args[0] & 0x3F; + lock_cmd = args[0] & (LCK_NONBLOCK | LCK_HOLD | LCK_SCOPE_MASK | LCK_TYPE_MASK); lock_flags = args[1]; lockname = &args[2]; DEBUGLOG("doing PRE command LOCK_VG '%s' at %x (client=%p)\n", lockname, lock_cmd, client); @@ -237,7 +237,7 @@ static int lock_vg(struct local_client *client) lock_cmd &= ~LCK_TYPE_MASK; lock_cmd |= LCK_PREAD; } - status = sync_lock(lockname, (int)lock_cmd, (lock_flags & LCK_NONBLOCK) ? LKF_NOQUEUE : 0, &lkid); + status = sync_lock(lockname, (int)lock_cmd, (lock_cmd & LCK_NONBLOCK) ? LKF_NOQUEUE : 0, &lkid); if (status) status = errno; else diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index e56d11b4b..7fee65d75 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -542,7 +542,7 @@ int pre_lock_lv(unsigned char command, unsigned char lock_flags, char *resource) lock out on this node (because we are the node modifying the metadata) before suspending cluster-wide. */ - if (command == LCK_LV_SUSPEND) { + if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_SUSPEND) { DEBUGLOG("pre_lock_lv: resource '%s', cmd = %s, flags = %s\n", resource, decode_locking_cmd(command), decode_flags(lock_flags)); @@ -559,7 +559,7 @@ int post_lock_lv(unsigned char command, unsigned char lock_flags, int status; /* Opposite of above, done on resume after a metadata update */ - if (command == LCK_LV_RESUME) { + if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_RESUME) { int oldmode; DEBUGLOG