Skip to contentSkip to conversation

main - vdo: support lvcreate with skipped activation

PATCH Zdenek Kabelac 1 participant 1 message Aug 31, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=419c93c87358ad311aa78dcd6fd8298325356df4
Commit:        419c93c87358ad311aa78dcd6fd8298325356df4
Parent:        4afe872fd6c43fcfcd519c862574d010cdbda653
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Aug 31 21:34:06 2021 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Aug 31 22:05:47 2021 +0200

vdo: support lvcreate with skipped activation

Support creation of VDO LV for 'lvcreate -ky...'.

---
 lib/metadata/lv_manip.c    | 14 ++++++++++++++
 test/shell/lvcreate-vdo.sh |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
lib/metadata/lv_manip.c +14 -0
index 730e3f0df..4bfedbe6e 100644
@@ -8721,6 +8721,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
 			goto revert_new_lv;
 		}
 		lv->status &= ~LV_TEMPORARY;
+	} else if (seg_is_vdo_pool(lp)) {
+		lv->status |= LV_TEMPORARY;
+		if (!activate_lv(cmd, lv)) {
+			log_error("Aborting. Failed to activate temporary "
+				  "volume for VDO pool creation.");
+			goto revert_new_lv;
+		}
+		lv->status &= ~LV_TEMPORARY;
 	} else if (!lv_active_change(cmd, lv, lp->activate)) {
 		log_error("Failed to activate new LV %s.", display_lvname(lv));
 		goto deactivate_and_revert_new_lv;
@@ -8747,6 +8755,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
 			stack;
 			goto deactivate_and_revert_new_lv;
 		}
+		if ((lv->status & LV_ACTIVATION_SKIP) &&
+		    !deactivate_lv(cmd, lv)) {
+			log_error("Aborting. Couldn't deactivate VDO LV %s with skipped activation.",
+				  display_lvname(lv));
+			return NULL; /* Let's retry on error path */
+		}
 	} else if (seg_is_cache(lp) || (origin_lv && lv_is_cache_pool(lv))) {
 		/* Finish cache conversion magic */
 		if (origin_lv) {
test/shell/lvcreate-vdo.sh +1 -1
index d66e35390..9fb2959db 100644
@@ -79,7 +79,7 @@ not fsck -n "$DM_DEV_DIR/mapper/$vg-${lv2}"
 lvremove -ff $vg
 
 
-lvcreate --type vdo -L10G -V1T -n $lv1 $vg
+lvcreate --type vdo -L10G -V1T -ky -n $lv1 $vg
 lvs -a $vg
 lvremove -ff $vg