*/
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;
}
/*
locking_init
locking_end
lock_resource
+lock_resource_query
reset_locking
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)
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);
}
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;
}