1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 03:27:58 +03:00

Fix locking query compatibility with old external locking libraries.

This commit is contained in:
Milan Broz 2009-05-20 12:58:03 +00:00
parent 49b9da5a56
commit 6ac30c94f2
4 changed files with 28 additions and 3 deletions

View File

@ -694,13 +694,30 @@ int lvs_in_vg_opened(const struct volume_group *vg)
*/
int lv_is_active(struct logical_volume *lv)
{
int ret;
if (_lv_active(lv->vg->cmd, lv, 0))
return 1;
if (!vg_is_clustered(lv->vg))
return 0;
return remote_lock_held(lv->lvid.s);
if ((ret = remote_lock_held(lv->lvid.s)) >= 0)
return ret;
/*
* Old compatibility code if locking doesn't support lock query
* FIXME: check status to not deactivate already activate device
*/
if (activate_lv_excl(lv->vg->cmd, lv)) {
deactivate_lv(lv->vg->cmd, lv);
return 0;
}
/*
* Exclusive local activation failed so assume it is active elsewhere.
*/
return 1;
}
/*

View File

@ -1,4 +1,5 @@
locking_init
locking_end
lock_resource
lock_resource_query
reset_locking

View File

@ -26,6 +26,7 @@ static int (*_lock_fn) (struct cmd_context * cmd, const char *resource,
uint32_t flags) = NULL;
static int (*_init_fn) (int type, struct config_tree * cft,
uint32_t *flags) = NULL;
static int (*_lock_query_fn) (const char *resource, int *mode) = NULL;
static int _lock_resource(struct cmd_context *cmd, const char *resource,
uint32_t flags)
@ -88,6 +89,10 @@ int init_external_locking(struct locking_type *locking, struct cmd_context *cmd)
return 0;
}
if (!(_lock_query_fn = dlsym(_locking_lib, "lock_resource_query")))
log_warn("WARNING: %s: _lock_resource_query() missing: "
"Using inferior activation method.", libname);
log_verbose("Loaded external locking library %s", libname);
return _init_fn(2, cmd->cft, &locking->flags);
}

View File

@ -489,11 +489,13 @@ int remote_lock_held(const char *vol)
if (!locking_is_clustered())
return 0;
if (!_locking.lock_resource_query)
return -1;
/*
* If an error occured, expect that volume is active
*/
if (!_locking.lock_resource_query ||
!_locking.lock_resource_query(vol, &mode)) {
if (!_locking.lock_resource_query(vol, &mode)) {
stack;
return 1;
}