[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] (2/5) tools & partial volume group handling



Hi,

the following two patches establish basic tool support for partial volume
groups, as defined by the previous patch for the library. The first one adds
handles_partial flag to toolcontext and enables the library to write out
partial volume group metadata, when this flag is set (it is off by default).

It also makes lvremove work on partial volume groups by default and adds
--partial flag to vgcfgrestore to allow it restoring partial volume groups.

The latter patch fixes vgreduce --removemissing to work with new partial VG
semantics.

Tue Jul  8 13:43:44 CEST 2008  me mornfall net
  * Make vgcfgrestore only handle partial VGs when --partial is supplied.
Thu Mar 13 17:14:44 CET 2008  me mornfall net
  * Let vgcfgrestore overwrite partial metadata.
  
  However, this probably deserves --partial, to ensure that this is what the user
  meant? On the other hand, vgcfgrestore is potentially destructive command
  already and this doesn't seem to make it worse. It is definitely useful to edit
  metadata by hand.....
Thu Mar 13 17:12:17 CET 2008  me mornfall net
  * Don't forget to reset cmd->handles_partial when done.
Fri Feb 15 09:50:19 CET 2008  me mornfall net
  * Make lvremove work on partial VGs.
Thu Feb 14 16:20:07 CET 2008  me mornfall net
  * Add possibility for commands to specify they handle partial VGs.
