summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2015-06-09 15:55:14 -0500
committerDavid Teigland <teigland@redhat.com>2015-06-23 17:08:53 -0500
commit88d0600cf64d158fd44867cd12e795cae795fea2 (patch)
tree688544354c85936bf3ae6fbd4b1164574d2401da
parent92077ba3ef336fcfbc56c2f386092a02f45027a7 (diff)
downloadlvm2-88d0600cf64d158fd44867cd12e795cae795fea2.tar.gz
lvmlockd: remove lv lock_type
-rw-r--r--daemons/lvmlockd/lvmlockd-core.c5
-rw-r--r--lib/format_text/export.c7
-rw-r--r--lib/format_text/import_vsn1.c5
-rw-r--r--lib/locking/lvmlockd.c98
-rw-r--r--lib/locking/lvmlockd.h26
-rw-r--r--lib/metadata/lv.c6
-rw-r--r--lib/metadata/lv.h2
-rw-r--r--lib/metadata/lv_manip.c25
-rw-r--r--lib/metadata/metadata-exported.h2
-rw-r--r--lib/metadata/metadata.c3
-rw-r--r--lib/report/columns.h1
-rw-r--r--lib/report/properties.c2
-rw-r--r--lib/report/report.c10
-rw-r--r--tools/lvconvert.c52
-rw-r--r--tools/lvcreate.c4
-rw-r--r--tools/vgchange.c16
16 files changed, 122 insertions, 142 deletions
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index cf3023ca4..7c962c8eb 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -1349,6 +1349,11 @@ static int res_update(struct lockspace *ls, struct resource *r,
return 0;
}
+/*
+ * There is nothing to deallocate when freeing a dlm LV, the LV
+ * will simply be unlocked by rem_resource.
+ */
+
static int free_lv(struct lockspace *ls, struct resource *r)
{
if (ls->lm_type == LD_LM_SANLOCK)
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index 8ebd3e930..a8fc2f4a2 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -660,11 +660,8 @@ static int _print_lv(struct formatter *f, struct logical_volume *lv)
lv->timestamp);
}
- if (lv->lock_type) {
- outf(f, "lock_type = \"%s\"", lv->lock_type);
- if (lv->lock_args)
- outf(f, "lock_args = \"%s\"", lv->lock_args);
- }
+ if (lv->lock_args)
+ outf(f, "lock_args = \"%s\"", lv->lock_args);
if (lv->alloc != ALLOC_INHERIT)
outf(f, "allocation_policy = \"%s\"",
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index 9c034c203..2cd75153a 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -579,11 +579,6 @@ static int _read_lvnames(struct format_instance *fid __attribute__((unused)),
return 0;
}
- if (dm_config_get_str(lvn, "lock_type", &str)) {
- if (!(lv->lock_type = dm_pool_strdup(mem, str)))
- return_0;
- }
-
if (dm_config_get_str(lvn, "lock_args", &str)) {
if (!(lv->lock_args = dm_pool_strdup(mem, str)))
return_0;
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index fb5532eac..6803d1529 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -1890,7 +1890,7 @@ static int _lockd_lv_thin(struct cmd_context *cmd, struct logical_volume *lv,
/*
* If the VG has no lock_type, then this function can return immediately.
- * The LV itself may have no lock (NULL lv->lock_type), but the lock request
+ * The LV itself may have no lock (NULL lv->lock_args), but the lock request
* may be directed to another lock, e.g. the pool LV lock in _lockd_lv_thin.
* If the lock request is not directed to another LV, and the LV has no
* lock_type set, it means that the LV has no lock, and no locking is done
@@ -1920,7 +1920,10 @@ int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv,
if (lv_is_thin_type(lv))
return _lockd_lv_thin(cmd, lv, def_mode, flags);
- if (!is_lockd_type(lv->lock_type))
+ /*
+ * An LV with NULL lock_args does not have a lock of its own.
+ */
+ if (!lv->lock_args)
return 1;
/*
@@ -2008,8 +2011,8 @@ out:
return ret;
}
-static int _free_lv_sanlock(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id, const char *lock_args)
+static int _free_lv(struct cmd_context *cmd, struct volume_group *vg,
+ const char *lv_name, struct id *lv_id, const char *lock_args)
{
char lv_uuid[64] __attribute__((aligned(8)));
daemon_reply reply;
@@ -2028,7 +2031,7 @@ static int _free_lv_sanlock(struct cmd_context *cmd, struct volume_group *vg,
"vg_name = %s", vg->name,
"lv_name = %s", lv_name,
"lv_uuid = %s", lv_uuid,
- "vg_lock_type = %s", "sanlock",
+ "vg_lock_type = %s", vg->lock_type,
"vg_lock_args = %s", vg->lock_args,
"lv_lock_args = %s", lock_args ?: "none",
NULL);
@@ -2040,7 +2043,7 @@ static int _free_lv_sanlock(struct cmd_context *cmd, struct volume_group *vg,
}
if (!ret)
- log_error("_free_lv_sanlock lvmlockd result %d", result);
+ log_error("_free_lv lvmlockd result %d", result);
daemon_reply_destroy(reply);
@@ -2048,38 +2051,35 @@ static int _free_lv_sanlock(struct cmd_context *cmd, struct volume_group *vg,
}
int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id,
+ struct logical_volume *lv,
const char *lock_type, const char **lock_args)
{
/* sanlock is the only lock type that sets per-LV lock_args. */
if (!strcmp(lock_type, "sanlock"))
- return _init_lv_sanlock(cmd, vg, lv_name, lv_id, lock_args);
+ return _init_lv_sanlock(cmd, vg, lv->name, &lv->lvid.id[1], lock_args);
return 1;
}
/*
* lvcreate
*
- * lvcreate sets lp lock_type to the vg lock_type, so any lv
- * created in a lockd vg will inherit the lock_type of the vg.
- * In some cases, e.g. thin lvs, this function may decide
- * that the lv should not be given a lock, in which case it
- * sets lp lock_type to NULL, which will cause the lv to not
- * have a lock_type set in its metadata. A lockd_lv() request
- * on an lv with no lock_type will do nothing (unless the lv
- * type causes the lock request to be directed to another lv
- * with a lock, e.g. to the thin pool LV for thin LVs.)
+ * An LV created in a lockd VG inherits the lock_type of the VG. In some
+ * cases, e.g. thin LVs, this function may decide that the LV should not be
+ * given a lock, in which case it sets lp lock_args to NULL, which will cause
+ * the LV to not have lock_args set in its metadata. A lockd_lv() request on
+ * an LV with no lock_args will do nothing (unless the LV type causes the lock
+ * request to be directed to another LV with a lock, e.g. to the thin pool LV
+ * for thin LVs.)
*
* Current limitations:
* - cache-type LV's in a lockd VG must be created with lvconvert.
* - creating a thin pool and thin lv in one command is not allowed.
*/
-int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id,
+int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv,
struct lvcreate_params *lp)
{
- int lock_type_num = lock_type_to_num(lp->lock_type);
+ int lock_type_num = lock_type_to_num(vg->lock_type);
if (cmd->lock_lv_mode && !strcmp(cmd->lock_lv_mode, "na"))
return 1;
@@ -2096,8 +2096,12 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
- if (seg_is_cache(lp) || seg_is_cache_pool(lp)) {
- log_error("Use lvconvert for cache with lock type %s", lp->lock_type);
+ if (!lp->needs_lockd_init) {
+ /* needs_lock_init is set for LVs that need a lockd lock. */
+ return 1;
+
+ } else if (seg_is_cache(lp) || seg_is_cache_pool(lp)) {
+ log_error("Use lvconvert for cache with lock type %s", vg->lock_type);
return 0;
} else if (!seg_is_thin_volume(lp) && lp->snapshot) {
@@ -2117,7 +2121,7 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
log_error("Failed to lock origin LV %s/%s", vg->name, lp->origin_name);
return 0;
}
- lp->lock_type = NULL;
+ lv->lock_args = NULL;
return 1;
} else if (seg_is_thin(lp)) {
@@ -2128,7 +2132,7 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
/*
* Creating a new thin lv or snapshot. These lvs do not get
* their own lock but use the pool lock. If an lv does not
- * use its own lock, its lock_type is set to NULL.
+ * use its own lock, its lock_args is set to NULL.
*/
if (!(lvl = find_lv_in_vg(vg, lp->pool_name))) {
@@ -2139,20 +2143,16 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
log_error("Failed to lock thin pool %s/%s", vg->name, lp->pool_name);
return 0;
}
- lp->lock_type = NULL;
+ lv->lock_args = NULL;
return 1;
} else if (seg_is_thin_volume(lp) && lp->create_pool) {
/*
* Creating a thin pool and a thin lv in it. We could
- * probably make this work by setting lp->lock_type and
- * lp->lock_args to NULL in lv_create_single after
- * creating the pool lv. Then we would just set
- * lv_name = lp->pool_name here. Stop it at least for now
- * to try to slow down some of the unnecessary complexity.
+ * probably make this work.
*/
- log_error("Create thin pool and thin lv separately with lock type %s",
- lp->lock_type);
+ log_error("Create thin pool and thin LV separately with lock type %s",
+ vg->lock_type);
return 0;
} else if (!seg_is_thin_volume(lp) && lp->create_pool) {
@@ -2170,6 +2170,8 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
}
/*
+ * The LV gets its own lock, so set lock_args to non-NULL.
+ *
* lockd_init_lv_args() will be called during vg_write()
* to complete the sanlock LV lock initialization, where
* actual space on disk is allocated. Waiting to do this
@@ -2182,14 +2184,15 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
* lvcreate:
*
* return lockd_init_lv_args(cmd, vg, lv_name_lock, lv_id,
- * lp->lock_type, &lp->lock_args);
+ * vg->lock_type, &lv->lock_args);
*/
- if (!strcmp(lp->lock_type, "sanlock"))
- lp->lock_args = "pending";
+ if (!strcmp(vg->lock_type, "sanlock"))
+ lv->lock_args = "pending";
+ else if (!strcmp(vg->lock_type, "dlm"))
+ lv->lock_args = "dlm";
return 1;
-
}
/* lvremove */
@@ -2203,10 +2206,12 @@ int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg,
switch (lock_type_to_num(vg->lock_type)) {
case LOCK_TYPE_NONE:
case LOCK_TYPE_CLVM:
- case LOCK_TYPE_DLM:
return 1;
+ case LOCK_TYPE_DLM:
case LOCK_TYPE_SANLOCK:
- return _free_lv_sanlock(cmd, vg, lv_name, lv_id, lock_args);
+ if (!lock_args)
+ return 1;
+ return _free_lv(cmd, vg, lv_name, lv_id, lock_args);
default:
log_error("lockd_free_lv: unknown lock_type.");
return 0;
@@ -2382,3 +2387,20 @@ out:
return lock_type;
}
+/* Some LV types have no lock. */
+
+int lockd_lv_uses_lock(struct logical_volume *lv)
+{
+ if (!lv_is_visible(lv) ||
+ lv_is_thin_volume(lv) ||
+ lv_is_thin_pool_data(lv) ||
+ lv_is_thin_pool_metadata(lv) ||
+ lv_is_pool_metadata_spare(lv) ||
+ lv_is_cache_pool(lv) ||
+ lv_is_cache_pool_data(lv) ||
+ lv_is_cache_pool_metadata(lv) ||
+ lv_is_lockd_sanlock_lv(lv))
+ return 0;
+ return 1;
+}
+
diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h
index 41c82b64f..7a50ebc37 100644
--- a/lib/locking/lvmlockd.h
+++ b/lib/locking/lvmlockd.h
@@ -137,18 +137,19 @@ int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv,
/* lvcreate/lvremove use init/free */
-int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id, struct lvcreate_params *lp);
+int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv,
+ struct lvcreate_params *lp);
+int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
+ struct logical_volume *lv, const char *lock_type, const char **lock_args);
int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg,
const char *lv_name, struct id *lv_id, const char *lock_args);
-int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id, const char *lock_type, const char **lock_args);
-
const char *lockd_running_lock_type(struct cmd_context *cmd);
int handle_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg);
+int lockd_lv_uses_lock(struct logical_volume *lv);
+
#else /* LVMLOCKD_SUPPORT */
static inline void lvmlockd_set_socket(const char *sock)
@@ -251,19 +252,19 @@ static inline int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv,
}
static inline int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id, struct lvcreate_params *lp)
+ struct logical_volume *lv, struct lvcreate_params *lp)
{
return 0;
}
-static inline int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id, const char *lock_args)
+static inline int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
+ struct logical_volume *lv, const char *lock_type, const char **lock_args)
{
return 0;
}
-static inline int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
- const char *lv_name, struct id *lv_id, const char *lock_type, const char **lock_args)
+static inline int lockd_free_lv(struct cmd_context *cmd, struct volume_group *vg,
+ const char *lv_name, struct id *lv_id, const char *lock_args)
{
return 0;
}
@@ -278,6 +279,11 @@ static inline int handle_sanlock_lv(struct cmd_context *cmd, struct volume_group
return 0;
}
+static inline int lockd_lv_uses_lock(struct logical_volume *lv)
+{
+ return 0;
+}
+
#endif /* LVMLOCKD_SUPPORT */
#endif
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 8813f24a5..24fbefe05 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -1020,12 +1020,6 @@ char *lv_profile_dup(struct dm_pool *mem, const struct logical_volume *lv)
return dm_pool_strdup(mem, profile_name);
}
-char *lv_lock_type_dup(struct dm_pool *mem, const struct logical_volume *lv)
-{
- const char *lock_type = lv->lock_type ? lv->lock_type : "";
- return dm_pool_strdup(mem, lock_type);
-}
-
char *lv_lock_args_dup(struct dm_pool *mem, const struct logical_volume *lv)
{
const char *lock_args = lv->lock_args ? lv->lock_args : "";
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 5523b133f..d7977709a 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -53,7 +53,6 @@ struct logical_volume {
uint64_t timestamp;
unsigned new_lock_args:1;
const char *hostname;
- const char *lock_type;
const char *lock_args;
};
@@ -106,7 +105,6 @@ const struct logical_volume *lv_lock_holder(const struct logical_volume *lv);
const struct logical_volume *lv_ondisk(const struct logical_volume *lv);
struct profile *lv_config_profile(const struct logical_volume *lv);
char *lv_profile_dup(struct dm_pool *mem, const struct logical_volume *lv);
-char *lv_lock_type_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_lock_args_dup(struct dm_pool *mem, const struct logical_volume *lv);
int lv_mirror_image_in_sync(const struct logical_volume *lv);
int lv_raid_image_in_sync(const struct logical_volume *lv);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b5ded0622..9dabe6ee7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5831,8 +5831,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
backup(vg);
lockd_lv(cmd, lock_lv, "un", LDLV_PERSISTENT | LDLV_MODE_NOARG);
- if (lv->lock_type)
- lockd_free_lv(cmd, vg, lv->name, &lv->lvid.id[1], lv->lock_args);
+ lockd_free_lv(cmd, vg, lv->name, &lv->lvid.id[1], lv->lock_args);
if (!suppress_remove_message && visible)
log_print_unless_silent("Logical volume \"%s\" successfully removed", lv->name);
@@ -7217,23 +7216,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
/*
- * lockd_init_lv clears lp lock_type if this LV does not use its own lock.
- * TODO: use lockd_free_lv if lv_extend fails below.
+ * The specific LV may not use a lock. lockd_init_lv() sets
+ * lv->lock_args to NULL if this LV does not use its own lock.
*/
- if (lp->lock_type && !lockd_init_lv(vg->cmd, vg, lv->name, &lv->lvid.id[1], lp))
- return_NULL;
-
- if (lp->lock_type && !(lv->lock_type = dm_pool_strdup(cmd->mem, lp->lock_type))) {
- log_error("Failed to allocate lock_type");
- lockd_free_lv(vg->cmd, vg, lp->lv_name, &lv->lvid.id[1], lp->lock_args);
- return NULL;
- }
- if (lp->lock_args && !(lv->lock_args = dm_pool_strdup(cmd->mem, lp->lock_args))) {
- log_error("Failed to allocate lock_args");
- lockd_free_lv(vg->cmd, vg, lp->lv_name, &lv->lvid.id[1], lp->lock_args);
- return NULL;
- }
+ if (!lockd_init_lv(vg->cmd, vg, lv, lp))
+ return_NULL;
dm_list_splice(&lv->tags, &lp->tags);
@@ -7542,8 +7530,7 @@ deactivate_and_revert_new_lv:
}
revert_new_lv:
- if (lp->lock_type)
- lockd_free_lv(vg->cmd, vg, lp->lv_name, &lv->lvid.id[1], lp->lock_args);
+ lockd_free_lv(vg->cmd, vg, lp->lv_name, &lv->lvid.id[1], lp->lock_args);
/* FIXME Better to revert to backup of metadata? */
if (!lv_remove(lv) || !vg_write(vg) || !vg_commit(vg))
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index a4df33c0e..734b76a9f 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -866,13 +866,13 @@ struct lvcreate_params {
#define THIN_CHUNK_SIZE_CALC_METHOD_GENERIC 0x01
#define THIN_CHUNK_SIZE_CALC_METHOD_PERFORMANCE 0x02
int thin_chunk_size_calc_policy;
+ unsigned needs_lockd_init : 1;
const char *vg_name; /* only-used when VG is not yet opened (in /tools) */
const char *lv_name; /* all */
const char *origin_name; /* snap */
const char *pool_name; /* thin */
- const char *lock_type;
const char *lock_args;
/* Keep args given by the user on command line */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 0d41dd465..cf7b71911 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2822,8 +2822,7 @@ int vg_write(struct volume_group *vg)
dm_list_iterate_items(lvl, &vg->lvs) {
if (lvl->lv->lock_args && !strcmp(lvl->lv->lock_args, "pending")) {
- if (!lockd_init_lv_args(vg->cmd, vg, lvl->lv->name, &lvl->lv->lvid.id[1],
- lvl->lv->lock_type, &lvl->lv->lock_args)) {
+ if (!lockd_init_lv_args(vg->cmd, vg, lvl->lv, vg->lock_type, &lvl->lv->lock_args)) {
log_error("Cannot allocate lock for new LV.");
return 0;
}
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 0e01bd82c..22141d885 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -84,7 +84,6 @@ FIELD(LVS, lv, STR, "Meta", lvid, 4, metadatalv, metadata_lv, "For thin and cach
FIELD(LVS, lv, STR, "Pool", lvid, 4, poollv, pool_lv, "For thin volumes, the thin pool LV for this volume.", 0)
FIELD(LVS, lv, STR_LIST, "LV Tags", tags, 7, tags, lv_tags, "Tags, if any.", 0)
FIELD(LVS, lv, STR, "LProfile", lvid, 8, lvprofile, lv_profile, "Configuration profile attached to this LV.", 0)
-FIELD(LVS, lv, STR, "Lock Type", lvid, 9, lvlocktype, lv_locktype, "Lock type of the LV used by lvmlockd.", 0)
FIELD(LVS, lv, STR, "Lock Args", lvid, 9, lvlockargs, lv_lockargs, "Lock args of the LV used by lvmlockd.", 0)
FIELD(LVS, lv, STR, "Time", lvid, 26, lvtime, lv_time, "Creation time of the LV, if known", 0)
FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 4b9b7b299..108836f2e 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -350,8 +350,6 @@ GET_LV_STR_PROPERTY_FN(lv_active, lv_active_dup(lv->vg->vgmem, lv))
#define _lv_active_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_profile, lv_profile_dup(lv->vg->vgmem, lv))
#define _lv_profile_set prop_not_implemented_set
-GET_LV_STR_PROPERTY_FN(lv_locktype, lv_lock_type_dup(lv->vg->vgmem, lv))
-#define _lv_locktype_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(lv_lockargs, lv_lock_args_dup(lv->vg->vgmem, lv))
#define _lv_lockargs_set prop_not_implemented_set
diff --git a/lib/report/report.c b/lib/report/report.c
index 426517323..5c6f64762 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -369,16 +369,6 @@ static int _lvprofile_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, "", NULL);
}
-static int _lvlocktype_disp(struct dm_report *rh, struct dm_pool *mem,
- struct dm_report_field *field,
- const void *data, void *private)
-{
- const struct logical_volume *lv = (const struct logical_volume *) data;
- const char *repstr = lv->lock_type ? lv->lock_type : "";
-
- return _string_disp(rh, mem, field, &repstr, private);
-}
-
static int _lvlockargs_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 6161b71cf..5b84cd868 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2648,16 +2648,15 @@ static int _lvconvert_pool(struct cmd_context *cmd,
struct logical_volume *data_lv;
struct logical_volume *metadata_lv = NULL;
struct logical_volume *pool_metadata_lv;
- char *free_data_name = NULL;
- char *free_meta_name = NULL;
- struct id free_data_id;
- struct id free_meta_id;
+ char *lockd_data_args = NULL;
+ char *lockd_meta_args = NULL;
+ char *lockd_data_name = NULL;
+ char *lockd_meta_name = NULL;
+ struct id lockd_data_id;
+ struct id lockd_meta_id;
char metadata_name[NAME_LEN], data_name[NAME_LEN];
int activate_pool;
- memset(&free_data_id, 0, sizeof(free_data_id));
- memset(&free_meta_id, 0, sizeof(free_meta_id));
-
if (lp->pool_data_name) {
if ((lp->thin || lp->cache) &&
!strcmp(lp->pool_data_name, pool_lv->name)) {
@@ -2672,9 +2671,10 @@ static int _lvconvert_pool(struct cmd_context *cmd,
}
/* An existing LV needs to have its lock freed once it becomes a data LV. */
- if (!lv_is_pool(pool_lv)) {
- free_data_name = dm_pool_strdup(cmd->mem, pool_lv->name);
- memcpy(&free_data_id, &pool_lv->lvid.id[1], sizeof(struct id));
+ if (is_lockd_type(vg->lock_type) && !lv_is_pool(pool_lv) && pool_lv->lock_args) {
+ lockd_data_args = dm_pool_strdup(cmd->mem, pool_lv->lock_args);
+ lockd_data_name = dm_pool_strdup(cmd->mem, pool_lv->name);
+ memcpy(&lockd_data_id, &pool_lv->lvid.id[1], sizeof(struct id));
}
if (!lv_is_visible(pool_lv)) {
@@ -2733,8 +2733,11 @@ static int _lvconvert_pool(struct cmd_context *cmd,
metadata_lv = lp->pool_metadata_lv;
/* An existing LV needs to have its lock freed once it becomes a meta LV. */
- free_meta_name = dm_pool_strdup(cmd->mem, metadata_lv->name);
- memcpy(&free_meta_id, &metadata_lv->lvid.id[1], sizeof(struct id));
+ if (is_lockd_type(vg->lock_type) && metadata_lv->lock_args) {
+ lockd_meta_args = dm_pool_strdup(cmd->mem, metadata_lv->lock_args);
+ lockd_meta_name = dm_pool_strdup(cmd->mem, metadata_lv->name);
+ memcpy(&lockd_meta_id, &metadata_lv->lvid.id[1], sizeof(struct id));
+ }
if (metadata_lv == pool_lv) {
log_error("Can't use same LV for pool data and metadata LV %s.",
@@ -3005,19 +3008,16 @@ static int _lvconvert_pool(struct cmd_context *cmd,
*/
if (is_lockd_type(vg->lock_type)) {
if (segtype_is_cache_pool(lp->segtype)) {
- data_lv->lock_type = NULL;
data_lv->lock_args = NULL;
- metadata_lv->lock_type = NULL;
metadata_lv->lock_args = NULL;
} else {
- data_lv->lock_type = NULL;
data_lv->lock_args = NULL;
- metadata_lv->lock_type = NULL;
metadata_lv->lock_args = NULL;
- pool_lv->lock_type = dm_pool_strdup(cmd->mem, vg->lock_type);
- if (!strcmp(pool_lv->lock_type, "sanlock"))
+ if (!strcmp(vg->lock_type, "sanlock"))
pool_lv->lock_args = "pending";
+ else if (!strcmp(vg->lock_type, "dlm"))
+ pool_lv->lock_args = "dlm";
/* The lock_args will be set in vg_write(). */
}
}
@@ -3088,16 +3088,16 @@ out:
* Unlock and free the locks from existing LVs that became pool data
* and meta LVs.
*/
- if (free_data_name) {
- if (!lockd_lv_name(cmd, vg, free_data_name, &free_data_id, NULL, "un", LDLV_PERSISTENT))
- log_error("Failed to unlock pool data LV %s/%s", vg->name, free_data_name);
- lockd_free_lv(cmd, vg, free_data_name, &free_data_id, NULL);
+ if (lockd_data_name) {
+ if (!lockd_lv_name(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args, "un", LDLV_PERSISTENT))
+ log_error("Failed to unlock pool data LV %s/%s", vg->name, lockd_data_name);
+ lockd_free_lv(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args);
}
- if (free_meta_name) {
- if (!lockd_lv_name(cmd, vg, free_meta_name, &free_meta_id, NULL, "un", LDLV_PERSISTENT))
- log_error("Failed to unlock pool metadata LV %s/%s", vg->name, free_meta_name);
- lockd_free_lv(cmd, vg, free_meta_name, &free_meta_id, NULL);
+ if (lockd_meta_name) {
+ if (!lockd_lv_name(cmd, vg, lockd_meta_name, &lockd_meta_id, lockd_meta_args, "un", LDLV_PERSISTENT))
+ log_error("Failed to unlock pool metadata LV %s/%s", vg->name, lockd_meta_name);
+ lockd_free_lv(cmd, vg, lockd_meta_name, &lockd_meta_id, lockd_meta_args);
}
return r;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index ec9b312b1..f3167673d 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1528,8 +1528,8 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
lp.snapshot ? " as snapshot of " : "",
lp.snapshot ? lp.origin_name : "", lp.segtype->name);
- if (vg->lock_type && !(lp.lock_type = dm_pool_strdup(cmd->mem, vg->lock_type)))
- goto_out;
+ if (is_lockd_type(vg->lock_type))
+ lp.needs_lockd_init = 1;
if (!lv_create_single(vg, &lp))
goto_out;
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 181584518..ec713aa67 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -549,10 +549,8 @@ static int _vgchange_locktype(struct cmd_context *cmd,
vg->lock_type = "none";
vg->lock_args = NULL;
- dm_list_iterate_items(lvl, &vg->lvs) {
- lvl->lv->lock_type = "none";
+ dm_list_iterate_items(lvl, &vg->lvs)
lvl->lv->lock_args = NULL;
- }
return 1;
}
@@ -676,23 +674,15 @@ static int _vgchange_locktype(struct cmd_context *cmd,
lv = lvl->lv;
/* Some LV types have no lock. */
- if (!lv_is_visible(lv) ||
- lv_is_thin_volume(lv) ||
- lv_is_thin_pool_data(lv) ||
- lv_is_thin_pool_metadata(lv) ||
- lv_is_pool_metadata_spare(lv) ||
- lv_is_cache_pool(lv) ||
- lv_is_cache_pool_data(lv) ||
- lv_is_cache_pool_metadata(lv))
+ if (!lockd_lv_uses_lock(lv))
continue;
- if (!lockd_init_lv_args(cmd, vg, lv->name, &lv->lvid.id[1], lock_type, &lock_args)) {
+ if (!lockd_init_lv_args(cmd, vg, lv, lock_type, &lock_args)) {
log_error("Failed to init %s lock args LV %s/%s",
lock_type, vg->name, lv->name);
return 0;
}
- lv->lock_type = dm_pool_strdup(cmd->mem, lock_type);
lv->lock_args = lock_args;
}