master - tests: detect version of thin_restore command
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8403bbd4adabb6...
Commit: 8403bbd4adabb6718f45f67e5a4a98f6de26dbb6
Parent: 6fb19f37fe6419fd2c22c04ffd71e0ac4a0bca36
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 16 17:46:54 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:43:05 2014 +0200
tests: detect version of thin_restore command
Skip test when missing.
---
test/shell/lvextend-thin-metadata-dmeventd.sh | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/test/shell/lvextend-thin-metadata-dmeventd.sh b/test/shell/lvextend-thin-metadata-dmeventd.sh
index 44144c6..d7be3a2 100644
--- a/test/shell/lvextend-thin-metadata-dmeventd.sh
+++ b/test/shell/lvextend-thin-metadata-dmeventd.sh
@@ -43,6 +43,7 @@ fake_metadata_() {
}
test -n "$LVM_TEST_THIN_RESTORE_CMD" || LVM_TEST_THIN_RESTORE_CMD=$(which thin_restore) || skip
+"$LVM_TEST_THIN_RESTORE_CMD" -V || skip
aux have_thin 1 10 0 || skip
aux prepare_dmeventd
@@ -62,7 +63,7 @@ lvchange -an $vg/thin $vg/pool
# Prepare some fake metadata with unmatching id
# Transaction_id is lower by 1 and there are no message -> ERROR
fake_metadata_ 10 0 >data
-$LVM_TEST_THIN_RESTORE_CMD -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
+"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
lvconvert -y --thinpool $vg/pool --poolmetadata $vg/$lv1
not vgchange -ay $vg 2>&1 | tee out
grep expected out
@@ -71,7 +72,7 @@ check inactive $vg pool_tmeta
# Transaction_id is higher by 1
fake_metadata_ 10 2 >data
-$LVM_TEST_THIN_RESTORE_CMD -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
+"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
lvconvert -y --thinpool $vg/pool --poolmetadata $vg/$lv1
not vgchange -ay $vg 2>&1 | tee out
grep expected out
@@ -80,7 +81,7 @@ check inactive $vg pool_tmeta
# Prepare some fake metadata prefilled to ~81% (>70%)
fake_metadata_ 400 1 >data
-$LVM_TEST_THIN_RESTORE_CMD -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
+"$LVM_TEST_THIN_RESTORE_CMD" -i data -o "$DM_DEV_DIR/mapper/$vg-$lv1"
# Swap volume with restored fake metadata
lvconvert -y --thinpool $vg/pool --poolmetadata $vg/$lv1
8 years, 11 months
master - tests: wait for udev
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6fb19f37fe6419...
Commit: 6fb19f37fe6419fd2c22c04ffd71e0ac4a0bca36
Parent: 0558b1a0869f9a68d78e80140500874756c70e4d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 16 13:37:22 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:43:04 2014 +0200
tests: wait for udev
Before test exits, wait for udev.
---
test/lib/aux.sh | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/test/lib/aux.sh b/test/lib/aux.sh
index f6f0d0b..76b93ef 100644
--- a/test/lib/aux.sh
+++ b/test/lib/aux.sh
@@ -200,6 +200,9 @@ teardown_devs() {
for i in "${stray_loops[@]}" ; do losetup -d $i ; done
}
}
+
+ # Leave test when udev processed all removed devices
+ udev_wait
}
kill_sleep_kill_() {
8 years, 11 months
master - cleanup: we already know max device name size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0558b1a0869f9a...
Commit: 0558b1a0869f9a68d78e80140500874756c70e4d
Parent: 7aef45f9bb8620e194d086ebeeaca0312e8aee04
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 16 12:39:32 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:43:04 2014 +0200
cleanup: we already know max device name size
Use NAME_LEN constant to simplify creation of device name.
Since the max size should be already tested in validation,
throw INTERNAL_ERROR if the size of vg/lv is bigger then NAME_LEN.
---
tools/lvconvert.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 731d4c8..75eb565 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -884,15 +884,13 @@ int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
* the polldaemon, lvconvert, pvmove code that a comprehensive
* audit/rework is needed
*/
- int len = strlen(lv->vg->name) + strlen(lv->name) + 2;
- char *uuid = alloca(sizeof(lv->lvid));
- char *lv_full_name = alloca(len);
+ char uuid[sizeof(lv->lvid)];
+ char lv_full_name[NAME_LEN];
- if (!uuid || !lv_full_name)
- return_0;
-
- if (dm_snprintf(lv_full_name, len, "%s/%s", lv->vg->name, lv->name) < 0)
- return_0;
+ if (dm_snprintf(lv_full_name, sizeof(lv_full_name), "%s/%s", lv->vg->name, lv->name) < 0) {
+ log_error(INTERNAL_ERROR "Name \"%s/%s\" is too long.", lv->vg->name, lv->name);
+ return 0;
+ }
memcpy(uuid, &lv->lvid, sizeof(lv->lvid));
8 years, 11 months
master - cleanup: use stack for small buffer
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7aef45f9bb8620...
Commit: 7aef45f9bb8620e194d086ebeeaca0312e8aee04
Parent: 494db110040cdc88ebf60abee87b04c6c8718cea
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 16 12:38:14 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:42:45 2014 +0200
cleanup: use stack for small buffer
Avoid error checking of allocation error when just few bytes are needed
for short string and use stack.
Stacktrace lvmetad_pv_gone() fail path.
---
tools/pvscan.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index ac43295..d161ba0 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -164,18 +164,15 @@ out:
static int _clear_dev_from_lvmetad_cache(dev_t devno, int32_t major, int32_t minor,
activation_handler handler)
{
- char *buf;
+ char buf[24];
- if (dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor) < 0)
- stack;
- if (!lvmetad_pv_gone(devno, buf ? : "", handler)) {
- dm_free(buf);
- return 0;
- }
+ (void) dm_snprintf(buf, sizeof(buf), "%" PRIi32 ":%" PRIi32, major, minor);
+
+ if (!lvmetad_pv_gone(devno, buf, handler))
+ return_0;
log_print_unless_silent("Device %s not found. "
- "Cleared from lvmetad cache.", buf ? : "");
- dm_free(buf);
+ "Cleared from lvmetad cache.", buf);
return 1;
}
8 years, 11 months
master - snapshot: %ORIGIN is relative to data size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=494db110040cdc...
Commit: 494db110040cdc88ebf60abee87b04c6c8718cea
Parent: cd6d6fc24e8093d437543613ddbcbdb0e9c5f8c8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 17 13:33:42 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:41:01 2014 +0200
snapshot: %ORIGIN is relative to data size
Let's use the size of origin as the real base for percenta calculation,
and 'silenly' add needed metadata space for snapshot.
So now command 'lvcreate -s -l100%ORIGIN vg/lv' should always create a
snapshot to handle full device overwrite.
---
WHATS_NEW | 1 +
man/lvcreate.8.in | 12 +++++++++---
tools/lvcreate.c | 4 +++-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5d83a66..77dfdcf 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.107 -
==================================
+ Automatically add snapshot metadata size for -l %ORIGIN calculation.
When converting RAID origin to cache LV, properly rename sub-LVs.
Use RemoveOnStop for lvm2-lvmetad.socket systemd unit.
Add thin-generic configuration profile for generic thin settings.
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 9301063..4ae2b9a 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -240,7 +240,8 @@ remaining free space in the Volume Group with the suffix \fI%FREE\fR, as a
percentage of the remaining free space for the specified
PhysicalVolume(s) with the suffix \fI%PVS\fR, or (for a snapshot) as a
percentage of the total space in the Origin Logical Volume with the
-suffix \fI%ORIGIN\fR. When expressed as a percentage, the number is treated
+suffix \fI%ORIGIN\fR (i.e. \fI100%ORIGIN\fR provides space for the whole origin).
+When expressed as a percentage, the number is treated
as an approximate upper limit for the total number of physical extents
to be allocated (including extents used by any mirrors, for example).
.TP
@@ -492,8 +493,8 @@ This operation would require 2 devices - the log is "in-memory":
.sp
.B lvcreate \-m1 \-\-mirrorlog core \-L 500M vg00
-Creates a snapshot logical volume named /dev/vg00/snap which has access to the
-contents of the original logical volume named /dev/vg00/lvol1
+Creates a snapshot logical volume named "vg00/snap" which has access to the
+contents of the original logical volume named "vg00/lvol1"
at snapshot logical volume creation time. If the original logical volume
contains a file system, you can mount the snapshot logical volume on an
arbitrary directory in order to access the contents of the filesystem to run
@@ -501,6 +502,11 @@ a backup while the original filesystem continues to get updated:
.sp
.B lvcreate \-\-size 100m \-\-snapshot \-\-name snap /dev/vg00/lvol1
+Creates a snapshot logical volume named "vg00/snap" with size
+for overwriting 20% of the original logical volume named "vg00/lvol1".:
+.sp
+.B lvcreate \-s \-l 20%ORIGIN \-\-name snap vg00/lvol1
+
Creates a sparse device named /dev/vg1/sparse of size 1TiB with space for just
under 100MiB of actual data on it:
.sp
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 1fa5aef..86264f3 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -394,7 +394,9 @@ static int _update_extents_params(struct volume_group *vg,
log_error(INTERNAL_ERROR "Couldn't find origin volume.");
return 0;
}
- extents = percent_of_extents(lp->extents, origin->le_count, 0);
+ /* Add whole metadata size estimation */
+ extents = cow_max_extents(origin, lp->chunk_size) - origin->le_count +
+ percent_of_extents(lp->extents, origin->le_count, 1);
break;
case PERCENT_NONE:
extents = lp->extents;
8 years, 11 months
master - snapshot: report proper error message
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cd6d6fc24e8093...
Commit: cd6d6fc24e8093d437543613ddbcbdb0e9c5f8c8
Parent: 15e7066fe3ea7ca9129b68e3b39e9667348a02cc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 17 13:13:23 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:36:33 2014 +0200
snapshot: report proper error message
Expresing -lXX%LV is not valid for snapshot, but error message for
snapshost case was not complete and missed %ORIGIN.
Also document correct settings for in manpage properly where
it missed %PVS.
---
man/lvcreate.8.in | 2 +-
tools/lvcreate.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 9892c21..9301063 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -90,7 +90,7 @@ lvcreate \- create a logical volume in an existing volume group
.B lvcreate
.RB [ \-l | \-\-extents
-.IR LogicalExtentsNumber [ % { VG | FREE | ORIGIN }]
+.IR LogicalExtentsNumber [ % { ORIGIN | VG | PVS | FREE }]
|
.BR \-L | \-\-size
.IR LogicalVolumeSize [ bBsSkKmMgGtTpPeE ]]
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 2156265..1fa5aef 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -380,8 +380,8 @@ static int _update_extents_params(struct volume_group *vg,
extents = percent_of_extents(lp->extents, vg->extent_count, 0);
break;
case PERCENT_LV:
- log_error("Please express size as %%VG, %%PVS, or "
- "%%FREE.");
+ log_error("Please express size as %s%%VG, %%PVS, "
+ "or %%FREE.", (lp->snapshot) ? "%ORIGIN, " : "");
return 0;
case PERCENT_ORIGIN:
if (lp->snapshot && lp->origin &&
8 years, 11 months
master - snapshot: do not spawn when origin is not active
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=15e7066fe3ea7c...
Commit: 15e7066fe3ea7ca9129b68e3b39e9667348a02cc
Parent: c46d4a745dc8c5cb4cfc0c94863e555387e9af75
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 16 12:43:22 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:36:07 2014 +0200
snapshot: do not spawn when origin is not active
Since the code is not doing anything when origin is not active,
avoid spawning polling thread.
---
tools/toollib.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index add20e3..c619d9b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1455,7 +1455,7 @@ int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
* - fortunately: polldaemon will immediately shutdown if the
* origin doesn't have a status with a snapshot percentage
*/
- if (background_polling() && lv_is_merging_origin(lv))
+ if (background_polling() && lv_is_merging_origin(lv) && lv_is_active_locally(lv))
lv_spawn_background_polling(cmd, lv);
return 1;
8 years, 11 months
master - snapshot: check snapshot exists
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c46d4a745dc8c5...
Commit: c46d4a745dc8c5cb4cfc0c94863e555387e9af75
Parent: 435c82f8f6312758e1d198d4cb0a2158b7a51bac
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 16 12:41:30 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:36:07 2014 +0200
snapshot: check snapshot exists
Return 0 if the LV is not even snapshot.
---
lib/metadata/snapshot_manip.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index 5df0f98..278edc8 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -141,8 +141,9 @@ int lv_is_merging_origin(const struct logical_volume *origin)
int lv_is_merging_cow(const struct logical_volume *snapshot)
{
+ struct lv_segment *snap_seg = find_snapshot(snapshot);
/* checks lv_segment's status to see if cow is merging */
- return (find_snapshot(snapshot)->status & MERGING) ? 1 : 0;
+ return (snap_seg && (snap_seg->status & MERGING)) ? 1 : 0;
}
struct lv_segment *find_snapshot(const struct logical_volume *lv)
8 years, 11 months
master - snapshot: check it's still snapshot
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=435c82f8f63127...
Commit: 435c82f8f6312758e1d198d4cb0a2158b7a51bac
Parent: a20de8af208725ff2054209aa7ff7f41cc770db6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 16 13:38:35 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Jun 17 13:36:07 2014 +0200
snapshot: check it's still snapshot
While polling for snapshot, detect first the snapshot still
exits. It's valid to have multiple polling threads watching
for the same thing and just 1 can 'win' the finish part.
All others should nicely 'fail'.
---
tools/lvconvert.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 82ce360..731d4c8 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -801,7 +801,8 @@ static progress_t _poll_merge_progress(struct cmd_context *cmd,
{
percent_t percent = PERCENT_0;
- if (!lv_snapshot_percent(lv, &percent)) {
+ if (!lv_is_merging_origin(lv) ||
+ !lv_snapshot_percent(lv, &percent)) {
log_error("%s: Failed query for merging percentage. Aborting merge.", lv->name);
return PROGRESS_CHECK_FAILED;
} else if (percent == PERCENT_INVALID) {
8 years, 11 months
master - poll_daemon: Cleanly exit polling if the LV is no longer active
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a20de8af208725...
Commit: a20de8af208725ff2054209aa7ff7f41cc770db6
Parent: 962a40b98134417f27e89709625ba2ec662204c2
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Jun 16 18:56:32 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Jun 16 18:56:32 2014 -0500
poll_daemon: Cleanly exit polling if the LV is no longer active
If the we are polling an LV due to some sort of conversion and it
becomes inactive, a rather worrisome message is produced, e.g.:
" ABORTING: Mirror percentage check failed."
We can cleanly exit if we do a simple check to see if the LV is
active before performing the check. This eliminates the scary
message.
---
tools/polldaemon.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index be8a5a3..0765930 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -152,6 +152,16 @@ static int _wait_for_single_lv(struct cmd_context *cmd, const char *name, const
return 0;
}
+ /*
+ * If the LV is not active locally, the kernel cannot be
+ * queried for its status. We must exit in this case.
+ */
+ if (!lv_is_active_locally(lv)) {
+ log_print_unless_silent("%s: Interrupted: No longer active.", name);
+ unlock_and_release_vg(cmd, vg, vg->name);
+ return 1;
+ }
+
if (!_check_lv_status(cmd, vg, lv, name, parms, &finished)) {
unlock_and_release_vg(cmd, vg, vg->name);
return_0;
8 years, 11 months