diff -rN -u -p old-hotspare-two/lib/commands/toolcontext.c new-hotspare-two/lib/commands/toolcontext.c
--- old-hotspare-two/lib/commands/toolcontext.c	2008-07-08 14:28:51.834696125 +0200
+++ new-hotspare-two/lib/commands/toolcontext.c	2008-07-08 14:28:51.886695221 +0200
@@ -936,6 +936,7 @@ struct cmd_context *create_toolcontext(s
 	cmd->args = the_args;
 	cmd->is_static = is_static;
 	cmd->is_long_lived = is_long_lived;
+	cmd->handles_partial = 0;
 	cmd->hosttags = 0;
 	list_init(&cmd->formats);
 	list_init(&cmd->segtypes);
diff -rN -u -p old-hotspare-two/lib/commands/toolcontext.h new-hotspare-two/lib/commands/toolcontext.h
--- old-hotspare-two/lib/commands/toolcontext.h	2008-07-08 14:28:51.834696125 +0200
+++ new-hotspare-two/lib/commands/toolcontext.h	2008-07-08 14:28:51.886695221 +0200
@@ -68,6 +68,7 @@ struct cmd_context {
 	char **argv;
 	unsigned is_static;	/* Static binary? */
 	unsigned is_long_lived;	/* Optimises persistent_filter handling */
+	unsigned handles_partial;
 
 	struct dev_filter *filter;
 	int dump_filter;	/* Dump filter when exiting? */
diff -rN -u -p old-hotspare-two/lib/metadata/metadata.c new-hotspare-two/lib/metadata/metadata.c
--- old-hotspare-two/lib/metadata/metadata.c	2008-07-08 14:28:51.830692245 +0200
+++ new-hotspare-two/lib/metadata/metadata.c	2008-07-08 14:28:51.902696770 +0200
@@ -1416,7 +1416,7 @@ int vg_write(struct volume_group *vg)
 	if (!vg_validate(vg))
 		return_0;
 
-	if (vg->status & PARTIAL_VG) {
+	if ((vg->status & PARTIAL_VG) && (!vg->cmd->handles_partial)) {
 		log_error("Cannot update volume group %s while physical "
 			  "volumes are missing.", vg->name);
 		return 0;
diff -rN -u -p old-hotspare-two/tools/commands.h new-hotspare-two/tools/commands.h
--- old-hotspare-two/tools/commands.h	2008-07-08 14:28:51.830692245 +0200
+++ new-hotspare-two/tools/commands.h	2008-07-08 14:28:51.874696784 +0200
@@ -645,13 +645,14 @@ xx(vgcfgrestore,
    "\t[-l[l]|--list [--list]]" "\n"
    "\t[-M|--metadatatype 1|2]" "\n"
    "\t[-n|--name VolumeGroupName] " "\n"
+   "\t[-P|--partial] " "\n"
    "\t[-h|--help]" "\n"
    "\t[-t|--test] " "\n"
    "\t[-v|--verbose]" "\n"
    "\t[--version] " "\n"
    "\tVolumeGroupName",
 
-   file_ARG, list_ARG, metadatatype_ARG, name_ARG, test_ARG)
+   file_ARG, list_ARG, metadatatype_ARG, name_ARG, partial_ARG, test_ARG)
 
 xx(vgchange,
    "Change volume group attributes",
diff -rN -u -p old-hotspare-two/tools/lvmcmdline.c new-hotspare-two/tools/lvmcmdline.c
--- old-hotspare-two/tools/lvmcmdline.c	2008-07-08 14:28:51.830692245 +0200
+++ new-hotspare-two/tools/lvmcmdline.c	2008-07-08 14:28:51.870696746 +0200
@@ -826,6 +826,7 @@ static void _apply_settings(struct cmd_c
 
 	cmd->fmt = arg_ptr_value(cmd, metadatatype_ARG,
 				 cmd->current_settings.fmt);
+	cmd->handles_partial = 0;
 }
 
 static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
diff -rN -u -p old-hotspare-two/tools/lvremove.c new-hotspare-two/tools/lvremove.c
--- old-hotspare-two/tools/lvremove.c	2008-07-08 14:28:51.830692245 +0200
+++ new-hotspare-two/tools/lvremove.c	2008-07-08 14:28:51.874696784 +0200
@@ -31,6 +31,8 @@ int lvremove(struct cmd_context *cmd, in
 		return EINVALID_CMD_LINE;
 	}
 
+	cmd->handles_partial = 1;
+
 	return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
 			       &lvremove_single);
 }
diff -rN -u -p old-hotspare-two/tools/vgcfgrestore.c new-hotspare-two/tools/vgcfgrestore.c
--- old-hotspare-two/tools/vgcfgrestore.c	2008-07-08 14:28:51.830692245 +0200
+++ new-hotspare-two/tools/vgcfgrestore.c	2008-07-08 14:28:51.870696746 +0200
@@ -19,6 +19,10 @@ int vgcfgrestore(struct cmd_context *cmd
 {
 	char *vg_name = NULL;
 
+	if (arg_count(cmd, partial_ARG)) {
+		cmd->handles_partial = 1;
+	}
+
 	if (argc == 1) {
 		vg_name = skip_dev_dir(cmd, argv[0], NULL);
 		if (!validate_name(vg_name)) {

Sun Apr 20 10:17:05 CEST 2008  me mornfall net
  * Check for MISSING_PV in vgreduce --removemissing.
Fri Feb 15 09:49:42 CET 2008  me mornfall net
  * Fix vgreduce --removemissing for consistent partial VGs.
diff -rN -u -p old-hotspare-prime/tools/vgreduce.c new-hotspare-prime/tools/vgreduce.c
--- old-hotspare-prime/tools/vgreduce.c	2008-07-08 14:23:26.994694248 +0200
+++ new-hotspare-prime/tools/vgreduce.c	2008-07-08 14:23:27.034696163 +0200
@@ -186,7 +186,7 @@ static int _make_vg_consistent(struct cm
 	/* Remove missing PVs */
 	list_iterate_safe(pvh, pvht, &vg->pvs) {
 		pvl = list_item(pvh, struct pv_list);
-		if (pvl->pv->dev)
+		if (pvl->pv->dev && !(pvl->pv->status & MISSING_PV))
 			continue;
 		if (!_remove_pv(vg, pvl))
 			return_0;
@@ -505,7 +505,7 @@ int vgreduce(struct cmd_context *cmd, in
 	}
 
 	if (arg_count(cmd, removemissing_ARG)) {
-		if (vg && consistent) {
+		if (vg && consistent && !(vg->status & PARTIAL_VG)) {
 			log_error("Volume group \"%s\" is already consistent",
 				  vg_name);
 			unlock_vg(cmd, vg_name);

-- 
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]