Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=403c87c1aa7b759c95c0d…
Commit: 403c87c1aa7b759c95c0d3e86eb919229b4fc242
Parent: 948f2d997990048ad6759bfb25f042a4ddbb6a83
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri May 25 13:26:16 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 30 09:25:45 2018 -0500
lvmlockd: enable creation of cache pool with lvcreate
Previously, cache pools needed to be created with lvconvert.
---
lib/locking/lvmlockd.c | 16 +++++++++++-----
tools/lvcreate.c | 3 +--
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 7f4fb2e..be37dc2 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2416,10 +2416,6 @@ int lockd_init_lv_args(struct cmd_context *cmd, struct volume_group *vg,
* 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, struct logical_volume *lv,
@@ -2448,7 +2444,17 @@ int lockd_init_lv(struct cmd_context *cmd, struct volume_group *vg, struct logic
/* 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)) {
+ } else if (seg_is_cache_pool(lp)) {
+ /*
+ * A cache pool does not use a lockd lock because it cannot be
+ * used by itself. When a cache pool is attached to an actual
+ * LV, the lockd lock for that LV covers the LV and the cache
+ * pool attached to it.
+ */
+ lv->lock_args = NULL;
+ return 1;
+
+ } else if (seg_is_cache(lp)) {
/*
* This should not happen because the command defs are
* checked and excluded for shared VGs early in lvcreate.
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 39170dd..ee6df02 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1638,8 +1638,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
lp->snapshot ? lp->origin_name : "", lp->segtype->name);
if (is_lockd_type(vg->lock_type)) {
- if (cmd->command->command_enum == lvcreate_cachepool_CMD ||
- cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_CMD ||
+ if (cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_CMD ||
cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD ||
cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool_CMD) {
log_error("Use lvconvert to create thin pools and cache pools in a shared VG.");
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=948f2d997990048ad6759…
Commit: 948f2d997990048ad6759bfb25f042a4ddbb6a83
Parent: db8d3bdfa93bb08a85953f2f3150ee27dffaa5fe
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri May 25 12:53:53 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 30 09:25:45 2018 -0500
lvmlockd: enable lvcreate of thin pool and thin lv in one command
Previously, thin pools and thin lvs need needed to be
created with separate commands, now the combined command
is permitted.
---
lib/metadata/lv_manip.c | 6 ++++++
tools/lvcreate.c | 3 +--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 8c76a38..4aefea0 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -8025,8 +8025,14 @@ struct logical_volume *lv_create_single(struct volume_group *vg,
if (!(lp->segtype = get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_THIN_POOL)))
return_NULL;
+ /* We want a lockd lock for the new thin pool, but not the thin lv. */
+ lp->needs_lockd_init = 1;
+
if (!(lv = _lv_create_an_lv(vg, lp, lp->pool_name)))
return_NULL;
+
+ lp->needs_lockd_init = 0;
+
} else if (seg_is_cache(lp)) {
if (!lp->origin_name) {
/* Until we have --pooldatasize we are lost */
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index e901968..39170dd 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1638,8 +1638,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
lp->snapshot ? lp->origin_name : "", lp->segtype->name);
if (is_lockd_type(vg->lock_type)) {
- if (cmd->command->command_enum == lvcreate_thin_vol_and_thinpool_CMD ||
- cmd->command->command_enum == lvcreate_cachepool_CMD ||
+ if (cmd->command->command_enum == lvcreate_cachepool_CMD ||
cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_CMD ||
cmd->command->command_enum == lvcreate_thin_vol_with_thinpool_or_sparse_snapshot_CMD ||
cmd->command->command_enum == lvcreate_cache_vol_with_new_origin_or_convert_to_cache_vol_with_cachepool_CMD) {
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=db8d3bdfa93bb08a85953…
Commit: db8d3bdfa93bb08a85953f2f3150ee27dffaa5fe
Parent: 3a4fe54ca12daf0af142e47092968cadb279d10b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 24 15:02:35 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 30 09:25:45 2018 -0500
lvmlockd: enable mirror split and merge with dlm lock_type
---
lib/metadata/mirror.c | 8 ++++++++
lib/metadata/raid_manip.c | 20 +++++++++++++++++---
man/lvmlockd.8_main | 5 ++++-
tools/lvconvert.c | 4 ++--
4 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 054ca99..25948ad 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -424,6 +424,11 @@ revert_new_lv:
static int _activate_lv_like_model(struct logical_volume *model,
struct logical_volume *lv)
{
+ /* FIXME: run all cases through lv_active_change when clvm variants are gone. */
+
+ if (is_lockd_type(lv->vg->lock_type))
+ return lv_active_change(lv->vg->cmd, lv, CHANGE_AEY, 0);
+
if (lv_is_active_exclusive(model)) {
if (!activate_lv_excl(lv->vg->cmd, lv))
return_0;
@@ -705,6 +710,9 @@ static int _split_mirror_images(struct logical_volume *lv,
return 0;
}
+ if (!strcmp(lv->vg->lock_type, "dlm"))
+ new_lv->lock_args = lv->lock_args;
+
if (!dm_list_empty(&split_images)) {
/*
* A number of images have been split and
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 703f285..0c631b4 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -21,6 +21,7 @@
#include "activate.h"
#include "lv_alloc.h"
#include "lvm-string.h"
+#include "lvmlockd.h"
typedef int (*fn_on_lv_t)(struct logical_volume *lv, void *data);
static int _eliminate_extracted_lvs_optional_write_vg(struct volume_group *vg,
@@ -3315,7 +3316,7 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
dm_list_init(&removal_lvs);
dm_list_init(&data_list);
- if (is_lockd_type(lv->vg->lock_type)) {
+ if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "sanlock")) {
log_error("Splitting raid image is not allowed with lock_type %s.",
lv->vg->lock_type);
return 0;
@@ -3394,6 +3395,9 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
lvl->lv->name = split_name;
+ if (!strcmp(lv->vg->lock_type, "dlm"))
+ lvl->lv->lock_args = lv->lock_args;
+
if (!vg_write(lv->vg)) {
log_error("Failed to write changes for %s.",
display_lvname(lv));
@@ -3419,7 +3423,13 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
* the original RAID LV having possibly had sub-LVs that have been
* shifted and renamed.
*/
- if (!activate_lv_excl_local(cmd, lvl->lv))
+
+ /* FIXME: run all cases through lv_active_change when clvm variants are gone. */
+
+ if (is_lockd_type(lvl->lv->vg->lock_type)) {
+ if (!lv_active_change(lv->vg->cmd, lvl->lv, CHANGE_AEY, 0))
+ return_0;
+ } else if (!activate_lv_excl_local(cmd, lvl->lv))
return_0;
dm_list_iterate_items(lvl, &removal_lvs)
@@ -3473,7 +3483,7 @@ int lv_raid_split_and_track(struct logical_volume *lv,
int s;
struct lv_segment *seg = first_seg(lv);
- if (is_lockd_type(lv->vg->lock_type)) {
+ if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "sanlock")) {
log_error("Splitting raid image is not allowed with lock_type %s.",
lv->vg->lock_type);
return 0;
@@ -3574,6 +3584,10 @@ int lv_raid_merge(struct logical_volume *image_lv)
return 0;
}
+ /* Ensure primary LV is not active elsewhere. */
+ if (!lockd_lv(vg->cmd, lvl->lv, "ex", 0))
+ return_0;
+
lv = lvl->lv;
seg = first_seg(lv);
for (s = 0; s < seg->area_count; ++s)
diff --git a/man/lvmlockd.8_main b/man/lvmlockd.8_main
index 6f982bd..90a07c7 100644
--- a/man/lvmlockd.8_main
+++ b/man/lvmlockd.8_main
@@ -852,7 +852,10 @@ using lvcreate to create cache pools or cache LVs (use lvconvert)
using external origins for thin LVs
.br
\[bu]
-splitting mirrors and snapshots from LVs
+splitting snapshots from LVs
+.br
+\[bu]
+splitting mirrors in sanlock VGs
.br
\[bu]
pvmove of entire PVs, or under LVs activated with shared locks
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 72f840a..e59a772 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -716,8 +716,8 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
*old_mimage_count = lv_mirror_count(lv);
*old_log_count = _get_log_count(lv);
- if (is_lockd_type(lv->vg->lock_type) && lp->keep_mimages) {
- /* FIXME: we need to create a lock for the new LV. */
+ if (lv->vg->lock_type && !strcmp(lv->vg->lock_type, "sanlock") && lp->keep_mimages) {
+ /* FIXME: we need to create a sanlock lock on disk for the new LV. */
log_error("Unable to split mirrors in VG with lock_type %s", lv->vg->lock_type);
return 0;
}
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7f7ec769d98cfe7af47b2…
Commit: 7f7ec769d98cfe7af47b202189b279f354763b5a
Parent: cd369d8a7fc5324f66d9965528ef9b92828b1a19
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 24 11:41:14 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 30 09:25:45 2018 -0500
lvmlockd: do not use an LV lock for some lvchange options
Some lvchange options can be used even if the LV is active.
---
lib/locking/lvmlockd.c | 5 +++--
tools/lvchange.c | 8 +++++---
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index bf9b7a9..7f4fb2e 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -2105,8 +2105,9 @@ int lockd_lv_name(struct cmd_context *cmd, struct volume_group *vg,
if (result == -EEXIST) {
/*
- * This happens if lvchange tries to modify the LV with an ex
- * LV lock when the LV is already active with a sh LV lock.
+ * This happens if a command like lvchange tries to modify the
+ * LV with an ex LV lock when the LV is already active with a
+ * sh LV lock.
*/
log_error("LV is already locked with incompatible mode: %s/%s", vg->name, lv_name);
return 0;
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 0aac5ac..6144852 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1056,9 +1056,11 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
int i, opt_enum;
uint32_t mr = 0;
- /* If LV is inactive here, ensure it's not active elsewhere. */
- if (!lockd_lv(cmd, lv, "ex", 0))
- return_ECMD_FAILED;
+ /*
+ * We do not acquire an lvmlockd lock on the LV here because these are
+ * VG metadata changes that do not conflict with the LV being active on
+ * another host.
+ */
/* First group of options which allow for one metadata commit/update for the whole group */
for (i = 0; i < cmd->command->ro_count; i++) {
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0c1d3db8dbe45df9f4311…
Commit: 0c1d3db8dbe45df9f4311f5c19014680ecf26613
Parent: 6a44dceb4895fc3e1b89cad0050bc766250d91a4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed May 23 13:16:48 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed May 30 09:25:45 2018 -0500
lvmlockd: accept repeated global lock requests
It's not an error if a command requests the global lock
when it has already acquired it. It shouldn't happen,
but there could be cases we've not found.
---
lib/locking/lvmlockd.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index d78b35c..bf9b7a9 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -1547,6 +1547,16 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
}
}
+ if (result == -EALREADY) {
+ /*
+ * This should generally not happen because commands should be coded
+ * to avoid reacquiring the global lock. If there is a case that's
+ * missed which causes the command to request the gl when it's already
+ * held, it's not a problem, so let it go.
+ */
+ log_debug("lockd global mode %s already held.", mode);
+ return 1;
+ }
if (!strcmp(mode, "un"))
return 1;