master - cache: disallow cache lvs and cache pools in cluster vg
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=40e1d5b269fa76...
Commit: 40e1d5b269fa76b839e3e8e2e7c9beb2bbbfed5e
Parent: 2e905d454058ef17bbb2b9758c59a5505d1c95be
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 31 15:50:09 2014 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Dec 16 10:30:27 2014 -0600
cache: disallow cache lvs and cache pools in cluster vg
Disable this combination until problems are resolved.
---
lib/metadata/segtype.c | 8 ++++++++
lib/metadata/segtype.h | 2 ++
tools/lvconvert.c | 16 +++++++++++++++-
tools/lvcreate.c | 6 ++++++
tools/vgchange.c | 12 ++++++++++++
5 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/segtype.c b/lib/metadata/segtype.c
index 02dff4c..c28c894 100644
--- a/lib/metadata/segtype.c
+++ b/lib/metadata/segtype.c
@@ -34,3 +34,11 @@ struct segment_type *get_segtype_from_string(struct cmd_context *cmd,
return segtype;
}
+
+int segtype_allowed_in_cluster_vg(const struct segment_type *segtype)
+{
+ if (segtype_is_cache(segtype) || segtype_is_cache_pool(segtype))
+ return 0;
+
+ return 1;
+}
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index ecb598d..3c387e2 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -138,6 +138,8 @@ struct segtype_handler {
struct segment_type *get_segtype_from_string(struct cmd_context *cmd,
const char *str);
+int segtype_allowed_in_cluster_vg(const struct segment_type *segtype);
+
struct segtype_library;
int lvm_register_segtype(struct segtype_library *seglib,
struct segment_type *segtype);
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c7acd5d..6f4a546 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3345,13 +3345,27 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return_ECMD_FAILED;
}
}
+
if (lp->merge) {
if ((lv_is_thin_volume(lv) && !_lvconvert_merge_thin_snapshot(cmd, lv, lp)) ||
(!lv_is_thin_volume(lv) && !_lvconvert_merge_old_snapshot(cmd, lv, lp))) {
log_print_unless_silent("Unable to merge LV \"%s\" into its origin.", lv->name);
return ECMD_FAILED;
}
- } else if (lp->snapshot) {
+ return ECMD_PROCESSED;
+ }
+
+ /*
+ * Converting to a new type.
+ */
+
+ if (vg_is_clustered(lv->vg) && !segtype_allowed_in_cluster_vg(lp->segtype)) {
+ log_error("LV segtype %s is not allowed in a cluster VG.",
+ lp->segtype->name);
+ return ECMD_FAILED;
+ }
+
+ if (lp->snapshot) {
if (!_lvconvert_snapshot(cmd, lv, lp))
return_ECMD_FAILED;
} else if (segtype_is_pool(lp->segtype) || lp->thin || lp->cache) {
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 7236ffc..c4691dd 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1450,6 +1450,12 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
if (!_read_activation_params(cmd, vg, &lp))
goto_out;
+ if (vg_is_clustered(vg) && !segtype_allowed_in_cluster_vg(lp.segtype)) {
+ log_error("LV segtype %s is not allowed in a cluster VG.",
+ lp.segtype->name);
+ goto_out;
+ }
+
/* Resolve segment types with opened VG */
if (lp.snapshot && lp.origin_name && !_determine_snapshot_type(vg, &lp, &lcp))
goto_out;
diff --git a/tools/vgchange.c b/tools/vgchange.c
index e5d700d..5e52a87 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -299,6 +299,7 @@ static int _vgchange_resizeable(struct cmd_context *cmd,
static int _vgchange_clustered(struct cmd_context *cmd,
struct volume_group *vg)
{
+ struct lv_list *lvl;
int clustered = arg_int_value(cmd, clustered_ARG, 0);
if (clustered && (vg_is_clustered(vg))) {
@@ -313,6 +314,17 @@ static int _vgchange_clustered(struct cmd_context *cmd,
return 0;
}
+ if (clustered) {
+ dm_list_iterate_items(lvl, &vg->lvs) {
+ if (!segtype_allowed_in_cluster_vg(first_seg(lvl->lv)->segtype)) {
+ log_error("LV %s segtype %s is not allowed in cluster VG.",
+ display_lvname(lvl->lv),
+ first_seg(lvl->lv)->segtype->name);
+ return 0;
+ }
+ }
+ }
+
if (clustered && !arg_count(cmd, yes_ARG)) {
if (!clvmd_is_running()) {
if (yes_no_prompt("LVM cluster daemon (clvmd) is not"
9 years, 4 months
master - man: put back the --binary reference in {pv, vg, lv}display man page
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2e905d454058ef...
Commit: 2e905d454058ef17bbb2b9758c59a5505d1c95be
Parent: 3b02ccd2011c058f01c3acce76c599f3a39408e7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 11 15:50:37 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 11 15:50:37 2014 +0100
man: put back the --binary reference in {pv,vg,lv}display man page
---
man/lvdisplay.8.in | 1 +
man/pvdisplay.8.in | 1 +
man/vgdisplay.8.in | 1 +
3 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/man/lvdisplay.8.in b/man/lvdisplay.8.in
index 1881b3f..3232853 100644
--- a/man/lvdisplay.8.in
+++ b/man/lvdisplay.8.in
@@ -25,6 +25,7 @@ lvdisplay \(em display attributes of a logical volume
.B lvdisplay
.BR \-C | \-\-columns
.RB [ \-\-aligned ]
+.RB [ \-\-binary ]
.RB [ \-a | \-\-all ]
.RB [ \-\-commandprofile
.IR ProfileName ]
diff --git a/man/pvdisplay.8.in b/man/pvdisplay.8.in
index 0399c1e..70c9bfc 100644
--- a/man/pvdisplay.8.in
+++ b/man/pvdisplay.8.in
@@ -26,6 +26,7 @@ pvdisplay \- display attributes of a physical volume
.B pvdisplay
.BR \-C | \-\-columns
.RB [ \-\-aligned ]
+.RB [ \-\-binary ]
.RB [ \-a | \-\-all ]
.RB [ \-\-commandprofile
.IR ProfileName ]
diff --git a/man/vgdisplay.8.in b/man/vgdisplay.8.in
index 97cb314..1e472d3 100644
--- a/man/vgdisplay.8.in
+++ b/man/vgdisplay.8.in
@@ -26,6 +26,7 @@ vgdisplay \(em display attributes of volume groups
.B vgdisplay
.BR \-C | \-\-columns
.RB [ \-\-aligned ]
+.RB [ \-\-binary ]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-d | \-\-debug ]
9 years, 4 months
master - tools, man: --binary option is available with -C for {pv, vg, lv}display
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3b02ccd2011c05...
Commit: 3b02ccd2011c058f01c3acce76c599f3a39408e7
Parent: 3ec482a3797261d867c097963e65c03306f01c97
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 11 15:16:04 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 11 15:20:16 2014 +0100
tools, man: --binary option is available with -C for {pv,vg,lv}display
The {pv,vg,lv}display *do* use reporting in case "-C|--columns" is used.
The man page was correct, the recognition for the --binary was missing
in the code though!
---
WHATS_NEW | 1 +
tools/commands.h | 23 ++++++++++++++---------
tools/lvdisplay.c | 1 +
tools/pvdisplay.c | 1 +
tools/vgdisplay.c | 1 +
5 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5e1b143..4855e1a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Add missing recognition for --binary option with {pv,vg,lv}display -C.
Fix vgimportclone to notify lvmetad about changes done if lvmetad is used.
Fix vgimportclone to properly override config if it is missing in lvm.conf.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
diff --git a/tools/commands.h b/tools/commands.h
index 8dc335c..8b6b607 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -374,6 +374,7 @@ xx(lvdisplay,
"lvdisplay --columns|-C\n"
"\t[--aligned]\n"
"\t[-a|--all]\n"
+ "\t[--binary]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
@@ -394,10 +395,11 @@ xx(lvdisplay,
"\t[--version]\n"
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
- aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG,
- ignoreskippedcluster_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG,
- options_ARG, sort_ARG, partial_ARG, readonly_ARG, segments_ARG,
- select_ARG, separator_ARG, unbuffered_ARG, units_ARG)
+ aligned_ARG, all_ARG, binary_ARG, colon_ARG, columns_ARG,
+ ignorelockingfailure_ARG, ignoreskippedcluster_ARG, maps_ARG,
+ noheadings_ARG, nosuffix_ARG, options_ARG, sort_ARG, partial_ARG,
+ readonly_ARG, segments_ARG, select_ARG, separator_ARG,
+ unbuffered_ARG, units_ARG)
xx(lvextend,
"Add space to a logical volume",
@@ -749,6 +751,7 @@ xx(pvdisplay,
"pvdisplay --columns|-C\n"
"\t[--aligned]\n"
"\t[-a|--all]\n"
+ "\t[--binary]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
@@ -767,10 +770,11 @@ xx(pvdisplay,
"\t[--version]\n"
"\t[PhysicalVolumePath [PhysicalVolumePath...]]\n",
- aligned_ARG, all_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG,
- ignoreskippedcluster_ARG, maps_ARG, noheadings_ARG, nosuffix_ARG,
- options_ARG, readonly_ARG, select_ARG, separator_ARG, short_ARG, sort_ARG,
- unbuffered_ARG, units_ARG)
+ aligned_ARG, all_ARG, binary_ARG, colon_ARG, columns_ARG,
+ ignorelockingfailure_ARG, ignoreskippedcluster_ARG, maps_ARG,
+ noheadings_ARG, nosuffix_ARG, options_ARG, readonly_ARG,
+ select_ARG, separator_ARG, short_ARG, sort_ARG, unbuffered_ARG,
+ units_ARG)
xx(pvmove,
"Move extents from one physical volume to another",
@@ -1045,6 +1049,7 @@ xx(vgdisplay,
"\n"
"vgdisplay --columns|-C\n"
"\t[--aligned]\n"
+ "\t[--binary]\n"
"\t[--commandprofile ProfileName]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
@@ -1064,7 +1069,7 @@ xx(vgdisplay,
"\t[--version]\n"
"\t[VolumeGroupName [VolumeGroupName...]]\n",
- activevolumegroups_ARG, aligned_ARG, colon_ARG, columns_ARG,
+ activevolumegroups_ARG, aligned_ARG, binary_ARG, colon_ARG, columns_ARG,
ignorelockingfailure_ARG, ignoreskippedcluster_ARG, noheadings_ARG,
nosuffix_ARG, options_ARG, partial_ARG, readonly_ARG, select_ARG,
short_ARG, separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
diff --git a/tools/lvdisplay.c b/tools/lvdisplay.c
index 185e539..fb3420a 100644
--- a/tools/lvdisplay.c
+++ b/tools/lvdisplay.c
@@ -43,6 +43,7 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
}
if (arg_count(cmd, aligned_ARG) ||
+ arg_count(cmd, binary_ARG) ||
arg_count(cmd, noheadings_ARG) ||
arg_count(cmd, options_ARG) ||
arg_count(cmd, select_ARG) ||
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index d4cb516..50522d9 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -73,6 +73,7 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, aligned_ARG) ||
arg_count(cmd, all_ARG) ||
+ arg_count(cmd, binary_ARG) ||
arg_count(cmd, noheadings_ARG) ||
arg_count(cmd, options_ARG) ||
arg_count(cmd, select_ARG) ||
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index 6e068aa..59d741a 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -63,6 +63,7 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
}
return vgs(cmd, argc, argv);
} else if (arg_count(cmd, aligned_ARG) ||
+ arg_count(cmd, binary_ARG) ||
arg_count(cmd, noheadings_ARG) ||
arg_count(cmd, options_ARG) ||
arg_count(cmd, select_ARG) ||
9 years, 4 months
master - man: remove reference to --binary in {pv, vg, lv}display man page
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3ec482a3797261...
Commit: 3ec482a3797261d867c097963e65c03306f01c97
Parent: b21a8412c482ae735d0d044d355e1541ccba6edf
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Dec 11 10:40:28 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Dec 11 10:42:31 2014 +0100
man: remove reference to --binary in {pv,vg,lv}display man page
The {pv,vg,lv}display commands don't use reporting capabilites and
as such they can't use --binary. This got into the man pages by
mistake - the display commands do not recognize --binary option.
---
man/lvdisplay.8.in | 1 -
man/pvdisplay.8.in | 1 -
man/vgdisplay.8.in | 1 -
3 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/man/lvdisplay.8.in b/man/lvdisplay.8.in
index 3232853..1881b3f 100644
--- a/man/lvdisplay.8.in
+++ b/man/lvdisplay.8.in
@@ -25,7 +25,6 @@ lvdisplay \(em display attributes of a logical volume
.B lvdisplay
.BR \-C | \-\-columns
.RB [ \-\-aligned ]
-.RB [ \-\-binary ]
.RB [ \-a | \-\-all ]
.RB [ \-\-commandprofile
.IR ProfileName ]
diff --git a/man/pvdisplay.8.in b/man/pvdisplay.8.in
index 70c9bfc..0399c1e 100644
--- a/man/pvdisplay.8.in
+++ b/man/pvdisplay.8.in
@@ -26,7 +26,6 @@ pvdisplay \- display attributes of a physical volume
.B pvdisplay
.BR \-C | \-\-columns
.RB [ \-\-aligned ]
-.RB [ \-\-binary ]
.RB [ \-a | \-\-all ]
.RB [ \-\-commandprofile
.IR ProfileName ]
diff --git a/man/vgdisplay.8.in b/man/vgdisplay.8.in
index 1e472d3..97cb314 100644
--- a/man/vgdisplay.8.in
+++ b/man/vgdisplay.8.in
@@ -26,7 +26,6 @@ vgdisplay \(em display attributes of volume groups
.B vgdisplay
.BR \-C | \-\-columns
.RB [ \-\-aligned ]
-.RB [ \-\-binary ]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-d | \-\-debug ]
9 years, 4 months
master - vgimportclone: also notify lvmetad about changes if it's used
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b21a8412c482ae...
Commit: b21a8412c482ae735d0d044d355e1541ccba6edf
Parent: 00b36ef06acb15c82d7c9b37872753f02c638316
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Dec 10 13:43:54 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Dec 10 14:00:56 2014 +0100
vgimportclone: also notify lvmetad about changes if it's used
All the LVM commands are run in mode without lvmetad use (since lvmetad
can't handle duplicates). When we're finished with vgimportclone, we
need to notify lvmetad about changes.
Before this patch (/dev/sda and /dev/sdb contains a copy VG called "vg"):
$ vgimportclone --basevgname vg_snap /dev/sdb
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Physical volume "/tmp/snap.zcJ8LCmj/vgimport0" changed 1 physical volume changed / 0 physical volumes not changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: Activation disabled. No device-mapper interaction will be attempted.
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "vg" successfully changed
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "vg" successfully renamed to "vg_snap"
Reading all physical volumes. This may take a while...
Found volume group "vg" using metadata type lvm2
Found volume group "fedora" using metadata type lvm2
$ vgs
VG #PV #LV #SN Attr VSize VFree
fedora 1 2 0 wz--n- 9.50g 0
vg 1 1 0 wz--n- 124.00m 120.00m
(...lvmetad doesn't see the new "vg_snap"!)
With this patch applied:
$ vgimportclone --basevgname vg_snap /dev/sdb
...
WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
Volume group "vg" successfully renamed to "vg_snap"
Notifying lvmetad about changes since it was disabled temporarily.
Reading all physical volumes. This may take a while...
Found volume group "vg_snap" using metadata type lvm2
Found volume group "fedora" using metadata type lvm2
Found volume group "vg" using metadata type lvm2
$ vgs
VG #PV #LV #SN Attr VSize VFree
fedora 1 2 0 wz--n- 9.50g 0
vg 1 1 0 wz--n- 124.00m 120.00m
vg_snap 1 1 0 wz--n- 124.00m 120.00m
The "restart lvmetad before enabling it" message is a bit misleading
here - we should probably suppress this one, but we can't suppress
warning messages selectively at the moment and we don't want to lose
other warning/error messages printed...
---
WHATS_NEW | 1 +
scripts/vgimportclone.sh | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 72d3b6a..5e1b143 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix vgimportclone to notify lvmetad about changes done if lvmetad is used.
Fix vgimportclone to properly override config if it is missing in lvm.conf.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index bfff131..719cd8d 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -363,6 +363,15 @@ fi
### the device nodes we need are straight
if [ ${CHANGES_MADE} -eq 1 ]
then
+ # get global/use_lvmetad config and if set also notify lvmetad about changes
+ # since we were running LVM commands above with use_lvmetad=0
+ eval $(${LVM} dumpconfig ${LVM_OPTS} global/use_lvmetad)
+ if [ "$use_lvmetad" = "1" ]
+ then
+ echo "Notifying lvmetad about changes since it was disabled temporarily."
+ LVM_OPTS="${LVM_OPTS} --cache"
+ fi
+
"$LVM" vgscan ${LVM_OPTS} --mknodes
fi
9 years, 4 months
master - vgimportclone: replace awk with dumpconfig to generate temporary lvm.conf for vgimportclone
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00b36ef06acb15...
Commit: 00b36ef06acb15c82d7c9b37872753f02c638316
Parent: 5378a1a63e8a8d89cca9460051d473b7547404f9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Dec 10 13:25:23 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Dec 10 13:59:38 2014 +0100
vgimportclone: replace awk with dumpconfig to generate temporary lvm.conf for vgimportclone
With current dumpconfig, we can generate lvm.conf easily - we can merge
current lvm.conf with the config given on cmd line:
lvm dumpconfig --mergedconfig --config "..."
This is a bit simpler than using awk and it also avoids problems when some of
the configuration is missing in existing lvm.conf file and hardcoded defaults
are used instead. The dumpconfig handles this transparently.
---
WHATS_NEW | 1 +
scripts/vgimportclone.sh | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9201f36..72d3b6a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix vgimportclone to properly override config if it is missing in lvm.conf.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
Add report/compact_output to lvm.conf to enable/disable compact report output.
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh
index 7087557..bfff131 100755
--- a/scripts/vgimportclone.sh
+++ b/scripts/vgimportclone.sh
@@ -242,17 +242,17 @@ export FILTER="filter=[ ${FILTER} \"r|.*|\" ]"
LVMCONF=${TMP_LVM_SYSTEM_DIR}/lvm.conf
-# FIXME convert to cmdline override
-"$LVM" dumpconfig ${LVM_OPTS} | \
-"$AWK" -v DEV=${TMP_LVM_SYSTEM_DIR} -v CACHE=${TMP_LVM_SYSTEM_DIR}/.cache \
- -v CACHE_DIR=${TMP_LVM_SYSTEM_DIR}/cache \
- '/^[ \t]*filter[ \t]*=/{print ENVIRON["FILTER"];next} \
- /^[ \t]*scan[ \t]*=/{print "scan = [ \"" DEV "\" ]";next} \
- /^[ \t]*cache[ \t]*=/{print "cache = \"" CACHE "\"";next} \
- /^[ \t]*use_lvmetad[ \t]*=/{print "use_lvmetad = 0";next} \
- /^[ \t]*global_filter[ \t]*=/{print "global_filter = [ \"a|.*|\" ]";next} \
- /^[ \t]*cache_dir[ \t]*=/{print "cache_dir = \"" CACHE_DIR "\"";next} \
- {print $0}' > ${LVMCONF}
+CMD_CONFIG_LINE="devices { \
+ scan = [ \"${TMP_LVM_SYSTEM_DIR}\" ] \
+ cache_dir = \"$TMP_LVM_SYSTEM_DIR}/cache\"
+ global_filter = [ \"a|.*|\" ] \
+ ${FILTER}
+ } \
+ global { \
+ use_lvmetad = 0 \
+ }"
+
+$LVM dumpconfig ${LVM_OPTS} --file ${LVMCONF} --mergedconfig --config "${CMD_CONFIG_LINE}"
checkvalue $? "Failed to generate ${LVMCONF}"
# Only keep TMP_LVM_SYSTEM_DIR if it contains something worth keeping
9 years, 4 months
master - WHATS_NEW: f94f846 actually fixes DM issue, not LVM issue
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5378a1a63e8a8d...
Commit: 5378a1a63e8a8d89cca9460051d473b7547404f9
Parent: f94f8463b0d3dddaa0e429123aba673d106f783e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Dec 9 10:52:07 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Dec 9 10:52:07 2014 +0100
WHATS_NEW: f94f846 actually fixes DM issue, not LVM issue
---
WHATS_NEW | 1 -
WHATS_NEW_DM | 1 +
2 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ff06b7b..9201f36 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,6 +1,5 @@
Version 2.02.115 -
=====================================
- Fix segfault while using --select with regex and --unbuffered for reporting.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
Add report/compact_output to lvm.conf to enable/disable compact report output.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index dcd35fa..02b8045 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.93 -
====================================
+ Fix segfault while using selection with regex and unbuffered reporting.
Add dm_report_compact_fields to remove empty fields from report output.
Remove unimplemented dm_report_set_output_selection from libdevmapper.h.
9 years, 4 months
master - libdm: report: fix incorrect memory use while using --select with --unbuffered for reporting
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f94f8463b0d3dd...
Commit: f94f8463b0d3dddaa0e429123aba673d106f783e
Parent: 4c62215bd178c17d0776448bdc99740180c85402
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Dec 9 10:36:27 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Dec 9 10:41:55 2014 +0100
libdm: report: fix incorrect memory use while using --select with --unbuffered for reporting
Under certain circumstances, the selection code can segfault:
$ vgs --select 'pv_name=~/dev/sda' --unbuffered vg0
VG #PV #LV #SN Attr VSize VFree
vg0 6 3 0 wz--n- 744.00m 588.00m
Segmentation fault (core dumped)
The problem here is the use of --ubuffered together with regex used in
selection criteria. If the report output is not buffered, each row is
discarded as soon as it is reported. The bug is in the use of report
handle's memory - in the example above, what happens is:
1) report handle is initialized together with its memory pool
2) selection tree is initialized from selection criteria string
(using the report handle's memory pool!)
2a) this also means the regex is initialized from report handle's mem pool
3) the object (row) is reported
3a) any memory needed for output is intialized out of report handle's mem pool
3b) selection criteria matching is executed - if the regex is checked the
very first time (for the very first row reported), some more memory
allocation happens as regex allocates internal structures "on-demand",
it's allocating from report handle's mem pool (see also step 2a)
4) the report output is executed
5) the object (row) is discarded, meaning discarding all the mem pool
memory used since step 3.
Now, with step 5) we have discarded the regex internal structures from step 3b.
When we execute reporting for another object (row), we're using the same
selection criteria (step 3b), but tihs is second time we're using the regex
and as such, it's already initialized completely. But the regex is missing the
internal structures now as they got discarded in step 5) from previous
object (row) reporting (because we're using "unbuffered" reporting).
To resolve this issue and to prevent any similar future issues where each
object/row memory is discarded after output (the unbuffered reporting) while
selection tree is global for all the object/rows, use separate memory pool
for report's selection.
This patch replaces "struct selection_node *selection_root" in struct
dm_report with new struct selection which contains both "selection_root"
and "mem" for separate mem pool used for selection.
We can change struct dm_report this way as it is not exposed via libdevmapper.
(This patch will have even more meaning for upcoming patches where selection
is used even for non-reporting commands where "internal" reporting and
selection criteria matching happens and where the internal reporting is
not buffered.)
---
WHATS_NEW | 1 +
libdm/libdm-report.c | 49 ++++++++++++++++++++++++++++++++-----------------
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9201f36..ff06b7b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix segfault while using --select with regex and --unbuffered for reporting.
Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
Add report/compact_output to lvm.conf to enable/disable compact report output.
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 6d36c1e..e3c3d2f 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -26,6 +26,11 @@
#define RH_HEADINGS_PRINTED 0x00000200
#define RH_ALREADY_REPORTED 0x00000400
+struct selection {
+ struct dm_pool *mem;
+ struct selection_node *selection_root;
+};
+
struct dm_report {
struct dm_pool *mem;
@@ -52,7 +57,9 @@ struct dm_report {
/* To store caller private data */
void *private;
- struct selection_node *selection_root;
+ /* Selection handle */
+ struct selection *selection;
+
/* Null-terminated array of reserved values */
const struct dm_report_reserved_value *reserved_values;
};
@@ -1193,6 +1200,8 @@ struct dm_report *dm_report_init(uint32_t *report_types,
void dm_report_free(struct dm_report *rh)
{
+ if (rh->selection)
+ dm_pool_destroy(rh->selection->mem);
dm_pool_destroy(rh->mem);
dm_free(rh);
}
@@ -1560,10 +1569,10 @@ static int _check_selection(struct dm_report *rh, struct selection_node *sn,
static int _check_report_selection(struct dm_report *rh, struct dm_list *fields)
{
- if (!rh->selection_root)
+ if (!rh->selection)
return 1;
- return _check_selection(rh, rh->selection_root, fields);
+ return _check_selection(rh, rh->selection->selection_root, fields);
}
int dm_report_object(struct dm_report *rh, void *object)
@@ -2410,7 +2419,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
}
/* set up selection */
- if (!(fs = dm_pool_zalloc(rh->mem, sizeof(struct field_selection)))) {
+ if (!(fs = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection)))) {
log_error("dm_report: struct field_selection "
"allocation failed for selection field %s", field_id);
return NULL;
@@ -2429,7 +2438,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
memcpy(s, v, len);
s[len] = '\0';
- fs->v.r = dm_regex_create(rh->mem, (const char **) &s, 1);
+ fs->v.r = dm_regex_create(rh->selection->mem, (const char **) &s, 1);
dm_free(s);
if (!fs->v.r) {
log_error("dm_report: failed to create regex "
@@ -2438,7 +2447,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
}
} else {
/* STRING, NUMBER, SIZE or STRING_LIST */
- if (!(s = dm_pool_alloc(rh->mem, len + 1))) {
+ if (!(s = dm_pool_alloc(rh->selection->mem, len + 1))) {
log_error("dm_report: dm_pool_alloc failed to store "
"value for selection field %s", field_id);
goto error;
@@ -2450,7 +2459,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
case DM_REPORT_FIELD_TYPE_STRING:
if (reserved) {
fs->v.s = (const char *) _get_reserved_value(reserved);
- dm_pool_free(rh->mem, s);
+ dm_pool_free(rh->selection->mem, s);
} else {
fs->v.s = s;
if (_check_value_is_reserved(rh, DM_REPORT_FIELD_TYPE_STRING, fs->v.s)) {
@@ -2473,7 +2482,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
goto error;
}
}
- dm_pool_free(rh->mem, s);
+ dm_pool_free(rh->selection->mem, s);
break;
case DM_REPORT_FIELD_TYPE_SIZE:
if (reserved)
@@ -2492,7 +2501,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
goto error;
}
}
- dm_pool_free(rh->mem, s);
+ dm_pool_free(rh->selection->mem, s);
break;
case DM_REPORT_FIELD_TYPE_PERCENT:
if (reserved)
@@ -2528,7 +2537,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
return fs;
error:
- dm_pool_free(rh->mem, fs);
+ dm_pool_free(rh->selection->mem, fs);
return NULL;
}
@@ -2730,7 +2739,7 @@ static struct selection_node *_parse_selection(struct dm_report *rh,
custom = NULL;
if (!(last = _tok_value(rh, ft, field_num, implicit,
last, &vs, &ve, &flags,
- &reserved, rh->mem, custom)))
+ &reserved, rh->selection->mem, custom)))
goto_bad;
}
@@ -2741,7 +2750,7 @@ static struct selection_node *_parse_selection(struct dm_report *rh,
return_NULL;
/* create selection node */
- if (!(sn = _alloc_selection_node(rh->mem, SEL_ITEM)))
+ if (!(sn = _alloc_selection_node(rh->selection->mem, SEL_ITEM)))
return_NULL;
/* add selection to selection node */
@@ -2828,7 +2837,7 @@ static struct selection_node *_parse_and_ex(struct dm_report *rh,
}
if (!and_sn) {
- if (!(and_sn = _alloc_selection_node(rh->mem, SEL_AND)))
+ if (!(and_sn = _alloc_selection_node(rh->selection->mem, SEL_AND)))
goto error;
}
dm_list_add(&and_sn->selection.set, &n->list);
@@ -2860,7 +2869,7 @@ static struct selection_node *_parse_or_ex(struct dm_report *rh,
}
if (!or_sn) {
- if (!(or_sn = _alloc_selection_node(rh->mem, SEL_OR)))
+ if (!(or_sn = _alloc_selection_node(rh->selection->mem, SEL_OR)))
goto error;
}
dm_list_add(&or_sn->selection.set, &n->list);
@@ -2893,7 +2902,7 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
return NULL;
if (!selection || !selection[0]) {
- rh->selection_root = NULL;
+ rh->selection = NULL;
return rh;
}
@@ -2914,7 +2923,13 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
return rh;
}
- if (!(root = _alloc_selection_node(rh->mem, SEL_OR)))
+ if (!(rh->selection = dm_pool_zalloc(rh->mem, sizeof(struct selection))) ||
+ !(rh->selection->mem = dm_pool_create("report selection", 10 * 1024))) {
+ log_error("Failed to allocate report selection structure.");
+ goto bad;
+ }
+
+ if (!(root = _alloc_selection_node(rh->selection->mem, SEL_OR)))
goto_bad;
if (!_parse_or_ex(rh, selection, &fin, root))
@@ -2930,7 +2945,7 @@ struct dm_report *dm_report_init_with_selection(uint32_t *report_types,
_dm_report_init_update_types(rh, report_types);
- rh->selection_root = root;
+ rh->selection->selection_root = root;
return rh;
bad:
dm_report_free(rh);
9 years, 4 months
master - configure: fix automatic use of configure --enable-udev-systemd-background-jobs
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4c62215bd178c1...
Commit: 4c62215bd178c17d0776448bdc99740180c85402
Parent: 42d71b9af393bdbf0e9409eea176b2801a07ea25
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Dec 8 10:51:33 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Dec 8 10:52:47 2014 +0100
configure: fix automatic use of configure --enable-udev-systemd-background-jobs
Fix incorrect test in configure which sets --enable-udev-systemd-background-jobs
automatically if proper systemd version is available.
The UDEV_SYSTEMD_BACKGROUND_JOBS variable was not properly set to "yes" in
case systemd is available and we had "maybe" for this variable before.
---
WHATS_NEW | 1 +
configure | 2 +-
configure.in | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 213cc31..9201f36 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.115 -
=====================================
+ Fix automatic use of configure --enable-udev-systemd-background-jobs.
Correctly rename active split LV with -splitmirrors for raid1.
Add report/compact_output to lvm.conf to enable/disable compact report output.
Still restrict mirror region size to power of 2 when VG extent size is not.
diff --git a/configure b/configure
index df902c3..9d1d32f 100755
--- a/configure
+++ b/configure
@@ -10694,7 +10694,7 @@ else
SYSTEMD_LIBS=$pkg_cv_SYSTEMD_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- test "UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes
+ test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes
fi
fi
diff --git a/configure.in b/configure.in
index 5b22b93..107bb29 100644
--- a/configure.in
+++ b/configure.in
@@ -1104,7 +1104,7 @@ AC_MSG_RESULT($UDEV_SYSTEMD_BACKGROUND_JOBS)
if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" != no; then
pkg_config_init
PKG_CHECK_MODULES(SYSTEMD, systemd >= 205,
- [test "UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes],
+ [test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe && UDEV_SYSTEMD_BACKGROUND_JOBS=yes],
[if test "$UDEV_SYSTEMD_BACKGROUND_JOBS" = maybe; then
UDEV_SYSTEMD_BACKGROUND_JOBS=no
else
9 years, 4 months
master - libdm: report: return immediately from dm_report_compact_fields without error if there are no rows
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42d71b9af393bd...
Commit: 42d71b9af393bdbf0e9409eea176b2801a07ea25
Parent: f867dc6b294c434e69499e38e66a67812361d8c9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Dec 5 15:10:50 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Dec 5 15:10:50 2014 +0100
libdm: report: return immediately from dm_report_compact_fields without error if there are no rows
Let's make dm_report_compact_fields consistent with dm_report_output fn
which also returns with success immediately if there are no rows.
---
libdm/libdm-report.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index f81d964..6d36c1e 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1696,11 +1696,12 @@ int dm_report_compact_fields(struct dm_report *rh)
struct field_properties *fp;
struct row *row;
- if (!(rh->flags & DM_REPORT_OUTPUT_BUFFERED))
+ if (!(rh->flags & DM_REPORT_OUTPUT_BUFFERED) ||
+ dm_list_empty(&rh->rows))
return 1;
- if (!rh || dm_list_empty(&rh->rows)) {
- log_error("dm_report_enable_compact_output: no report fields to compact");
+ if (!rh) {
+ log_error("dm_report_enable_compact_output: dm report handler is NULL.");
return 0;
}
9 years, 4 months