mirror of
git://sourceware.org/git/lvm2.git
synced 2025-04-01 18:50:41 +03:00
Fix locking query compatibility with old external locking libraries.
This commit is contained in:
parent
49b9da5a56
commit
6ac30c94f2
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,5 @@
|
||||
locking_init
|
||||
locking_end
|
||||
lock_resource
|
||||
lock_resource_query
|
||||
reset_locking
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user