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

[lvm-devel] [PATCH] partial activation revisited



Hi,

I have added backward compatibility for missing_stripe_filler. We will almost
surely want to flip the value to "error" in default configuration file, as the
tools will cry bloody murder if it is set to an invalid device (which
/dev/ioerror is, in most setups). I'll likely make it only print the warning if
partial activation is actually used, but I need to rework some more code first
(since right now, partial activation is determined by partial_mode(), which I
want to get rid of... since it is not compatible with how we now treat volume
groups with missing PVs nowadays).

The patch now actually passes tests, and merged with my experimental lvconvert
code yields working combination (now, that those bugs have been
addressed). I'll give lvconvert a little more time and post revised version as
well.

User documentation is TBD (that includes the default configuration change).

Tue Jul 15 17:12:15 CEST 2008  me mornfall net
  * Remove the redundant dm->stripe_filler field.
Mon Jul 14 16:41:38 CEST 2008  me mornfall net
  tagged hotspare: base 2
Tue Jul 15 16:46:22 CEST 2008  me mornfall net
  * Explain the **tree hack.
Tue Jul 15 16:46:11 CEST 2008  me mornfall net
  * Use return_NULL instead of return_0 where appropriate.
Tue Jul 15 16:45:46 CEST 2008  me mornfall net
  * Don't forget to actually compute the error area size.
Mon Jul 14 16:36:24 CEST 2008  me mornfall net
  * Missed return and error handling.
Mon Jul 14 16:36:05 CEST 2008  me mornfall net
  * Missed static keywords.
Mon Jul 14 15:43:56 CEST 2008  me mornfall net
  * Backward-compatibility with missing_stripe_filler. Warn user if it does not exist.
Fri Jul 11 14:44:56 CEST 2008  me mornfall net
  tagged hotspare: partial activation 1
Sun Jun  8 13:12:30 CEST 2008  me mornfall net
  * It's better when it compiles.
Sun Jun  8 13:11:14 CEST 2008  me mornfall net
  * Use human-readable names in error tables + coding style.
Sun Jun  8 13:09:56 CEST 2008  me mornfall net
  * First working iteration of /dev/ioerror-less activation.
Sun May 11 14:11:49 CEST 2008  me mornfall net
  * Sketch out how partial activation should work without /dev/ioerror.
diff -rN -p -u old-lib-partial_activation/lib/activate/dev_manager.c new-lib-partial_activation/lib/activate/dev_manager.c
--- old-lib-partial_activation/lib/activate/dev_manager.c	2008-07-15 17:15:36.145762841 +0200
+++ new-lib-partial_activation/lib/activate/dev_manager.c	2008-07-15 17:15:36.261762615 +0200
@@ -47,7 +47,6 @@ struct dev_manager {
 
 	struct cmd_context *cmd;
 
-	const char *stripe_filler;
 	void *target_state;
 	uint32_t pvmove_mirror_count;
 
@@ -59,8 +58,6 @@ struct lv_layer {
 	const char *old_name;
 };
 
-static const char *stripe_filler = NULL;
-
 static char *_build_dlid(struct dm_pool *mem, const char *lvid, const char *layer)
 {
 	char *dlid;
@@ -444,13 +441,6 @@ struct dev_manager *dev_manager_create(s
 	dm->cmd = cmd;
 	dm->mem = mem;
 
-	if (!stripe_filler) {
-		stripe_filler = find_config_tree_str(cmd,
-						"activation/missing_stripe_filler",
-						DEFAULT_STRIPE_FILLER);
-	}
-	dm->stripe_filler = stripe_filler;
-
 	if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name)))
 		goto_bad;
 
@@ -700,6 +690,55 @@ bad:
 	return NULL;
 }
 
+static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
+			       struct lv_segment *seg, int s)
+{
+	char *id, *name;
+	char errid[32];
+	struct dm_tree_node *node;
+	uint64_t size = seg->len * seg->lv->vg->extent_size;
+
+	sprintf(errid, "missing_%d", s);
+
+	if (!(id = build_dlid(dm, seg->lv->lvid.s, errid))) 
+		return_NULL;
+
+	if (!(name = build_dm_name(dm->mem, seg->lv->vg->name,
+				   seg->lv->name, errid)))
+		return_NULL;
+	if (!(node = dm_tree_add_new_dev(dtree, name, id, 0, 0, 0, 0, 0)))
+		return_NULL;
+	if (!dm_tree_node_add_error_target(node, size))
+		return_NULL;
+
+	return id;
+}
+
+static int _add_error_area(struct dev_manager *dm, struct dm_tree_node *node,
+			   struct lv_segment *seg, int s)
+{
+	char *dlid;
+	uint64_t extent_size = seg->lv->vg->extent_size;
+
+	if (!strcmp(dm->cmd->stripe_filler, "error")) {
+		/*
+		 * FIXME, the tree pointer is first field of dm_tree_node, but
+		 * we don't have the struct definition available.
+		 */
+		struct dm_tree **tree = (struct dm_tree **) node;
+		dlid = _add_error_device(dm, *tree, seg, s);
+		if (!dlid)
+			return_0;
+		dm_tree_node_add_target_area(node, NULL, dlid,
+					     extent_size * seg_le(seg, s));
+	} else {
+		dm_tree_node_add_target_area(node,
+					     dm->cmd->stripe_filler,
+					     NULL, UINT64_C(0));
+	}
+	return 1;
+}
+
 int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
 		   struct dm_tree_node *node, uint32_t start_area,
 		   uint32_t areas)
