Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2ef48b91ed74f732…
Commit: 2ef48b91ed74f732b6150a9492da624d204b331d
Parent: caa77b33f2d5e59f2906b9f08f59ac2e64b14682
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Aug 26 16:36:30 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Aug 26 16:36:30 2013 -0500
pvmove: Allow moving snapshot/origin. Disallow converting and merging LVs
The patch allows the user to also pvmove snapshots and origin logical
volumes. This means pvmove should be able to move all segment types.
I have, however, disallowed moving converting or merging logical volumes.
---
WHATS_NEW | 2 ++
man/pvmove.8.in | 5 -----
tools/pvmove.c | 12 +++++++-----
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 069c3c2..29af78d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.101 -
===================================
+ Disable pvmove of merging or converting logical volumes.
+ Enable pvmove of snapshots and snapshot origins.
Fix inability to specify LV name when pvmove'ing a RAID, mirror, or thin-LV.
Inform lvmetad about any lost PV label to make it in sync with system state.
Support most of lvchange operations on stacked thin pool meta/data LVs.
diff --git a/man/pvmove.8.in b/man/pvmove.8.in
index ba6ea1e..79ccf1c 100644
--- a/man/pvmove.8.in
+++ b/man/pvmove.8.in
@@ -75,9 +75,6 @@ is updated so that the Logical Volumes reflect the new data locations.
Note that this new process cannot support the original LVM1
type of on-disk metadata. Metadata can be converted using \fBvgconvert\fP(8).
-N.B. The moving of non-thinly provisioned snapshots and their
-origins is not supported.
-
.SH OPTIONS
See \fBlvm\fP(8) for common options.
.TP
@@ -110,8 +107,6 @@ To move all Physical Extents that are used by simple Logical Volumes on
.sp
.B pvmove /dev/sdb1
.P
-Any non-thinly provisioned snapshots and their origins are left unchanged.
-.P
Additionally, a specific destination device /dev/sdc1
can be specified like this:
.sp
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 2868290..1007370 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -295,6 +295,13 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
if (!lv_is_on_pvs(lv, source_pvl))
continue;
+ if (lv->status & (CONVERTING | MERGING)) {
+ log_error("Unable to pvmove when %s volumes are present",
+ (lv->status & CONVERTING) ?
+ "converting" : "merging");
+ return NULL;
+ }
+
if (seg_is_raid(first_seg(lv)) ||
seg_is_mirrored(first_seg(lv))) {
dm_list_init(&trim_list);
@@ -327,11 +334,6 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
if (!lv_is_on_pvs(lv, source_pvl))
continue;
- if (lv_is_origin(lv) || lv_is_cow(lv)) {
- lv_skipped = 1;
- log_print_unless_silent("Skipping snapshot-related LV %s", lv->name);
- continue;
- }
seg = first_seg(lv);
if (seg_is_raid(seg) || seg_is_mirrored(seg) ||
lv_is_thin_volume(lv) || lv_is_thin_pool(lv)) {
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=caa77b33f2d5e59f…
Commit: caa77b33f2d5e59f2906b9f08f59ac2e64b14682
Parent: d34ab5e0d39543db4f17994432a49a77709b3487
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Aug 26 14:12:31 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Aug 26 14:12:31 2013 -0500
pvmove: Fix inability to specify LV name when moving RAID, mirror, or thin LV
Top-level LVs (like RAID, mirror or thin) are ignored when determining which
portions of an LV to pvmove. If the user specified the name of an LV to
move and it was one of the above types, it would be skipped. The code would
never move on to check whether its sub-LVs needed moving because their names
did not match what the user specified.
The solution is to check whether a sub-LVs is part of the LV whose name was
specified by the user - not just if there was a name match.
---
WHATS_NEW | 1 +
tools/pvmove.c | 26 +++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c0744f6..069c3c2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
+ Fix inability to specify LV name when pvmove'ing a RAID, mirror, or thin-LV.
Inform lvmetad about any lost PV label to make it in sync with system state.
Support most of lvchange operations on stacked thin pool meta/data LVs.
Add ability to pvmove RAID, mirror, and thin volumes.
diff --git a/tools/pvmove.c b/tools/pvmove.c
index 8e95048..2868290 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -16,6 +16,7 @@
#include "tools.h"
#include "polldaemon.h"
#include "display.h"
+#include "metadata.h" /* for 'get_only_segment_using_this_lv' */
#define PVMOVE_FIRST_TIME 0x00000001 /* Called for first time */
#define PVMOVE_EXCLUSIVE 0x00000002 /* Require exclusive LV */
@@ -209,6 +210,29 @@ static int _insert_pvmove_mirrors(struct cmd_context *cmd,
return 1;
}
+/*
+ * Is 'lv' a sub_lv of the LV by the name of 'lv_name'?
+ *
+ * Returns: 1 if true, 0 otherwise
+ */
+static int sub_lv_of(struct logical_volume *lv, const char *lv_name)
+{
+ struct lv_segment *seg;
+
+ /* Sub-LVs only ever have one segment using them */
+ if (dm_list_size(&lv->segs_using_this_lv) != 1)
+ return 0;
+
+ if (!(seg = get_only_segment_using_this_lv(lv)))
+ return_0;
+
+ if (!strcmp(seg->lv->name, lv_name))
+ return 1;
+
+ /* Continue up the tree */
+ return sub_lv_of(seg->lv, lv_name);
+}
+
/* Create new LV with mirror segments for the required copies */
static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
struct volume_group *vg,
@@ -295,7 +319,7 @@ static struct logical_volume *_set_up_pvmove_lv(struct cmd_context *cmd,
if (lv == lv_mirr)
continue;
if (lv_name) {
- if (strcmp(lv->name, lv_name))
+ if (strcmp(lv->name, lv_name) && !sub_lv_of(lv, lv_name))
continue;
lv_found = 1;
}
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d34ab5e0d39543db…
Commit: d34ab5e0d39543db4f17994432a49a77709b3487
Parent: 4d3b5724e0b51782000a45027de00e0fed1c9833
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 26 15:52:15 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 26 15:52:15 2013 +0200
WHATS_NEW: for 4d3b5724e0b51782000a45027de00e0fed1c9833
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index bf13023..c0744f6 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.101 -
===================================
+ Inform lvmetad about any lost PV label to make it in sync with system state.
Support most of lvchange operations on stacked thin pool meta/data LVs.
Add ability to pvmove RAID, mirror, and thin volumes.
Make lvm2-activation-generator silent unless it's in error state.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4d3b5724e0b51782…
Commit: 4d3b5724e0b51782000a45027de00e0fed1c9833
Parent: 6b416f837f4ee71ca5705cb40fad22b26b0c664a
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 26 15:27:00 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 26 15:40:16 2013 +0200
udev: inform lvmetad about lost PV label
In stacked environment where we have a PV layered on top of a
snapshot LV and then removing the LV, lvmetad still keeps information
about the PV:
[0] raw/~ $ pvcreate /dev/sda
Physical volume "/dev/sda" successfully created
[0] raw/~ $ vgcreate vg /dev/sda
Volume group "vg" successfully created
[0] raw/~ $ lvcreate -L32m vg
Logical volume "lvol0" created
[0] raw/~ $ lvcreate -L32m -s vg/lvol0
Logical volume "lvol1" created
[0] raw/~ $ pvcreate /dev/vg/lvol1
Physical volume "/dev/vg/lvol1" successfully created
[0] raw/~ $ lvremove -ff vg/lvol1
Logical volume "lvol1" successfully removed
[0] raw/~ $ pvs
No device found for PV BdNlu2-7bHV-XcIp-mFFC-PPuR-ef6K-yffdzO.
PV VG Fmt Attr PSize PFree
/dev/sda vg lvm2 a-- 124.00m 92.00m
[0] raw/~ $ pvscan --cache --major 253 --minor 3
Device 253:3 not found. Cleared from lvmetad cache.
This is because of the reactivation that is done just before
snapshot removal as part of the process (vg/lvol1 from the example above).
This causes a CHANGE event to be generated, but any scan done
on the LV does not see the original data anymore (in this case
the stacked PV label on top) and consequently the ID_FS_TYPE="LVM2_member"
(provided by blkid scan) is not stored in udev db anymore for the LV.
Consequently, the pvscan --cache is not run anymore as the dev is not
identified as LVM PV by the "LVM2_member" id - lvmetad loses this info
and still keeps records about the PV.
We can run into a very similar problem with erasing the PV label directly:
[0] raw/~ $ lvcreate -L32m vg
Logical volume "lvol0" created
[0] raw/~ $ pvcreate /dev/vg/lvol0
Physical volume "/dev/vg/lvol0" successfully created
[0] raw/~ $ dd if=/dev/zero of=/dev/vg/lvol0 bs=1M
dd: error writing '/dev/vg/lvol0': No space left on device
33+0 records in
32+0 records out
33554432 bytes (34 MB) copied, 0.380921 s, 88.1 MB/s
[0] raw/~ $ pvs
PV VG Fmt Attr PSize PFree
/dev/sda vg lvm2 a-- 124.00m 92.00m
/dev/vg/lvol0 lvm2 a-- 32.00m 32.00m
[0] raw/~ $ pvscan --cache --major 253 --minor 2
No PV label found on /dev/vg/lvol0.
This patch adds detection of this change from ID_FS_LABEL="LVM2_member"
to ID_FS_LABEL="<whatever_else>" and hence informing the lvmetad
about PV being gone.
---
udev/13-dm-disk.rules.in | 4 ++++
udev/69-dm-lvm-metad.rules.in | 3 +++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/udev/13-dm-disk.rules.in b/udev/13-dm-disk.rules.in
index 1920260..f8e4ac6 100644
--- a/udev/13-dm-disk.rules.in
+++ b/udev/13-dm-disk.rules.in
@@ -17,6 +17,10 @@ ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}=="1", GOTO="dm_end"
SYMLINK+="disk/by-id/dm-name-$env{DM_NAME}"
ENV{DM_UUID}=="?*", SYMLINK+="disk/by-id/dm-uuid-$env{DM_UUID}"
+# Save previously detected dev type.
+IMPORT{db}="ID_FS_TYPE"
+ENV{ID_FS_TYPE}=="?*", ENV{DM_ID_FS_TYPE_OLD}="$env{ID_FS_TYPE}", ENV{ID_FS_TYPE}=""
+
ENV{DM_SUSPENDED}=="1", GOTO="dm_end"
(BLKID_RULE)
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index d5087e3..2d6720e 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -17,6 +17,9 @@
SUBSYSTEM!="block", GOTO="lvm_end"
(LVM_EXEC_RULE)
+# If the PV label got lost, inform lvmetad about it.
+ENV{DM_ID_FS_TYPE_OLD}=="LVM2_member", ENV{DM_ID_FS_TYPE}!="LVM2_member", GOTO="lvm_scan"
+
# Only process devices already marked as a PV - this requires blkid to be called before.
ENV{ID_FS_TYPE}!="LVM2_member|LVM1_member", GOTO="lvm_end"