Blame SOURCES/bz626417_21-add_option_that_postpones_any_metadata_updates.patch

41b6f0
diff --git a/include/dmraid/lib_context.h b/include/dmraid/lib_context.h
41b6f0
index c2e16e6..c2b3c4d 100644
41b6f0
--- a/include/dmraid/lib_context.h
41b6f0
+++ b/include/dmraid/lib_context.h
41b6f0
@@ -46,7 +46,8 @@ enum lc_options {
41b6f0
 	LC_CREATE,
41b6f0
 	LC_REBUILD_SET,
41b6f0
 	LC_REBUILD_DISK,
41b6f0
-	LC_HOT_SPARE_SET,	/* Add new options below this one ! */
41b6f0
+	LC_HOT_SPARE_SET,	
41b6f0
+	LC_DEFER_UPDATE,	/* Add new options below this one ! */
41b6f0
 	LC_OPTIONS_SIZE,	/* Must be the last enumerator. */
41b6f0
 };
41b6f0
 
41b6f0
@@ -67,6 +68,7 @@ enum lc_options {
41b6f0
 #define	OPT_CREATE(lc)		(lc_opt(lc, LC_CREATE))
41b6f0
 #define OPT_HOT_SPARE_SET(lc)	(lc_opt(lc, LC_HOT_SPARE_SET))
41b6f0
 #define OPT_REBUILD_DISK(lc)	(lc_opt(lc, LC_REBUILD_DISK))
41b6f0
+#define OPT_DEFER_UPDATE(lc)	(lc_opt(lc, LC_DEFER_UPDATE))
41b6f0
 
41b6f0
 /* Return option value. */
41b6f0
 #define	OPT_STR(lc, o)		(lc->options[o].arg.str)
41b6f0
@@ -76,6 +78,7 @@ enum lc_options {
41b6f0
 #define	OPT_STR_PARTCHAR(lc)	OPT_STR(lc, LC_PARTCHAR)
41b6f0
 #define OPT_STR_HOT_SPARE_SET(lc)	OPT_STR(lc, LC_HOT_SPARE_SET)
41b6f0
 #define OPT_STR_REBUILD_DISK(lc)	OPT_STR(lc, LC_REBUILD_DISK)
41b6f0
+#define OPT_STR_DEFER_UPDATE(lc)	OPT_STR(lc, LC_DEFER_UPDATE)
41b6f0
 
41b6f0
 struct lib_version {
41b6f0
 	const char *text;
41b6f0
diff --git a/lib/metadata/reconfig.c b/lib/metadata/reconfig.c
41b6f0
index 73f7604..19768a9 100644
41b6f0
--- a/lib/metadata/reconfig.c
41b6f0
+++ b/lib/metadata/reconfig.c
41b6f0
@@ -249,9 +249,9 @@ add_dev_to_raid(struct lib_context *lc, struct raid_set *rs,
41b6f0
 			strncat(lib_name, ".so", 3);
41b6f0
 		} else
41b6f0
 			goto err;
41b6f0
-
41b6f0
+		
41b6f0
 		/* Check registration */
41b6f0
-		if (!dm_monitored_events(&pending, sub_rs->name, lib_name)) {
41b6f0
+		if (!dm_monitored_events(&pending, sub_rs->name, lib_name) && !OPT_DEFER_UPDATE(lc)) {
41b6f0
 			/* If NOT registered update metadata to OK state. */
41b6f0
 			if (check_rd->fmt->metadata_handler)
41b6f0
 				check_rd->fmt->metadata_handler(lc, UPDATE_REBUILD_STATE, NULL, (void *) rs);
41b6f0
diff --git a/man/dmraid.8 b/man/dmraid.8
41b6f0
index b4de737..62a6091 100644
41b6f0
--- a/man/dmraid.8
41b6f0
+++ b/man/dmraid.8
41b6f0
@@ -11,6 +11,7 @@ dmraid \- discover, configure and activate software (ATA)RAID
41b6f0
  [-Z|--rm_partitions]
41b6f0
  [--separator SEPARATOR]
41b6f0
  [-t|--test]
41b6f0
+ [-u|--update_defer]
41b6f0
  [RAID-set...]
41b6f0
 
41b6f0
 .B dmraid
41b6f0
@@ -38,6 +39,7 @@ dmraid \- discover, configure and activate software (ATA)RAID
41b6f0
  {-R| --rebuild}
41b6f0
  RAID-set
41b6f0
  [device-path]
41b6f0
+ [-u|--update_defer]
41b6f0
 
41b6f0
 .B dmraid
41b6f0
  {-x| --remove}
41b6f0
@@ -118,7 +120,14 @@ underlying the set, ie if sda is part of the set, remove sda1, sda2, etc.
41b6f0
 This prevents applications from directly accessiong the disks bypassing dmraid.
41b6f0
 RAID set names given on command line don't need to be fully specified
41b6f0
 (eg, "dmraid -ay sil" would activate all discovered Silicon Image Medley
41b6f0
-RAID sets).
41b6f0
+RAID sets). Option 
41b6f0
+.B -u
41b6f0
+defers metadata update in case of rebuild is triggered parallelly with activation.
41b6f0
+Awoids metadata update to "OK" state if volume is not registered to the event
41b6f0
+monitoring. 
41b6f0
+Useful if volume is activating at early stage of booting process when registration
41b6f0
+to the event monitoring is impossible.
41b6f0
+
41b6f0
 
41b6f0
 .TP
41b6f0
 .I {-b|--block_devices} [device-path...]
41b6f0
@@ -208,7 +217,11 @@ Use CHAR as the separator between the device name and the partition number.
41b6f0
 .I {-R| --rebuild} RAID-set [device-path]
41b6f0
 Rebuild raid array after a drive has failed and a new drive is added. 
41b6f0
 For Intel chipset based systems, there are two methods in which a new drive 
41b6f0
-is added to the system.
41b6f0
+is added to the system. Option
41b6f0
+.B -u
41b6f0
+defers metadata update in case of rebuild is triggered. 
41b6f0
+Awoids metadata update to "OK" state if volume is not registered to the event
41b6f0
+monitoring. 
41b6f0
 
41b6f0
 1. Using OROM to identify a new drive
41b6f0
     During system reboot, enter OROM and mark the new drive as the rebuild drive.  
41b6f0
diff --git a/tools/commands.c b/tools/commands.c
41b6f0
index 4c71ae1..a3c77d2 100644
41b6f0
--- a/tools/commands.c
41b6f0
+++ b/tools/commands.c
41b6f0
@@ -30,7 +30,7 @@ int add_dev_to_array(struct lib_context *lc, struct raid_set *rs,
41b6f0
 /*
41b6f0
  * Command line options.
41b6f0
  */
41b6f0
-static char const *short_opts = "a:hipP:"
41b6f0
+static char const *short_opts = "a:hipP:u"
41b6f0
 #ifndef	DMRAID_MINI
41b6f0
 	"bc::dDEf:glxM:"
41b6f0
 #ifdef	DMRAID_NATIVE_LOG
41b6f0
@@ -46,6 +46,7 @@ static struct option long_opts[] = {
41b6f0
 	{"format", required_argument, NULL, 'f'},
41b6f0
 	{"partchar", required_argument, NULL, 'P'},
41b6f0
 	{"no_partitions", no_argument, NULL, 'p'},
41b6f0
+	{"update_defer", no_argument, NULL, 'u'},
41b6f0
 # ifndef DMRAID_MINI
41b6f0
 	{"block_devices", no_argument, NULL, 'b'},
41b6f0
 	{"display_columns", optional_argument, NULL, 'c'},
41b6f0
@@ -197,6 +198,15 @@ check_part_separator(struct lib_context *lc, int arg)
41b6f0
 	return lc_stralloc_opt(lc, LC_PARTCHAR, optarg) ? 1 : 0;
41b6f0
 }
41b6f0
 
41b6f0
+/* Defer any mtadata updates in case of volume activation 
41b6f0
+ * at early stage of OS boot */
41b6f0
+static int
41b6f0
+defer_update(struct lib_context *lc, int arg)
41b6f0
+{
41b6f0
+    	lc_inc_opt(lc, arg);
41b6f0
+	return 1;
41b6f0
+}
41b6f0
+
41b6f0
 /* Display help information */
41b6f0
 static int
41b6f0
 help(struct lib_context *lc, int arg)
41b6f0
@@ -211,6 +221,7 @@ help(struct lib_context *lc, int arg)
41b6f0
 		  "\t[-P|--partchar CHAR]\n"
41b6f0
 		  "\t[-p|--no_partitions]\n"
41b6f0
 		  "\t[-Z|--rm_partitions]\n"
41b6f0
+		  "\t[-d|--update_defer]\n"
41b6f0
 		  "\t[--separator SEPARATOR]\n" "\t[RAID-set...]\n", c);
41b6f0
 	log_print(lc, "%s\t{-h|--help}\n", c);
41b6f0
 	log_print(lc, "%s\t{-V/--version}\n", c);
41b6f0
@@ -219,11 +230,12 @@ help(struct lib_context *lc, int arg)
41b6f0
 	log_print(lc,
41b6f0
 		  "* = [-d|--debug]... [-v|--verbose]... [-i|--ignorelocking]\n");
41b6f0
 	log_print(lc,
41b6f0
-		  "%s\t{-a|--activate} {y|n|yes|no} *\n"
41b6f0
+		  "%s\t{-a|--activate} {y|n|yes|no} \n"
41b6f0
 		  "\t[-f|--format FORMAT[,FORMAT...]]\n"
41b6f0
 		  "\t[-P|--partchar CHAR]\n" "\t[-p|--no_partitions]\n"
41b6f0
 		  "\t[--separator SEPARATOR]\n" "\t[-t|--test]\n"
41b6f0
-		  "\t[-Z|--rm_partitions] [RAID-set...]\n", c);
41b6f0
+		  "\t[-Z|--rm_partitions] [RAID-set...]\n"
41b6f0
+		  "\t[-u|--update_defer]", c);
41b6f0
 	log_print(lc,
41b6f0
 		  "%s\t{-b|--block_devices} *\n"
41b6f0
 		  "\t[-c|--display_columns][FIELD[,FIELD...]]...\n"
41b6f0
@@ -255,7 +267,8 @@ help(struct lib_context *lc, int arg)
41b6f0
 		  "\t[--str[i[de]] [0-9]...[kK][bB]]\n"
41b6f0
 		  "\t{--disk[s] \"device-path[, device-path...\"}\n", c);
41b6f0
 	log_print(lc, "%s\t{-x|--remove RAID-set} \n");
41b6f0
-	log_print(lc, "%s\t{-R|--rebuild} RAID-set [drive_name]\n", c);
41b6f0
+	log_print(lc, "%s\t{-R|--rebuild} RAID-set [drive_name]\n"
41b6f0
+		  "\t[-u|--update_defer]", c);
41b6f0
 	log_print(lc, "%s\t[{-f|--format FORMAT}]\n"
41b6f0
 		  "\t{-S|--spare [RAID-set]} \n"
41b6f0
 		  "\t{-M|--media \"device-path\"}\n", c);
41b6f0
@@ -285,6 +298,19 @@ static struct actions actions[] = {
41b6f0
 	 0,
41b6f0
 	 },
41b6f0
 
41b6f0
+	/* Defer metadata update */
41b6f0
+	{'u',
41b6f0
+	 UNDEF,
41b6f0
+	 UNDEF,
41b6f0
+	 ACTIVATE | REBUILD
41b6f0
+#ifndef DMRAID_MINI
41b6f0
+	 | DBG | TEST | VERBOSE
41b6f0
+#endif
41b6f0
+	 , NO_ARGS,
41b6f0
+	 defer_update,
41b6f0
+	 LC_DEFER_UPDATE,
41b6f0
+	 },
41b6f0
+
41b6f0
 	/* Format option. */
41b6f0
 	{'f',
41b6f0
 	 FORMAT,
41b6f0
@@ -726,7 +752,7 @@ handle_args(struct lib_context *lc, int argc, char ***argv)
41b6f0
 		if (o == 'C') {
41b6f0
 			*argv += optind - 1;
41b6f0
 			return 1;
41b6f0
-		} else if (o == 'R' && argc == 4) {
41b6f0
+		} else if (o == 'R' && (argc == 4 || argc == 5)) {
41b6f0
 			if (*(*argv + optind))
41b6f0
 				save_drive_name(lc, *(*argv + optind));
41b6f0
 		}
41b6f0
@@ -744,7 +770,7 @@ handle_args(struct lib_context *lc, int argc, char ***argv)
41b6f0
 		ret = check_actions_arguments(lc);
41b6f0
 
41b6f0
 	*argv += optind;
41b6f0
-	if (argc == 4 && lc->options[LC_REBUILD_SET].opt)
41b6f0
+	if ((argc == 4 || argc == 5) && lc->options[LC_REBUILD_SET].opt)
41b6f0
 		*argv += 1;
41b6f0
 
41b6f0
 	return ret;
41b6f0
@@ -871,7 +897,7 @@ struct prepost prepost[] = {
41b6f0
 	 0,
41b6f0
 	 activate_or_deactivate_sets,
41b6f0
 	 },
41b6f0
-
41b6f0
+	
41b6f0
 #ifndef DMRAID_MINI
41b6f0
 	/* Display block devices. */
41b6f0
 	{BLOCK_DEVICES,
41b6f0
-- 
41b6f0
1.7.0.4
41b6f0