mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Simplify locking code by using saLckResourceLock rather than
saLckResourceLockAsync. Thanks to Xinwei Hu for the patch.
This commit is contained in:
parent
fd1b118942
commit
9ba7d6d08b
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.36 -
|
Version 2.02.36 -
|
||||||
=================================
|
=================================
|
||||||
|
Simply clvmd-openais by using non-async saLckResourceLock.
|
||||||
Check lv_count in vg_validate.
|
Check lv_count in vg_validate.
|
||||||
Fix internal LV counter when a snapshot is removed.
|
Fix internal LV counter when a snapshot is removed.
|
||||||
Fix metadata corruption writing lvm1-formatted metadata with snapshots.
|
Fix metadata corruption writing lvm1-formatted metadata with snapshots.
|
||||||
|
@ -50,11 +50,6 @@
|
|||||||
/* Timeout value for several openais calls */
|
/* Timeout value for several openais calls */
|
||||||
#define TIMEOUT 10
|
#define TIMEOUT 10
|
||||||
|
|
||||||
static void lck_lock_callback(SaInvocationT invocation,
|
|
||||||
SaLckLockStatusT lockStatus,
|
|
||||||
SaAisErrorT error);
|
|
||||||
static void lck_unlock_callback(SaInvocationT invocation,
|
|
||||||
SaAisErrorT error);
|
|
||||||
static void cpg_deliver_callback (cpg_handle_t handle,
|
static void cpg_deliver_callback (cpg_handle_t handle,
|
||||||
struct cpg_name *groupName,
|
struct cpg_name *groupName,
|
||||||
uint32_t nodeid,
|
uint32_t nodeid,
|
||||||
@ -92,11 +87,6 @@ cpg_callbacks_t cpg_callbacks = {
|
|||||||
.cpg_confchg_fn = cpg_confchg_callback,
|
.cpg_confchg_fn = cpg_confchg_callback,
|
||||||
};
|
};
|
||||||
|
|
||||||
SaLckCallbacksT lck_callbacks = {
|
|
||||||
.saLckLockGrantCallback = lck_lock_callback,
|
|
||||||
.saLckResourceUnlockCallback = lck_unlock_callback
|
|
||||||
};
|
|
||||||
|
|
||||||
struct node_info
|
struct node_info
|
||||||
{
|
{
|
||||||
enum {NODE_UNKNOWN, NODE_DOWN, NODE_UP, NODE_CLVMD} state;
|
enum {NODE_UNKNOWN, NODE_DOWN, NODE_UP, NODE_CLVMD} state;
|
||||||
@ -305,32 +295,6 @@ static void cpg_confchg_callback(cpg_handle_t handle,
|
|||||||
num_nodes = joined_list_entries;
|
num_nodes = joined_list_entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lck_lock_callback(SaInvocationT invocation,
|
|
||||||
SaLckLockStatusT lockStatus,
|
|
||||||
SaAisErrorT error)
|
|
||||||
{
|
|
||||||
struct lock_wait *lwait = (struct lock_wait *)(long)invocation;
|
|
||||||
|
|
||||||
DEBUGLOG("lck_lock_callback, error = %d\n", error);
|
|
||||||
|
|
||||||
lwait->status = error;
|
|
||||||
pthread_mutex_lock(&lwait->mutex);
|
|
||||||
pthread_cond_signal(&lwait->cond);
|
|
||||||
pthread_mutex_unlock(&lwait->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lck_unlock_callback(SaInvocationT invocation,
|
|
||||||
SaAisErrorT error)
|
|
||||||
{
|
|
||||||
struct lock_wait *lwait = (struct lock_wait *)(long)invocation;
|
|
||||||
|
|
||||||
DEBUGLOG("lck_unlock_callback\n");
|
|
||||||
|
|
||||||
lwait->status = SA_AIS_OK;
|
|
||||||
pthread_mutex_lock(&lwait->mutex);
|
|
||||||
pthread_cond_signal(&lwait->cond);
|
|
||||||
pthread_mutex_unlock(&lwait->mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lck_dispatch(struct local_client *client, char *buf, int len,
|
static int lck_dispatch(struct local_client *client, char *buf, int len,
|
||||||
const char *csid, struct local_client **new_client)
|
const char *csid, struct local_client **new_client)
|
||||||
@ -359,7 +323,7 @@ static int _init_cluster(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = saLckInitialize(&lck_handle,
|
err = saLckInitialize(&lck_handle,
|
||||||
&lck_callbacks,
|
NULL,
|
||||||
&ver);
|
&ver);
|
||||||
if (err != SA_AIS_OK) {
|
if (err != SA_AIS_OK) {
|
||||||
cpg_initialize(&cpg_handle, &cpg_callbacks);
|
cpg_initialize(&cpg_handle, &cpg_callbacks);
|
||||||
@ -495,15 +459,11 @@ static int _cluster_do_node_callback(struct local_client *master_client,
|
|||||||
/* Real locking */
|
/* Real locking */
|
||||||
static int _lock_resource(char *resource, int mode, int flags, int *lockid)
|
static int _lock_resource(char *resource, int mode, int flags, int *lockid)
|
||||||
{
|
{
|
||||||
struct lock_wait lwait;
|
|
||||||
struct lock_info *linfo;
|
struct lock_info *linfo;
|
||||||
SaLckResourceHandleT res_handle;
|
SaLckResourceHandleT res_handle;
|
||||||
SaAisErrorT err;
|
SaAisErrorT err;
|
||||||
SaLckLockIdT lock_id;
|
SaLckLockIdT lock_id;
|
||||||
|
SaLckLockStatusT lockStatus;
|
||||||
pthread_cond_init(&lwait.cond, NULL);
|
|
||||||
pthread_mutex_init(&lwait.mutex, NULL);
|
|
||||||
pthread_mutex_lock(&lwait.mutex);
|
|
||||||
|
|
||||||
/* This needs to be converted from DLM/LVM2 value for OpenAIS LCK */
|
/* This needs to be converted from DLM/LVM2 value for OpenAIS LCK */
|
||||||
if (flags & LCK_NONBLOCK) flags = SA_LCK_LOCK_NO_QUEUE;
|
if (flags & LCK_NONBLOCK) flags = SA_LCK_LOCK_NO_QUEUE;
|
||||||
@ -526,24 +486,24 @@ static int _lock_resource(char *resource, int mode, int flags, int *lockid)
|
|||||||
return ais_to_errno(err);
|
return ais_to_errno(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = saLckResourceLockAsync(res_handle,
|
err = saLckResourceLock(
|
||||||
(SaInvocationT)(long)&lwait,
|
res_handle,
|
||||||
&lock_id,
|
&lock_id,
|
||||||
mode,
|
mode,
|
||||||
flags,
|
flags,
|
||||||
0);
|
0,
|
||||||
if (err != SA_AIS_OK)
|
SA_TIME_END,
|
||||||
|
&lockStatus);
|
||||||
|
if (err != SA_AIS_OK && lockStatus != SA_LCK_LOCK_GRANTED)
|
||||||
{
|
{
|
||||||
free(linfo);
|
free(linfo);
|
||||||
saLckResourceClose(res_handle);
|
saLckResourceClose(res_handle);
|
||||||
return ais_to_errno(err);
|
return ais_to_errno(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for it to complete */
|
/* Wait for it to complete */
|
||||||
pthread_cond_wait(&lwait.cond, &lwait.mutex);
|
|
||||||
pthread_mutex_unlock(&lwait.mutex);
|
|
||||||
|
|
||||||
DEBUGLOG("lock_resource returning %d, lock_id=%llx\n", lwait.status,
|
DEBUGLOG("lock_resource returning %d, lock_id=%llx\n", err,
|
||||||
lock_id);
|
lock_id);
|
||||||
|
|
||||||
linfo->lock_id = lock_id;
|
linfo->lock_id = lock_id;
|
||||||
@ -551,43 +511,34 @@ static int _lock_resource(char *resource, int mode, int flags, int *lockid)
|
|||||||
|
|
||||||
dm_hash_insert(lock_hash, resource, linfo);
|
dm_hash_insert(lock_hash, resource, linfo);
|
||||||
|
|
||||||
return ais_to_errno(lwait.status);
|
return ais_to_errno(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _unlock_resource(char *resource, int lockid)
|
static int _unlock_resource(char *resource, int lockid)
|
||||||
{
|
{
|
||||||
struct lock_wait lwait;
|
|
||||||
SaAisErrorT err;
|
SaAisErrorT err;
|
||||||
struct lock_info *linfo;
|
struct lock_info *linfo;
|
||||||
|
|
||||||
pthread_cond_init(&lwait.cond, NULL);
|
|
||||||
pthread_mutex_init(&lwait.mutex, NULL);
|
|
||||||
pthread_mutex_lock(&lwait.mutex);
|
|
||||||
|
|
||||||
DEBUGLOG("unlock_resource %s\n", resource);
|
DEBUGLOG("unlock_resource %s\n", resource);
|
||||||
linfo = dm_hash_lookup(lock_hash, resource);
|
linfo = dm_hash_lookup(lock_hash, resource);
|
||||||
if (!linfo)
|
if (!linfo)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
DEBUGLOG("unlock_resource: lockid: %llx\n", linfo->lock_id);
|
DEBUGLOG("unlock_resource: lockid: %llx\n", linfo->lock_id);
|
||||||
err = saLckResourceUnlockAsync((SaInvocationT)(long)&lwait, linfo->lock_id);
|
err = saLckResourceUnlock(linfo->lock_id, SA_TIME_END);
|
||||||
if (err != SA_AIS_OK)
|
if (err != SA_AIS_OK)
|
||||||
{
|
{
|
||||||
DEBUGLOG("Unlock returned %d\n", err);
|
DEBUGLOG("Unlock returned %d\n", err);
|
||||||
return ais_to_errno(err);
|
return ais_to_errno(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for it to complete */
|
|
||||||
pthread_cond_wait(&lwait.cond, &lwait.mutex);
|
|
||||||
pthread_mutex_unlock(&lwait.mutex);
|
|
||||||
|
|
||||||
/* Release the resource */
|
/* Release the resource */
|
||||||
dm_hash_remove(lock_hash, resource);
|
dm_hash_remove(lock_hash, resource);
|
||||||
saLckResourceClose(linfo->res_handle);
|
saLckResourceClose(linfo->res_handle);
|
||||||
free(linfo);
|
free(linfo);
|
||||||
|
|
||||||
return ais_to_errno(lwait.status);
|
return ais_to_errno(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _sync_lock(const char *resource, int mode, int flags, int *lockid)
|
static int _sync_lock(const char *resource, int mode, int flags, int *lockid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user