master - lvconvert: enable --uncache with dm-writecache cachevol
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9a8e6ad014c7dd6785a...
Commit: 9a8e6ad014c7dd6785ad6859551d68a264bad1f8
Parent: 26596ce7faf1cd8b0aa4b199fa917fb14eace666
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 24 15:49:21 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 24 15:51:05 2019 -0500
lvconvert: enable --uncache with dm-writecache cachevol
splitcache followed by an automatic lvremove of
the cachevol LV
---
tools/lvconvert.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 07b5d6a..60ab956 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4715,17 +4715,17 @@ static int _lvconvert_split_cache_single(struct cmd_context *cmd,
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv_main, "ex", 0))
- return_0;
+ return ECMD_FAILED;
if (lv_is_writecache(lv_main)) {
+ if (!_lvconvert_detach_writecache(cmd, lv_main, lv_fast))
+ return ECMD_FAILED;
+
if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD) {
- log_error("Detach cache from %s with --splitcache.", display_lvname(lv));
- log_error("The writecache %s may then be removed with lvremove.", display_lvname(lv_fast));
- return 0;
+ if (lvremove_single(cmd, lv_fast, NULL) != ECMD_PROCESSED)
+ return ECMD_FAILED;
}
- ret = _lvconvert_detach_writecache(cmd, lv_main, lv_fast);
-
} else if (lv_is_cache(lv_main) && lv_is_cache_vol(lv_fast)) {
if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD) {
ret = _lvconvert_split_and_remove_cachevol(cmd, lv_main, lv_fast);
4 years, 7 months
master - writecache: allow removing LV with attached writecache
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=26596ce7faf1cd8b0aa...
Commit: 26596ce7faf1cd8b0aa4b199fa917fb14eace666
Parent: 76dd9b2b518e85a4fecbc752424a8a0f36616838
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 24 15:33:09 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 24 15:51:05 2019 -0500
writecache: allow removing LV with attached writecache
---
lib/metadata/lv_manip.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f404555..21d21ca 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1599,11 +1599,6 @@ int lv_reduce(struct logical_volume *lv, uint32_t extents)
{
struct lv_segment *seg = first_seg(lv);
- if (lv_is_writecache(lv)) {
- log_error("Remove not yet allowed on LVs with writecache attached.");
- return 0;
- }
-
/* Ensure stripe boundary extents on RAID LVs */
if (lv_is_raid(lv) && extents != lv->le_count)
extents =_round_to_stripe_boundary(lv->vg, extents,
@@ -6318,6 +6313,25 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
+ if (lv_is_writecache(lv)) {
+ struct logical_volume *cachevol_lv = first_seg(lv)->writecache;
+
+ if (!deactivate_lv(cmd, lv)) {
+ log_error("Failed to deactivate LV %s", display_lvname(lv));
+ return 0;
+ }
+
+ if (!lv_detach_writecache_cachevol(lv, 1)) {
+ log_error("Failed to detach writecache from %s", display_lvname(lv));
+ return 0;
+ }
+
+ if (!lv_remove_single(cmd, cachevol_lv, force, suppress_remove_message)) {
+ log_error("Failed to remove cachevol %s.", display_lvname(cachevol_lv));
+ return 0;
+ }
+ }
+
if (!lv_is_historical(lv) && (force == PROMPT) && ask_discard &&
yes_no_prompt("Do you really want to remove and DISCARD "
"logical volume %s? [y/n]: ",
4 years, 7 months
master - writecache: move code into new file
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=76dd9b2b518e85a4fec...
Commit: 76dd9b2b518e85a4fecbc752424a8a0f36616838
Parent: 56aadd7fe2a1d24043ea9d06543c29317ac1cc58
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 24 15:28:02 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 24 15:51:05 2019 -0500
writecache: move code into new file
put writecache specific code in writecache_manip.c
should be no functional change
---
lib/Makefile.in | 1 +
lib/metadata/metadata-exported.h | 1 +
lib/metadata/metadata.c | 27 -----
lib/metadata/writecache_manip.c | 201 ++++++++++++++++++++++++++++++++++++++
tools/lvconvert.c | 142 +--------------------------
5 files changed, 208 insertions(+), 164 deletions(-)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 654c322..c037b41 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -66,6 +66,7 @@ SOURCES =\
locking/locking.c \
log/log.c \
metadata/cache_manip.c \
+ metadata/writecache_manip.c \
metadata/lv.c \
metadata/lv_manip.c \
metadata/merge.c \
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 7c9aebb..ea8635e 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1282,6 +1282,7 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_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 noflush);
+int lv_detach_writecache_cachevol(struct logical_volume *cache_lv, int noflush);
int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* -- metadata/cache_manip.c */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 644cd59..b434967 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -5166,30 +5166,3 @@ struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_
return vg;
}
-
-int lv_is_writecache_origin(const struct logical_volume *lv)
-{
- struct seg_list *sl;
-
- dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
- if (!sl->seg || !sl->seg->lv || !sl->seg->origin)
- continue;
- if (lv_is_writecache(sl->seg->lv) && (sl->seg->origin == lv))
- return 1;
- }
- return 0;
-}
-
-int lv_is_writecache_cachevol(const struct logical_volume *lv)
-{
- struct seg_list *sl;
-
- dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
- if (!sl->seg || !sl->seg->lv || !sl->seg->writecache)
- continue;
- if (lv_is_writecache(sl->seg->lv) && (sl->seg->writecache == lv))
- return 1;
- }
- return 0;
-}
-
diff --git a/lib/metadata/writecache_manip.c b/lib/metadata/writecache_manip.c
new file mode 100644
index 0000000..73fbd2e
--- /dev/null
+++ b/lib/metadata/writecache_manip.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2014-2015 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * 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 Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser 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
+ */
+
+#include "lib/misc/lib.h"
+#include "lib/metadata/metadata.h"
+#include "lib/locking/locking.h"
+#include "lib/misc/lvm-string.h"
+#include "lib/commands/toolcontext.h"
+#include "lib/display/display.h"
+#include "lib/metadata/segtype.h"
+#include "lib/activate/activate.h"
+#include "lib/config/defaults.h"
+#include "lib/metadata/lv_alloc.h"
+#include "lib/misc/lvm-signal.h"
+#include "lib/activate/dev_manager.h"
+
+int lv_is_writecache_origin(const struct logical_volume *lv)
+{
+ struct seg_list *sl;
+
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
+ if (!sl->seg || !sl->seg->lv || !sl->seg->origin)
+ continue;
+ if (lv_is_writecache(sl->seg->lv) && (sl->seg->origin == lv))
+ return 1;
+ }
+ return 0;
+}
+
+int lv_is_writecache_cachevol(const struct logical_volume *lv)
+{
+ struct seg_list *sl;
+
+ dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
+ if (!sl->seg || !sl->seg->lv || !sl->seg->writecache)
+ continue;
+ if (lv_is_writecache(sl->seg->lv) && (sl->seg->writecache == lv))
+ return 1;
+ }
+ return 0;
+}
+
+static int _lv_writecache_detach(struct cmd_context *cmd, struct logical_volume *lv,
+ struct logical_volume *lv_fast)
+{
+ struct lv_segment *seg = first_seg(lv);
+ struct logical_volume *origin;
+
+ if (!seg_is_writecache(seg)) {
+ log_error("LV %s segment is not writecache.", display_lvname(lv));
+ return 0;
+ }
+
+ if (!seg->writecache) {
+ log_error("LV %s writecache segment has no writecache.", display_lvname(lv));
+ return 0;
+ }
+
+ if (!(origin = seg_lv(seg, 0))) {
+ log_error("LV %s writecache segment has no origin", display_lvname(lv));
+ return 0;
+ }
+
+ if (!remove_seg_from_segs_using_this_lv(seg->writecache, seg))
+ return_0;
+
+ lv_set_visible(seg->writecache);
+
+ lv->status &= ~WRITECACHE;
+ seg->writecache = NULL;
+
+ lv_fast->status &= ~LV_CACHE_VOL;
+
+ if (!remove_layer_from_lv(lv, origin))
+ return_0;
+
+ if (!lv_remove(origin))
+ return_0;
+
+ return 1;
+}
+
+static int _get_writecache_kernel_error(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ uint32_t *kernel_error)
+{
+ struct lv_with_info_and_seg_status status;
+
+ memset(&status, 0, sizeof(status));
+ status.seg_status.type = SEG_STATUS_NONE;
+
+ status.seg_status.seg = first_seg(lv);
+
+ /* FIXME: why reporter_pool? */
+ if (!(status.seg_status.mem = dm_pool_create("reporter_pool", 1024))) {
+ log_error("Failed to get mem for LV status.");
+ return 0;
+ }
+
+ if (!lv_info_with_seg_status(cmd, first_seg(lv), &status, 1, 1)) {
+ log_error("Failed to get device mapper status for %s", display_lvname(lv));
+ goto fail;
+ }
+
+ if (!status.info.exists) {
+ log_error("No device mapper info exists for %s", display_lvname(lv));
+ goto fail;
+ }
+
+ if (status.seg_status.type != SEG_STATUS_WRITECACHE) {
+ log_error("Invalid device mapper status type (%d) for %s",
+ (uint32_t)status.seg_status.type, display_lvname(lv));
+ goto fail;
+ }
+
+ *kernel_error = status.seg_status.writecache->error;
+
+ dm_pool_destroy(status.seg_status.mem);
+ return 1;
+
+fail:
+ dm_pool_destroy(status.seg_status.mem);
+ return 0;
+}
+
+int lv_detach_writecache_cachevol(struct logical_volume *lv, int noflush)
+{
+ struct cmd_context *cmd = lv->vg->cmd;
+ struct logical_volume *lv_fast;
+ uint32_t kernel_error = 0;
+
+ lv_fast = first_seg(lv)->writecache;
+
+ if (noflush)
+ 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
+ * and being accessed.
+ */
+
+ lv->status |= LV_TEMPORARY;
+
+ if (!activate_lv(cmd, lv)) {
+ log_error("Failed to activate LV %s for flushing writecache.", display_lvname(lv));
+ return 0;
+ }
+
+ if (!sync_local_dev_names(cmd)) {
+ log_error("Failed to sync local devices before detaching writecache.");
+ return 0;
+ }
+
+ if (!lv_writecache_message(lv, "flush")) {
+ log_error("Failed to flush writecache for %s.", display_lvname(lv));
+ if (!deactivate_lv(cmd, lv))
+ log_error("Failed to deactivate %s.", display_lvname(lv));
+ return 0;
+ }
+
+ if (!_get_writecache_kernel_error(cmd, lv, &kernel_error)) {
+ log_error("Failed to get writecache error status for %s.", display_lvname(lv));
+ if (!deactivate_lv(cmd, lv))
+ log_error("Failed to deactivate %s.", display_lvname(lv));
+ return 0;
+ }
+
+ if (kernel_error) {
+ log_error("Failed to flush writecache (error %u) for %s.", kernel_error, display_lvname(lv));
+ deactivate_lv(cmd, lv);
+ return 0;
+ }
+
+ if (!deactivate_lv(cmd, lv)) {
+ log_error("Failed to deactivate LV %s for detaching writecache.", display_lvname(lv));
+ return 0;
+ }
+
+ 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;
+ }
+
+ return 1;
+}
+
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index e4f605e..07b5d6a 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5237,94 +5237,11 @@ int lvconvert_to_vdopool_param_cmd(struct cmd_context *cmd, int argc, char **arg
NULL, NULL, &_lvconvert_to_vdopool_single);
}
-static int _lv_writecache_detach(struct cmd_context *cmd, struct logical_volume *lv,
- struct logical_volume *lv_fast)
-{
- struct lv_segment *seg = first_seg(lv);
- struct logical_volume *origin;
-
- if (!seg_is_writecache(seg)) {
- log_error("LV %s segment is not writecache.", display_lvname(lv));
- return 0;
- }
-
- if (!seg->writecache) {
- log_error("LV %s writecache segment has no writecache.", display_lvname(lv));
- return 0;
- }
-
- if (!(origin = seg_lv(seg, 0))) {
- log_error("LV %s writecache segment has no origin", display_lvname(lv));
- return 0;
- }
-
- if (!remove_seg_from_segs_using_this_lv(seg->writecache, seg))
- return_0;
-
- lv_set_visible(seg->writecache);
-
- lv->status &= ~WRITECACHE;
- seg->writecache = NULL;
-
- lv_fast->status &= ~LV_CACHE_VOL;
-
- if (!remove_layer_from_lv(lv, origin))
- return_0;
-
- if (!lv_remove(origin))
- return_0;
-
- return 1;
-}
-
-static int _get_writecache_kernel_error(struct cmd_context *cmd,
- struct logical_volume *lv,
- uint32_t *kernel_error)
-{
- struct lv_with_info_and_seg_status status;
-
- memset(&status, 0, sizeof(status));
- status.seg_status.type = SEG_STATUS_NONE;
-
- status.seg_status.seg = first_seg(lv);
-
- /* FIXME: why reporter_pool? */
- if (!(status.seg_status.mem = dm_pool_create("reporter_pool", 1024))) {
- log_error("Failed to get mem for LV status.");
- return 0;
- }
-
- if (!lv_info_with_seg_status(cmd, first_seg(lv), &status, 1, 1)) {
- log_error("Failed to get device mapper status for %s", display_lvname(lv));
- goto fail;
- }
-
- if (!status.info.exists) {
- log_error("No device mapper info exists for %s", display_lvname(lv));
- goto fail;
- }
-
- if (status.seg_status.type != SEG_STATUS_WRITECACHE) {
- log_error("Invalid device mapper status type (%d) for %s",
- (uint32_t)status.seg_status.type, display_lvname(lv));
- goto fail;
- }
-
- *kernel_error = status.seg_status.writecache->error;
-
- dm_pool_destroy(status.seg_status.mem);
- return 1;
-
-fail:
- dm_pool_destroy(status.seg_status.mem);
- return 0;
-}
-
static int _lvconvert_detach_writecache(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *lv_fast)
{
- uint32_t kernel_error = 0;
+ int noflush = 0;
/*
* LV must be inactive externally before detaching cache.
@@ -5354,61 +5271,12 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
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
- * and being accessed.
- */
-
- lv->status |= LV_TEMPORARY;
-
- if (!activate_lv(cmd, lv)) {
- log_error("Failed to activate LV %s for flushing.", display_lvname(lv));
- return 0;
- }
-
- if (!sync_local_dev_names(cmd)) {
- log_error("Failed to sync local devices before detaching LV %s.",
- display_lvname(lv));
- return 0;
- }
-
- if (!lv_writecache_message(lv, "flush")) {
- log_error("Failed to flush writecache for %s.", display_lvname(lv));
- if (!deactivate_lv(cmd, lv))
- log_error("Failed to deactivate %s.", display_lvname(lv));
- return 0;
- }
-
- if (!_get_writecache_kernel_error(cmd, lv, &kernel_error)) {
- log_error("Failed to get writecache error status for %s.", display_lvname(lv));
- if (!deactivate_lv(cmd, lv))
- log_error("Failed to deactivate %s.", display_lvname(lv));
- return 0;
- }
-
- if (kernel_error) {
- log_error("Failed to flush writecache (error %u) for %s.", kernel_error, display_lvname(lv));
- deactivate_lv(cmd, lv);
- return 0;
- }
-
- if (!deactivate_lv(cmd, lv)) {
- log_error("Failed to deactivate LV %s for detaching writecache.", display_lvname(lv));
- return 0;
+
+ noflush = 1;
}
- 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;
- }
+ if (!lv_detach_writecache_cachevol(lv, noflush))
+ return_0;
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
4 years, 7 months
master - lvremove: remove attached cachevol with removed LV
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=56aadd7fe2a1d24043e...
Commit: 56aadd7fe2a1d24043ea9d06543c29317ac1cc58
Parent: 3b36de573ec53a3e616594903ff3ca64ee2dcafa
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 24 13:46:40 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 24 15:51:05 2019 -0500
lvremove: remove attached cachevol with removed LV
When an LV is removed that has an attached cachevol,
also remove the cachevol LV.
---
lib/metadata/lv_manip.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 79e3d15..f404555 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6283,10 +6283,16 @@ 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)) {
+ struct logical_volume *cachevol_lv = first_seg(lv)->pool_lv;
+
if (!lv_detach_cache_vol(lv, 0)) {
log_error("Failed to detach cache from %s", display_lvname(lv));
return 0;
}
+ if (!lv_remove_single(cmd, cachevol_lv, force, suppress_remove_message)) {
+ log_error("Failed to remove cachevol %s.", display_lvname(cachevol_lv));
+ return 0;
+ }
}
/* FIXME Ensure not referred to by another existing LVs */
4 years, 7 months
master - tests: update cache-single-split
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3b36de573ec53a3e616...
Commit: 3b36de573ec53a3e616594903ff3ca64ee2dcafa
Parent: f27625f005f5a96a7ed44d2dbc9f71cfcc981c54
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 24 13:17:40 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 24 15:51:05 2019 -0500
tests: update cache-single-split
add some uncache commands
---
test/shell/cache-single-split.sh | 125 +++++++++++++++++++++++++++++++++++++-
1 files changed, 124 insertions(+), 1 deletions(-)
diff --git a/test/shell/cache-single-split.sh b/test/shell/cache-single-split.sh
index 90c3ddb..3224ea1 100644
--- a/test/shell/cache-single-split.sh
+++ b/test/shell/cache-single-split.sh
@@ -289,5 +289,128 @@ lvs $vg
vgchange -an $vg
vgextend --restoremissing $vg "$dev3"
-vgremove -ff $vg
+#
+# uncache when no devs are missing
+# while inactive
+# both cachemodes work the same
+#
+
+lvremove $vg/$lv1
+lvremove $vg/$lv2
+
+lvcreate -n $lv1 -l 16 -an $vg "$dev1" "$dev4"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+
+mkfs_mount_umount $lv1
+
+lvconvert --uncache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+
+mkfs_mount_umount $lv1
+
+lvconvert --uncache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+
+mount_umount $lv1
+
+#
+# uncache when no devs are missing
+# while active
+# both cachemodes work the same
+#
+
+lvremove $vg/$lv1
+
+lvcreate -n $lv1 -l 16 -an $vg "$dev1" "$dev4"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+
+mkfs_mount_umount $lv1
+
+lvchange -ay $vg/$lv1
+
+lvconvert --uncache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+
+lvchange -an $vg/$lv1
+
+mkfs_mount_umount $lv1
+
+lvchange -ay $vg/$lv1
+
+lvconvert --uncache $vg/$lv1
+lvs -o segtype $vg/$lv1 | grep linear
+
+mount_umount $lv1
+
+#
+# uncache while cachevol is missing
+# writethrough
+#
+
+lvremove $vg/$lv1
+
+lvcreate -n $lv1 -l 16 -an $vg "$dev1" "$dev4"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writethrough $vg/$lv1
+
+mkfs_mount_umount $lv1
+
+aux disable_dev "$dev2"
+
+lvconvert --uncache $vg/$lv1
+
+lvs -o segtype $vg/$lv1 | grep linear
+
+aux enable_dev "$dev2"
+
+not lvs -o segtype $vg/$lv2
+
+vgck --updatemetadata $vg
+lvs $vg
+
+vgchange -an $vg
+
+mount_umount $lv1
+
+#
+# uncache while cachevol is missing
+# writeback
+#
+lvremove $vg/$lv1
+
+lvcreate -n $lv1 -l 16 -an $vg "$dev1" "$dev4"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+
+lvconvert -y --type cache --cachevol $lv2 --cachemode writeback $vg/$lv1
+
+mkfs_mount_umount $lv1
+
+aux disable_dev "$dev2"
+
+not lvconvert --uncache $vg/$lv1
+lvconvert --uncache --force --yes $vg/$lv1
+
+lvs -o segtype $vg/$lv1 | grep linear
+
+aux enable_dev "$dev2"
+
+not lvs -o segtype $vg/$lv2
+
+vgck --updatemetadata $vg
+lvs $vg
+
+vgremove -ff $vg
4 years, 7 months
master - lvconvert: enable --uncache with dm-cache cachevol
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f27625f005f5a96a7ed...
Commit: f27625f005f5a96a7ed44d2dbc9f71cfcc981c54
Parent: 44640043628425e09122aa3775fd40a5b13c0fd0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 24 11:57:44 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 24 15:50:58 2019 -0500
lvconvert: enable --uncache with dm-cache cachevol
splitcache followed by an automatic lvremove of
the cachevol LV
---
tools/lvconvert.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 352a588..e4f605e 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1884,8 +1884,18 @@ static int _lvconvert_split_and_keep_cachevol(struct cmd_context *cmd,
backup(lv->vg);
- log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
- display_lvname(lv), display_lvname(lv_fast));
+ return 1;
+}
+
+static int _lvconvert_split_and_remove_cachevol(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct logical_volume *lv_fast)
+{
+ if (!_lvconvert_split_and_keep_cachevol(cmd, lv, lv_fast))
+ return_0;
+
+ if (lvremove_single(cmd, lv_fast, NULL) != ECMD_PROCESSED)
+ return_0;
return 1;
}
@@ -1918,15 +1928,6 @@ static int _lvconvert_split_and_keep_cachepool(struct cmd_context *cmd,
return 1;
}
-static int _lvconvert_split_and_remove_cachevol(struct cmd_context *cmd,
- struct logical_volume *lv,
- struct logical_volume *lv_fast)
-{
- log_error("Detach cache from %s with --splitcache.", display_lvname(lv));
- log_error("The cache %s may then be removed with lvremove.", display_lvname(lv_fast));
- return 0;
-}
-
static int _lvconvert_split_and_remove_cachepool(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *cachepool_lv)
@@ -4726,13 +4727,19 @@ static int _lvconvert_split_cache_single(struct cmd_context *cmd,
ret = _lvconvert_detach_writecache(cmd, lv_main, lv_fast);
} else if (lv_is_cache(lv_main) && lv_is_cache_vol(lv_fast)) {
- if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD)
+ if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD) {
ret = _lvconvert_split_and_remove_cachevol(cmd, lv_main, lv_fast);
- else if (cmd->command->command_enum == lvconvert_split_and_keep_cache_CMD)
+ log_print_unless_silent("Logical volume %s is not cached and %s is removed.",
+ display_lvname(lv), display_lvname(lv_fast));
+
+ } else if (cmd->command->command_enum == lvconvert_split_and_keep_cache_CMD) {
ret = _lvconvert_split_and_keep_cachevol(cmd, lv_main, lv_fast);
- else {
+ log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
+ display_lvname(lv), display_lvname(lv_fast));
+
+ } else {
log_error(INTERNAL_ERROR "Unknown cache split command.");
ret = 0;
}
4 years, 7 months
master - lvconvert: separate splitcache and uncache functions
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=44640043628425e0912...
Commit: 44640043628425e09122aa3775fd40a5b13c0fd0
Parent: e35cf0f623ba591c12a1a2eaed126d47bf11103c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Sep 24 11:28:30 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Sep 24 13:55:21 2019 -0500
lvconvert: separate splitcache and uncache functions
Reorg code so there are separate functions for splitcache
and uncache for both cachepool and cachevol. Should be no
functional change.
---
tools/lvconvert.c | 121 +++++++++++++++++++++++++++++++++--------------------
1 files changed, 75 insertions(+), 46 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 5d1267a..352a588 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1836,7 +1836,7 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
return 1;
}
-static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
+static int _lvconvert_split_and_keep_cachevol(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *lv_fast)
{
@@ -1847,51 +1847,66 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
if (!archive(lv->vg))
return_0;
- if (lv_is_cache_vol(cache_seg->pool_lv)) {
- log_debug("Detaching cachevol %s from LV %s.", display_lvname(lv_fast), display_lvname(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.");
+ /*
+ * 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;
+ }
- 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;
- }
+ log_warn("WARNING: Data may be lost by detaching writeback cache without flushing.");
- noflush = 1;
+ 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 (!lv_detach_cache_vol(lv, noflush))
+ return_0;
- 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 (!vg_write(lv->vg) || !vg_commit(lv->vg))
+ return_0;
- if (!lv_cache_remove(lv))
- return_0;
+ backup(lv->vg);
+
+ log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
+ display_lvname(lv), display_lvname(lv_fast));
+
+ return 1;
+}
+
+static int _lvconvert_split_and_keep_cachepool(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct logical_volume *lv_fast)
+{
+ if (!archive(lv->vg))
+ return_0;
+
+ 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;
+
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
@@ -1903,7 +1918,16 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd,
return 1;
}
-static int _lvconvert_split_and_remove_cache(struct cmd_context *cmd,
+static int _lvconvert_split_and_remove_cachevol(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ struct logical_volume *lv_fast)
+{
+ log_error("Detach cache from %s with --splitcache.", display_lvname(lv));
+ log_error("The cache %s may then be removed with lvremove.", display_lvname(lv_fast));
+ return 0;
+}
+
+static int _lvconvert_split_and_remove_cachepool(struct cmd_context *cmd,
struct logical_volume *lv,
struct logical_volume *cachepool_lv)
{
@@ -4701,19 +4725,24 @@ static int _lvconvert_split_cache_single(struct cmd_context *cmd,
ret = _lvconvert_detach_writecache(cmd, lv_main, lv_fast);
- } else if (lv_is_cache(lv_main)) {
- if ((cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD) &&
- lv_is_cache_vol(lv_fast)) {
- log_error("Detach cache from %s with --splitcache.", display_lvname(lv));
- log_error("The cache %s may then be removed with lvremove.", display_lvname(lv_fast));
- return 0;
+ } else if (lv_is_cache(lv_main) && lv_is_cache_vol(lv_fast)) {
+ if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD)
+ ret = _lvconvert_split_and_remove_cachevol(cmd, lv_main, lv_fast);
+
+ else if (cmd->command->command_enum == lvconvert_split_and_keep_cache_CMD)
+ ret = _lvconvert_split_and_keep_cachevol(cmd, lv_main, lv_fast);
+
+ else {
+ log_error(INTERNAL_ERROR "Unknown cache split command.");
+ ret = 0;
}
+ } else if (lv_is_cache(lv_main) && lv_is_cache_pool(lv_fast)) {
if (cmd->command->command_enum == lvconvert_split_and_remove_cache_CMD)
- ret = _lvconvert_split_and_remove_cache(cmd, lv_main, lv_fast);
+ ret = _lvconvert_split_and_remove_cachepool(cmd, lv_main, lv_fast);
else if (cmd->command->command_enum == lvconvert_split_and_keep_cache_CMD)
- ret = _lvconvert_split_and_keep_cache(cmd, lv_main, lv_fast);
+ ret = _lvconvert_split_and_keep_cachepool(cmd, lv_main, lv_fast);
else {
log_error(INTERNAL_ERROR "Unknown cache split command.");
4 years, 7 months
stable-2.02 - tests: allow-mixed-block-sizes skip with older losetup
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2327f3997bfb70d6729...
Commit: 2327f3997bfb70d67299f3dfa45436132e0a8521
Parent: 9fcda0d9752bf06b619d29aa6738b4ac52acedfc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Sep 11 13:52:51 2019 -0500
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Tue Sep 24 14:08:23 2019 +0200
tests: allow-mixed-block-sizes skip with older losetup
(cherry picked from commit 69b7c00a77e09d23d57eef9d35afb1dc4663478c)
---
test/shell/allow-mixed-block-sizes.sh | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/test/shell/allow-mixed-block-sizes.sh b/test/shell/allow-mixed-block-sizes.sh
index 1803256..2f0b3a0 100644
--- a/test/shell/allow-mixed-block-sizes.sh
+++ b/test/shell/allow-mixed-block-sizes.sh
@@ -14,6 +14,8 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
+losetup -h | grep sector-size || skip
+
dd if=/dev/zero of=loopa bs=$((1024*1024)) count=2 2> /dev/null
dd if=/dev/zero of=loopb bs=$((1024*1024)) count=2 2> /dev/null
LOOP1=$(losetup -f loopa --sector-size 4096 --show)
4 years, 7 months
stable-2.02 - WHATS_NEW: vgcreate/vgextend logical block size
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9fcda0d9752bf06b619...
Commit: 9fcda0d9752bf06b619d29aa6738b4ac52acedfc
Parent: f758d16b30afd1848ea874b5ebd20185c5300320
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Aug 1 10:15:27 2019 -0500
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Tue Sep 24 10:51:50 2019 +0200
WHATS_NEW: vgcreate/vgextend logical block size
(cherry picked from commit 3a0d493d918510d863ddbdbc63d8a8ccb6ca2dd9)
Conflicts:
WHATS_NEW
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0a5bda3..3811c5c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.187 -
===================================
+ Prevent creating VGs with PVs with different logical block sizes.
Pvmove runs in exlusively activating mode for exclusively active LVs.
Activate thin-pool layered volume as 'read-only' device.
Ignore crypto devices with UUID signature CRYPT-SUBDEV.
4 years, 7 months
stable-2.02 - tests: allow-mixed-block-sizes
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f758d16b30afd1848ea...
Commit: f758d16b30afd1848ea874b5ebd20185c5300320
Parent: 444dedea2355b42000f60b4ca0eb4a2f027123aa
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Aug 1 10:13:41 2019 -0500
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Tue Sep 24 10:48:39 2019 +0200
tests: allow-mixed-block-sizes
(cherry picked from commit cd8a0133fa28a0dff2714c80f822e8c665fe6237)
---
test/shell/allow-mixed-block-sizes.sh | 44 +++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/test/shell/allow-mixed-block-sizes.sh b/test/shell/allow-mixed-block-sizes.sh
new file mode 100644
index 0000000..1803256
--- /dev/null
+++ b/test/shell/allow-mixed-block-sizes.sh
@@ -0,0 +1,44 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2019 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
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+dd if=/dev/zero of=loopa bs=$((1024*1024)) count=2 2> /dev/null
+dd if=/dev/zero of=loopb bs=$((1024*1024)) count=2 2> /dev/null
+LOOP1=$(losetup -f loopa --sector-size 4096 --show)
+LOOP2=$(losetup -f loopb --show)
+
+echo $LOOP1
+echo $LOOP2
+
+aux extend_filter "a|$LOOP1|"
+aux extend_filter "a|$LOOP2|"
+
+not vgcreate --config 'devices {allow_mixed_block_sizes=0 scan="/dev"}' $vg $LOOP1 $LOOP2
+vgcreate --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg $LOOP1 $LOOP2
+vgs --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg
+
+wipefs -a $LOOP1
+wipefs -a $LOOP2
+
+vgcreate --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg $LOOP1
+vgs --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg
+not vgextend --config 'devices {allow_mixed_block_sizes=0 scan="/dev"}' $vg $LOOP2
+vgextend --config 'devices {allow_mixed_block_sizes=1 scan="/dev"}' $vg $LOOP2
+
+losetup -d $LOOP1
+losetup -d $LOOP2
+rm loopa
+rm loopb
+
4 years, 7 months