stable-2.02 - dmeventd: avoid bail out preventing repair in raid plugin but keep message
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d3e01ff4f94a8d36b1...
Commit: 8d3e01ff4f94a8d36b16520a5e402dbc7539dd2c
Parent: 0585754593d7c010d83274c3a25dd6c3e8c8b4a8
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Sep 20 17:35:35 2019 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Sep 20 17:52:02 2019 +0200
dmeventd: avoid bail out preventing repair in raid plugin but keep message
Followup patch mentioned in previous commit 0585754593d7c010d83274c3a25dd6c3e8c8b4a8.
Problem:
even though dead raid component devices are detected, the
raid plugin is bailing out thus preventing a repair attempt.
Rational:
in case of component device errors, the MD resynchronization
thread runs in parallel with the thrown event being processed
by the raid plugin. The plugin retrieves the raid device status
but that still reflects insync regions as 0 (when it should
already be total regions) because the MD thread didn't update it yet.
Solution:
Remove the insync regions check but keep the informal message
"waiting for resynchronization" and let lvconvert carry out its
pre-repair checks and optionally carry out a repair attempt.
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1751887
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1560739
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1468590
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1654860
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1729303
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1741016
---
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index 52cf43d..fda1320 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -76,14 +76,17 @@ static int _process_raid_event(struct dso_state *state, char *params, const char
}
if (dead) {
- if (status->insync_regions < status->total_regions) {
- if (!state->warned) {
- state->warned = 1;
- log_warn("WARNING: waiting for resynchronization to finish "
- "before initiating repair on RAID device %s.", device);
- }
-
- goto out; /* Not yet done syncing with accessible devices */
+ /*
+ * Use the first event to run a repair ignoring any additonal ones.
+ *
+ * We presume lvconvert to do pre-repair
+ * checks to avoid bloat in this plugin.
+ */
+ if (!state->warned && status->insync_regions < status->total_regions) {
+ state->warned = 1;
+ log_warn("WARNING: waiting for resynchronization to finish "
+ "before initiating repair on RAID device %s.", device);
+ /* Fall through to allow lvconvert to run. */
}
if (state->failed)
4 years, 7 months
stable-2.02 - Revert "dmeventd: avoid bail out preventing repair in raid plugin"
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0585754593d7c010d83...
Commit: 0585754593d7c010d83274c3a25dd6c3e8c8b4a8
Parent: 6cad4eba9b8d59cfc78dcaab2fa13de1889367c6
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Sep 20 17:48:20 2019 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Sep 20 17:48:48 2019 +0200
Revert "dmeventd: avoid bail out preventing repair in raid plugin"
This reverts commit 9e438b4bc6b9240b63fc79acfef3c77c01a848d8.
The reverted patch also removed the warning which we realized we need
to keep as valuable process information (see related bugzilla below).
In a followup patch, we'll keep the message and avoid bailing out thus
always allowing lvconvert to try repairing if 'allocate' fault policy set.
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1751887
---
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index f435043..52cf43d 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -76,12 +76,16 @@ static int _process_raid_event(struct dso_state *state, char *params, const char
}
if (dead) {
- /*
- * Use the first event to run a repair ignoring any additonal ones.
- *
- * We presume lvconvert to do pre-repair
- * checks to avoid bloat in this plugin.
- */
+ if (status->insync_regions < status->total_regions) {
+ if (!state->warned) {
+ state->warned = 1;
+ log_warn("WARNING: waiting for resynchronization to finish "
+ "before initiating repair on RAID device %s.", device);
+ }
+
+ goto out; /* Not yet done syncing with accessible devices */
+ }
+
if (state->failed)
goto out; /* already reported */
4 years, 7 months
master - dmeventd: avoid bail out preventing repair in raid plugin but keep message
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6f355c673631b0d7959...
Commit: 6f355c673631b0d7959191c8a56a577b3a0e97c9
Parent: 6fc46af8ecd9532aca41df43fd588fb207ed4e92
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Sep 20 17:35:35 2019 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Sep 20 17:53:20 2019 +0200
dmeventd: avoid bail out preventing repair in raid plugin but keep message
Followup patch mentioned in previous commit fe577f84cbf6bd7be76b457c9d54d0e54e57f93d.
Problem:
even though dead raid component devices are detected, the
raid plugin is bailing out thus preventing a repair attempt.
Rational:
in case of component device errors, the MD resynchronization
thread runs in parallel with the thrown event being processed
by the raid plugin. The plugin retrieves the raid device status
but that still reflects insync regions as 0 (when it should
already be total regions) because the MD thread didn't update it yet.
Solution:
Remove the insync regions check but keep the informal message
"waiting for resynchronization" and let lvconvert carry out its
pre-repair checks and optionally carry out a repair attempt.
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1751887
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1560739
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1468590
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1654860
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1729303
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1741016
---
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index aa2b578..525b721 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -76,14 +76,17 @@ static int _process_raid_event(struct dso_state *state, char *params, const char
}
if (dead) {
- if (status->insync_regions < status->total_regions) {
- if (!state->warned) {
- state->warned = 1;
- log_warn("WARNING: waiting for resynchronization to finish "
- "before initiating repair on RAID device %s.", device);
- }
-
- goto out; /* Not yet done syncing with accessible devices */
+ /*
+ * Use the first event to run a repair ignoring any additonal ones.
+ *
+ * We presume lvconvert to do pre-repair
+ * checks to avoid bloat in this plugin.
+ */
+ if (!state->warned && status->insync_regions < status->total_regions) {
+ state->warned = 1;
+ log_warn("WARNING: waiting for resynchronization to finish "
+ "before initiating repair on RAID device %s.", device);
+ /* Fall through to allow lvconvert to run. */
}
if (state->failed)
4 years, 7 months
master - Revert "dmeventd: avoid bail out preventing repair in raid plugin"
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6fc46af8ecd9532aca4...
Commit: 6fc46af8ecd9532aca41df43fd588fb207ed4e92
Parent: 8d8b5e4f75694f62a9af9cda707509f0814d8c8a
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Fri Sep 20 17:26:36 2019 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Fri Sep 20 17:52:37 2019 +0200
Revert "dmeventd: avoid bail out preventing repair in raid plugin"
This reverts commit ad560a286a0b5d08086324e6194b060c136e9353.
The reverted patch also removed the warning which we realized we need
to keep as valuable process information (see related bugzilla below).
In a followup patch, we'll keep the message and avoid bailing out thus
always allowing lvconvert to try repairing if 'allocate' fault policy set.
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1751887
---
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index 3431f1e..aa2b578 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -76,12 +76,16 @@ static int _process_raid_event(struct dso_state *state, char *params, const char
}
if (dead) {
- /*
- * Use the first event to run a repair ignoring any additonal ones.
- *
- * We presume lvconvert to do pre-repair
- * checks to avoid bloat in this plugin.
- */
+ if (status->insync_regions < status->total_regions) {
+ if (!state->warned) {
+ state->warned = 1;
+ log_warn("WARNING: waiting for resynchronization to finish "
+ "before initiating repair on RAID device %s.", device);
+ }
+
+ goto out; /* Not yet done syncing with accessible devices */
+ }
+
if (state->failed)
goto out; /* already reported */
4 years, 7 months
master - tests: add cache-single-split
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8d8b5e4f75694f62a9a...
Commit: 8d8b5e4f75694f62a9af9cda707509f0814d8c8a
Parent: 5d3bced5eab1244939958422446e0dfb5b6b79d4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Sep 18 15:14:22 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Sep 20 09:59:37 2019 -0500
tests: add cache-single-split
---
test/shell/cache-single-split.sh | 293 ++++++++++++++++++++++++++++++++++++++
1 files changed, 293 insertions(+), 0 deletions(-)
diff --git a/test/shell/cache-single-split.sh b/test/shell/cache-single-split.sh
new file mode 100644
index 0000000..90c3ddb
--- /dev/null
+++ b/test/shell/cache-single-split.sh
@@ -0,0 +1,293 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Test single lv cache options
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+mkfs_mount_umount()
+{
+ lvt=$1
+
+ lvchange -ay $vg/$lvt
+
+ mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lvt"
+ mount "$DM_DEV_DIR/$vg/$lvt" "$mount_dir"
+ cp pattern1 "$mount_dir/pattern1"
+ dd if=/dev/zero of="$mount_dir/zeros2M" bs=1M count=32 conv=fdatasync
+ umount "$mount_dir"
+
+ lvchange -an $vg/$lvt
+}
+
+mount_umount()
+{
+ lvt=$1
+
+ lvchange -ay $vg/$lvt
+
+ mount "$DM_DEV_DIR/$vg/$lvt" "$mount_dir"
+ diff pattern1 "$mount_dir/pattern1"
+ dd if="$mount_dir/zeros2M" of=/dev/null bs=1M count=32
+ umount "$mount_dir"
+
+ lvchange -an $vg/$lvt
+}
+
+aux have_cache 1 10 0 || skip
+which mkfs.xfs || skip
+
+mount_dir="mnt"
+mkdir -p "$mount_dir"
+
+# generate random data
+dd if=/dev/urandom of=pattern1 bs=512K count=1
+
+aux prepare_devs 4
+
+vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3" "$dev4"
+
+lvcreate -n $lv1 -l 16 -an $vg "$dev1" "$dev4"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+#
+# split when no devs are missing
+# while inactive
+# both cachemodes work the same
+#
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writethrough"
+
+mkfs_mount_umount $lv1
+
+lvconvert --splitcache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writeback"
+
+mkfs_mount_umount $lv1
+
+lvconvert --splitcache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+mount_umount $lv1
+
+
+#
+# split when no devs are missing
+# while active
+# both cachemodes work the same
+#
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writethrough"
+
+mkfs_mount_umount $lv1
+
+lvchange -ay $vg/$lv1
+
+lvconvert --splitcache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+mount_umount $lv1
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writeback"
+
+lvchange -an $vg/$lv1
+lvchange -an $vg/$lv2
+
+mkfs_mount_umount $lv1
+
+lvchange -ay $vg/$lv1
+
+lvconvert --splitcache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+#
+# split while cachevol is missing
+# writethrough
+#
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writethrough"
+
+lvchange -an $vg/$lv1
+lvchange -an $vg/$lv2
+
+mkfs_mount_umount $lv1
+
+lvchange -ay $vg/$lv1
+
+aux disable_dev "$dev2"
+
+lvconvert --splitcache $vg/$lv1
+
+lvs -o segtype $vg/$lv1 | grep linear
+
+aux enable_dev "$dev2"
+
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay --activationmode partial $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+vgck --updatemetadata $vg
+lvs $vg
+vgchange -an $vg
+vgextend --restoremissing $vg "$dev2"
+
+mount_umount $lv1
+
+#
+# split while cachevol is missing
+# writeback
+#
+
+lvremove $vg/$lv2
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writeback"
+
+mkfs_mount_umount $lv1
+
+aux disable_dev "$dev2"
+
+not lvconvert --splitcache $vg/$lv1
+lvconvert --splitcache --force --yes $vg/$lv1
+
+lvs -o segtype $vg/$lv1 | grep linear
+
+aux enable_dev "$dev2"
+
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay --activationmode partial $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+vgck --updatemetadata $vg
+lvs $vg
+vgchange -an $vg
+vgextend --restoremissing $vg "$dev2"
+
+#
+# split while cachevol has 1 of 2 PVs
+# writethrough
+#
+
+lvremove $vg/$lv2
+lvcreate -n $lv2 -l 14 -an $vg "$dev2" "$dev3"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writethrough"
+
+mkfs_mount_umount $lv1
+
+aux disable_dev "$dev3"
+
+lvconvert --splitcache $vg/$lv1
+
+lvs -o segtype $vg/$lv1 | grep linear
+
+aux enable_dev "$dev3"
+
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay --activationmode partial $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+vgck --updatemetadata $vg
+lvs $vg
+vgchange -an $vg
+vgextend --restoremissing $vg "$dev3"
+
+mount_umount $lv1
+
+#
+# split while cachevol has 1 of 2 PVs
+# writeback
+#
+
+lvremove $vg/$lv2
+lvcreate -n $lv2 -l 14 -an $vg "$dev2" "$dev3"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+
+check lv_field $vg/$lv1 segtype "cache"
+check lv_field $vg/$lv1 cachemode "writeback"
+
+mkfs_mount_umount $lv1
+
+aux disable_dev "$dev3"
+
+not lvconvert --splitcache $vg/$lv1
+lvconvert --splitcache --force --yes $vg/$lv1
+
+lvs -o segtype $vg/$lv1 | grep linear
+
+aux enable_dev "$dev3"
+
+lvs -o segtype $vg/$lv2 | grep linear
+
+lvchange -ay --activationmode partial $vg/$lv2
+cache_check "$DM_DEV_DIR/$vg/$lv2"
+lvchange -an $vg/$lv2
+
+vgck --updatemetadata $vg
+lvs $vg
+vgchange -an $vg
+vgextend --restoremissing $vg "$dev3"
+
+vgremove -ff $vg
+
4 years, 7 months
master - lvconvert: detaching cachevol with missing PVs
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5d3bced5eab12449399...
Commit: 5d3bced5eab1244939958422446e0dfb5b6b79d4
Parent: b46dce0badb221b1417231e7bbf2d7d898a5a8c1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 17 16:32:34 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Sep 20 09:59:37 2019 -0500
lvconvert: detaching cachevol with missing PVs
. For dm-cache in writethrough, always allow splitcache,
whether the cache is missing PVs or not.
. For dm-cache in writeback, if the cache is missing PVs,
allow splitcache with force and yes.
. For dm-writecache, if the cache is missing PVs,
allow splitcache with force and yes.
---
lib/metadata/cache_manip.c | 8 ++--
lib/metadata/lv_manip.c | 2 +-
lib/metadata/metadata-exported.h | 2 +-
tools/lvconvert.c | 84 ++++++++++++++++++++++++++++++-------
4 files changed, 74 insertions(+), 22 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 7ea2c0e..65589f7 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -655,7 +655,7 @@ static int _lv_detach_cache_vol_while_active(struct cmd_context *cmd, struct log
return 1;
}
-static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct logical_volume *cache_lv)
+static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct logical_volume *cache_lv, int noflush)
{
struct lv_segment *cache_seg = first_seg(cache_lv);
struct logical_volume *corigin_lv;
@@ -673,7 +673,7 @@ static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct l
* With these modes there is no flush needed so we can immediately
* detach without temporarily activating the LV to flush it.
*/
- if ((cache_mode == CACHE_MODE_WRITETHROUGH) || (cache_mode == CACHE_MODE_PASSTHROUGH))
+ if ((cache_mode == CACHE_MODE_WRITETHROUGH) || (cache_mode == CACHE_MODE_PASSTHROUGH) || noflush)
goto detach;
/*
@@ -727,7 +727,7 @@ static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct l
return 1;
}
-int lv_detach_cache_vol(struct logical_volume *cache_lv)
+int lv_detach_cache_vol(struct logical_volume *cache_lv, int noflush)
{
struct cmd_context *cmd = cache_lv->vg->cmd;
@@ -739,7 +739,7 @@ int lv_detach_cache_vol(struct logical_volume *cache_lv)
if (lv_is_active(cache_lv))
return _lv_detach_cache_vol_while_active(cmd, cache_lv);
else
- return _lv_detach_cache_vol_while_inactive(cmd, cache_lv);
+ return _lv_detach_cache_vol_while_inactive(cmd, cache_lv, noflush);
}
/*
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6451368..107074a 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6256,7 +6256,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return_0;
if (lv_is_cache(lv) && lv_is_cache_vol(first_seg(lv)->pool_lv)) {
- if (!lv_detach_cache_vol(lv)) {
+ if (!lv_detach_cache_vol(lv, 0)) {
log_error("Failed to detach cache from %s", display_lvname(lv));
return 0;
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index a910aa3..1c10390 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1276,7 +1276,7 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv,
struct logical_volume *origin_lv);
int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean);
int lv_cache_remove(struct logical_volume *cache_lv);
-int lv_detach_cache_vol(struct logical_volume *cache_lv);
+int lv_detach_cache_vol(struct logical_volume *cache_lv, int noflush);
int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* -- metadata/cache_manip.c */
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d64ab22..77aad9d 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1841,16 +1841,53 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
struct logical_volume *lv_fast)
{
struct lv_segment *cache_seg = first_seg(lv);
-
- log_debug("Detaching cache %s from LV %s.", display_lvname(lv_fast), display_lvname(lv));
+ int cache_mode = cache_seg->cache_mode;
+ int noflush = 0;
if (!archive(lv->vg))
return_0;
if (lv_is_cache_vol(cache_seg->pool_lv)) {
- if (!lv_detach_cache_vol(lv))
+ log_debug("Detaching cachevol %s from LV %s.", display_lvname(lv_fast), display_lvname(lv));
+
+ /*
+ * Detaching a writeback cache generally requires flushing;
+ * doing otherwise can mean data loss/corruption.
+ * If the cache devices are missing, the cache can't be
+ * flushed, so require the user to use a force option to
+ * detach the cache in this case.
+ */
+ if ((cache_mode != CACHE_MODE_WRITETHROUGH) && lv_is_partial(lv_fast)) {
+ if (!arg_count(cmd, force_ARG)) {
+ log_warn("WARNING: writeback cache on %s is not complete and cannot be flushed.", display_lvname(lv_fast));
+ log_warn("WARNING: cannot detach writeback cache from %s without --force.", display_lvname(lv));
+ log_error("Conversion aborted.");
+ return 0;
+ }
+
+ log_warn("WARNING: Data may be lost by detaching writeback cache without flushing.");
+
+ if (!arg_count(cmd, yes_ARG) &&
+ yes_no_prompt("Detach writeback cache %s from %s without flushing data?",
+ display_lvname(lv_fast),
+ display_lvname(lv)) == 'n') {
+ log_error("Conversion aborted.");
+ return 0;
+ }
+
+ noflush = 1;
+ }
+
+ if (!lv_detach_cache_vol(lv, noflush))
return_0;
} else {
+ log_debug("Detaching cachepool %s from LV %s.", display_lvname(lv_fast), display_lvname(lv));
+
+ if (vg_missing_pv_count(lv->vg)) {
+ log_error("Cannot split cache pool while PVs are missing, see --uncache to delete cache pool.");
+ return 0;
+ }
+
if (!lv_cache_remove(lv))
return_0;
}
@@ -1860,7 +1897,7 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
backup(lv->vg);
- log_print_unless_silent("Logical volume %s is not cached and cache pool %s is unused.",
+ log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
display_lvname(lv), display_lvname(lv_fast));
return 1;
@@ -1895,7 +1932,7 @@ static int _lvconvert_split_and_remove_cache(struct cmd_context *cmd,
if (first_seg(seg->pool_lv)->cache_mode != CACHE_MODE_WRITETHROUGH) {
if (!arg_count(cmd, force_ARG)) {
log_error("Conversion aborted.");
- log_error("Cannot uncache writethrough cache volume %s without --force.",
+ log_error("Cannot uncache writeback cache volume %s without --force.",
display_lvname(lv));
return 0;
}
@@ -4607,7 +4644,7 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *lv_fast);
-static int _lvconvert_split_cache_vol(struct cmd_context *cmd,
+static int _lvconvert_split_cache_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
@@ -4635,6 +4672,7 @@ static int _lvconvert_split_cache_vol(struct cmd_context *cmd,
} else if (lv_is_thin_pool(lv)) {
lv_main = seg_lv(first_seg(lv), 0); /* cached _tdata */
lv_fast = first_seg(lv_main)->pool_lv;
+
} else if (lv_is_vdo_pool(lv)) {
lv_main = seg_lv(first_seg(lv), 0); /* cached _vdata */
lv_fast = first_seg(lv_main)->pool_lv;
@@ -4694,13 +4732,11 @@ static int _lvconvert_split_cache_vol(struct cmd_context *cmd,
int lvconvert_split_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
{
- if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD) {
- cmd->handles_missing_pvs = 1;
- cmd->partial_activation = 1;
- }
+ cmd->handles_missing_pvs = 1;
+ cmd->partial_activation = 1;
return process_each_lv(cmd, 1, cmd->position_argv, NULL, NULL, READ_FOR_UPDATE,
- NULL, NULL, &_lvconvert_split_cache_vol);
+ NULL, NULL, &_lvconvert_split_cache_single);
}
static int _lvconvert_raid_types_single(struct cmd_context *cmd, struct logical_volume *lv,
@@ -5246,11 +5282,6 @@ fail:
return 0;
}
-/*
- * TODO: add a new option that will skip activating and flushing the
- * writecache and move directly to detaching.
- */
-
static int _lvconvert_detach_writecache(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *lv_fast)
@@ -5269,6 +5300,26 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
if (!archive(lv->vg))
return_0;
+ if (lv_is_partial(lv_fast)) {
+ if (!arg_count(cmd, force_ARG)) {
+ log_warn("WARNING: writecache on %s is not complete and cannot be flushed.", display_lvname(lv_fast));
+ log_warn("WARNING: cannot detach writecache from %s without --force.", display_lvname(lv));
+ log_error("Conversion aborted.");
+ return 0;
+ }
+
+ log_warn("WARNING: Data may be lost by detaching writecache without flushing.");
+
+ if (!arg_count(cmd, yes_ARG) &&
+ yes_no_prompt("Detach writecache %s from %s without flushing data?",
+ display_lvname(lv_fast), display_lvname(lv)) == 'n') {
+ log_error("Conversion aborted.");
+ return 0;
+ }
+
+ goto detach;
+ }
+
/*
* Activate LV internally since the LV needs to be active to flush.
* LV_TEMPORARY should keep the LV from being exposed to the user
@@ -5315,6 +5366,7 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
lv->status &= ~LV_TEMPORARY;
+ detach:
if (!_lv_writecache_detach(cmd, lv, lv_fast)) {
log_error("Failed to detach writecache from %s", display_lvname(lv));
return 0;
4 years, 7 months
master - lvchange: allow activating cachevol
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b46dce0badb221b1417...
Commit: b46dce0badb221b1417231e7bbf2d7d898a5a8c1
Parent: 515e37b6dd352bd71e63bdef24fc13e2ee75ff98
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Sep 19 16:18:47 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Sep 20 09:59:37 2019 -0500
lvchange: allow activating cachevol
---
tools/lvchange.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 03a7793..65cea6c 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1391,6 +1391,20 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
struct processing_handle *handle,
int lv_is_named_arg)
{
+ int do_activate = is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY));
+
+ if (lv_is_cache_vol(lv) && lv_is_named_arg) {
+ if (!do_activate)
+ return 1;
+
+ if (arg_is_set(cmd, yes_ARG) ||
+ (yes_no_prompt("Do you want to activate component LV in read-only mode? [y/n]: ") == 'y')) {
+ log_print_unless_silent("Allowing activation of component LV.");
+ cmd->activate_component = 1;
+ }
+ return 1;
+ }
+
if (!lv_is_visible(lv) &&
!cmd->activate_component && /* activation of named component LV */
((first_seg(lv)->status & MERGING) || /* merging already started */
4 years, 7 months
master - cachevol: add dm uuid suffixes to hidden lvs
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=515e37b6dd352bd71e6...
Commit: 515e37b6dd352bd71e63bdef24fc13e2ee75ff98
Parent: d2c065789cfac0ebfc5b6f3d85d9b2ce84d90e55
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Sep 20 09:46:03 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Sep 20 09:59:37 2019 -0500
cachevol: add dm uuid suffixes to hidden lvs
to indicate they are private lvm devs
---
lib/activate/dev_manager.c | 14 +++++++-------
lib/cache_segtype/cache.c | 4 ++--
lib/misc/lvm-string.c | 2 ++
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 5ee5efe..b85237d 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -46,7 +46,7 @@ typedef enum {
} action_t;
/* This list must match lib/misc/lvm-string.c:build_dm_uuid(). */
-const char *uuid_suffix_list[] = { "pool", "cdata", "cmeta", "tdata", "tmeta", "vdata", "vpool", NULL};
+const char *uuid_suffix_list[] = { "pool", "cdata", "cmeta", "tdata", "tmeta", "vdata", "vpool", "cvol", NULL};
struct dlid_list {
struct dm_list list;
@@ -859,9 +859,9 @@ int get_cache_vol_meta_data(struct cmd_context *cmd,
memcpy(&lvid_data.id[0], &lv->vg->id, sizeof(struct id));
memcpy(&lvid_data.id[1], &lvseg->data_id, sizeof(struct id));
- if (!(dlid_meta = dm_build_dm_uuid(cmd->mem, UUID_PREFIX, (const char *)&lvid_meta.s, NULL)))
+ if (!(dlid_meta = dm_build_dm_uuid(cmd->mem, UUID_PREFIX, (const char *)&lvid_meta.s, "cmeta")))
return_0;
- if (!(dlid_data = dm_build_dm_uuid(cmd->mem, UUID_PREFIX, (const char *)&lvid_data.s, NULL)))
+ if (!(dlid_data = dm_build_dm_uuid(cmd->mem, UUID_PREFIX, (const char *)&lvid_data.s, "cdata")))
return_0;
if (!(name_meta = dm_build_dm_name(cmd->mem, lv->vg->name, pool_lv->name, "_cmeta")))
return_0;
@@ -2500,9 +2500,9 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
memcpy(&lvid_data.id[0], &lv->vg->id, sizeof(struct id));
memcpy(&lvid_data.id[1], &lvseg->data_id, sizeof(struct id));
- if (!(dlid_meta = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_meta.s, NULL)))
+ if (!(dlid_meta = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_meta.s, "cmeta")))
return_0;
- if (!(dlid_data = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_data.s, NULL)))
+ if (!(dlid_data = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_data.s, "cdata")))
return_0;
if (!(name_meta = dm_build_dm_name(dm->mem, lv->vg->name, pool_lv->name, "_cmeta")))
return_0;
@@ -3242,9 +3242,9 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
memcpy(&lvid_data.id[0], &vg->id, sizeof(struct id));
memcpy(&lvid_data.id[1], &lvseg->data_id, sizeof(struct id));
- if (!(dlid_meta = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_meta.s, NULL)))
+ if (!(dlid_meta = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_meta.s, "cmeta")))
return_0;
- if (!(dlid_data = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_data.s, NULL)))
+ if (!(dlid_data = dm_build_dm_uuid(dm->mem, UUID_PREFIX, (const char *)&lvid_data.s, "cdata")))
return_0;
if (!(name_meta = dm_build_dm_name(dm->mem, vg->name, pool_lv->name, "_cmeta")))
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 20a4261..798b157 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -699,9 +699,9 @@ static int _cache_add_target_line(struct dev_manager *dm,
memcpy(&data_lvid.id[0], &seg->lv->vg->id, sizeof(struct id));
memcpy(&data_lvid.id[1], &seg->data_id, sizeof(struct id));
- if (!(metadata_uuid = dm_build_dm_uuid(mem, UUID_PREFIX, (const char *)&metadata_lvid.s, NULL)))
+ if (!(metadata_uuid = dm_build_dm_uuid(mem, UUID_PREFIX, (const char *)&metadata_lvid.s, "cmeta")))
return_0;
- if (!(data_uuid = dm_build_dm_uuid(mem, UUID_PREFIX, (const char *)&data_lvid.s, NULL)))
+ if (!(data_uuid = dm_build_dm_uuid(mem, UUID_PREFIX, (const char *)&data_lvid.s, "cdata")))
return_0;
}
diff --git a/lib/misc/lvm-string.c b/lib/misc/lvm-string.c
index fe24f23..b7c1c12 100644
--- a/lib/misc/lvm-string.c
+++ b/lib/misc/lvm-string.c
@@ -157,6 +157,7 @@ static const char *_lvname_has_reserved_component_string(const char *lvname)
"_cdata",
"_cmeta",
"_corig",
+ "_cvol",
"_mimage",
"_mlog",
"_rimage",
@@ -251,6 +252,7 @@ char *build_dm_uuid(struct dm_pool *mem, const struct logical_volume *lv,
(lv_is_cache(lv) && lv_is_pending_delete(lv)) ? "real" :
lv_is_cache_pool_data(lv) ? "cdata" :
lv_is_cache_pool_metadata(lv) ? "cmeta" :
+ lv_is_cache_vol(lv) ? "cvol" :
// FIXME: dm-tree needs fixes for mirrors/raids
//lv_is_mirror_image(lv) ? "mimage" :
//lv_is_mirror_log(lv) ? "mlog" :
4 years, 7 months
master - lvconvert: cachevol LV can have multiple segments
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d2c065789cfac0ebfc5...
Commit: d2c065789cfac0ebfc5b6f3d85d9b2ce84d90e55
Parent: 3ce0dc59f26ef22d38ffc6e26aa354ef8727ea19
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Sep 18 15:11:14 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Sep 20 09:59:37 2019 -0500
lvconvert: cachevol LV can have multiple segments
---
lib/metadata/merge.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index 08f8fbe..e482921 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -805,7 +805,6 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
if ((seg_count != 1) &&
(lv_is_cache(lv) ||
lv_is_cache_pool(lv) ||
- lv_is_cache_vol(lv) ||
lv_is_raid(lv) ||
lv_is_snapshot(lv) ||
lv_is_thin_pool(lv) ||
4 years, 7 months
master - spec: Move blkdeactivate to device-mapper
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3ce0dc59f26ef22d38f...
Commit: 3ce0dc59f26ef22d38ffc6e26aa354ef8727ea19
Parent: 38a3da532f27a8ccda652842bb89dbecb1e4a3f9
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Fri Sep 20 10:55:29 2019 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Fri Sep 20 10:59:59 2019 +0200
spec: Move blkdeactivate to device-mapper
---
spec/packages.inc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/spec/packages.inc b/spec/packages.inc
index 196cbf6..cbddbd5 100644
--- a/spec/packages.inc
+++ b/spec/packages.inc
@@ -33,7 +33,6 @@ fi
%defattr(-,root,root,-)
%doc COPYING COPYING.LIB INSTALL README VERSION WHATS_NEW
%doc doc/lvm_fault_handling.txt
-%{_sbindir}/blkdeactivate
%{_sbindir}/fsadm
%{_sbindir}/lvchange
%{_sbindir}/lvconvert
@@ -87,7 +86,6 @@ fi
%{_mandir}/man7/lvmsystemid.7.gz
%{_mandir}/man7/lvmreport.7.gz
%{_mandir}/man7/lvmraid.7.gz
-%{_mandir}/man8/blkdeactivate.8.gz
%{_mandir}/man8/fsadm.8.gz
%{_mandir}/man8/lvchange.8.gz
%{_mandir}/man8/lvconvert.8.gz
@@ -420,8 +418,10 @@ for the kernel device-mapper.
%files -n device-mapper
%defattr(-,root,root,-)
%doc COPYING COPYING.LIB WHATS_NEW_DM VERSION_DM README INSTALL
+%{_sbindir}/blkdeactivate
%attr(755,root,root) %{_sbindir}/dmsetup
%{_sbindir}/dmstats
+%{_mandir}/man8/blkdeactivate.8.gz
%{_mandir}/man8/dmsetup.8.gz
%{_mandir}/man8/dmstats.8.gz
%if %{enable_dmfilemapd}
4 years, 7 months