From ce1aa2c3fffd1634a01004afb177dc1a4990a1a1 Mon Sep 17 00:00:00 2001 From: Patrick Caulfield Date: Mon, 21 Feb 2005 14:36:09 +0000 Subject: [PATCH] Always manipulate both locks in sync_lock() otherwise they get left hanging around and cause trouble. --- WHATS_NEW | 1 + daemons/clvmd/clvmd-gulm.c | 31 +++++++++++-------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index bdc701b82..53b49838e 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.01.06 - ==================================== + Fix clvmd-gulm locking. Version 2.01.05 - 18th February 2005 ==================================== diff --git a/daemons/clvmd/clvmd-gulm.c b/daemons/clvmd/clvmd-gulm.c index 5ff10d154..88782c464 100644 --- a/daemons/clvmd/clvmd-gulm.c +++ b/daemons/clvmd/clvmd-gulm.c @@ -224,7 +224,7 @@ static int _init_cluster(void) exit(status); } - /* Request a list of nodes, we can;t really do anything until + /* Request a list of nodes, we can't really do anything until this comes back */ status = lg_core_nodelist(gulm_if); if (status) @@ -763,7 +763,7 @@ static int _sync_lock(const char *resource, int mode, int flags, int *lockid) if (status) goto out; - /* If we can't get this lock then bail out */ + /* If we can't get this lock too then bail out */ status = _lock_resource(lock2, lg_lock_state_Exclusive, LCK_NONBLOCK, lockid); if (status == lg_err_TryFailed) { @@ -775,10 +775,16 @@ static int _sync_lock(const char *resource, int mode, int flags, int *lockid) case LCK_READ: status = _lock_resource(lock1, lg_lock_state_Shared, flags, lockid); + if (status) + goto out; + status = _unlock_resource(lock2, *lockid); break; case LCK_WRITE: status = _lock_resource(lock2, lg_lock_state_Exclusive, flags, lockid); + if (status) + goto out; + status = _unlock_resource(lock1, *lockid); break; default: @@ -805,25 +811,10 @@ static int _sync_unlock(const char *resource, int lockid) lockid == LCK_READ || lockid == LCK_WRITE); - switch (lockid) - { - case LCK_EXCL: - status = _unlock_resource(lock1, lockid); - if (status) - goto out; - status = _unlock_resource(lock2, lockid); - break; + status = _unlock_resource(lock1, lockid); + if (!status) + status = _unlock_resource(lock2, lockid); - case LCK_READ: - status = _unlock_resource(lock1, lockid); - break; - - case LCK_WRITE: - status = _unlock_resource(lock2, lockid); - break; - } - - out: return status; }