Blame SOURCES/bz626417_21-add_option_that_postpones_any_metadata_updates.patch

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