master - thin: fix lvconvert for active pool.
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1b7631101b2ac3...
Commit: 1b7631101b2ac34d25cd5d3140001e86371997f9
Parent: 48df36b8c531a43da8602b50759c9e841e1d9f44
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 16 10:11:37 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Oct 16 10:53:01 2013 +0200
thin: fix lvconvert for active pool.
Prohibit conversion of pool device with active thin volumes.
Properly restore active states only for active thin pool volume.
Use new LV_NOSCAN when converting volume into thin pool's metadata.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 16 +++++++++++++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index f5f0256..79a960c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Fix lvconvert swap of poolmetadata volume for active thin pool.
Check for open count with a timeout before removal/deactivation of an LV.
Report RAID images split with tracking as out-of-sync ("I").
Improve parsing of snapshot lv segment.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ee6d868..eaac565 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2275,6 +2275,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
struct logical_volume *pool_metadata_lv;
struct logical_volume *external_lv = NULL;
char metadata_name[NAME_LEN], data_name[NAME_LEN];
+ int activate_pool;
if (!lv_is_visible(pool_lv)) {
log_error("Can't convert internal LV %s/%s.",
@@ -2303,6 +2304,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
}
if (lv_is_thin_pool(pool_lv)) {
+ activate_pool = lv_is_active(pool_lv);
r = 1; /* Already existing thin pool */
goto out;
}
@@ -2315,6 +2317,9 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
+ /* Allow to have only thinpool active and restore it's active state */
+ activate_pool = lv_is_active(pool_lv);
+
/* We are changing target type, so deactivate first */
if (!deactivate_lv(cmd, pool_lv)) {
log_error("Aborting. Failed to deactivate logical volume %s/%s.",
@@ -2322,6 +2327,13 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
+ if (pool_is_active(pool_lv)) {
+ /* If any thin volume is also active - abort here */
+ log_error("Cannot convert pool %s/%s with active thin volumes.",
+ pool_lv->vg->name, pool_lv->name);
+ return 0;
+ }
+
if ((dm_snprintf(metadata_name, sizeof(metadata_name), "%s_tmeta",
pool_lv->name) < 0) ||
(dm_snprintf(data_name, sizeof(data_name), "%s_tdata",
@@ -2423,6 +2435,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
goto mda_write;
}
+ metadata_lv->status |= LV_NOSCAN;
if (!lv_is_active(metadata_lv) &&
!activate_lv_local(cmd, metadata_lv)) {
log_error("Aborting. Failed to activate thin metadata lv.");
@@ -2515,7 +2528,8 @@ mda_write:
if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
return_0;
- if (!activate_lv_excl(cmd, pool_lv)) {
+ if (activate_pool &&
+ !activate_lv_excl(cmd, pool_lv)) {
log_error("Failed to activate pool logical volume %s/%s.",
pool_lv->vg->name, pool_lv->name);
/* Deactivate subvolumes */
10 years, 6 months
master - activation: check for open count with a timeout before removal/deactivation of an LV
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=48df36b8c531a4...
Commit: 48df36b8c531a43da8602b50759c9e841e1d9f44
Parent: d97583cfd395e5e31888558361ae9467cea60260
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 15 12:44:42 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Oct 15 12:44:42 2013 +0200
activation: check for open count with a timeout before removal/deactivation of an LV
This patch reinstates the lv_info call to check for open count of
the LV we're removing/deactivating - this was changed with commit 125712b
some time ago and we relied on the ioctl retry logic deeper in the libdm
while calling the exact 'remove' ioctl.
However, there are still some situations in which it's still required to
check for open count before we do any 'remove' actions - this mainly
applies to LVs which consist of several sub LVs, like it is for
virtual snapshot devices.
The commit 1146691 fixed the issue with ordering of actions during
virtual snapshot removal while the snapshot is still open. But
the check for the open status of the snapshot is still prone to
marking the snapshot as in use with an immediate exit even though
this could be a temporary asynchronous open only, most notably
because of udev and its WATCH udev rule with accompanying scans
for the event which is asynchronous. The situation where this crops
up most often is when we're closing the LV that was open for read-write
and then calling lvremove immediately.
This patch reinstates the original lv_info call for the open status
of the LV in the lv_check_not_in_use fn that gets called before
we do any LV removal/deactivation. In addition to original logic,
this patch adds its own retry loop with a delay (25x0.2 seconds)
besides the existing ioctl retry loop.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 51 ++++++++++++++++++++++++++++++----------------
2 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 04be5f1..f5f0256 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Check for open count with a timeout before removal/deactivation of an LV.
Report RAID images split with tracking as out-of-sync ("I").
Improve parsing of snapshot lv segment.
Add workaround for deactivation problem of opened virtual snapshot.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 6948060..131a093 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -251,8 +251,8 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
{
return 0;
}
-int lv_check_not_in_use(struct cmd_context *cmd __attribute__((unused)),
- struct logical_volume *lv, struct lvinfo *info)
+int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv,
+ struct lvinfo *info)
{
return 0;
}
@@ -676,33 +676,48 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
return r;
}
-int lv_check_not_in_use(struct cmd_context *cmd __attribute__((unused)),
- struct logical_volume *lv, struct lvinfo *info)
+#define OPEN_COUNT_CHECK_RETRIES 25
+#define OPEN_COUNT_CHECK_USLEEP_DELAY 200000
+
+int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv,
+ struct lvinfo *info)
{
+ unsigned int open_count_check_retries;
+
if (!info->exists)
return 1;
/* If sysfs is not used, use open_count information only. */
- if (!*dm_sysfs_dir()) {
- if (info->open_count) {
- log_error("Logical volume %s/%s in use.",
+ if (dm_sysfs_dir()) {
+ if (dm_device_has_holders(info->major, info->minor)) {
+ log_error("Logical volume %s/%s is used by another device.",
lv->vg->name, lv->name);
return 0;
}
- return 1;
- }
-
- if (dm_device_has_holders(info->major, info->minor)) {
- log_error("Logical volume %s/%s is used by another device.",
- lv->vg->name, lv->name);
- return 0;
+ if (dm_device_has_mounted_fs(info->major, info->minor)) {
+ log_error("Logical volume %s/%s contains a filesystem in use.",
+ lv->vg->name, lv->name);
+ return 0;
+ }
}
- if (dm_device_has_mounted_fs(info->major, info->minor)) {
- log_error("Logical volume %s/%s contains a filesystem in use.",
- lv->vg->name, lv->name);
- return 0;
+ open_count_check_retries = retry_deactivation() ? OPEN_COUNT_CHECK_RETRIES : 1;
+ while (open_count_check_retries--) {
+ if (info->open_count > 0) {
+ if (open_count_check_retries) {
+ usleep(OPEN_COUNT_CHECK_USLEEP_DELAY);
+ log_debug_activation("Retrying open_count check for %s/%s.",
+ lv->vg->name, lv->name);
+ if (!lv_info(cmd, lv, 0, info, 1, 0))
+ return -1;
+ continue;
+ }
+ log_error("Logical volume %s/%s in use.",
+ lv->vg->name, lv->name);
+ return 0;
+ } else
+ break;
}
return 1;
10 years, 6 months
master - RAID: Better error message when attempting scrubbing op on thinpool LV
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d97583cfd395e5...
Commit: d97583cfd395e5e31888558361ae9467cea60260
Parent: f58b26b6338b2939e6a88174ac2dc185b345118b
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Oct 14 15:14:16 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Oct 14 15:14:16 2013 -0500
RAID: Better error message when attempting scrubbing op on thinpool LV
Component LVs of a thinpool can be RAID LVs. Users who attempt a
scrubbing operation directly on a thinpool will be prompted to
specify the sub-LV they wish the operation to be performed on. If
neither of the sub-LVs are RAID, then a message telling them that
the operation can only be performed on a RAID LV will be given.
---
lib/activate/activate.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 7621f44..6948060 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -888,6 +888,18 @@ int lv_raid_message(const struct logical_volume *lv, const char *msg)
struct dm_status_raid *status;
if (!seg_is_raid(first_seg(lv))) {
+ /*
+ * Make it easier for user to know what to do when
+ * they are using thinpool.
+ */
+ if (lv_is_thin_pool(lv) &&
+ (lv_is_raid(seg_lv(first_seg(lv), 0)) ||
+ lv_is_raid(first_seg(lv)->metadata_lv))) {
+ log_error("Thinpool data or metadata volume"
+ " must be specified. (e.g. \"%s/%s_tdata\")",
+ lv->vg->name, lv->name);
+ return 0;
+ }
log_error("%s/%s must be a RAID logical volume to"
" perform this action.", lv->vg->name, lv->name);
return 0;
10 years, 6 months
master - RAID: Report RAID images split with tracking as out-of-sync ("I").
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f58b26b6338b29...
Commit: f58b26b6338b2939e6a88174ac2dc185b345118b
Parent: 0f55d7ccccb2c274f31760d1c97286ee03e24e4c
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Mon Oct 14 10:48:44 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Mon Oct 14 10:48:44 2013 -0500
RAID: Report RAID images split with tracking as out-of-sync ("I").
Split image should have an out-of-sync attr ('I') - always. Even if
the RAID LV has not been written to since the LV was split off, it is
still not part of the group that makes up the RAID and is therefore
"out-of-sync".
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 887a256..04be5f1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Report RAID images split with tracking as out-of-sync ("I").
Improve parsing of snapshot lv segment.
Add workaround for deactivation problem of opened virtual snapshot.
Disable unsupported merge for virtual snapshot.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index e3fda18..e59bd8e 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -565,7 +565,13 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
else if (lv->status & MIRROR_IMAGE)
repstr[0] = (_lv_mimage_in_sync(lv)) ? 'i' : 'I';
else if (lv->status & RAID_IMAGE)
- repstr[0] = (_lv_raid_image_in_sync(lv)) ? 'i' : 'I';
+ /*
+ * Visible RAID_IMAGES are sub-LVs that have been exposed for
+ * top-level use by being split from the RAID array with
+ * '--splitmirrors 1 --trackchanges'. They always report 'I'.
+ */
+ repstr[0] = (!lv_is_visible(lv) && _lv_raid_image_in_sync(lv)) ?
+ 'i' : 'I';
else if (lv->status & MIRROR_LOG)
repstr[0] = 'l';
else if (lv_is_cow(lv))
10 years, 6 months
master - tests: lvcreate and snapshot update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0f55d7ccccb2c2...
Commit: 0f55d7ccccb2c274f31760d1c97286ee03e24e4c
Parent: 9f8f6bfefe0636880a1d70c8f7c99ff9938eb5eb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 11 23:59:14 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 00:29:03 2013 +0200
tests: lvcreate and snapshot update
Test creation really in cluster.
Update test to check removal when snapshot device is being held open.
---
test/shell/lvcreate-usage.sh | 16 ++++++++--------
test/shell/snapshot-usage.sh | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/test/shell/lvcreate-usage.sh b/test/shell/lvcreate-usage.sh
index 7f32bbc..105fbce 100644
--- a/test/shell/lvcreate-usage.sh
+++ b/test/shell/lvcreate-usage.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2008-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
@@ -15,7 +15,7 @@
aux prepare_pvs 4
aux pvcreate --metadatacopies 0 "$dev1"
-vgcreate -cn $vg $(cat DEVICES)
+vgcreate $vg $(cat DEVICES)
# "lvcreate rejects repeated invocation (run 2 times) (bz178216)"
lvcreate -n $lv -l 4 $vg
@@ -58,7 +58,7 @@ test -z "$(lvdisplay $vg)"
# Setting max_lv works. (bz490298)
lvremove -ff $vg
vgchange -l 3 $vg
-lvcreate -l1 -n $lv1 $vg
+lvcreate -aey -l1 -n $lv1 $vg
lvcreate -l1 -s -n $lv2 $vg/$lv1
lvcreate -l1 -n $lv3 $vg
not lvcreate -l1 -n $lv4 $vg
@@ -71,7 +71,7 @@ not lvcreate -l1 -n $lv4 $vg
not lvcreate -l1 --type mirror -m1 -n $lv4 $vg
lvremove -ff $vg/$lv3
-lvcreate -l1 --type mirror -m1 -n $lv3 $vg
+lvcreate -aey -l1 --type mirror -m1 -n $lv3 $vg
vgs -o +max_lv $vg
not lvcreate -l1 -n $lv4 $vg
not lvcreate -l1 --type mirror -m1 -n $lv4 $vg
@@ -90,8 +90,8 @@ vgchange -l 0 $vg
# lvcreate rejects invalid chunksize, accepts between 4K and 512K
# validate origin_size
vgremove -ff $vg
-vgcreate -cn $vg $(cat DEVICES)
-lvcreate -L 32m -n $lv1 $vg
+vgcreate $vg $(cat DEVICES)
+lvcreate -aey -L 32m -n $lv1 $vg
not lvcreate -L 8m -n $lv2 -s --chunksize 3k $vg/$lv1
not lvcreate -L 8m -n $lv2 -s --chunksize 1024k $vg/$lv1
lvcreate -L 8m -n $lv2 -s --chunksize 4k $vg/$lv1
@@ -111,10 +111,10 @@ not lvcreate -L 32m -n $lv -R0 $vg 2>err
grep "Non-zero region size must be supplied." err
not lvcreate -L 32m -n $lv -R 11k $vg
not lvcreate -L 32m -n $lv -R 1k $vg
-lvcreate -L 32m -n $lv --regionsize 128m --type mirror -m 1 $vg
+lvcreate -aey -L 32m -n $lv --regionsize 128m --type mirror -m 1 $vg
check lv_field $vg/$lv regionsize "32.00m"
lvremove -ff $vg
-lvcreate -L 32m -n $lv --regionsize 4m --type mirror -m 1 $vg
+lvcreate -aey -L 32m -n $lv --regionsize 4m --type mirror -m 1 $vg
check lv_field $vg/$lv regionsize "4.00m"
lvremove -ff $vg
diff --git a/test/shell/snapshot-usage.sh b/test/shell/snapshot-usage.sh
index 9c1c2f6..d7a602b 100644
--- a/test/shell/snapshot-usage.sh
+++ b/test/shell/snapshot-usage.sh
@@ -17,6 +17,12 @@ fill() {
dd if=/dev/zero of=$DM_DEV_DIR/$vg1/lvol0 bs=$1 count=1
}
+cleanup_tail()
+{
+ test -z "$SLEEP_PID" || kill $SLEEP_PID
+ aux teardown
+}
+
aux prepare_pvs 1
vgcreate -s 4M $vg $(cat DEVICES)
@@ -30,6 +36,32 @@ aux lvmconf "activation/snapshot_autoextend_percent = 20" \
pvcreate --setphysicalvolumesize 4T $DM_DEV_DIR/$vg/$lv
vgcreate -s 1K $vg1 $DM_DEV_DIR/$vg/$lv
+# Test removal of opened snapshot
+lvcreate -V50 -L10 -n $lv1 -s $vg1
+
+lvs -a -o+lv_active $vg1
+lvchange -an $vg1
+
+# Snapshot get exclusive activation
+lvchange -ay $vg1
+lvs -a -o+lv_active $vg1
+
+trap 'cleanup_tail' EXIT
+# Keep device busy (but not mounted) for a while
+sleep 30 < $DM_DEV_DIR/$vg1/$lv1 &
+SLEEP_PID=$!
+
+# Opened virtual snapshot device is not removable
+# it should retry device removal for a few seconds
+not lvremove -f $vg1/$lv1
+
+kill $SLEEP_PID
+SLEEP_PID=
+
+lvremove -f $vg1/$lv1
+not dmsetup info $vg1-$lv1 >/dev/null || \
+ die "$vg1/$lv1 expected to be removed, but there are mappings!"
+
# Check border size
lvcreate -aey -L4095G $vg1
lvcreate -s -L100K $vg1/lvol0
@@ -79,7 +111,7 @@ lvcreate -an -Zn -l50%FREE -n $lv1 $vg1
lvcreate -s -l100%FREE -n $lv2 $vg1/$lv1
check lv_field $vg1/$lv2 size "7.50p"
lvremove -ff $vg1
-
+
lvcreate -aey -V15E -l1 -n $lv1 -s $vg1
check lv_field $vg1/$lv1 origin_size "15.00e"
10 years, 6 months
master - tests: harness updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9f8f6bfefe0636...
Commit: 9f8f6bfefe0636880a1d70c8f7c99ff9938eb5eb
Parent: 851bba258cc6989db78d547b9983c523caae9026
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 11 22:31:57 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 00:26:59 2013 +0200
tests: harness updates
Reshape code a bit to make sockepair 'swappable' with plain old pipe
call.
Display status for FAILED error.
Increase buffer to hold always at least 1 page size.
Print error results with capitals.
---
test/lib/harness.c | 30 ++++++++++++++++--------------
1 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/test/lib/harness.c b/test/lib/harness.c
index 0036502..8c9f4a7 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -173,7 +173,7 @@ static void _append_buf(const char *buf, size_t len)
kill(-pid, SIGINT);
return;
}
- readbuf_sz = readbuf_sz ? 2 * readbuf_sz : 4096;
+ readbuf_sz = readbuf_sz ? 2 * readbuf_sz : 16384;
readbuf = realloc(readbuf, readbuf_sz);
}
@@ -221,7 +221,7 @@ static const char *_append_with_stamp(const char *buf, int stamp)
static void drain(int fd)
{
- char buf[4096];
+ char buf[4096 + 1];
const char *bp;
int stamp = 0;
int sz;
@@ -322,7 +322,7 @@ static void failed(int i, char *f, int st) {
++ s.nfailed;
s.status[i] = FAILED;
- printf("FAILED.\n");
+ printf("FAILED (status %d).\n", WEXITSTATUS(st));
if (!verbose && readbuf) {
printf("-- FAILED %s ------------------------------------\n", f);
dump();
@@ -340,12 +340,12 @@ static void run(int i, char *f) {
exit(201);
} else if (pid == 0) {
if (!interactive) {
- close(0);
- dup2(fds[0], 1);
- dup2(fds[0], 2);
- close(fds[0]);
+ close(STDIN_FILENO);
+ dup2(fds[1], STDOUT_FILENO);
+ dup2(fds[1], STDERR_FILENO);
close(fds[1]);
}
+ close(fds[0]);
if (strchr(f, ':')) {
strcpy(flavour, f);
*strchr(flavour, ':') = 0;
@@ -372,6 +372,7 @@ static void run(int i, char *f) {
FILE *varlogmsg;
int fd_vlm = -1;
+ //close(fds[1]);
snprintf(buf, sizeof(buf), "%s ...", f);
printf("Running %-60s ", buf);
fflush(stdout);
@@ -404,14 +405,14 @@ static void run(int i, char *f) {
}
FD_ZERO(&set);
- FD_SET(fds[1], &set);
+ FD_SET(fds[0], &set);
selectwait.tv_sec = 0;
selectwait.tv_usec = 500000; /* timeout 0.5s */
- if (select(fds[1] + 1, &set, NULL, NULL, &selectwait) <= 0) {
+ if (select(fds[0] + 1, &set, NULL, NULL, &selectwait) <= 0) {
no_write++;
continue;
}
- drain(fds[1]);
+ drain(fds[0]);
no_write = 0;
if (fd_vlm >= 0)
drain(fd_vlm);
@@ -420,7 +421,7 @@ static void run(int i, char *f) {
perror("waitpid");
exit(206);
}
- drain(fds[1]);
+ drain(fds[0]);
if (fd_vlm >= 0)
drain(fd_vlm);
if (die == 2)
@@ -472,12 +473,13 @@ int main(int argc, char **argv) {
results = getenv("LVM_TEST_RESULTS") ? : "results";
(void) snprintf(results_list, sizeof(results_list), "%s/list", results);
+ //if (pipe(fds)) {
if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds)) {
perror("socketpair");
return 201;
}
- if (fcntl(fds[1], F_SETFL, O_NONBLOCK ) == -1) {
+ if (fcntl(fds[0], F_SETFL, O_NONBLOCK ) == -1) {
perror("fcntl on socket");
return 202;
}
@@ -537,10 +539,10 @@ int main(int argc, char **argv) {
printf("skipped: %s\n", argv[i]);
break;
case INTERRUPTED:
- printf("interrupted: %s\n", argv[i]);
+ printf("INTERRUPTED: %s\n", argv[i]);
break;
case TIMEOUT:
- printf("timeout: %s\n", argv[i]);
+ printf("TIMEOUT: %s\n", argv[i]);
break;
default: /* do nothing */ ;
}
10 years, 6 months
master - snapshot: rework parsing of snapshot metadata
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=851bba258cc698...
Commit: 851bba258cc6989db78d547b9983c523caae9026
Parent: 1146691afc740257d03c7ca53bfa07918a4bc715
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Oct 9 14:50:51 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 00:26:58 2013 +0200
snapshot: rework parsing of snapshot metadata
Add better parsing code for snapshot metadata, which describe
properly errors found for snapshot segment.
---
WHATS_NEW | 1 +
lib/snapshot/snapshot.c | 59 +++++++++++++++++++++++------------------------
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6539f19..887a256 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Improve parsing of snapshot lv segment.
Add workaround for deactivation problem of opened virtual snapshot.
Disable unsupported merge for virtual snapshot.
Move code to remove virtual snapshot from tools to lib for lvm2app.
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 506d618..91e778f 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -23,6 +23,10 @@
#include "str_list.h"
#include "defaults.h"
+#define SEG_LOG_ERROR(t, p...) \
+ log_error(t " segment %s of logical volume %s.", ## p, \
+ dm_config_parent_name(sn), seg->lv->name), 0;
+
static const char *_snap_name(const struct lv_segment *seg)
{
return seg->segtype->name;
@@ -41,50 +45,45 @@ static int _snap_text_import(struct lv_segment *seg, const struct dm_config_node
struct dm_hash_table *pv_hash __attribute__((unused)))
{
uint32_t chunk_size;
- const char *org_name, *cow_name;
struct logical_volume *org, *cow;
- int old_suppress, merge = 0;
+ const char *org_name = NULL, *cow_name = NULL;
+ int merge = 0;
if (!dm_config_get_uint32(sn, "chunk_size", &chunk_size)) {
log_error("Couldn't read chunk size for snapshot.");
return 0;
}
- old_suppress = log_suppress(1);
-
- if ((cow_name = dm_config_find_str(sn, "merging_store", NULL))) {
- if (dm_config_find_str(sn, "cow_store", NULL)) {
- log_suppress(old_suppress);
- log_error("Both snapshot cow and merging storage were specified.");
- return 0;
- }
+ if (dm_config_has_node(sn, "merging_store")) {
+ if (!(cow_name = dm_config_find_str(sn, "merging_store", NULL)))
+ return SEG_LOG_ERROR("Merging store must be a string in");
merge = 1;
}
- else if (!(cow_name = dm_config_find_str(sn, "cow_store", NULL))) {
- log_suppress(old_suppress);
- log_error("Snapshot cow storage not specified.");
- return 0;
- }
- if (!(org_name = dm_config_find_str(sn, "origin", NULL))) {
- log_suppress(old_suppress);
- log_error("Snapshot origin not specified.");
- return 0;
+ if (dm_config_has_node(sn, "cow_store")) {
+ if (cow_name)
+ return SEG_LOG_ERROR("Both snapshot cow and merging storage were specified in");
+
+ if (!(cow_name = dm_config_find_str(sn, "cow_store", NULL)))
+ return SEG_LOG_ERROR("Cow store must be a string in");
}
- log_suppress(old_suppress);
+ if (!cow_name)
+ return SEG_LOG_ERROR("Snapshot cow storage not specified in");
- if (!(cow = find_lv(seg->lv->vg, cow_name))) {
- log_error("Unknown logical volume specified for "
- "snapshot cow store.");
- return 0;
- }
+ if (!dm_config_has_node(sn, "origin"))
+ return SEG_LOG_ERROR("Snapshot origin not specified in");
- if (!(org = find_lv(seg->lv->vg, org_name))) {
- log_error("Unknown logical volume specified for "
- "snapshot origin.");
- return 0;
- }
+ if (!(org_name = dm_config_find_str(sn, "origin", NULL)))
+ return SEG_LOG_ERROR("Snapshot origin must be a string in");
+
+ if (!(cow = find_lv(seg->lv->vg, cow_name)))
+ return SEG_LOG_ERROR("Unknown logical volume %s specified for "
+ "snapshot cow store in", cow_name);
+
+ if (!(org = find_lv(seg->lv->vg, org_name)))
+ return SEG_LOG_ERROR("Unknown logical volume %s specified for "
+ "snapshot origin in", org_name);
init_snapshot_seg(seg, org, cow, chunk_size, merge);
10 years, 6 months
master - snapshot: deactivate virtual snapshot first
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1146691afc7402...
Commit: 1146691afc740257d03c7ca53bfa07918a4bc715
Parent: ac961087b0fe9846f95bedee7687d9ca840b217d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 11 23:53:28 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 14 00:25:15 2013 +0200
snapshot: deactivate virtual snapshot first
Since the virtual snapshot has no reason to stay alive once we
detach related snapshot - deactivate whole thing in front of
snapshot removal - otherwice the code would get tricky for
support in cluster.
The correct full solution would require to have transactions
for libdm operations.
Also enable to the check for snapshot being opened prior
the origin deactivation, otherwise we could easily end
with the origin being deactivate, but snapshot still kept
active, desynchronizing locking state in cluster.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 2 +-
lib/metadata/snapshot_manip.c | 10 ++++++++++
3 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 37fe7ad..6539f19 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Add workaround for deactivation problem of opened virtual snapshot.
Disable unsupported merge for virtual snapshot.
Move code to remove virtual snapshot from tools to lib for lvm2app.
Fix possible race during daemon worker thread creation (lvmetad).
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c077113..7621f44 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1929,7 +1929,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s, struct logical_vo
goto out;
}
- if (lv_is_visible(lv)) {
+ if (lv_is_visible(lv) || lv_is_virtual_origin(lv)) {
if (!lv_check_not_in_use(cmd, lv, &info))
goto_out;
diff --git a/lib/metadata/snapshot_manip.c b/lib/metadata/snapshot_manip.c
index 325a4e8..fc1273e 100644
--- a/lib/metadata/snapshot_manip.c
+++ b/lib/metadata/snapshot_manip.c
@@ -227,6 +227,16 @@ int vg_remove_snapshot(struct logical_volume *cow)
struct logical_volume *origin = origin_from_cow(cow);
int is_origin_active = lv_is_active(origin);
+ if (is_origin_active &&
+ lv_is_virtual_origin(origin)) {
+ if (!deactivate_lv(origin->vg->cmd, origin)) {
+ log_error("Failed to deactivate logical volume \"%s\"",
+ origin->name);
+ return 0;
+ }
+ is_origin_active = 0;
+ }
+
dm_list_del(&cow->snapshot->origin_list);
origin->origin_count--;
10 years, 6 months
master - snapshot: disable merging for virtual snaps
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ac961087b0fe98...
Commit: ac961087b0fe9846f95bedee7687d9ca840b217d
Parent: 81504ba70caec0adaa63cb4a074b7296d109e807
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 11 22:47:45 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Oct 12 00:15:55 2013 +0200
snapshot: disable merging for virtual snaps
Merging into virtual origin is not supposed to work.
---
WHATS_NEW | 1 +
tools/lvconvert.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8d83f71..37fe7ad 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Disable unsupported merge for virtual snapshot.
Move code to remove virtual snapshot from tools to lib for lvm2app.
Fix possible race during daemon worker thread creation (lvmetad).
Fix possible deadlock while clearing lvmetad cache for full rescan.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 1970ca3..ee6d868 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1891,6 +1891,10 @@ static int lvconvert_merge(struct cmd_context *cmd,
find_merging_snapshot(origin)->cow->name);
return 0;
}
+ if (lv_is_virtual_origin(origin)) {
+ log_error("Snapshot %s has virtual origin.", lv->name);
+ return 0;
+ }
/*
* Prevent merge with open device(s) as it would likely lead
10 years, 6 months
master - snapshot: move virtsnap code from tool to lib
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=81504ba70caec0...
Commit: 81504ba70caec0adaa63cb4a074b7296d109e807
Parent: 6b35c70e8b17b09691d2db6ea2eadba2ee2d095d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 11 22:42:34 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Oct 12 00:14:52 2013 +0200
snapshot: move virtsnap code from tool to lib
Move code for removal dependency from tool's remove.c
into lib's manipulation code.
Same code then works with lvm2app.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 6 +++++-
tools/lvremove.c | 8 --------
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d0ed2ce..8d83f71 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.104
===================================
+ Move code to remove virtual snapshot from tools to lib for lvm2app.
Fix possible race during daemon worker thread creation (lvmetad).
Fix possible deadlock while clearing lvmetad cache for full rescan.
Fix possible race while creating/destroying memory pools.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 22327d7..8f09af7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4685,6 +4685,7 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
struct dm_list *snh, *snht;
struct lv_list *lvl;
struct lvinfo info;
+ struct logical_volume *origin;
int is_last_pool;
if (lv_is_cow(lv)) {
@@ -4713,7 +4714,10 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
return 0;
}
}
- }
+ } else if (!level && lv_is_virtual_origin(origin = origin_from_cow(lv)))
+ /* If this is a sparse device, remove its origin too. */
+ /* Stacking is not supported */
+ lv = origin;
}
if (lv_is_origin(lv)) {
diff --git a/tools/lvremove.c b/tools/lvremove.c
index 4f48746..dfc435c 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -18,14 +18,6 @@
static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle __attribute__((unused)))
{
- struct logical_volume *origin;
-
- /*
- * If this is a sparse device, remove its origin too.
- */
- if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
- lv = origin;
-
if (!lv_remove_with_dependencies(cmd, lv, (force_t) arg_count(cmd, force_ARG), 0))
return_ECMD_FAILED;
10 years, 6 months