Skip to contentSkip to conversation

master - lvconvert: detaching cachevol with missing PVs

PATCH David Teigland 1 participant 1 message Sep 20, 2019

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5d3bced5eab1244939958422446e0dfb5b6b79d4
Commit:        5d3bced5eab1244939958422446e0dfb5b6b79d4
Parent:        b46dce0badb221b1417231e7bbf2d7d898a5a8c1
Author:        David Teigland <[email protected]>
AuthorDate:    Tue Sep 17 16:32:34 2019 -0500
Committer:     David Teigland <[email protected]>
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(-)
lib/metadata/cache_manip.c +4 -4
index 7ea2c0e..65589f7 100644
@@ -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);
 }
 
 /*
lib/metadata/lv_manip.c +1 -1
index 6451368..107074a 100644
@@ -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;
 		}
lib/metadata/metadata-exported.h +1 -1
index a910aa3..1c10390 100644
@@ -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 */
 
tools/lvconvert.c +68 -16

147 lines not on this page · raw message