@@ -713,11 +752,10 @@ int add_areas_line(struct dev_manager *d
 		     (!seg_pvseg(seg, s) ||
 		      !seg_pv(seg, s) ||
 		      !seg_dev(seg, s))) ||
-		    (seg_type(seg, s) == AREA_LV && !seg_lv(seg, s)))
-			dm_tree_node_add_target_area(node,
-							dm->stripe_filler,
-							NULL, UINT64_C(0));
-		else if (seg_type(seg, s) == AREA_PV)
+		    (seg_type(seg, s) == AREA_LV && !seg_lv(seg, s))) {
+			if (!_add_error_area(dm, node, seg, s))
+				return_0;
+		} else if (seg_type(seg, s) == AREA_PV)
 			dm_tree_node_add_target_area(node,
 							dev_name(seg_dev(seg, s)),
 							NULL,
diff -rN -p -u old-lib-partial_activation/lib/commands/toolcontext.c new-lib-partial_activation/lib/commands/toolcontext.c
--- old-lib-partial_activation/lib/commands/toolcontext.c	2008-07-15 17:15:36.145762841 +0200
+++ new-lib-partial_activation/lib/commands/toolcontext.c	2008-07-15 17:15:36.253762679 +0200
@@ -154,6 +154,7 @@ static int _process_config(struct cmd_co
 {
 	mode_t old_umask;
 	const char *read_ahead;
+	struct stat st;
 
 	/* umask */
 	cmd->default_settings.umask = find_config_tree_int(cmd,
@@ -218,6 +219,24 @@ static int _process_config(struct cmd_co
 		return 0;
 	}
 
+	cmd->stripe_filler = find_config_tree_str(cmd,
+						  "activation/missing_stripe_filler",
+						  DEFAULT_STRIPE_FILLER);
+	if (strcmp(cmd->stripe_filler, "error")) {
+		if (stat(cmd->stripe_filler, &st)) {
+			log_warn("WARNING: activation/missing_stripe_filler = \"%s\" "
+				 "is invalid,", cmd->stripe_filler);
+			log_warn("         stat failed: %s", strerror(errno));
+			log_warn("Falling back to \"error\" missing_stripe_filler.");
+			cmd->stripe_filler = "error";
+		} else if (!S_ISBLK(st.st_mode)) {
+			log_warn("WARNING: activation/missing_stripe_filler = \"%s\" "
+				 "is not a block device.", cmd->stripe_filler);
+			log_warn("Falling back to \"error\" missing_stripe_filler.");
+			cmd->stripe_filler = "error";
+		}
+	}
+
 	return 1;
 }
 
diff -rN -p -u old-lib-partial_activation/lib/commands/toolcontext.h new-lib-partial_activation/lib/commands/toolcontext.h
--- old-lib-partial_activation/lib/commands/toolcontext.h	2008-07-15 17:15:36.145762841 +0200
+++ new-lib-partial_activation/lib/commands/toolcontext.h	2008-07-15 17:15:36.253762679 +0200
@@ -81,6 +81,7 @@ struct cmd_context {
 
 	struct archive_params *archive_params;
 	struct backup_params *backup_params;
+	const char *stripe_filler;
 
 	/* List of defined tags */
 	struct list tags;
diff -rN -p -u old-lib-partial_activation/lib/config/defaults.h new-lib-partial_activation/lib/config/defaults.h
--- old-lib-partial_activation/lib/config/defaults.h	2008-07-15 17:15:36.145762841 +0200
+++ new-lib-partial_activation/lib/config/defaults.h	2008-07-15 17:15:36.269764856 +0200
@@ -91,7 +91,7 @@
 #  define DEFAULT_ACTIVATION 0
 #endif
 
-#define DEFAULT_STRIPE_FILLER "/dev/ioerror"
+#define DEFAULT_STRIPE_FILLER "error"
 #define DEFAULT_MIRROR_REGION_SIZE 512	/* KB */
 #define DEFAULT_INTERVAL 15
 

-- 
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]