return ret;
}
-static int _query_lock_lv(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, char *lv_uuid,
- const char *lock_args, int *ex, int *sh)
+int lockd_query_lv(struct volume_group *vg, const char *lv_name, char *lv_uuid,
+ const char *lock_args, int *ex, int *sh)
{
daemon_reply reply;
const char *opts = NULL;
int result;
int ret;
+ if (!vg_is_shared(vg))
+ return 1;
+ if (!_use_lvmlockd)
+ return 0;
+ if (!_lvmlockd_connected)
+ return 0;
+
log_debug("lockd query LV %s/%s", vg->name, lv_name);
reply = _lockd_send("query_lock_lv",
!strcmp(cmd->name, "lvchange") || !strcmp(cmd->name, "lvconvert")) {
int ex = 0, sh = 0;
- if (!_query_lock_lv(cmd, vg, lv_name, lv_uuid, lock_args, &ex, &sh))
+ if (!lockd_query_lv(vg, lv_name, lv_uuid, lock_args, &ex, &sh))
return 1;
if (sh) {
log_warn("WARNING: shared LV may require refresh on other hosts where it is active.");
int lockd_lv_refresh(struct cmd_context *cmd, struct lvresize_params *lp);
+int lockd_query_lv(struct volume_group *vg, const char *lv_name, char *lv_uuid,
+ const char *lock_args, int *ex, int *sh);
+
#else /* LVMLOCKD_SUPPORT */
static inline void lvmlockd_set_socket(const char *sock)
return 0;
}
+static inline int lockd_query_lv(struct volume_group *vg, const char *lv_name,
+ char *lv_uuid, const char *lock_args, int *ex, int *sh)
+{
+ return 0;
+}
+
#endif /* LVMLOCKD_SUPPORT */
#endif /* _LVMLOCKD_H */
#include "lib/cache/lvmcache.h"
#include "lib/device/device-types.h"
#include "lib/datastruct/str_list.h"
+#include "lib/locking/lvmlockd.h"
#include <stddef.h> /* offsetof() */
#include <float.h> /* DBL_MAX */
const void *data, void *private)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- int active_exclusively;
+ int active_exclusively, _sh = 0;
if (!activation())
return _binary_undef_disp(rh, mem, field, private);
active_exclusively = lv_is_active(lv);
+ if (active_exclusively && vg_is_shared(lv->vg)) {
+ active_exclusively = 0;
+ if (!lockd_query_lv(lv->vg, lv->name, lv_uuid_dup(NULL, lv),
+ lv->lock_args, &active_exclusively, &_sh))
+ return _binary_undef_disp(rh, mem, field, private);
+ }
+
return _binary_disp(rh, mem, field, active_exclusively, GET_FIRST_RESERVED_NAME(lv_active_exclusively_y), private);
}