master - cmirror: Adjust region size to work around CPG msg limit to avoid hang.
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dd0ee35378cc2f...
Commit: dd0ee35378cc2ff405183fea9a3d970aab96ac63
Parent: a88430c6a1e072f326bf4f20fbfd6c11735d0e91
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Feb 25 14:42:15 2015 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Feb 25 14:42:15 2015 -0600
cmirror: Adjust region size to work around CPG msg limit to avoid hang.
cmirror uses the CPG library to pass messages around the cluster and maintain
its bitmaps. When a cluster mirror starts-up, it must send the current state
to any joining members - a checkpoint. When mirrors are large (or the region
size is small), the bitmap size can exceed the message limit of the CPG
library. When this happens, the CPG library returns CPG_ERR_TRY_AGAIN.
(This is also a bug in CPG, since the message will never be successfully sent.)
There is an outstanding bug (bug 682771) that is meant to lift this message
length restriction in CPG, but for now we work around the issue by increasing
the mirror region size. This limits the size of the bitmap and avoids any
issues we would otherwise have around checkpointing.
Since this issue only affects cluster mirrors, the region size adjustments
are only made on cluster mirrors. This patch handles cluster mirror issues
involving pvmove, lvconvert (from linear to mirror), and lvcreate. It also
ensures that when users convert a VG from single-machine to clustered, any
mirrors with too many regions (i.e. a bitmap that would be too large to
properly checkpoint) are trapped.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 3 +-
lib/metadata/metadata-exported.h | 6 ++++-
lib/metadata/mirror.c | 44 ++++++++++++++++++++++++++++++++++++-
lib/mirror/mirrored.c | 3 +-
tools/lvconvert.c | 6 +++-
tools/vgchange.c | 16 +++++++++++++
7 files changed, 72 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8e80241..c119f3e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.117 -
====================================
+ Fix hang by adjusting cluster mirror regionsize, avoiding CPG msg limit.
Do not crash when --cachepolicy is given without --cachesettings.
Add NEEDS_FOREIGN_VGS flag to vgimport so --foreign is always supplied.
Add --foreign to the 6 display and reporting tools and vgcfgbackup.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a77142c..c9c1145 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6854,7 +6854,8 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lp->region_size = adjusted_mirror_region_size(vg->extent_size,
lp->extents,
- lp->region_size, 0);
+ lp->region_size, 0,
+ vg_is_clustered(vg));
} else if (pool_lv && seg_is_thin_volume(lp)) {
if (!lv_is_thin_pool(pool_lv)) {
log_error("Logical volume %s is not a thin pool.",
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 2dbaaf0..758fa53 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1032,8 +1032,12 @@ 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);
+
+/* Remove CMIRROR_REGION_COUNT_LIMIT when http://bugzilla.redhat.com/682771 is fixed */
+#define CMIRROR_REGION_COUNT_LIMIT (256*1024 * 8)
uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
- uint32_t region_size, int internal);
+ uint32_t region_size, int internal, int clustered);
+
int remove_mirrors_from_segments(struct logical_volume *lv,
uint32_t new_mirrors, uint64_t status_mask);
int add_mirrors_to_segments(struct cmd_context *cmd, struct logical_volume *lv,
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index edbf7d4..3f2fa2f 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -159,9 +159,10 @@ struct lv_segment *find_mirror_seg(struct lv_segment *seg)
* For internal use only log only in verbose mode
*/
uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
- uint32_t region_size, int internal)
+ uint32_t region_size, int internal, int clustered)
{
uint64_t region_max;
+ uint64_t region_min, region_min_pow2;
region_max = (1 << (ffs((int)extents) - 1)) * (uint64_t) (1 << (ffs((int)extent_size) - 1));
@@ -175,6 +176,44 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
PRIu32 " sectors.", region_size);
}
+#ifdef CMIRROR_REGION_COUNT_LIMIT
+ if (clustered) {
+ /*
+ * The CPG code used by cluster mirrors can only handle a
+ * payload of < 1MB currently. (This deficiency is tracked by
+ * http://bugzilla.redhat.com/682771.) The region size for cluster
+ * mirrors must be restricted in such a way as to limit the
+ * size of the bitmap to < 512kB, because there are two bitmaps
+ * which get sent around during checkpointing while a cluster
+ * mirror starts up. Ergo, the number of regions must not
+ * exceed 512k * 8. We also need some room for the other
+ * checkpointing structures as well, so we reduce by another
+ * factor of two.
+ *
+ * This code should be removed when the CPG restriction is
+ * lifted.
+ */
+ region_min = extents;
+ region_min *= extent_size;
+ region_min /= CMIRROR_REGION_COUNT_LIMIT;
+ region_min_pow2 = 1;
+ while (region_min_pow2 < region_min)
+ region_min_pow2 *= 2;
+
+ if (region_size < region_min_pow2) {
+ if (internal)
+ log_print_unless_silent("Increasing mirror region size from %"
+ PRIu32 " to %" PRIu32 " sectors.",
+ region_size, region_min_pow2);
+ else
+ log_verbose("Increasing mirror region size from %"
+ PRIu32 " to %" PRIu32 " sectors.",
+ region_size, region_min_pow2);
+ region_size = region_min_pow2;
+ }
+ }
+#endif /* CMIRROR_REGION_COUNT_LIMIT */
+
return region_size;
}
@@ -1708,7 +1747,8 @@ static int _add_mirrors_that_preserve_segments(struct logical_volume *lv,
adjusted_region_size = adjusted_mirror_region_size(lv->vg->extent_size,
lv->le_count,
- region_size, 1);
+ region_size, 1,
+ vg_is_clustered(lv->vg));
if (!(ah = allocate_extents(lv->vg, NULL, segtype, 1, mirrors, 0, 0,
lv->le_count, allocatable_pvs, alloc, 0,
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 7ab11c2..e57e9bb 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -435,7 +435,8 @@ static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem
} else
region_size = adjusted_mirror_region_size(seg->lv->vg->extent_size,
seg->area_len,
- mirr_state->default_region_size, 1);
+ mirr_state->default_region_size, 1,
+ vg_is_clustered(seg->lv->vg));
if (!dm_tree_node_add_mirror_target(node, len))
return_0;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 9ec0b0b..0e6f162 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1209,7 +1209,8 @@ static int _lv_update_log_type(struct cmd_context *cmd,
if (old_log_count < log_count) {
region_size = adjusted_mirror_region_size(lv->vg->extent_size,
lv->le_count,
- region_size, 0);
+ region_size, 0,
+ vg_is_clustered(lv->vg));
if (!add_mirror_log(cmd, original_lv, log_count,
region_size, operable_pvs, alloc))
@@ -1425,7 +1426,8 @@ static int _lvconvert_mirrors_aux(struct cmd_context *cmd,
region_size = adjusted_mirror_region_size(lv->vg->extent_size,
lv->le_count,
- lp->region_size, 0);
+ lp->region_size, 0,
+ vg_is_clustered(lv->vg));
if (!operable_pvs)
operable_pvs = lp->pvh;
diff --git a/tools/vgchange.c b/tools/vgchange.c
index c03d814..bf3d97d 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -300,6 +300,8 @@ static int _vgchange_clustered(struct cmd_context *cmd,
struct volume_group *vg)
{
int clustered = arg_int_value(cmd, clustered_ARG, 0);
+ struct lv_list *lvl;
+ struct lv_segment *mirror_seg;
if (clustered && vg_is_clustered(vg)) {
if (vg->system_id && *vg->system_id)
@@ -338,6 +340,20 @@ static int _vgchange_clustered(struct cmd_context *cmd,
log_error("No volume groups changed.");
return 0;
}
+#ifdef CMIRROR_REGION_COUNT_LIMIT
+ dm_list_iterate_items(lvl, &vg->lvs) {
+ if (!lv_is_mirror(lvl->lv))
+ continue;
+ mirror_seg = first_seg(lvl->lv);
+ if ((lvl->lv->size / mirror_seg->region_size) >
+ CMIRROR_REGION_COUNT_LIMIT) {
+ log_error("Unable to convert %s to clustered mode:"
+ " Mirror region size of %s is too small.",
+ vg->name, lvl->lv->name);
+ return 0;
+ }
+ }
+#endif
}
if (!vg_set_system_id(vg, clustered ? NULL : cmd->system_id))
9 years, 2 months
master - lvcreate.8: Mention --cachepolicy and --cachesettings.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a88430c6a1e072...
Commit: a88430c6a1e072f326bf4f20fbfd6c11735d0e91
Parent: 0d313282f2f824e321c5a78bec2ab0c5cc37f2d1
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Feb 25 18:34:01 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Feb 25 18:34:01 2015 +0100
lvcreate.8: Mention --cachepolicy and --cachesettings.
---
man/lvcreate.8.in | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 8c1ee4b..de4f168 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -14,6 +14,10 @@ lvcreate \- create a logical volume in an existing volume group
.RB [ \-H | \-\-cache ]
.RB [ \-\-cachemode
.RI { writeback | writethrough }]
+.RB [ \-\-cachepolicy
+.IR policy ]
+.RB [ \-\-cachesettings
+.IR key=value ]
.RB [ \-\-cachepool
.IR CachePoolLogicalVolume { Name | Path }
.RB [ \-c | \-\-chunksize
@@ -246,6 +250,11 @@ Ignore the flag to skip Logical Volumes during activation.
Use \fB\-\-setactivationskip\fP option to set or reset
activation skipping flag persistently for logical volume.
.TP
+.BR \-\-cachepolicy " " policy ", " \-\-cachesettings " " key=value
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache policy and its associated tunable settings. In most use-cases,
+default values should be adequate.
+.TP
.B \-\-ignoremonitoring
Make no attempt to interact with dmeventd unless \fB\-\-monitor\fP
is specified.
9 years, 2 months
master - lvmcache.7: add a section on --cachepolicy/--cachesettings
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0d313282f2f824...
Commit: 0d313282f2f824e321c5a78bec2ab0c5cc37f2d1
Parent: aa30e95271734d213440dd1150e2bdc7c9f4f171
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Wed Feb 25 18:20:06 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Wed Feb 25 18:21:30 2015 +0100
lvmcache.7: add a section on --cachepolicy/--cachesettings
---
man/lvmcache.7.in | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/man/lvmcache.7.in b/man/lvmcache.7.in
index 24ce5b4..c77633a 100644
--- a/man/lvmcache.7.in
+++ b/man/lvmcache.7.in
@@ -254,6 +254,38 @@ defines the default cache mode.
# lvconvert \-\-type cache \-\-cachepool vg/cache1 vg/lv1
.fi
+.SS Cache policy & policy settings
+
+\&
+
+The cache subsystem has an additional per-LV parameter, namely the cache policy
+to use, and possibly the tunable parameters of the said cache policy. In the
+current implementation, two policies are available, "mq" which is the default
+policy and "cleaner" which is used to force the cache to write back (flush) all
+cached writes to the origin LV. Moreover, the "mq" policy has a number of
+tunable parameters: the defaults are chosen to be suitable for the vast
+majority of systems. However, under special circumstances, changing the tunable
+settings of the cache policy can improve performance.
+
+On an existing cache LV, the policy can be set (to "mq") and the cache settings
+can be changed using commands like these:
+
+.I Example
+
+.nf
+# lvchange \-\-cachepolicy mq vg/lv1
+# lvchange \-\-cachesettings 'migration_threshold=2048 random_threshold=4' \\
+ vg/lv1
+.fi
+
+Both commands can be combined, setting both cache policy and its settings
+together. Moreover, when creating a cache LV for the first time (using
+lvcreate), the \-\-cachepolicy and \-\-cachesettings parameters can be used as
+well. The current policy and the policy settings can be listed using the lvs
+command, using 'cache_policy' and 'cache_settings' fields:
+
+# lvs -o +cache_policy,cache_settings
+
.SS Spare metadata LV
\&
9 years, 2 months
master - vgcfgbackup: enable foreign VG access
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aa30e95271734d...
Commit: aa30e95271734d213440dd1150e2bdc7c9f4f171
Parent: 8668a9e81c5bde921c9c8e6ba1162c5d4f7ffbe5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 11:01:37 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 11:01:37 2015 -0600
vgcfgbackup: enable foreign VG access
Backup of a foreign VG is allowed.
---
tools/commands.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 3cb8f56..5cd7c2d 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -908,7 +908,7 @@ xx(tags,
xx(vgcfgbackup,
"Backup volume group configuration(s)",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
"vgcfgbackup\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
9 years, 2 months
master - systemid: silently ignore foreign vgs unless named
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8668a9e81c5bde...
Commit: 8668a9e81c5bde921c9c8e6ba1162c5d4f7ffbe5
Parent: 4ff9abd01f60e3bfe433da5596078a12fb49f9eb
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 10:44:42 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 10:53:52 2015 -0600
systemid: silently ignore foreign vgs unless named
A foreign VG should be silently ignored by a reporting/display
command like 'vgs'. If the reporting/display command specifies
a foreign VG by name on the command line, it should produce an
error message.
Scanning commands pvscan/vgscan/lvscan are always allowed to
read and update caches from all PVs, including those that belong
to foreign VGs.
Other non-report/display/scan commands always ignore a foreign
VG, or report an error if they attempt to use a foreign VG.
vgimport should always invalidate the lvmetad cache because
lvmetad likely holds a pre-vgexported copy of the VG.
(This is unrelated to using foreign VGs; the pre-vgexported
VG may have had no system_id at all.)
---
lib/commands/toolcontext.h | 1 +
lib/metadata/metadata.c | 15 +++++++++++++--
tools/commands.h | 20 ++++++++++----------
tools/lvmcmdline.c | 6 +++---
tools/tools.h | 4 ++--
tools/vgimport.c | 11 +++++++++++
6 files changed, 40 insertions(+), 17 deletions(-)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 8b38fb1..f491d1c 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -98,6 +98,7 @@ struct cmd_context {
unsigned independent_metadata_areas:1; /* Active formats have MDAs outside PVs */
unsigned unknown_system_id:1;
unsigned include_foreign_vgs:1;
+ unsigned error_foreign_vgs:1;
struct dev_types *dev_types;
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 71197ba..f011af8 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4430,8 +4430,19 @@ static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
return 0;
}
- log_error("Cannot access VG %s with system id \"%s\" with local system ID %s.",
- vg->name, vg->system_id, cmd->system_id);
+ /*
+ * Some commands always produce an error when accessing foreign VG.
+ */
+ if (cmd->error_foreign_vgs) {
+ log_error("Cannot access VG %s with system id \"%s\" with local system ID %s.",
+ vg->name, vg->system_id, cmd->system_id);
+ return 0;
+ }
+
+ /*
+ * When include_foreign_vgs is 0 and error_foreign_vgs is 0,
+ * the result is to silently ignore foreign vgs.
+ */
return 0;
}
diff --git a/tools/commands.h b/tools/commands.h
index 00708f6..3cb8f56 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -356,7 +356,7 @@ xx(lvcreate,
xx(lvdisplay,
"Display information about a logical volume",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
"lvdisplay\n"
"\t[-a|--all]\n"
"\t[-c|--colon]\n"
@@ -578,7 +578,7 @@ xx(lvresize,
xx(lvs,
"Display information about logical volumes",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
"lvs\n"
"\t[-a|--all]\n"
"\t[--aligned]\n"
@@ -616,7 +616,7 @@ xx(lvs,
xx(lvscan,
"List all logical volumes in all volume groups",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
"lvscan\n"
"\t[-a|--all]\n"
"\t[-b|--blockdevice]\n"
@@ -742,7 +742,7 @@ xx(pvdata,
xx(pvdisplay,
"Display various attributes of physical volume(s)",
- CACHE_VGMETADATA | PERMITTED_READ_ONLY | ENABLE_ALL_DEVS,
+ CACHE_VGMETADATA | PERMITTED_READ_ONLY | ENABLE_ALL_DEVS | ENABLE_FOREIGN_VGS,
"pvdisplay\n"
"\t[-c|--colon]\n"
"\t[--commandprofile ProfileName]\n"
@@ -833,7 +833,7 @@ xx(pvremove,
xx(pvs,
"Display information about physical volumes",
- CACHE_VGMETADATA | PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_ALL_DEVS,
+ CACHE_VGMETADATA | PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_ALL_DEVS | ENABLE_FOREIGN_VGS,
"pvs\n"
"\t[-a|--all]\n"
"\t[--aligned]\n"
@@ -871,7 +871,7 @@ xx(pvs,
xx(pvscan,
"List all physical volumes",
- PERMITTED_READ_ONLY,
+ PERMITTED_READ_ONLY | ENABLE_FOREIGN_VGS,
"pvscan\n"
"\t[-b|--background]\n"
"\t[--cache [-a|--activate ay] [ DevicePath | -j|--major major --minor minor]...]\n"
@@ -1056,7 +1056,7 @@ xx(vgcreate,
xx(vgdisplay,
"Display volume group information",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
"vgdisplay\n"
"\t[-A|--activevolumegroups]\n"
"\t[-c|--colon | -s|--short | -v|--verbose]\n"
@@ -1142,7 +1142,7 @@ xx(vgextend,
xx(vgimport,
"Register exported volume group with system",
- ALL_VGS_IS_DEFAULT | NEEDS_FOREIGN_VGS,
+ ALL_VGS_IS_DEFAULT,
"vgimport\n"
"\t[-a|--all]\n"
"\t[--commandprofile ProfileName]\n"
@@ -1244,7 +1244,7 @@ xx(vgrename,
xx(vgs,
"Display information about volume groups",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
"vgs\n"
"\t[--aligned]\n"
"\t[--binary]\n"
@@ -1281,7 +1281,7 @@ xx(vgs,
xx(vgscan,
"Search for all volume groups",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
"vgscan "
"\t[--cache]\n"
"\t[--commandprofile ProfileName]\n"
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index b38039b..7a11183 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1075,9 +1075,9 @@ static int _get_settings(struct cmd_context *cmd)
init_ignorelockingfailure(0);
cmd->ignore_clustered_vgs = arg_is_set(cmd, ignoreskippedcluster_ARG);
- cmd->include_foreign_vgs =
- ((cmd->command->flags & NEEDS_FOREIGN_VGS) || arg_is_set(cmd, foreign_ARG)) ? 1 : 0;
-
+ cmd->error_foreign_vgs = cmd->command->flags & ENABLE_FOREIGN_VGS ? 0 : 1;
+ cmd->include_foreign_vgs = arg_is_set(cmd, foreign_ARG) ? 1 : 0;
+
if (!arg_count(cmd, sysinit_ARG))
lvmetad_connect_or_warn();
diff --git a/tools/tools.h b/tools/tools.h
index be4b166..1f344b0 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -108,8 +108,8 @@ struct arg_value_group_list {
#define ENABLE_ALL_DEVS 0x00000008
/* Exactly one VG name argument required. */
#define ONE_VGNAME_ARG 0x00000010
-/* Processes foreign VGs by default */
-#define NEEDS_FOREIGN_VGS 0x00000020
+/* Command is allowed to read foreign VGs. */
+#define ENABLE_FOREIGN_VGS 0x00000020
/* a register of the lvm commands */
struct command {
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 7000284..b416e21 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -85,6 +85,17 @@ int vgimport(struct cmd_context *cmd, int argc, char **argv)
cmd->handles_missing_pvs = 1;
}
+ /*
+ * Rescan devices and update lvmetad. lvmetad may hold a copy of the
+ * VG from before it was exported, if it was exported by another host.
+ * We need to reread it to see that it's been exported before we can
+ * import it.
+ */
+ if (lvmetad_used() && !lvmetad_pvscan_all_devs(cmd, NULL)) {
+ log_error("Failed to scan devices.");
+ return ECMD_FAILED;
+ }
+
return process_each_vg(cmd, argc, argv,
READ_FOR_UPDATE | READ_ALLOW_EXPORTED,
NULL,
9 years, 2 months
master - toolcontext: Fix lvmlocal.conf load fail path.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4ff9abd01f60e3...
Commit: 4ff9abd01f60e3bfe433da5596078a12fb49f9eb
Parent: 1e59c0346a3d9f5d125708529bd6d2ff4d0a16d5
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Feb 25 16:36:47 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Feb 25 16:36:47 2015 +0000
toolcontext: Fix lvmlocal.conf load fail path.
---
lib/commands/toolcontext.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c917b0a..1936ea7 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1741,7 +1741,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
/* Load lvmlocal.conf */
if (*cmd->system_dir && !_load_config_file(cmd, "", 1))
- return_0;
+ goto_out;
if (!_init_tag_configs(cmd))
goto_out;
9 years, 2 months
master - example.conf: Update systemid comments.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1e59c0346a3d9f...
Commit: 1e59c0346a3d9f5d125708529bd6d2ff4d0a16d5
Parent: 809a5e142eec520aab2702fd3b8cfafc1d16ffac
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Feb 25 14:22:24 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Feb 25 14:22:24 2015 +0000
example.conf: Update systemid comments.
Avoid using 'cluster' (ambiguous).
Add holding ref for machine-id source.
---
conf/example.conf.in | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 574842a..1f10dad 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -840,8 +840,8 @@ global {
# The method, if any, used to define a local system ID on this host.
# By placing the same system ID on a Volume Group you can prevent
- # other co-operating hosts in a cluster (each with a different
- # system ID) from accessing the same Volume Group.
+ # other co-operating hosts that see the same storage devices (each
+ # with a different system ID) from accessing the same Volume Group.
#
# Set this to one of: none, machineid, uname, lvmlocal, or file.
#
@@ -861,8 +861,8 @@ global {
# system_id_source = "uname"
#
# Use the contents of the file @DEFAULT_SYS_DIR@/machine-id
- # to set the system ID.
- # Comments starting with the character # are ignored.
+ # to set the system ID. Some systems create this file at
+ # installation time - see 'man machine-id'.
#
# system_id_source = "machineid"
#
9 years, 2 months
master - systemid: Improve concurrent warning.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=809a5e142eec52...
Commit: 809a5e142eec520aab2702fd3b8cfafc1d16ffac
Parent: ac6a4cd7079fa97f866cde5ba3adedbf7fd61cba
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Feb 25 14:17:35 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Feb 25 14:17:35 2015 +0000
systemid: Improve concurrent warning.
---
tools/toollib.c | 2 +-
tools/vgchange.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 628bc55..8b750d8 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -775,7 +775,7 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
log_warn("VG with system ID \"%s\" might become inaccessible as local system ID is \"%s\"",
vp_new->system_id, cmd->system_id);
else
- log_warn("WARNING: A VG without a system ID allows concurrent access from other hosts.");
+ log_warn("WARNING: A VG without a system ID allows unsafe access from other hosts.");
}
}
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 8d5b48a..c03d814 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -506,7 +506,7 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
if (cmd->system_id && strcmp(system_id, cmd->system_id)) {
if (!*system_id) {
- log_warn("WARNING: Removing the system ID allows concurrent access from other hosts.");
+ log_warn("WARNING: Removing the system ID allows unsafe access from other hosts.");
if (!arg_count(cmd, yes_ARG) &&
yes_no_prompt("Remove system ID %s on volume group %s? [y/n]: ",
9 years, 2 months
master - systemid: Allow empty systemid with warnings.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ac6a4cd7079fa9...
Commit: ac6a4cd7079fa97f866cde5ba3adedbf7fd61cba
Parent: 7d615a3fe58e76af4d3b192298d55a60de9b0d5d
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Feb 25 14:12:24 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Feb 25 14:12:24 2015 +0000
systemid: Allow empty systemid with warnings.
Add warning messages when empty system ID is set.
---
lib/commands/toolcontext.c | 13 +++++++++--
tools/toollib.c | 10 ++++++--
tools/vgchange.c | 46 +++++++++++++++++++++++++------------------
3 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 7539b4a..c917b0a 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -62,6 +62,11 @@ const char *system_id_from_string(struct cmd_context *cmd, const char *str)
{
char *system_id;
+ if (!str || !*str) {
+ log_warn("WARNING: Empty system ID supplied.");
+ return "";
+ }
+
if (!(system_id = dm_pool_zalloc(cmd->mem, strlen(str) + 1))) {
log_warn("WARNING: Failed to allocate system ID.");
return NULL;
@@ -109,13 +114,13 @@ static const char *_read_system_id_from_file(struct cmd_context *cmd, const char
if (!*start || *start == '#')
continue;
- if (system_id) {
+ if (system_id && *system_id) {
log_warn("WARNING: Ignoring extra line(s) in system ID file %s.", file);
break;
}
/* Remove any comments from end of line */
- for (end = start; *end; start++)
+ for (end = start; *end; end++)
if (*end == '#') {
*end = '\0';
break;
@@ -445,8 +450,10 @@ static int _init_system_id(struct cmd_context *cmd)
if (!strcmp(source, "none"))
return 1;
- if ((cmd->system_id = _system_id_from_source(cmd, source)))
+ if ((system_id = _system_id_from_source(cmd, source)) && *system_id) {
+ cmd->system_id = system_id;
return 1;
+ }
/*
* The source failed to resolve a system_id. In this case allow
diff --git a/tools/toollib.c b/tools/toollib.c
index b8b0bad..628bc55 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -770,9 +770,13 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
/* FIXME Take local/extra_system_ids into account */
if (vp_new->system_id && cmd->system_id &&
- strcmp(vp_new->system_id, cmd->system_id))
- log_warn("VG with system ID \"%s\" might become inaccessible as local system ID is \"%s\"",
- vp_new->system_id, cmd->system_id);
+ strcmp(vp_new->system_id, cmd->system_id)) {
+ if (*vp_new->system_id)
+ log_warn("VG with system ID \"%s\" might become inaccessible as local system ID is \"%s\"",
+ vp_new->system_id, cmd->system_id);
+ else
+ log_warn("WARNING: A VG without a system ID allows concurrent access from other hosts.");
+ }
}
return 1;
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 0b78230..8d5b48a 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -494,36 +494,44 @@ static int _vgchange_system_id(struct cmd_context *cmd, struct volume_group *vg)
const char *system_id;
const char *system_id_arg_str = arg_str_value(cmd, systemid_ARG, NULL);
- if (!system_id_arg_str || !*system_id_arg_str) {
- log_error("Invalid system ID supplied: %s", system_id_arg_str);
+ if (!(system_id = system_id_from_string(cmd, system_id_arg_str))) {
+ log_error("Unable to set system ID.");
return 0;
}
- if (!(system_id = system_id_from_string(cmd, system_id_arg_str)))
- return_0;
-
if (!strcmp(vg->system_id, system_id)) {
log_error("Volume Group system ID is already \"%s\"", vg->system_id);
return 0;
}
if (cmd->system_id && strcmp(system_id, cmd->system_id)) {
- if (lvs_in_vg_activated(vg)) {
- log_error("Logical Volumes in VG %s must be deactivated before system ID can be changed.",
- vg->name);
- return 0;
- }
+ if (!*system_id) {
+ log_warn("WARNING: Removing the system ID allows concurrent access from other hosts.");
+
+ if (!arg_count(cmd, yes_ARG) &&
+ yes_no_prompt("Remove system ID %s on volume group %s? [y/n]: ",
+ vg->system_id, vg->name) == 'n') {
+ log_error("Volume group \"%s\" system ID not changed.", vg->name);
+ return 0;
+ }
+ } else {
+ if (lvs_in_vg_activated(vg)) {
+ log_error("Logical Volumes in VG %s must be deactivated before system ID can be changed.",
+ vg->name);
+ return 0;
+ }
- log_warn("WARNING: Requested system ID \"%s\" does not match local system ID \"%s\"",
- system_id, cmd->system_id);
- log_warn("WARNING: Volume group %s might become inaccessible from this machine.",
- vg->name);
+ log_warn("WARNING: Requested system ID \"%s\" does not match local system ID \"%s\"",
+ system_id, cmd->system_id);
+ log_warn("WARNING: Volume group %s might become inaccessible from this machine.",
+ vg->name);
- if (!arg_count(cmd, yes_ARG) &&
- yes_no_prompt("Set foreign system ID %s on volume group %s? [y/n]: ",
- system_id, vg->name) == 'n') {
- log_error("Volume group \"%s\" system ID not changed.", vg->name);
- return 0;
+ if (!arg_count(cmd, yes_ARG) &&
+ yes_no_prompt("Set foreign system ID %s on volume group %s? [y/n]: ",
+ system_id, vg->name) == 'n') {
+ log_error("Volume group \"%s\" system ID not changed.", vg->name);
+ return 0;
+ }
}
}
9 years, 2 months
master - cache: Fix a segfault when passing --cachepolicy without --cachesettings.
by Petr Rockai
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7d615a3fe58e76...
Commit: 7d615a3fe58e76af4d3b192298d55a60de9b0d5d
Parent: 5793ecd16541961ebb91239395dc82504ad31906
Author: Petr Rockai <me(a)mornfall.net>
AuthorDate: Tue Feb 24 11:36:30 2015 +0100
Committer: Petr Rockai <me(a)mornfall.net>
CommitterDate: Tue Feb 24 11:39:35 2015 +0100
cache: Fix a segfault when passing --cachepolicy without --cachesettings.
---
WHATS_NEW | 1 +
lib/metadata/cache_manip.c | 5 +++--
test/shell/lvchange-cache.sh | 5 +++++
tools/toollib.c | 13 ++++++++-----
4 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6220398..8e80241 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.117 -
====================================
+ Do not crash when --cachepolicy is given without --cachesettings.
Add NEEDS_FOREIGN_VGS flag to vgimport so --foreign is always supplied.
Add --foreign to the 6 display and reporting tools and vgcfgbackup.
Install /etc/lvm/lvmlocal.conf template with local section for systemid.
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 6a13ec1..41de440 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -418,7 +418,8 @@ int lv_cache_setpolicy(struct logical_volume *lv, struct dm_config_tree *policy)
goto_out;
}
- if (!(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, policy->root, 0)))
+ if ((cn = dm_config_find_node(policy->root, "policy_settings")) &&
+ !(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, cn, 0)))
goto_out;
if ((name = dm_config_find_str(policy->root, "policy", NULL)) &&
@@ -426,7 +427,7 @@ int lv_cache_setpolicy(struct logical_volume *lv, struct dm_config_tree *policy)
goto_out;
restart: /* remove any 'default" nodes */
- cn = seg->policy_settings->child;
+ cn = seg->policy_settings ? seg->policy_settings->child : NULL;
while (cn) {
if (cn->v->type == DM_CFG_STRING && !strcmp(cn->v->v.str, "default")) {
dm_config_remove_node(seg->policy_settings, cn);
diff --git a/test/shell/lvchange-cache.sh b/test/shell/lvchange-cache.sh
index 87a217a..9959f93 100644
--- a/test/shell/lvchange-cache.sh
+++ b/test/shell/lvchange-cache.sh
@@ -21,7 +21,12 @@ lvcreate -n noncache -l 1 $vg
not lvchange --cachepolicy mq $vg/noncache
not lvchange --cachesettings foo=bar $vg/noncache
+lvchange --cachepolicy cleaner $vg/corigin
+dmsetup status | grep $vg-corigin | grep 'cleaner'
+
lvchange --cachepolicy mq --cachesettings migration_threshold=333 $vg/corigin
+dmsetup status | grep $vg-corigin | not grep 'cleaner'
+dmsetup status | grep $vg-corigin | grep 'mq'
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
lvchange --refresh $vg/corigin
dmsetup status | grep $vg-corigin | grep 'migration_threshold 333'
diff --git a/tools/toollib.c b/tools/toollib.c
index b1795e7..b8b0bad 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1232,17 +1232,20 @@ struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
if (!(result = dm_config_flatten(current)))
goto_out;
- if (!(cn = dm_config_create_node(result, "policy_settings")))
- goto_out;
+ if (result->root) {
+ if (!(cn = dm_config_create_node(result, "policy_settings")))
+ goto_out;
- cn->child = result->root;
- result->root = cn;
+ cn->child = result->root;
+ result->root = cn;
+ }
if (arg_count(cmd, cachepolicy_ARG)) {
if (!(cn = dm_config_create_node(result, "policy")))
goto_out;
- result->root->sib = cn;
+ cn->sib = result->root;
+ result->root = cn;
if (!(cn->v = dm_config_create_value(result)))
goto_out;
9 years, 2 months