mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_13-vgsplit-add-support-for-option-poolmetadataspare.patch

16deb6
 WHATS_NEW                 |  1 +
16deb6
 lib/metadata/pool_manip.c | 11 +++++++++++
16deb6
 man/vgsplit.8_pregen      |  9 +++++++++
16deb6
 tools/command-lines.in    |  2 +-
16deb6
 tools/vgsplit.c           |  8 ++++++++
16deb6
 5 files changed, 30 insertions(+), 1 deletion(-)
16deb6
16deb6
diff --git a/WHATS_NEW b/WHATS_NEW
16deb6
index 097160e..0b8e3f2 100644
16deb6
--- a/WHATS_NEW
16deb6
+++ b/WHATS_NEW
16deb6
@@ -1,5 +1,6 @@
16deb6
 Version 2.03.13 - 
16deb6
 ===============================
16deb6
+  Support --poolmetadataspare with vgsplit.
16deb6
   Fix detection of active components of external origin volume.
16deb6
   Add vdoimport tool to support conversion of VDO volumes.
16deb6
   Support configurable allocation/vdo_pool_header_size.
16deb6
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
16deb6
index 9ceec3a..e451e92 100644
16deb6
--- a/lib/metadata/pool_manip.c
16deb6
+++ b/lib/metadata/pool_manip.c
16deb6
@@ -722,6 +722,17 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
16deb6
 		return 1;
16deb6
 	}
16deb6
 
16deb6
+	if (!extents) {
16deb6
+		/* pmspare is not needed */
16deb6
+		if (lv) {
16deb6
+			log_debug_metadata("Dropping unused pool metadata spare LV %s.",
16deb6
+					   display_lvname(lv));
16deb6
+			if (!lv_remove_single(vg->cmd, lv, DONT_PROMPT, 0))
16deb6
+				return_0;
16deb6
+		}
16deb6
+		return 1;
16deb6
+	}
16deb6
+
16deb6
 	if (extents > MAX_SIZE)
16deb6
 		extents = MAX_SIZE;
16deb6
 
16deb6
diff --git a/man/vgsplit.8_pregen b/man/vgsplit.8_pregen
16deb6
index 331c6e4..8a0ae59 100644
16deb6
--- a/man/vgsplit.8_pregen
16deb6
+++ b/man/vgsplit.8_pregen
16deb6
@@ -70,6 +70,8 @@ Common options for command:
16deb6
 .hy
16deb6
 ]
16deb6
 .br
16deb6
+[    \fB--poolmetadataspare\fP \fBy\fP|\fBn\fP ]
16deb6
+.br
16deb6
 [    \fB--\fP[\fBvg\fP]\fBmetadatacopies\fP \fBall\fP|\fBunmanaged\fP|\fINumber\fP ]
16deb6
 .ad b
16deb6
 .RE
16deb6
@@ -235,6 +237,13 @@ Move only PVs used by the named LV.
16deb6
 Disable locking.
16deb6
 .
16deb6
 .HP
16deb6
+\fB--poolmetadataspare\fP \fBy\fP|\fBn\fP
16deb6
+.br
16deb6
+Enable or disable the automatic creation and management of a
16deb6
+spare pool metadata LV in the VG. A spare metadata LV is reserved
16deb6
+space that can be used when repairing a pool.
16deb6
+.
16deb6
+.HP
16deb6
 \fB--profile\fP \fIString\fP
16deb6
 .br
16deb6
 An alias for --commandprofile or --metadataprofile, depending
16deb6
diff --git a/tools/command-lines.in b/tools/command-lines.in
16deb6
index 8607305..a4785b3 100644
16deb6
--- a/tools/command-lines.in
16deb6
+++ b/tools/command-lines.in
16deb6
@@ -1912,7 +1912,7 @@ ID: vgscan_general
16deb6
 
16deb6
 ---
16deb6
 
16deb6
-OO_VGSPLIT: --autobackup Bool
16deb6
+OO_VGSPLIT: --autobackup Bool, --poolmetadataspare Bool
16deb6
 
16deb6
 # used only when the destination VG is new
16deb6
 OO_VGSPLIT_NEW: --alloc Alloc,
16deb6
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
16deb6
index 296248e..a085ac2 100644
16deb6
--- a/tools/vgsplit.c
16deb6
+++ b/tools/vgsplit.c
16deb6
@@ -525,6 +525,7 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
16deb6
 	int existing_vg = 0;
16deb6
 	int r = ECMD_FAILED;
16deb6
 	const char *lv_name;
16deb6
+	int poolmetadataspare = arg_int_value(cmd, poolmetadataspare_ARG, DEFAULT_POOL_METADATA_SPARE);
16deb6
 
16deb6
 	if ((arg_is_set(cmd, name_ARG) + argc) < 3) {
16deb6
 		log_error("Existing VG, new VG and either physical volumes "
16deb6
@@ -699,6 +700,13 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
16deb6
 	 */
16deb6
 	vg_to->status |= EXPORTED_VG;
16deb6
 
16deb6
+
16deb6
+	if (!handle_pool_metadata_spare(vg_to, 0, &vg_to->pvs, poolmetadataspare))
16deb6
+		goto_bad;
16deb6
+
16deb6
+	if (!handle_pool_metadata_spare(vg_from, 0, &vg_from->pvs, poolmetadataspare))
16deb6
+		goto_bad;
16deb6
+
16deb6
 	if (!archive(vg_to))
16deb6
 		goto_bad;
16deb6