master - WHATS_NEW: line for previous commit
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=08ac12d5e7dd83...
Commit: 08ac12d5e7dd8375fda49dc44c4ee924dcf05b1b
Parent: c0e17bca90326104020ba31b00fb9f66abf278b6
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jan 9 11:57:25 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jan 9 11:57:25 2015 +0100
WHATS_NEW: line for previous commit
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 419f9c9..893c382 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Do not filter out snapshot origin LVs as unusable devices for an LVM stack.
Fix incorrect rimage names when converting from mirror to raid1 LV (2.02.112).
Avoid excessive re-reading of metadata and related error messages in pvremove.
Check for cmirror availability during cluster mirror creation and activation.
9 years, 2 months
master - dev_manager: do not mark snapshot origins as unusable devices just because of possible blocked mirror underneath
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c0e17bca903261...
Commit: c0e17bca90326104020ba31b00fb9f66abf278b6
Parent: 9dbeacf303f34d4a9f4ccad666e44ca55b83fada
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jan 9 11:24:16 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jan 9 11:24:16 2015 +0100
dev_manager: do not mark snapshot origins as unusable devices just because of possible blocked mirror underneath
At first, all snapshot-origins where marked as unusable unconditionally
here, but we can't cut off whole snapshot-origin use in a stack just
because of this possible mirror state. This whole "device_is_usable"
check was even incorrectly part of persistent filter before commit
a843d0d97c66aae1872c05b0f6cf4bda176aae2 (where filter cleanup was
done).
The persistent filter is used only if obtain_device_list_from_udev=0,
which means that the former check for snapshot-origin here had not even
been hit with default configuration for a few years before commit
a843d0d97c66aae1872c05b0f6cf4bda176aae2 (the check for snapshot-origin and
skipping of this LV was introduced with commit a71d6051ed3d72af6895733c599cc44b49f24dbb
back in 2010).
The obtain_device_list_from_udev=1 (and hence not using persistent
filter and hence not hitting this check for snapshot-origins and skipping) has been
in action since commit edcda01a1e18af6599275801a8237fe10112ed6f (that is 2011).
So for 3 years this condition was not even checked with default configuration,
making it superfluous.
This all changed in 2014 with commit 8a843d0d97c66aae1872c05b0f6cf4bda176aae2
where "filter-usable" is introduced and since then all snapshot-origins
have been marked as unusable more often than before and making snapshot-origins
practically unusable in a stack.
This patch removes this incorrect check from commit a71d6051ed3d72af6895733c599cc44b49f24dbb
which caused snapshot-origins to be unusable more often recently.
If we want to fix this eventually in a correct way, we need to look
down the stack and if snapshot-origin is hit and there's a blocked
mirror underneath, only then mark the device as unusable. But mirrors
in stack are not supported anymore so it's questionable whether it's
worth spending more time on this at all...
---
lib/activate/dev_manager.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index e336933..18092db 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -547,18 +547,22 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
}
/*
- * Snapshot origin could be sitting on top of a mirror which
- * could be blocking I/O. Skip snapshot origins entirely for
- * now.
- *
- * FIXME: rather than skipping origin, check if mirror is
- * underneath and if the mirror is blocking I/O.
+ * FIXME: Snapshot origin could be sitting on top of a mirror
+ * which could be blocking I/O. We should add a check for the
+ * stack here and see if there's blocked mirror underneath.
+ * Currently, mirrors used as origin or snapshot is not
+ * supported anymore and in general using mirrors in a stack
+ * is disabled by default (with a warning that if enabled,
+ * it could cause various deadlocks).
+ * This is former check used, but it's not correct as it
+ * disables snapshot-origins to be used in a stack in
+ * general, not just over mirrors!
*/
- if (check.check_suspended && target_type && !strcmp(target_type, "snapshot-origin")) {
+ /*if (check.check_suspended && target_type && !strcmp(target_type, "snapshot-origin")) {
log_debug_activation("%s: Snapshot-origin device %s not usable.",
dev_name(dev), name);
goto out;
- }
+ }*/
if (target_type && strcmp(target_type, "error"))
only_error_target = 0;
9 years, 2 months
master - WHATS_NEW: previous commit
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9dbeacf303f34d...
Commit: 9dbeacf303f34d4a9f4ccad666e44ca55b83fada
Parent: aaecbb181838102e1ce58ea19df14eb69db79dd9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jan 7 13:47:16 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 7 13:47:16 2015 +0100
WHATS_NEW: previous commit
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 37611da..419f9c9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix incorrect rimage names when converting from mirror to raid1 LV (2.02.112).
Avoid excessive re-reading of metadata and related error messages in pvremove.
Check for cmirror availability during cluster mirror creation and activation.
Add cache_policy and cache_settings reporting fields.
9 years, 2 months
master - raid: fix mirror image naming when converting from mirror to raid1
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aaecbb18183810...
Commit: aaecbb181838102e1ce58ea19df14eb69db79dd9
Parent: ff1eca3b6f1b40158fa5a5877b1ad6de72e4ed1e
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Jan 7 13:25:08 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 7 13:25:08 2015 +0100
raid: fix mirror image naming when converting from mirror to raid1
$ lvcreate -l1 -m1 --type mirror vg
Logical volume "lvol0" created.
$ lvconvert --type raid1 vg/lvol0
Before:
$ lvs -a vg
LV VG Active Attr LSize Cpy%Sync Layout Role
lvol0 vg active rwi-a-r--- 4.00m 100.00 raid,raid1 public
[lvol0_mimage_0_rimage_0] vg active iwi-aor--- 4.00m linear private,raid,image
[lvol0_mimage_1_rimage_1] vg active iwi-aor--- 4.00m linear private,raid,image
[lvol0_rmeta_0] vg active ewi-aor--- 4.00m linear private,raid,metadata
[lvol0_rmeta_1] vg active ewi-aor--- 4.00m linear private,raid,metadata
Incorrect name: lvol0_mimage_0_rimage_0
With this patch applied:
$ lvs -a vg
LV VG Active Attr LSize Cpy%Sync Layout Role
lvol0 vg active rwi-a-r--- 4.00m 100.00 raid,raid1 public
[lvol0_rimage_0] vg active iwi-aor--- 4.00m linear private,raid,image
[lvol0_rimage_1] vg active iwi-aor--- 4.00m linear private,raid,image
[lvol0_rmeta_0] vg active ewi-aor--- 4.00m linear private,raid,metadata
[lvol0_rmeta_1] vg active ewi-aor--- 4.00m linear private,raid,metadata
Proper name: lvol0_rimage_0
---
lib/metadata/raid_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 59d3adb..6f951f4 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1409,7 +1409,7 @@ static int _convert_mirror_to_raid1(struct logical_volume *lv,
}
for (s = 0; s < seg->area_count; ++s) {
- if (!(new_name = _generate_raid_name(seg_lv(seg, s), "rimage", s)))
+ if (!(new_name = _generate_raid_name(lv, "rimage", s)))
return_0;
log_debug_metadata("Renaming %s to %s", seg_lv(seg, s)->name, new_name);
seg_lv(seg, s)->name = new_name;
9 years, 2 months
master - mirror: do not try to reactivate inactive mirror when removing its LVs which have missing PVs
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ff1eca3b6f1b40...
Commit: ff1eca3b6f1b40158fa5a5877b1ad6de72e4ed1e
Parent: e97023804a8aa94d723025506fa23cf4a5c323e9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jan 7 10:52:38 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jan 7 11:16:19 2015 +0100
mirror: do not try to reactivate inactive mirror when removing its LVs which have missing PVs
When mirror has missing PVs and there are mirror images on those missing
PVs, we delete the images and during this delete operation, we also
reactivate the LV. But if we're trying to reactivate the LV in cluster
which is not active and at the same time cmirrord is not running (which
is OK since we may have created the mirror LV as inactive), we end up
with:
"Error locking on node <node_name>: Shared cluster mirrors are not available."
That is because we're trying to activate the mirror LV without cmirrord.
However, there's no need to do this reactivation if the mirror LV (and
hence it's sub LVs) were not activated before.
This issue caused failure in mirror-vgreduce-removemissing.sh test
recently with this sequence (excerpt from the test script):
prepare_lvs_
lvcreate -an -Zn -l2 --type mirror -m1 --nosync -n $lv1 $vg "$dev1" $dev2" "$dev3":$BLOCKS
mimages_are_on_ $lv1 "$dev1" "$dev2"
mirrorlog_is_on_ $lv1 "$dev3"
aux disable_dev "$dev2"
vgreduce --removemissing --force $vg
The important thing about that test is that we're not running cmirrord,
we're activating the mirror with "-an" so it's inactive and then
vgreduce --removemissing tries to reactivate the mirror images
as part of the _delete_lv function call inside and since cmirrord
is not running, we end up with the "Shared cluster mirrors are not
available." error.
---
lib/metadata/mirror.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index bac1ffb..edbf7d4 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -420,7 +420,8 @@ static int _activate_lv_like_model(struct logical_volume *model,
/*
* Delete independent/orphan LV, it must acquire lock.
*/
-static int _delete_lv(struct logical_volume *mirror_lv, struct logical_volume *lv)
+static int _delete_lv(struct logical_volume *mirror_lv, struct logical_volume *lv,
+ int reactivate)
{
struct cmd_context *cmd = mirror_lv->vg->cmd;
struct dm_str_list *sl;
@@ -440,15 +441,17 @@ static int _delete_lv(struct logical_volume *mirror_lv, struct logical_volume *l
}
}
- /* FIXME: the 'model' should be 'mirror_lv' not 'lv', I think. */
- if (!_activate_lv_like_model(lv, lv))
- return_0;
+ if (reactivate) {
+ /* FIXME: the 'model' should be 'mirror_lv' not 'lv', I think. */
+ if (!_activate_lv_like_model(lv, lv))
+ return_0;
- /* FIXME Is this superfluous now? */
- sync_local_dev_names(cmd);
+ /* FIXME Is this superfluous now? */
+ sync_local_dev_names(cmd);
- if (!deactivate_lv(cmd, lv))
- return_0;
+ if (!deactivate_lv(cmd, lv))
+ return_0;
+ }
if (!lv_remove(lv))
return_0;
@@ -799,11 +802,11 @@ static int _split_mirror_images(struct logical_volume *lv,
}
/* Remove original mirror layer if it has been converted to linear */
- if (sub_lv && !_delete_lv(lv, sub_lv))
+ if (sub_lv && !_delete_lv(lv, sub_lv, 1))
return_0;
/* Remove the log if it has been converted to linear */
- if (detached_log_lv && !_delete_lv(lv, detached_log_lv))
+ if (detached_log_lv && !_delete_lv(lv, detached_log_lv, 1))
return_0;
return 1;
@@ -852,6 +855,7 @@ static int _remove_mirror_images(struct logical_volume *lv,
struct lv_list *lvl;
struct dm_list tmp_orphan_lvs;
uint32_t orig_removed = num_removed;
+ int reactivate;
if (removed)
*removed = 0;
@@ -864,6 +868,7 @@ static int _remove_mirror_images(struct logical_volume *lv,
if (collapse && (old_area_count - num_removed != 1)) {
log_error("Incompatible parameters to _remove_mirror_images");
return 0;
+
}
num_removed = 0;
@@ -1093,16 +1098,17 @@ static int _remove_mirror_images(struct logical_volume *lv,
}
/* Save or delete the 'orphan' LVs */
+ reactivate = lv_is_active(lv_lock_holder(lv));
if (!collapse) {
dm_list_iterate_items(lvl, &tmp_orphan_lvs)
- if (!_delete_lv(lv, lvl->lv))
+ if (!_delete_lv(lv, lvl->lv, reactivate))
return_0;
}
- if (temp_layer_lv && !_delete_lv(lv, temp_layer_lv))
+ if (temp_layer_lv && !_delete_lv(lv, temp_layer_lv, reactivate))
return_0;
- if (detached_log_lv && !_delete_lv(lv, detached_log_lv))
+ if (detached_log_lv && !_delete_lv(lv, detached_log_lv, reactivate))
return_0;
/* Mirror with only 1 area is 'in sync'. */
9 years, 2 months
master - pvremove: Avoid metadata re-reads & related error messages.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e97023804a8aa9...
Commit: e97023804a8aa94d723025506fa23cf4a5c323e9
Parent: 0987f290a7b53840c2811392868f050d9a632ea3
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jan 6 14:17:53 2015 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jan 6 14:27:30 2015 +0100
pvremove: Avoid metadata re-reads & related error messages.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 4 ++-
lib/metadata/pv_manip.c | 61 +++++++++++++++++++++++++++----------
liblvm/lvm_pv.c | 9 +++++-
test/shell/pvremove-warnings.sh | 5 +++
tools/pvremove.c | 15 +++++----
6 files changed, 69 insertions(+), 26 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c1a38c7..37611da 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Avoid excessive re-reading of metadata and related error messages in pvremove.
Check for cmirror availability during cluster mirror creation and activation.
Add cache_policy and cache_settings reporting fields.
Add missing recognition for --binary option with {pv,vg,lv}display -C.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index b8946ba..14a5ef5 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -635,7 +635,9 @@ struct physical_volume *pv_create(const struct cmd_context *cmd,
int pvremove_single(struct cmd_context *cmd, const char *pv_name,
void *handle __attribute__((unused)), unsigned force_count,
- unsigned prompt);
+ unsigned prompt, struct dm_list *pvslist);
+int pvremove_many(struct cmd_context *cmd, struct dm_list *pv_names,
+ unsigned force_count, unsigned prompt);
int pv_resize_single(struct cmd_context *cmd,
struct volume_group *vg,
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 6499e36..ce7f661 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -24,6 +24,7 @@
#include "display.h"
#include "label.h"
#include "archiver.h"
+#include "lvm-signal.h"
static struct pv_segment *_alloc_pv_segment(struct dm_pool *mem,
struct physical_volume *pv,
@@ -694,12 +695,11 @@ const char _really_wipe[] =
* 0 indicates we may not.
*/
static int pvremove_check(struct cmd_context *cmd, const char *name,
- unsigned force_count, unsigned prompt)
+ unsigned force_count, unsigned prompt, struct dm_list *pvslist)
{
struct device *dev;
struct label *label;
struct pv_list *pvl;
- struct dm_list *pvslist;
struct physical_volume *pv = NULL;
int r = 0;
@@ -720,10 +720,6 @@ static int pvremove_check(struct cmd_context *cmd, const char *name,
return 0;
}
- lvmcache_seed_infos_from_lvmetad(cmd);
- if (!(pvslist = get_pvs(cmd)))
- return_0;
-
dm_list_iterate_items(pvl, pvslist)
if (pvl->pv->dev == dev)
pv = pvl->pv;
@@ -765,26 +761,18 @@ static int pvremove_check(struct cmd_context *cmd, const char *name,
r = 1;
out:
- if (pvslist)
- dm_list_iterate_items(pvl, pvslist)
- free_pv_fid(pvl->pv);
return r;
}
int pvremove_single(struct cmd_context *cmd, const char *pv_name,
void *handle __attribute__((unused)), unsigned force_count,
- unsigned prompt)
+ unsigned prompt, struct dm_list *pvslist)
{
struct device *dev;
struct lvmcache_info *info;
int r = 0;
- if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
- log_error("Can't get lock for orphan PVs");
- return 0;
- }
-
- if (!pvremove_check(cmd, pv_name, force_count, prompt))
+ if (!pvremove_check(cmd, pv_name, force_count, prompt, pvslist))
goto out;
if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
@@ -820,9 +808,48 @@ int pvremove_single(struct cmd_context *cmd, const char *pv_name,
r = 1;
out:
+ return r;
+}
+
+int pvremove_many(struct cmd_context *cmd, struct dm_list *pv_names,
+ unsigned force_count, unsigned prompt)
+{
+ int ret = 1;
+ struct dm_list *pvslist = NULL;
+ struct pv_list *pvl;
+ const struct dm_str_list *pv_name;
+
+ if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
+ log_error("Can't get lock for orphan PVs");
+ return 0;
+ }
+
+ lvmcache_seed_infos_from_lvmetad(cmd);
+
+ if (!(pvslist = get_pvs(cmd))) {
+ ret = 0;
+ goto_out;
+ }
+
+ dm_list_iterate_items(pv_name, pv_names) {
+ if (!pvremove_single(cmd, pv_name->str, NULL, force_count, prompt, pvslist)) {
+ stack;
+ ret = 0;
+ }
+ if (sigint_caught()) {
+ ret = 0;
+ goto_out;
+ }
+ }
+
+out:
unlock_vg(cmd, VG_ORPHANS);
- return r;
+ if (pvslist)
+ dm_list_iterate_items(pvl, pvslist)
+ free_pv_fid(pvl->pv);
+
+ return ret;
}
int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index 64b01d5..24b2732 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -16,6 +16,7 @@
#include "lib.h"
#include "metadata.h"
#include "lvm-string.h"
+#include "str_list.h"
#include "lvm_misc.h"
#include "lvm2app.h"
#include "locking.h"
@@ -118,8 +119,14 @@ int lvm_pv_remove(lvm_t libh, const char *pv_name)
int rc = 0;
struct cmd_context *cmd = (struct cmd_context *)libh;
struct saved_env e = store_user_env(cmd);
+ struct dm_list pv_names;
- if (!pvremove_single(cmd, pv_name, NULL, 0, 0))
+ dm_list_init(&pv_names);
+
+ if (!str_list_add(cmd->mem, &pv_names, pv_name))
+ rc = -1;
+
+ if (rc >= 0 && !pvremove_many(cmd, &pv_names, 0, 0))
rc = -1;
restore_user_env(&e);
diff --git a/test/shell/pvremove-warnings.sh b/test/shell/pvremove-warnings.sh
index f9d2737..865a31e 100644
--- a/test/shell/pvremove-warnings.sh
+++ b/test/shell/pvremove-warnings.sh
@@ -14,3 +14,8 @@ aux prepare_devs 2
pvcreate "$dev1" "$dev2"
pvremove "$dev1" "$dev2" 2>&1 | tee pvremove.txt
not grep "No physical" pvremove.txt
+
+pvcreate "$dev1" "$dev2"
+vgcreate bla $dev1 $dev2
+pvremove -ff -y $dev1 $dev2 2>&1 | tee pvremove.txt
+not grep "device missing" pvremove.txt
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 035d4fd..b40ff79 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -18,9 +18,9 @@
int pvremove(struct cmd_context *cmd, int argc, char **argv)
{
int i;
- int ret = ECMD_PROCESSED;
unsigned force_count;
unsigned prompt;
+ struct dm_list pv_names;
if (!argc) {
log_error("Please enter a physical volume path");
@@ -30,15 +30,16 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv)
force_count = arg_count(cmd, force_ARG);
prompt = arg_count(cmd, yes_ARG);
+ dm_list_init(&pv_names);
+
for (i = 0; i < argc; i++) {
dm_unescape_colons_and_at_signs(argv[i], NULL, NULL);
- if (!pvremove_single(cmd, argv[i], NULL, force_count, prompt)) {
- stack;
- ret = ECMD_FAILED;
- }
- if (sigint_caught())
+ if (!str_list_add(cmd->mem, &pv_names, argv[i]))
return_ECMD_FAILED;
}
- return ret;
+ if (!pvremove_many(cmd, &pv_names, force_count, prompt))
+ return_ECMD_FAILED;
+
+ return ECMD_PROCESSED;
}
9 years, 2 months
master - lvmetad: Re-use fmt from the VG for PVs when possible.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0987f290a7b538...
Commit: 0987f290a7b53840c2811392868f050d9a632ea3
Parent: 509650ec4cb1ef65e277870e96976d7dd8882170
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Tue Jan 6 12:39:57 2015 +0100
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Tue Jan 6 14:27:30 2015 +0100
lvmetad: Re-use fmt from the VG for PVs when possible.
---
lib/cache/lvmetad.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 5612c1b..20302c1 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -264,7 +264,7 @@ static int _read_mda(struct lvmcache_info *info,
static struct lvmcache_info *_pv_populate_lvmcache(struct cmd_context *cmd,
struct dm_config_node *cn,
- dev_t fallback)
+ struct format_type *fmt, dev_t fallback)
{
struct device *dev;
struct id pvid, vgid;
@@ -283,7 +283,8 @@ static struct lvmcache_info *_pv_populate_lvmcache(struct cmd_context *cmd,
uint64_t devsize = dm_config_find_int64(cn->child, "dev_size", 0),
label_sector = dm_config_find_int64(cn->child, "label_sector", 0);
- struct format_type *fmt = fmt_name ? get_format_by_name(cmd, fmt_name) : NULL;
+ if (!fmt && fmt_name)
+ fmt = get_format_by_name(cmd, fmt_name);
if (!fmt) {
log_error("PV %s not recognised. Is the device missing?", pvid_txt);
@@ -422,7 +423,7 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd, const char *vgna
if ((pvcn = dm_config_find_node(top, "metadata/physical_volumes")))
for (pvcn = pvcn->child; pvcn; pvcn = pvcn->sib)
- _pv_populate_lvmcache(cmd, pvcn, 0);
+ _pv_populate_lvmcache(cmd, pvcn, fmt, 0);
top->key = name;
if (!(vg = import_vg_from_config_tree(reply.cft, fid)))
@@ -573,7 +574,7 @@ int lvmetad_pv_lookup(struct cmd_context *cmd, struct id pvid, int *found)
if (!(cn = dm_config_find_node(reply.cft->root, "physical_volume")))
goto_out;
- else if (!_pv_populate_lvmcache(cmd, cn, 0))
+ else if (!_pv_populate_lvmcache(cmd, cn, NULL, 0))
goto_out;
out_success:
@@ -603,7 +604,7 @@ int lvmetad_pv_lookup_by_dev(struct cmd_context *cmd, struct device *dev, int *f
goto out_success;
cn = dm_config_find_node(reply.cft->root, "physical_volume");
- if (!cn || !_pv_populate_lvmcache(cmd, cn, dev->dev))
+ if (!cn || !_pv_populate_lvmcache(cmd, cn, NULL, dev->dev))
goto_out;
out_success:
@@ -631,7 +632,7 @@ int lvmetad_pv_list_to_lvmcache(struct cmd_context *cmd)
if ((cn = dm_config_find_node(reply.cft->root, "physical_volumes")))
for (cn = cn->child; cn; cn = cn->sib)
- _pv_populate_lvmcache(cmd, cn, 0);
+ _pv_populate_lvmcache(cmd, cn, NULL, 0);
daemon_reply_destroy(reply);
9 years, 2 months
master - cmirror: do not check for cmirror availability when creating deactivated cluster mirrors
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=509650ec4cb1ef...
Commit: 509650ec4cb1ef65e277870e96976d7dd8882170
Parent: cba6186325f0d5806cf1ddec276b3bb8e178687a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Jan 6 09:59:04 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Jan 6 09:59:04 2015 +0100
cmirror: do not check for cmirror availability when creating deactivated cluster mirrors
When creating cluster mirrors while they're not supposed to be activated
immediately after creation, we don't need to check for cmirrord availability.
We can just create these mirrors and let the check to be done on activation
later on. This is addendum for commit cba6186325f0d5806cf1ddec276b3bb8e178687a.
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 260a76a..457cf9e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6817,8 +6817,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!(create_segtype = get_segtype_from_string(vg->cmd, "striped")))
return_0;
} else if (seg_is_mirrored(lp) || seg_is_raid(lp)) {
- if (lp->activate != CHANGE_AEY && vg_is_clustered(vg) &&
- seg_is_mirrored(lp) && !seg_is_raid(lp) &&
+ if (is_change_activating(lp->activate) && (lp->activate != CHANGE_AEY) &&
+ vg_is_clustered(vg) && seg_is_mirrored(lp) && !seg_is_raid(lp) &&
!cluster_mirror_is_available(vg->cmd)) {
log_error("Shared cluster mirrors are not available.");
return NULL;
9 years, 2 months
master - cmirror: check for cmirror availability during cluster mirror creation and activation
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cba6186325f0d5...
Commit: cba6186325f0d5806cf1ddec276b3bb8e178687a
Parent: 3e0ed83bc8103d36efe0e2dcdfd4b5ad5fd822a8
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jan 5 16:45:30 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jan 5 16:54:07 2015 +0100
cmirror: check for cmirror availability during cluster mirror creation and activation
When creating/activating clustered mirrors, we should have cmirrord
available and running. If it's not, we ended up with rather cryptic
errors like:
$ lvcreate -l1 -m1 --type mirror vg
Error locking on node 1: device-mapper: reload ioctl on failed: Invalid argument
Failed to activate new LV.
$ vgchange -ay vg
Error locking on node node 1: device-mapper: reload ioctl on failed: Invalid argument
This patch adds check for cmirror availability and it errors out
properly, also giving a more precise error messge so users are able
to identify the source of the problem easily:
$ lvcreate -l1 -m1 --type mirror vg
Shared cluster mirrors are not available.
$ vgchange -ay vg
Error locking on node 1: Shared cluster mirrors are not available.
Exclusively activated cluster mirror LVs are OK even without cmirrord:
$ vgchange -aey vg
1 logical volume(s) in volume group "vg" now active
---
WHATS_NEW | 1 +
lib/activate/activate.c | 10 ++++++++++
lib/metadata/lv_manip.c | 7 +++++++
lib/metadata/metadata-exported.h | 1 +
lib/metadata/mirror.c | 7 +++----
5 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index cc11a9a..c1a38c7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Check for cmirror availability during cluster mirror creation and activation.
Add cache_policy and cache_settings reporting fields.
Add missing recognition for --binary option with {pv,vg,lv}display -C.
Fix vgimportclone to notify lvmetad about changes done if lvmetad is used.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index dd0a4f9..c63cbde 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2203,6 +2203,16 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
goto out;
}
+ /*
+ * Check if cmirord is running for clustered mirrors.
+ */
+ if (!laopts->exclusive && vg_is_clustered(lv->vg) &&
+ lv_is_mirror(lv) && !lv_is_raid(lv) &&
+ !cluster_mirror_is_available(lv->vg->cmd)) {
+ log_error("Shared cluster mirrors are not available.");
+ goto out;
+ }
+
if (test_mode()) {
_skip("Activating '%s'.", lv->name);
r = 1;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 4483fba..260a76a 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6817,6 +6817,13 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!(create_segtype = get_segtype_from_string(vg->cmd, "striped")))
return_0;
} else if (seg_is_mirrored(lp) || seg_is_raid(lp)) {
+ if (lp->activate != CHANGE_AEY && vg_is_clustered(vg) &&
+ seg_is_mirrored(lp) && !seg_is_raid(lp) &&
+ !cluster_mirror_is_available(vg->cmd)) {
+ log_error("Shared cluster mirrors are not available.");
+ return NULL;
+ }
+
/* FIXME This will not pass cluster lock! */
init_mirror_in_sync(lp->nosync);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index d70602d..b8946ba 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1017,6 +1017,7 @@ int lv_remove_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
const char *get_mirror_log_name(int log_count);
int set_mirror_log_count(int *log_count, const char *mirrorlog);
+int cluster_mirror_is_available(struct cmd_context *cmd);
int is_temporary_mirror_layer(const struct logical_volume *lv);
struct logical_volume * find_temporary_mirror(const struct logical_volume *lv);
uint32_t lv_mirror_count(const struct logical_volume *lv);
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index d0b1ebf..bac1ffb 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -78,10 +78,9 @@ struct logical_volume *find_temporary_mirror(const struct logical_volume *lv)
*
* Returns: 1 if available, 0 otherwise
*/
-static int _cluster_mirror_is_available(struct logical_volume *lv)
+int cluster_mirror_is_available(struct cmd_context *cmd)
{
unsigned attr = 0;
- struct cmd_context *cmd = lv->vg->cmd;
const struct segment_type *segtype;
if (!(segtype = get_segtype_from_string(cmd, "mirror")))
@@ -90,7 +89,7 @@ static int _cluster_mirror_is_available(struct logical_volume *lv)
if (!segtype->ops->target_present)
return_0;
- if (!segtype->ops->target_present(lv->vg->cmd, NULL, &attr))
+ if (!segtype->ops->target_present(cmd, NULL, &attr))
return_0;
if (!(attr & MIRROR_LOG_CLUSTERED))
@@ -2127,7 +2126,7 @@ int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
if (!lv_is_pvmove(lv) && !lv_is_locked(lv) &&
lv_is_active(lv) &&
!lv_is_active_exclusive_locally(lv) && /* lv_is_active_remotely */
- !_cluster_mirror_is_available(lv)) {
+ !cluster_mirror_is_available(lv->vg->cmd)) {
log_error("Shared cluster mirrors are not available.");
return 0;
}
9 years, 2 months