master - tests: update pvmove-test
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c144305d3e6b68...
Commit: c144305d3e6b68bc9f85641a5038013fdc07b5a2
Parent: 7c6b14b74f88a58a9589922a3fa7be18334f3936
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 4 17:05:44 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 17:10:31 2013 +0100
tests: update pvmove-test
Do not lock test when trying to grab cluster lock.
There seems to be still something weird in this test
so it still needs some inspection.
---
test/shell/pvmove-restart.sh | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/test/shell/pvmove-restart.sh b/test/shell/pvmove-restart.sh
index c8da45e..e1d5381 100644
--- a/test/shell/pvmove-restart.sh
+++ b/test/shell/pvmove-restart.sh
@@ -33,16 +33,37 @@ PVMOVE=$!
# Let's wait a bit till pvmove starts and kill it
sleep 1
kill -9 $PVMOVE
+wait
# Simulate reboot - forcibly remove related devices
dmsetup remove $vg-$lv1
dmsetup remove $vg-pvmove0
+if test -e LOCAL_CLVMD ; then
+ # giveup all clvmd locks (faster then restarting clvmd)
+ # no deactivation happen, nodes are already removed
+ vgchange -an $vg
+ # Restart clvmd
+ #kill $(cat LOCAL_CLVMD)
+ #while test -e "/var/run/clvmd.pid"; do echo -n .; sleep .1; done # wait for the pid removal
+ #aux prepare_clvmd
+fi
+
+if test -e LOCAL_LVMETAD ; then
+ # Restart lvmetad
+ kill $(cat LOCAL_LVMETAD)
+ aux prepare_lvmetad
+fi
+
# Only PVs should be left in table...
dmsetup table
# Restart pvmove
-vgchange -ay $vg
+# use exclusive activation to have usable pvmove without cmirrord
+#vgchange -vvvv -ay $vg
+vgchange -aey $vg
+dmsetup table
+#pvmove
pvmove --abort
10 years, 3 months
master - tests: monitor debug.log size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7c6b14b74f88a5...
Commit: 7c6b14b74f88a58a9589922a3fa7be18334f3936
Parent: 598c82fc077c8a3edfbdb664b41efd89d05b5a10
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 4 17:01:59 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 17:10:31 2013 +0100
tests: monitor debug.log size
Show testing directory from test and monitor it in
harness - so when it gets too big - kill test.
---
test/lib/harness.c | 15 +++++++++++++++
test/lib/test.sh | 1 +
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/test/lib/harness.c b/test/lib/harness.c
index dca0198..47a331d 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -21,6 +21,7 @@
#include <sys/resource.h> /* rusage */
#include <sys/select.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -55,6 +56,7 @@ static const char *results;
static unsigned fullbuffer = 0;
static FILE *outfile = NULL;
+char testdirdebug[PATH_MAX];
struct subst {
const char *key;
@@ -100,6 +102,9 @@ static int outline(FILE *out, char *buf, int start, int force) {
subst[1].key = "@PREFIX@";
free(subst[1].value);
subst[1].value = strndup(from + 8, next - from - 8 - 1);
+ } else if (!testdirdebug[0] && !strncmp(from, "RUNTESTDIR=", 11)) {
+ from[strlen(from) - 1] = '\0'; /* Cut \n */
+ snprintf(testdirdebug, sizeof(testdirdebug), "%s/debug.log", from + 11);
} else {
char *line = strndup(from, next - from);
char *a = line, *b;
@@ -366,6 +371,7 @@ static void run(int i, char *f) {
char outpath[PATH_MAX];
char *c = outpath + strlen(results) + 1;
struct timeval selectwait;
+ struct stat statbuf;
fd_set set;
int runaway = 0;
int no_write = 0;
@@ -373,6 +379,7 @@ static void run(int i, char *f) {
int fd_vlm = -1;
//close(fds[1]);
+ testdirdebug[0] = '\0'; /* Capture RUNTESTDIR */
snprintf(buf, sizeof(buf), "%s ...", f);
printf("Running %-60s ", buf);
fflush(stdout);
@@ -409,6 +416,14 @@ static void run(int i, char *f) {
selectwait.tv_sec = 0;
selectwait.tv_usec = 500000; /* timeout 0.5s */
if (select(fds[0] + 1, &set, NULL, NULL, &selectwait) <= 0) {
+ /* Still checking debug log size if it's not growing too much */
+ if (testdirdebug[0] && (stat(testdirdebug, &statbuf) == 0) &&
+ statbuf.st_size > 8 * 1024 * 1024) { /* 8MB command log size */
+ fprintf(stderr, "Killing test since debug.log has gone wild (size %ld)\n",
+ statbuf.st_size);
+ kill(-pid, SIGINT);
+ }
+
no_write++;
continue;
}
diff --git a/test/lib/test.sh b/test/lib/test.sh
index 265d61d..9e25e26 100644
--- a/test/lib/test.sh
+++ b/test/lib/test.sh
@@ -39,6 +39,7 @@ test -n "$BASH" && trap 'set +vx; STACKTRACE; set -vx' ERR
trap 'aux teardown' EXIT # don't forget to clean up
cd "$TESTDIR"
+echo "RUNTESTDIR=$TESTDIR"
if test -n "$LVM_TEST_FLAVOUR"; then
touch flavour_overrides
10 years, 3 months
master - vgchange: move detection of remote exlusivness
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=598c82fc077c8a...
Commit: 598c82fc077c8a3edfbdb664b41efd89d05b5a10
Parent: 28939dba09fcd36cd0e4e470e73b172f19dd45e8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Nov 28 23:22:03 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 17:09:51 2013 +0100
vgchange: move detection of remote exlusivness
Since activation takes only read-lock, there could be
multiple activation running in parallel.
So instead of checking before taking any real lock,
let the locking resolve the problem and just
detect if the reason for failure has been remote
exlusive activation.
It should be also faster, since each activation does
not need to do explicit lock query.
---
WHATS_NEW | 1 +
tools/vgchange.c | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5d41700..60571ff 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Test for remote exclusive activation after activation fails.
Support lvconvert --merge for thin snapshots.
Add support to read thin device id from table line entry.
Drop extra test for origin when testing merging origin in lv_refresh().
diff --git a/tools/vgchange.c b/tools/vgchange.c
index b50b444..f9811d2 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -121,16 +121,6 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
((lv->status & PVMOVE) ))
continue;
- /*
- * If the LV is active exclusive remotely,
- * then ignore it here
- */
- if (lv_is_active_exclusive_remotely(lv)) {
- log_verbose("%s/%s is exclusively active on"
- " a remote node", vg->name, lv->name);
- continue;
- }
-
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG), 0)) {
log_verbose("ACTIVATION_SKIP flag set for LV %s/%s, skipping activation.",
lv->vg->name, lv->name);
@@ -144,7 +134,17 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
expected_count++;
if (!lv_change_activate(cmd, lv, activate)) {
- stack;
+ if (!lv_is_active_exclusive_remotely(lv))
+ stack;
+ else {
+ /*
+ * If the LV is active exclusive remotely,
+ * then ignore it here
+ */
+ log_verbose("%s/%s is exclusively active on"
+ " a remote node", vg->name, lv->name);
+ expected_count--; /* not accounted */
+ }
continue;
}
10 years, 3 months
master - configure: also LDFLAGS, not LDLAGS for proper restore
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=28939dba09fcd3...
Commit: 28939dba09fcd36cd0e4e470e73b172f19dd45e8
Parent: 1592bb216e47269b1a2839031b8e92d8c359461c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Dec 4 14:58:40 2013 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Dec 4 15:00:56 2013 +0100
configure: also LDFLAGS, not LDLAGS for proper restore
---
acinclude.m4 | 2 +-
configure | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index b9473db..601ae9d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -49,7 +49,7 @@ AC_DEFUN([AC_TRY_LDFLAGS],
[AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[AS_VAR_SET([ac_cv_flag_$2], [yes])],
[AS_VAR_SET([ac_cv_flag_$2], [no])])])
- LDLAGS=$ac_save_LDFLAGS
+ LDFLAGS=$ac_save_LDFLAGS
$2=AS_VAR_GET([ac_cv_flag_$2])
if test "$2" = yes; then
ifelse([$3], [], [:], [$3])
diff --git a/configure b/configure
index 2ecc7ba..ff7185d 100755
--- a/configure
+++ b/configure
@@ -6812,7 +6812,7 @@ rm -f core conftest.err conftest.$ac_objext \
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_flag_HAVE_FULL_RELRO" >&5
$as_echo "$ac_cv_flag_HAVE_FULL_RELRO" >&6; }
- LDLAGS=$ac_save_LDFLAGS
+ LDFLAGS=$ac_save_LDFLAGS
HAVE_FULL_RELRO=$ac_cv_flag_HAVE_FULL_RELRO
if test "HAVE_FULL_RELRO" = yes; then
:
10 years, 3 months
master - test: thin snapshot merge
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1592bb216e4726...
Commit: 1592bb216e47269b1a2839031b8e92d8c359461c
Parent: 91496e0eda9969f1efcf290803c13d79456067d4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Dec 4 14:17:54 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:26 2013 +0100
test: thin snapshot merge
Testing thin snapshot merge cases.
TODO: Probably still misses some cases.
---
test/shell/thin-merge.sh | 107 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/test/shell/thin-merge.sh b/test/shell/thin-merge.sh
new file mode 100644
index 0000000..10a81f0
--- /dev/null
+++ b/test/shell/thin-merge.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# test merge of thin snapshot
+
+. lib/test
+
+which mkfs.ext2 || skip
+which fsck || skip
+
+#
+# Main
+#
+aux have_thin 1 0 0 || skip
+
+aux prepare_vg 2
+
+lvcreate -T -L8M $vg/pool -V10M -n $lv1
+lvchange --addtag tagL $vg/$lv1
+
+mkdir mnt
+mkfs.ext2 $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
+mount $DM_DEV_DIR/$vg/snap mntsnap
+touch mntsnap/test_snap
+
+lvs -o+tags,thin_id $vg
+
+lvconvert --merge $vg/snap
+
+umount mnt
+
+# Merge cannot happen
+lvchange --refresh $vg/$lv1
+check lv_field $vg/$lv1 thin_id "1"
+
+# Fails since it cannot deactivate both
+not lvchange -an $vg/$lv1
+
+# But test $lv1 is not active
+check inactive $vg $lv1
+
+# Also still cannot reactivate $lv1
+not lvchange -ay $vg/$lv1
+
+umount mntsnap
+
+lvdisplay -a $vg | tee out
+grep "merged with" out
+grep "merging to" out
+
+# Check there is no support for manipulation with hidden 'snap'
+not lvchange --refresh $vg/snap
+not lvchange -an $vg/snap
+not lvremove $vg/snap
+
+
+# Finally deactivate 'snap' again via $lv1
+lvchange -an $vg/$lv1
+
+# Still must not be activable
+not lvchange -K -ay $vg/snap
+
+lvs -a -o +tags,thin_id $vg
+dmsetup table
+
+# Test if merge happens
+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
+
+fsck -n $DM_DEV_DIR/$vg/$lv1
+mount $DM_DEV_DIR/$vg/$lv1 mnt
+test -e mnt/test_snap
+umount mnt
+
+
+# test if thin snapshot has also 'old-snapshot'
+
+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}
+
+# Add old snapshot to thin snapshot
+lvcreate -s -L10 -n oldsnapof_snap $vg/snap
+lvconvert --merge $vg/snap
+lvremove -f $vg/oldsnapof_snap
+
+vgremove -ff $vg
10 years, 3 months
master - thin: enable thin snapshot merge
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=91496e0eda9969...
Commit: 91496e0eda9969f1efcf290803c13d79456067d4
Parent: 971ab733b74e0ffecc3f9f60af48628cd3fba1db
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 21:28:18 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:26 2013 +0100
thin: enable thin snapshot merge
---
WHATS_NEW | 1 +
tools/lvconvert.c | 170 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 168 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c81cb7a..5d41700 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.105 -
=====================================
+ Support lvconvert --merge for thin snapshots.
Add support to read thin device id from table line entry.
Drop extra test for origin when testing merging origin in lv_refresh().
Extend lv_remove_single() to not print info about removed LV.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 84479fe..11ee21a 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -689,6 +689,46 @@ static int _swap_lv_identifiers(struct cmd_context *cmd,
return 1;
}
+static void _move_lv_attributes(struct logical_volume *to, struct logical_volume *from)
+{
+ /* Maybe move this code into _finish_thin_merge() */
+ to->status = from->status; // FIXME maybe some masking ?
+ to->alloc = from->alloc;
+ to->profile = from->profile;
+ to->read_ahead = from->read_ahead;
+ to->major = from->major;
+ to->minor = from->minor;
+ to->timestamp = from->timestamp;
+ to->hostname = from->hostname;
+
+ /* Move tags */
+ dm_list_init(&to->tags);
+ dm_list_splice(&to->tags, &from->tags);
+
+ /* Anything else to preserve? */
+}
+
+/* Finalise merging of lv into merge_lv */
+static int _finish_thin_merge(struct cmd_context *cmd,
+ struct logical_volume *merge_lv,
+ struct logical_volume *lv)
+{
+ if (!_swap_lv_identifiers(cmd, merge_lv, lv)) {
+ log_error("Failed to swap %s with merging %s.",
+ lv->name, merge_lv->name);
+ return 0;
+ }
+
+ /* Preserve origins' attributes */
+ _move_lv_attributes(lv, merge_lv);
+
+ /* Removed LV has to be visible */
+ if (!lv_remove_single(cmd, merge_lv, DONT_PROMPT, 1))
+ return_0;
+
+ return 1;
+}
+
static int _finish_lvconvert_merge(struct cmd_context *cmd,
struct volume_group *vg,
struct logical_volume *lv,
@@ -702,7 +742,14 @@ static int _finish_lvconvert_merge(struct cmd_context *cmd,
}
log_print_unless_silent("Merge of snapshot into logical volume %s has finished.", lv->name);
- if (!lv_remove_single(cmd, snap_seg->cow, DONT_PROMPT, 0)) {
+
+ if (seg_is_thin_volume(snap_seg)) {
+ clear_snapshot_merge(lv);
+
+ if (!_finish_thin_merge(cmd, lv, snap_seg->lv))
+ return_0;
+
+ } else if (!lv_remove_single(cmd, snap_seg->cow, DONT_PROMPT, 0)) {
log_error("Could not remove snapshot %s merged into %s.",
snap_seg->cow->name, lv->name);
return 0;
@@ -742,6 +789,31 @@ static progress_t _poll_merge_progress(struct cmd_context *cmd,
return PROGRESS_UNFINISHED;
}
+static progress_t _poll_thin_merge_progress(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ const char *name __attribute__((unused)),
+ struct daemon_parms *parms)
+{
+ uint32_t device_id;
+
+ if (!lv_thin_device_id(lv, &device_id)) {
+ stack;
+ return PROGRESS_CHECK_FAILED;
+ }
+
+ /*
+ * There is no need to poll more than once,
+ * a thin snapshot merge is immediate.
+ */
+
+ if (device_id != find_snapshot(lv)->device_id) {
+ log_error("LV %s is not merged.", lv->name);
+ return PROGRESS_CHECK_FAILED;
+ }
+
+ return PROGRESS_FINISHED_ALL; /* Merging happend */
+}
+
static struct poll_functions _lvconvert_mirror_fns = {
.get_copy_vg = _get_lvconvert_vg,
.get_copy_lv = _get_lvconvert_lv,
@@ -756,6 +828,13 @@ static struct poll_functions _lvconvert_merge_fns = {
.finish_copy = _finish_lvconvert_merge,
};
+static struct poll_functions _lvconvert_thin_merge_fns = {
+ .get_copy_vg = _get_lvconvert_vg,
+ .get_copy_lv = _get_lvconvert_lv,
+ .poll_progress = _poll_thin_merge_progress,
+ .finish_copy = _finish_lvconvert_merge,
+};
+
int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
unsigned background)
{
@@ -782,7 +861,9 @@ 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,
- &_lvconvert_merge_fns, "Merged");
+ lv_is_thin_volume(lv) ?
+ &_lvconvert_thin_merge_fns : &_lvconvert_merge_fns,
+ "Merged");
return poll_daemon(cmd, lv_full_name, uuid, background, 0,
&_lvconvert_mirror_fns, "Converted");
@@ -2097,6 +2178,88 @@ out:
return r;
}
+static int _lvconvert_merge_thin_snapshot(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct lvconvert_params *lp)
+{
+ int origin_is_active = 0, r = 0;
+ struct lv_segment *snap_seg = first_seg(lv);
+ struct logical_volume *origin = snap_seg->origin;
+
+ if (!origin) {
+ log_error("\"%s\" is not a mergeable logical volume.",
+ lv->name);
+ return 0;
+ }
+
+ /* Check if merge is possible */
+ if (lv_is_merging_origin(origin)) {
+ log_error("Snapshot %s is already merging into the origin.",
+ find_snapshot(origin)->lv->name);
+ return 0;
+ }
+
+ if (lv_is_external_origin(origin)) {
+ log_error("\"%s\" is read-only external origin \"%s\".",
+ lv->name, origin_from_cow(lv)->name);
+ return 0;
+ }
+
+ if (lv_is_origin(origin)) {
+ log_error("Merging into the old snapshot origin %s is not supported.",
+ origin->name);
+ return 0;
+ }
+
+ if (!archive(lv->vg))
+ return_0;
+
+ // FIXME: allow origin to be specified
+ // FIXME: verify snapshot is descendant of specified origin
+
+ /*
+ * Prevent merge with open device(s) as it would likely lead
+ * to application/filesystem failure. Merge on origin's next
+ * activation if either the origin or snapshot LV can't be
+ * deactivated.
+ */
+ if (!deactivate_lv(cmd, lv))
+ log_print_unless_silent("Delaying merge since snapshot is open.");
+ else if ((origin_is_active = lv_is_active(origin)) &&
+ !deactivate_lv(cmd, origin))
+ log_print_unless_silent("Delaying merge since origin volume is open.");
+ else {
+ /*
+ * Both thin snapshot and origin are inactive,
+ * replace the origin LV with its snapshot LV.
+ */
+ if (!_finish_thin_merge(cmd, origin, lv))
+ goto_out;
+
+ if (origin_is_active && !activate_lv(cmd, lv)) {
+ log_error("Failed to reactivate origin %s.", lv->name);
+ goto out;
+ }
+
+ r = 1;
+ goto out;
+ }
+
+ init_snapshot_merge(snap_seg, origin);
+
+ /* Commit vg, merge will start with next activation */
+ if (!vg_write(lv->vg) || !vg_commit(lv->vg))
+ return_0;
+
+ log_print_unless_silent("Merging of thin snapshot %s will occur on "
+ "next activation.", lv->name);
+ r = 1;
+out:
+ backup(lv->vg);
+
+ return r;
+}
+
static int _lvconvert_thinpool_repair(struct cmd_context *cmd,
struct logical_volume *pool_lv,
struct lvconvert_params *lp)
@@ -2742,7 +2905,8 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
if (lp->merge) {
- if (!_lvconvert_merge_old_snapshot(cmd, lv, lp)) {
+ 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;
}
10 years, 3 months
master - thin: activation of merging thin snapshot
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=971ab733b74e0f...
Commit: 971ab733b74e0ffecc3f9f60af48628cd3fba1db
Parent: ff112eee181748dbf827d91a7ebf0c0f1d7878a0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 21:25:58 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:26 2013 +0100
thin: activation of merging thin snapshot
For merging thin snapshot we have to do couple extra
checks before we allow this operation.
We pretend thin-snapshot and thin-origin
are tied together and we have to properly
maintain locking.
---
tools/toollib.c | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 183d832..65a7089 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1403,6 +1403,34 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd,
int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
activation_change_t activate)
{
+ int r = 1;
+
+ if (lv_is_merging_origin(lv)) {
+ /*
+ * For merging origin, its snapshot must be inactive.
+ * If it's still active and cannot be deactivated
+ * activation or deactivation of origin fails!
+ *
+ * When origin is deactivated and merging snapshot is thin
+ * it allows to deactivate origin, but still report error,
+ * since the thin snapshot remains active.
+ *
+ * User could retry to deactivate it with another
+ * deactivation of origin, which is the only visible LV
+ */
+ if (!deactivate_lv(cmd, find_snapshot(lv)->lv)) {
+ if ((activate != CHANGE_AN) && (activate != CHANGE_ALN)) {
+ log_error("Refusing to activate merging \"%s\" while snapshot \"%s\" is still active.",
+ lv->name, find_snapshot(lv)->lv->name);
+ return 0;
+ }
+
+ log_error("Cannot fully deactivate merging origin \"%s\" while snapshot \"%s\" is still active.",
+ lv->name, find_snapshot(lv)->lv->name);
+ r = 0; /* and continue to deactivate origin... */
+ }
+ }
+
if (!lv_active_change(cmd, lv, activate))
return_0;
@@ -1412,7 +1440,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
(lv->status & (PVMOVE|CONVERTING|MERGING)))
lv_spawn_background_polling(cmd, lv);
- return 1;
+ return r;
}
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
10 years, 3 months
master - thin: merge display
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ff112eee181748...
Commit: ff112eee181748dbf827d91a7ebf0c0f1d7878a0
Parent: 1200b7e7c2be18fcd2644817a5e57c6182800ee0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 15:54:51 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:26 2013 +0100
thin: merge display
---
lib/display/display.c | 6 ++++++
lib/metadata/lv.c | 3 ++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/lib/display/display.c b/lib/display/display.c
index 2fd37a2..1babffc 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -607,8 +607,14 @@ int lvdisplay_full(struct cmd_context *cmd,
if (seg->external_lv)
log_print("LV External origin name %s",
seg->external_lv->name);
+ if (seg->merge_lv)
+ log_print("LV merging to %s",
+ seg->merge_lv->name);
if (inkernel)
thin_active = lv_thin_percent(lv, 0, &thin_percent);
+ if (lv_is_merging_origin(lv))
+ log_print("LV merged with %s",
+ find_snapshot(lv)->lv->name);
} else if (lv_is_thin_pool(lv)) {
if (inkernel) {
thin_data_active = lv_thin_pool_percent(lv, 0, &thin_data_percent);
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index c1f6271..3e1458c 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -555,7 +555,8 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
else if (lv->status & MIRRORED)
repstr[0] = (lv->status & LV_NOTSYNCED) ? 'M' : 'm';
else if (lv_is_thin_volume(lv))
- repstr[0] = 'V';
+ repstr[0] = lv_is_merging_origin(lv) ?
+ 'O' : (lv_is_merging_thin_snapshot(lv) ? 'S' : 'V');
else if (lv->status & VIRTUAL)
repstr[0] = 'v';
else if (lv_is_thin_pool(lv))
10 years, 3 months
master - thin: deactivation of merging thin snapshot
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1200b7e7c2be18...
Commit: 1200b7e7c2be18fcd2644817a5e57c6182800ee0
Parent: 5fc3352a1563f0fc5a14d163b03a357742e3987e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 21:22:55 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:26 2013 +0100
thin: deactivation of merging thin snapshot
Before trying to deactivate merging thin snapshot
(which is invisible) check if it's not in-use.
---
lib/activate/activate.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 80eef32..4c8c16d 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1973,7 +1973,8 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, struct logical_vo
goto out;
}
- if (lv_is_visible(lv) || lv_is_virtual_origin(lv)) {
+ if (lv_is_visible(lv) || lv_is_virtual_origin(lv) ||
+ lv_is_merging_thin_snapshot(lv)) {
if (!lv_check_not_in_use(cmd, lv, &info))
goto_out;
10 years, 3 months
master - thin: merge removal
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5fc3352a1563f0...
Commit: 5fc3352a1563f0fc5a14d163b03a357742e3987e
Parent: 664a695561c98645dd557428108766b702db530d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Nov 29 21:21:00 2013 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Dec 4 14:30:26 2013 +0100
thin: merge removal
When thin is merged - properly handly device removal.
---
lib/metadata/lv_manip.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2458447..9806758 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -775,11 +775,23 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
uint32_t count = extents;
uint32_t reduction;
+ if (lv_is_merging_origin(lv)) {
+ log_debug_metadata("Dropping snapshot merge of %s to removed origin %s.",
+ find_snapshot(lv)->lv->name, lv->name);
+ clear_snapshot_merge(lv);
+ }
+
dm_list_iterate_back_items(seg, &lv->segments) {
if (!count)
break;
if (seg->len <= count) {
+ if (seg->merge_lv) {
+ log_debug_metadata("Dropping snapshot merge of removed %s to origin %s.",
+ seg->lv->name, seg->merge_lv->name);
+ clear_snapshot_merge(seg->merge_lv);
+ }
+
/* remove this segment completely */
/* FIXME Check this is safe */
if (seg->log_lv && !lv_remove(seg->log_lv))
@@ -4734,6 +4746,27 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
return_0;
}
+ if (lv_is_merging_origin(lv)) {
+ if (!deactivate_lv(cmd, lv)) {
+ log_error("Unable to fully deactivate merging origin \"%s\".",
+ lv->name);
+ return 0;
+ }
+ if (!lv_remove_with_dependencies(cmd, find_snapshot(lv)->lv,
+ force, level + 1)) {
+ log_error("Unable to remove merging origin \"%s\".",
+ lv->name);
+ return 0;
+ }
+ }
+
+ if (!level && lv_is_merging_thin_snapshot(lv)) {
+ /* Merged snapshot LV is no longer available for the user */
+ log_error("Unable to remove \"%s\", volume is merged to \"%s\".",
+ lv->name, first_seg(lv)->merge_lv->name);
+ return 0;
+ }
+
if (lv_is_external_origin(lv) &&
!_lv_remove_segs_using_this_lv(cmd, lv, force, level, "external origin"))
return_0;
10 years, 3 months