master - pvcreate: do not print stack when pv not found while doing pvcreate_check
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b1e8284f339cb4...
Commit: b1e8284f339cb412b83f730783ee8a06feac9341
Parent: 6a00a7e33dc9919610e953456081b057c8b981f6
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Feb 18 09:59:21 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Feb 18 10:01:11 2014 +0100
pvcreate: do not print stack when pv not found while doing pvcreate_check
Not finding an existing PV on a disk where we're just
creating the PV is not an error or any bad condition.
Remove misleading "stack" call.
---
lib/metadata/metadata.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 88447a3..74f23b0 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1322,8 +1322,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name,
/* FIXME Check partition type is LVM unless --force is given */
/* Is there a pv here already? */
- if (!(pv = find_pv_by_name(cmd, name, 1, 1)))
- stack;
+ pv = find_pv_by_name(cmd, name, 1, 1);
/* Allow partial & exported VGs to be destroyed. */
/* We must have -ff to overwrite a non orphan */
10 years, 4 months
master - RAID: Allow implicit stripe (and parity) when creating RAID LVs
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6a00a7e33dc991...
Commit: 6a00a7e33dc9919610e953456081b057c8b981f6
Parent: 0be6caba6e4251200eb888a2686ddf9af8065d6c
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Feb 17 20:18:23 2014 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Feb 17 20:18:23 2014 -0600
RAID: Allow implicit stripe (and parity) when creating RAID LVs
There are typically 2 functions for the more advanced segment types that
deal with parameters in lvcreate.c: _get_*_params() and _check_*_params().
(Not all segment types name their functions according to this scheme.)
The former function is responsible for reading parameters before the VG
has been read. The latter is for sanity checking and possibly setting
parameters after the VG has been read.
This patch adds a _check_raid_parameters() function that will determine
if the user has specified 'stripe' or 'mirror' parameters. If not, the
proper number is computed from the list of PVs the user has supplied or
the number that are available in the VG. Now that _check_raid_parameters()
is available, we move the check for proper number of stripes from
_get_* to _check_*.
This gives the user the ability to create RAID LVs as follows:
# 5-device RAID5, 4-data, 1-parity (i.e. implicit '-i 4')
~> lvcreate --type raid5 -L 100G -n lv vg /dev/sd[abcde]1
# 5-device RAID6, 3-data, 2-parity (i.e. implicit '-i 3')
~> lvcreate --type raid6 -L 100G -n lv vg /dev/sd[abcde]1
# If 5 PVs in VG, 4-data, 1-parity RAID5
~> lvcreate --type raid5 -L 100G -n lv vg
Considerations:
This patch only affects RAID. It might also be useful to apply this to
the 'stripe' segment type. LVM RAID may include RAID0 at some point in
the future and the implicit stripes would apply there. It would be odd
to have RAID0 be able to auto-determine the stripe count while 'stripe'
could not.
The only draw-back of this patch that I can see is that there might be
less error checking. Rather than informing the user that they forgot
to supply an argument (e.g. '-i'), the value would be computed and it
may differ from what the user actually wanted. I don't see this as a
problem, because the user can check the device count after creation
and remove the LV if they have made an error.
---
WHATS_NEW | 1 +
man/lvcreate.8.in | 14 +++++++++-
test/shell/lvcreate-raid.sh | 39 +++++++++++++++++++++++++++++
tools/lvcreate.c | 57 ++++++++++++++++++++++++++++++++----------
4 files changed, 95 insertions(+), 16 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 03a3b8a..39e8b88 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ lvcreate computes RAID4/5/6 stripes if not given from # of allocatable PVs.
Fix merging of old snapshot into thin volume origin.
Use --ignoreskippedcluster in lvm2-monitor initscript/systemd unit.
Do not use VG read/write state for LV read/write state.
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 029d8da..f03fd48 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -204,7 +204,11 @@ the extra devices which are necessary for parity are
internally accounted for. Specifying
.BI \-i 3
would use 3 devices for striped logical volumes,
-4 devices for RAID 4/5, and 5 devices for RAID 6.
+4 devices for RAID 4/5, and 5 devices for RAID 6. Alternatively,
+RAID 4/5/6 will stripe across all PVs in the volume group or
+all of the PVs specified if the
+.B \-i
+argument is omitted.
.TP
.BR \-I ", " \-\-stripesize " " \fIStripeSize
Gives the number of kilobytes for the granularity of the stripes.
@@ -491,8 +495,14 @@ a parity drive for a total of 4 devices) and a stripesize of 64KiB:
.sp
.B lvcreate \-\-type raid5 \-L 5G \-i 3 \-I 64 \-n my_lv vg00
+Creates a RAID5 logical volume "vg00/my_lv", using all of the free
+space in the VG and spanning all the PVs in the VG:
+.sp
+.B lvcreate \-\-type raid5 \-l 100%FREE \-n my_lv vg00
+
Creates a 5GiB RAID10 logical volume "vg00/my_lv", with 2 stripes on
-2 2-way mirrors. Note that the \fB-i\fP and \fB-m\fP arguments behave differently.
+2 2-way mirrors. Note that the \fB-i\fP and \fB-m\fP arguments behave
+differently.
The \fB-i\fP specifies the number of stripes.
The \fB-m\fP specifies the number of
.B additional
diff --git a/test/shell/lvcreate-raid.sh b/test/shell/lvcreate-raid.sh
index 2a1ed6d..3f467f5 100644
--- a/test/shell/lvcreate-raid.sh
+++ b/test/shell/lvcreate-raid.sh
@@ -11,6 +11,14 @@
. lib/test
+lv_devices() {
+ local local_vg=$1
+ local local_lv=$2
+ local count=$3
+
+ [ $count == `lvs --noheadings -o devices $local_vg/$local_lv | sed s/,/' '/g | wc -w` ]
+}
+
########################################################
# MAIN
########################################################
@@ -154,3 +162,34 @@ lvcreate -l 18 -n lv $vg $dev1
lvcreate -i 2 -l 100%FREE -n stripe $vg
check lv_field $vg/stripe size "93.00m"
lvremove -ff $vg
+
+# Create RAID (implicit stripe count based on PV count)
+#######################################################
+
+# Not enough drives
+not lvcreate --type raid1 -l1 $vg $dev1
+not lvcreate --type raid5 -l2 $vg $dev1 $dev2
+not lvcreate --type raid6 -l3 $vg $dev1 $dev2 $dev3 $dev4
+not lvcreate --type raid10 -l2 $vg $dev1 $dev2 $dev3
+
+# Implicit count comes from #PVs given (always 2 for mirror though)
+lvcreate --type raid1 -l1 -n raid1 $vg $dev1 $dev2
+lv_devices $vg raid1 2
+lvcreate --type raid5 -l2 -n raid5 $vg $dev1 $dev2 $dev3
+lv_devices $vg raid5 3
+lvcreate --type raid6 -l3 -n raid6 $vg $dev1 $dev2 $dev3 $dev4 $dev5
+lv_devices $vg raid6 5
+lvcreate --type raid10 -l2 -n raid10 $vg $dev1 $dev2 $dev3 $dev4
+lv_devices $vg raid10 4
+lvremove -ff $vg
+
+# Implicit count comes from total #PVs in VG (always 2 for mirror though)
+lvcreate --type raid1 -l1 -n raid1 $vg
+lv_devices $vg raid1 2
+lvcreate --type raid5 -l2 -n raid5 $vg
+lv_devices $vg raid5 6
+lvcreate --type raid6 -l3 -n raid6 $vg
+lv_devices $vg raid6 6
+lvcreate --type raid10 -l2 -n raid10 $vg
+lv_devices $vg raid10 6
+lvremove -ff $vg
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index b413f34..67ea8c6 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -619,20 +619,7 @@ static int _read_raid_params(struct lvcreate_params *lp,
return 0;
}
- /*
- * get_stripe_params is called before _read_raid_params
- * and already sets:
- * lp->stripes
- * lp->stripe_size
- *
- * For RAID 4/5/6/10, these values must be set.
- */
- if (!segtype_is_mirrored(lp->segtype) &&
- (lp->stripes <= lp->segtype->parity_devs)) {
- log_error("Number of stripes must be at least %d for %s",
- lp->segtype->parity_devs + 1, lp->segtype->name);
- return 0;
- } else if (!strcmp(lp->segtype->name, "raid10") && (lp->stripes < 2)) {
+ if (!strcmp(lp->segtype->name, "raid10") && (lp->stripes < 2)) {
if (arg_count(cmd, stripes_ARG)) {
/* User supplied the bad argument */
log_error("Segment type 'raid10' requires 2 or more stripes.");
@@ -1184,6 +1171,45 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
return 1;
}
+static int _check_raid_parameters(struct volume_group *vg,
+ struct lvcreate_params *lp,
+ struct lvcreate_cmdline_params *lcp)
+{
+ int devs = lcp->pv_count ? lcp->pv_count : dm_list_size(&vg->pvs);
+ struct cmd_context *cmd = vg->cmd;
+
+ /*
+ * If number of devices was not supplied, we can infer from
+ * the PVs given.
+ */
+ if (!seg_is_mirrored(lp)) {
+ if (!arg_count(cmd, stripes_ARG) &&
+ (devs > 2 * lp->segtype->parity_devs))
+ lp->stripes = devs - lp->segtype->parity_devs;
+
+ if (!lp->stripe_size)
+ lp->stripe_size = find_config_tree_int(cmd, metadata_stripesize_CFG, NULL) * 2;
+
+ if (lp->stripes <= lp->segtype->parity_devs) {
+ log_error("Number of stripes must be at least %d for %s",
+ lp->segtype->parity_devs + 1,
+ lp->segtype->name);
+ return 0;
+ }
+ } else if (!strcmp(lp->segtype->name, "raid10")) {
+ if (!arg_count(cmd, stripes_ARG))
+ lp->stripes = devs / lp->mirrors;
+ if (lp->stripes < 2) {
+ log_error("Unable to create RAID10 LV,"
+ " insufficient number of devices.");
+ return 0;
+ }
+ }
+ /* 'mirrors' defaults to 2 - not the number of PVs supplied */
+
+ return 1;
+}
+
/*
* Ensure the set of thin parameters extracted from the command line is consistent.
*/
@@ -1249,6 +1275,9 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
if (seg_is_cache(&lp) && !_determine_cache_argument(vg, &lp))
goto_out;
+ if (seg_is_raid(&lp) && !_check_raid_parameters(vg, &lp, &lcp))
+ goto_out;
+
/*
* Check activation parameters to support inactive thin snapshot creation
* FIXME: anything else needs to be moved past _determine_snapshot_type()?
10 years, 4 months
master - tests: drop more debug.log
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0be6caba6e4251...
Commit: 0be6caba6e4251200eb888a2686ddf9af8065d6c
Parent: 18cac1654045a8eebc09ba418f2f8b4f6ebd9556
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Feb 15 20:40:57 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 17 22:25:53 2014 +0100
tests: drop more debug.log
Avoid login result from last lvm command when target_at_least fails.
---
test/lib/aux.sh | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index 9420528..7587c4b 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -691,6 +691,7 @@ can_use_16T()
# i.e. dm_target_at_least dm-thin-pool 1 0
target_at_least()
{
+ rm -f debug.log
case "$1" in
dm-*) modprobe "$1" || true ;;
esac
10 years, 4 months
master - tests: more clustered testing
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=18cac1654045a8...
Commit: 18cac1654045a8eebc09ba418f2f8b4f6ebd9556
Parent: 37cf2019063aa34cddf88ae3e2ee0f974f97b105
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Feb 15 20:40:42 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 17 22:25:53 2014 +0100
tests: more clustered testing
---
test/shell/pvmove-all-segtypes.sh | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/test/shell/pvmove-all-segtypes.sh b/test/shell/pvmove-all-segtypes.sh
index fcd8913..5e1c71c 100644
--- a/test/shell/pvmove-all-segtypes.sh
+++ b/test/shell/pvmove-all-segtypes.sh
@@ -13,12 +13,11 @@ test_description="ensure pvmove works with all common segment types"
. lib/test
-test -e LOCAL_CLVMD && skip
which mkfs.ext2 || skip
which md5sum || skip
aux prepare_pvs 5 20
-vgcreate -c n -s 256k $vg $(cat DEVICES)
+vgcreate -s 256k $vg $(cat DEVICES)
# Each of the following tests does:
# 1) Create two LVs - one linear and one other segment type
@@ -27,8 +26,8 @@ vgcreate -c n -s 256k $vg $(cat DEVICES)
# 3) Move only the second LV by name
# Testing pvmove of linear LV
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
-lvcreate -l 2 -n $lv1 $vg "$dev1"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 -n $lv1 $vg "$dev1"
check lv_tree_on $vg ${lv1}_foo "$dev1"
check lv_tree_on $vg $lv1 "$dev1"
aux mkdev_md5sum $vg $lv1
@@ -43,8 +42,8 @@ check dev_md5sum $vg $lv1
lvremove -ff $vg
# Testing pvmove of stripe LV
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
-lvcreate -l 4 -i 2 -n $lv1 $vg "$dev1" "$dev2"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 4 -i 2 -n $lv1 $vg "$dev1" "$dev2"
check lv_tree_on $vg ${lv1}_foo "$dev1"
check lv_tree_on $vg $lv1 "$dev1" "$dev2"
aux mkdev_md5sum $vg $lv1
@@ -58,9 +57,14 @@ check lv_tree_on $vg ${lv1}_foo "$dev5"
check dev_md5sum $vg $lv1
lvremove -ff $vg
+if test -e LOCAL_CLVMD ; then
+#FIXME these tests currently fail end require cmirrord
+echo "TEST WARNING, FIXME!!! pvmove in clustered VG not fully supported!"
+else
+
# Testing pvmove of mirror LV
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
-lvcreate -l 2 --type mirror -m 1 -n $lv1 $vg "$dev1" "$dev2"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 --type mirror -m 1 -n $lv1 $vg "$dev1" "$dev2"
check lv_tree_on $vg ${lv1}_foo "$dev1"
check lv_tree_on $vg $lv1 "$dev1" "$dev2"
aux mkdev_md5sum $vg $lv1
@@ -76,8 +80,8 @@ lvremove -ff $vg
# Dummy LV and snap share dev1, while origin is on dev2
# Testing pvmove of snapshot LV
-lvcreate -l 2 -n ${lv1}_foo $vg "$dev1"
-lvcreate -l 2 -n $lv1 $vg "$dev2"
+lvcreate -aey -l 2 -n ${lv1}_foo $vg "$dev1"
+lvcreate -aey -l 2 -n $lv1 $vg "$dev2"
lvcreate -s $vg/$lv1 -l 2 -n snap "$dev1"
check lv_tree_on $vg ${lv1}_foo "$dev1"
check lv_tree_on $vg snap "$dev1"
@@ -91,3 +95,4 @@ check lv_tree_on $vg snap "$dev4"
check lv_tree_on $vg ${lv1}_foo "$dev5"
check dev_md5sum $vg snap
lvremove -ff $vg
+fi
10 years, 4 months
master - tests: on older system use mirror type
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=37cf2019063aa3...
Commit: 37cf2019063aa34cddf88ae3e2ee0f974f97b105
Parent: 8eedb18c73f81de8682649afd21c996883c33e76
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Feb 15 13:28:16 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 17 22:25:53 2014 +0100
tests: on older system use mirror type
---
test/shell/lvchange-partial.sh | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/test/shell/lvchange-partial.sh b/test/shell/lvchange-partial.sh
index 891dd0a..4e508a9 100644
--- a/test/shell/lvchange-partial.sh
+++ b/test/shell/lvchange-partial.sh
@@ -11,11 +11,13 @@
. lib/test
-aux target_at_least dm-raid 1 1 0 || skip
aux prepare_vg 4
-lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg
+TYPE=raid1
+aux target_at_least dm-raid 1 1 0 || TYPE=mirror
+
+lvcreate --type $TYPE -m 1 -l 2 -n $lv1 $vg
lvchange -an $vg/$lv1
aux disable_dev "$dev1"
10 years, 4 months
master - tests: add short delay
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8eedb18c73f81d...
Commit: 8eedb18c73f81de8682649afd21c996883c33e76
Parent: 9974136b907962438079e4c634541f97d1f9fd61
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Feb 15 13:02:41 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 17 22:25:53 2014 +0100
tests: add short delay
Give some extra delay so the file will be opened.
---
test/shell/snapshot-usage.sh | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index 9e6a14f..14a87c0 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -55,6 +55,9 @@ trap 'cleanup_tail' EXIT
sleep 30 < $DM_DEV_DIR/$vg1/$lv1 &
SLEEP_PID=$!
+# give some short time to lock file above
+sleep 0.1
+
# Opened virtual snapshot device is not removable
# it should retry device removal for a few seconds
not lvremove -f $vg1/$lv1
10 years, 4 months
master - cleanup: indent
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9974136b907962...
Commit: 9974136b907962438079e4c634541f97d1f9fd61
Parent: 25cea92338876f7ed02b05652a2de3f28c9bae1c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 17 21:49:51 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 17 22:25:53 2014 +0100
cleanup: indent
---
lib/activate/dev_manager.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index fe36149..6b5f8c2 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2506,7 +2506,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
dinfo->open_count)) {
if (seg_is_thin_volume(seg) ||
/* FIXME Is there anything simpler to check for instead? */
- !lv_has_target_type(dm->mem, lv, NULL, "snapshot-merge"))
+ !lv_has_target_type(dm->mem, lv, NULL, "snapshot-merge"))
laopts->no_merging = 1;
}
}
@@ -2562,7 +2562,7 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
if (!laopts->no_merging && lv_is_merging_origin(lv)) {
if (!_add_new_lv_to_dtree(dm, dtree,
- find_snapshot(lv)->cow, laopts, "cow"))
+ find_snapshot(lv)->cow, laopts, "cow"))
return_0;
/*
* Must also add "real" LV for use when
10 years, 4 months
master - thin: fix merge of old snaphost
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=25cea92338876f...
Commit: 25cea92338876f7ed02b05652a2de3f28c9bae1c
Parent: f33a224ef016f2071d7f0f6fdacfe56d98c3c58a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 17 21:48:27 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 17 22:25:53 2014 +0100
thin: fix merge of old snaphost
Fix merging of old snapshot into thinvolume origin.
Add also internal error for the error case when
merging requests activation of merged LV.
---
WHATS_NEW | 1 +
lib/metadata/snapshot_manip.c | 3 ++-
lib/thin/thin.c | 11 ++++++-----
test/shell/thin-merge.sh | 15 +++++++++------
tools/lvconvert.c | 2 +-
5 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c02fcae..03a3b8a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Fix merging of old snapshot into thin volume origin.
Use --ignoreskippedcluster in lvm2-monitor initscript/systemd unit.
Do not use VG read/write state for LV read/write state.
Use --ignoreskippedcluster in activation systemd units if use_lvmetad=0.
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index e563a78..362c805 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -15,6 +15,7 @@
#include "lib.h"
#include "metadata.h"
+#include "segtype.h"
#include "locking.h"
#include "toolcontext.h"
#include "lv_alloc.h"
@@ -151,7 +152,7 @@ void init_snapshot_merge(struct lv_segment *snap_seg,
origin->snapshot = snap_seg;
origin->status |= MERGING;
- if (lv_is_thin_volume(origin)) {
+ if (seg_is_thin_volume(snap_seg)) {
snap_seg->merge_lv = origin;
/* Making thin LV inivisible with regular log */
lv_set_hidden(snap_seg->lv);
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 8eaa73d..92767a8 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -542,18 +542,19 @@ static int _thin_add_target_line(struct dev_manager *dm,
}
if (!laopts->no_merging) {
+ if (seg->merge_lv) {
+ log_error(INTERNAL_ERROR "Failed to add merged segment of %s.",
+ seg->lv->name);
+ return 0;
+ }
/*
* merge support for thinp snapshots is implemented by
* simply swapping the thinp device_id of the snapshot
* and origin.
*/
- if (seg->merge_lv) {
- /* snapshot, use merging lv's device_id */
- device_id = first_seg(seg->merge_lv)->device_id;
- } else if (lv_is_merging_origin(seg->lv)) {
+ if (lv_is_merging_origin(seg->lv) && seg_is_thin_volume(find_snapshot(seg->lv)))
/* origin, use merging snapshot's device_id */
device_id = find_snapshot(seg->lv)->device_id;
- }
}
if (!dm_tree_node_add_thin_target(node, len, pool_dlid, device_id))
diff --git a/test/shell/thin-merge.sh b/test/shell/thin-merge.sh
index 10a81f0..0bb5ee7 100644
--- a/test/shell/thin-merge.sh
+++ b/test/shell/thin-merge.sh
@@ -13,7 +13,8 @@
. lib/test
-which mkfs.ext2 || skip
+MKFS=mkfs.ext2
+which $MKFS || skip
which fsck || skip
#
@@ -27,13 +28,13 @@ lvcreate -T -L8M $vg/pool -V10M -n $lv1
lvchange --addtag tagL $vg/$lv1
mkdir mnt
-mkfs.ext2 $DM_DEV_DIR/$vg/$lv1
+$MKFS $DM_DEV_DIR/$vg/$lv1
mount $DM_DEV_DIR/$vg/$lv1 mnt
touch mnt/test
lvcreate -K -s -n snap --addtag tagS $vg/$lv1
mkdir mntsnap
-mkfs.ext2 $DM_DEV_DIR/$vg/snap
+$MKFS $DM_DEV_DIR/$vg/snap
mount $DM_DEV_DIR/$vg/snap mntsnap
touch mntsnap/test_snap
@@ -82,7 +83,7 @@ lvchange -ay $vg/$lv1
check lv_exists $vg $lv1
check lv_field $vg/$lv1 thin_id "2"
check lv_field $vg/$lv1 tags "tagL"
-not check lv_exists $vg snap
+check lv_not_exists $vg snap
fsck -n $DM_DEV_DIR/$vg/$lv1
mount $DM_DEV_DIR/$vg/$lv1 mnt
@@ -97,8 +98,10 @@ lvcreate -s -n snap $vg/$lv1
# Also add old snapshot to thin origin
lvcreate -s -L10 -n oldsnapof_${lv1} $vg/$lv1
not lvconvert --merge $vg/snap
-lvremove -f $vg/oldsnapof_${lv1}
-
+$MKFS $DM_DEV_DIR/$vg/oldsnapof_${lv1}
+lvconvert --merge $vg/oldsnapof_${lv1}
+fsck -n $DM_DEV_DIR/$vg/$lv1
+check lv_not_exists $vg oldsnapof_${lv1}
# Add old snapshot to thin snapshot
lvcreate -s -L10 -n oldsnapof_snap $vg/snap
lvconvert --merge $vg/snap
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d53b83a..7fc1949 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -897,7 +897,7 @@ int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
if (lv_is_merging_origin(lv))
return poll_daemon(cmd, lv_full_name, uuid, background, 0,
- lv_is_thin_volume(lv) ?
+ seg_is_thin_volume(find_snapshot(lv)) ?
&_lvconvert_thin_merge_fns : &_lvconvert_merge_fns,
"Merged");
10 years, 4 months
master - scripts: use --ignoreskippedcluster in lvm2-monitor initscript/systemd unit
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f33a224ef016f2...
Commit: f33a224ef016f2071d7f0f6fdacfe56d98c3c58a
Parent: 6e2f70623351fe5de0e8179d377578a08b0a3625
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Feb 17 16:25:32 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Feb 17 16:29:49 2014 +0100
scripts: use --ignoreskippedcluster in lvm2-monitor initscript/systemd unit
When clustered VG is available in the system but we don't have
clustering set up for whatever reason, the lvm2-monitor scripts should
not fail completely just because these clustered VGs are skipped during
vgs/vgchange calls in lvm2-monitor initscript/systemd unit.
---
WHATS_NEW | 1 +
scripts/lvm2_monitoring_init_red_hat.in | 8 ++++----
scripts/lvm2_monitoring_systemd_red_hat.service.in | 4 ++--
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 17b79ba..c02fcae 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Use --ignoreskippedcluster in lvm2-monitor initscript/systemd unit.
Do not use VG read/write state for LV read/write state.
Use --ignoreskippedcluster in activation systemd units if use_lvmetad=0.
Allow approximate allocation when specifying size in percentage terms.
diff --git a/scripts/lvm2_monitoring_init_red_hat.in b/scripts/lvm2_monitoring_init_red_hat.in
index cae652c..44de07f 100644
--- a/scripts/lvm2_monitoring_init_red_hat.in
+++ b/scripts/lvm2_monitoring_init_red_hat.in
@@ -48,10 +48,10 @@ start()
{
ret=0
# TODO do we want to separate out already active groups only?
- VGSLIST=`$VGS --noheadings -o name --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
+ VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
for vg in $VGSLIST
do
- action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y --poll y --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
+ action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y --poll y --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
done
return $ret
@@ -66,10 +66,10 @@ stop()
echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override."
return 1
fi
- VGSLIST=`$VGS --noheadings -o name --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
+ VGSLIST=`$VGS --noheadings -o name --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' 2> /dev/null`
for vg in $VGSLIST
do
- action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
+ action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n --ignoreskippedcluster --config 'log{command_names=0 prefix=" "}' $vg || ret=$?
done
return $ret
}
diff --git a/scripts/lvm2_monitoring_systemd_red_hat.service.in b/scripts/lvm2_monitoring_systemd_red_hat.service.in
index 670d0c4..05f911b 100644
--- a/scripts/lvm2_monitoring_systemd_red_hat.service.in
+++ b/scripts/lvm2_monitoring_systemd_red_hat.service.in
@@ -10,9 +10,9 @@ Conflicts=shutdown.target
[Service]
Type=oneshot
Environment=LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
-ExecStart=@sbindir@/lvm vgchange --monitor y
+ExecStart=@sbindir@/lvm vgchange --monitor y --ignoreskippedcluster
# The lvmetad must be disabled here, it needs https://bugzilla.redhat.com/show_bug.cgi?id=843587 to be resolved first.
-ExecStop=@sbindir@/lvm vgchange --monitor n --config 'global{use_lvmetad=0}'
+ExecStop=@sbindir@/lvm vgchange --monitor n --config 'global{use_lvmetad=0}' --ignoreskippedcluster
RemainAfterExit=yes
[Install]
10 years, 4 months
master - cleanup: use struct initializer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6e2f70623351fe...
Commit: 6e2f70623351fe5de0e8179d377578a08b0a3625
Parent: a508786664f225d22c3549739abe7a749fc10960
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 14 21:36:56 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Feb 15 11:36:53 2014 +0100
cleanup: use struct initializer
---
libdm/libdm-deptree.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 6d45e08..cede734 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -3110,14 +3110,13 @@ int dm_tree_node_add_raid_target(struct dm_tree_node *node,
uint64_t rebuilds,
uint64_t flags)
{
- struct dm_tree_node_raid_params params;
-
- memset(¶ms, 0, sizeof(params));
- params.raid_type = raid_type;
- params.region_size = region_size;
- params.stripe_size = stripe_size;
- params.rebuilds = rebuilds;
- params.flags = flags;
+ struct dm_tree_node_raid_params params = {
+ .raid_type = raid_type,
+ .region_size = region_size,
+ .stripe_size = stripe_size,
+ .rebuilds = rebuilds,
+ .flags = flags
+ };
return dm_tree_node_add_raid_target_with_params(node, size, ¶ms);
}
10 years, 4 months