[PATCH] 3/6: Add the ability to reload a dm device's configuration data

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

 



Signed-off-by: Adam DiCarlo <bikko@xxxxxxxxxx>
Signed-off-by: James Simshaw <simshawj@xxxxxxxxxx>
Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx>




--- ORIGINAL/lib/activate/activate.c	2006-07-14 08:36:58.000000000 -0700
+++ PATCHED/lib/activate/activate.c	2006-08-29 11:59:17.000000000 -0700
@@ -572,6 +575,65 @@ static int unregister_devices(struct lib
 	return do_device(lc, rs, dm_unregister_for_event);
 }
 
+/* Reload a single set. */
+static int reload_subset(struct lib_context *lc, struct raid_set *rs)
+{
+	int ret = 0;
+	char *table = NULL;
+
+	if (T_GROUP(rs))
+		return 1;
+
+	/* Suspend device */
+	if (!(ret = dm_suspend(lc, rs)))
+		LOG_ERR(lc, ret, "Device suspend failed.");
+
+	/* Call type handler */
+	if ((ret = (handler(rs))->f(lc, &table, rs))) {
+		if (OPT_TEST(lc))
+			display_table(lc, rs->name, table);
+		else
+			ret = dm_reload(lc, rs, table);
+	} else
+		log_err(lc, "no mapping possible for RAID set %s", rs->name);
+
+	free_string(lc, &table);
+
+	/* Try to resume */
+	if (ret)
+		dm_resume(lc, rs);
+	else
+		if (!(ret = dm_resume(lc, rs)))
+			LOG_ERR(lc, ret, "Device resume failed.");
+
+	return ret;
+}
+
+/* Reload a RAID set recursively (eg, RAID1 on top of RAID0). */
+static int reload_set(struct lib_context *lc, struct raid_set *rs)
+{
+	struct raid_set *r;
+
+	/* FIXME: Does it matter if the set is (in)active? */
+#if 0
+	if (!OPT_TEST(lc) &&
+	    what == DM_ACTIVATE &&
+	    dm_status(lc, rs)) {
+		log_print(lc, "RAID set \"%s\" already active", rs->name);
+		return 1;
+	}
+#endif
+
+	/* Recursively walk down the chain of stacked RAID sets */
+	list_for_each_entry(r, &rs->sets, list) {
+		/* Activate set below this one */
+		if (!reload_set(lc, r) && !T_GROUP(rs))
+			return 0;
+	}
+
+	return reload_subset(lc, rs);
+}
+
 /* Activate a single set. */
 static int activate_subset(struct lib_context *lc, struct raid_set *rs,
 			   enum dm_what what)
@@ -683,6 +745,10 @@ int change_set(struct lib_context *lc, e
 	case A_DEACTIVATE:
 		ret = deactivate_set(lc, rs, DM_REGISTER) &&
 		      deactivate_set(lc, rs, DM_ACTIVATE);
+		break;
+	case A_RELOAD:
+		ret = reload_set(lc, rs);
+		break;
 	}
 
 	return ret;
--- ORIGINAL/lib/activate/activate.h	2005-02-02 06:49:18.000000000 -0800
+++ PATCHED/lib/activate/activate.h	2006-08-03 14:46:25.000000000 -0700
@@ -11,6 +11,7 @@
 enum activate_type {
 	A_ACTIVATE,
 	A_DEACTIVATE,
+	A_RELOAD,
 };
 
 int change_set(struct lib_context *lc, enum activate_type what, void *rs);



_______________________________________________
Ataraid-list mailing list
Ataraid-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/ataraid-list

[Index of Archives]     [Linux RAID]     [Linux Device Mapper]     [Linux IDE]     [Linux SCSI]     [Kernel]     [Linux Books]     [Linux Admin]     [GFS]     [RPM]     [Yosemite Campgrounds]     [AMD 64]

  Powered by Linux