diff mbox

dm ioctl: retrieve status from inactive table

Message ID 1256072571-5193-1-git-send-email-snitzer@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Alasdair Kergon
Headers show

Commit Message

Mike Snitzer Oct. 20, 2009, 9:02 p.m. UTC
None
diff mbox

Patch

Index: linux-2.6/drivers/md/dm-ioctl.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-ioctl.c
+++ linux-2.6/drivers/md/dm-ioctl.c
@@ -650,6 +650,23 @@  static struct mapped_device *find_device
 	return md;
 }
 
+static struct dm_table *dm_get_inactive_table(struct dm_ioctl *param)
+{
+	struct hash_cell *hc;
+	struct dm_table *table = NULL;
+
+	down_read(&_hash_lock);
+	hc = __find_device_hash_cell(param);
+	if (hc) {
+		table = hc->new_map;
+		if (table)
+			dm_table_get(table);
+	}
+        up_read(&_hash_lock);
+
+	return table;
+}
+
 static int dev_remove(struct dm_ioctl *param, size_t param_size)
 {
 	struct hash_cell *hc;
@@ -1226,6 +1243,20 @@  static int table_deps(struct dm_ioctl *p
 	return r;
 }
 
+static struct dm_table* __dm_get_table(struct mapped_device *md,
+				       struct dm_ioctl *param)
+{
+	struct dm_table *table = NULL;
+
+	if (param->flags & DM_STATUS_INACTIVE_FLAG) {
+		if (param->flags & DM_INACTIVE_PRESENT_FLAG)
+			table = dm_get_inactive_table(param);
+	} else
+		table = dm_get_table(md);
+
+	return table;
+}
+
 /*
  * Return the status of a device as a text string for each
  * target.
@@ -1244,7 +1275,7 @@  static int table_status(struct dm_ioctl 
 	if (r)
 		goto out;
 
-	table = dm_get_table(md);
+	table = __dm_get_table(md, param);
 	if (table) {
 		retrieve_status(table, param, param_size);
 		dm_table_put(table);
Index: linux-2.6/include/linux/dm-ioctl.h
===================================================================
--- linux-2.6.orig/include/linux/dm-ioctl.h
+++ linux-2.6/include/linux/dm-ioctl.h
@@ -266,9 +266,9 @@  enum {
 #define DM_DEV_SET_GEOMETRY	_IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
 
 #define DM_VERSION_MAJOR	4
-#define DM_VERSION_MINOR	15
+#define DM_VERSION_MINOR	16
 #define DM_VERSION_PATCHLEVEL	0
-#define DM_VERSION_EXTRA	"-ioctl (2009-04-01)"
+#define DM_VERSION_EXTRA	"-ioctl (2009-10-20)"
 
 /* Status bits */
 #define DM_READONLY_FLAG	(1 << 0) /* In/Out */
@@ -282,6 +282,12 @@  enum {
 #define DM_STATUS_TABLE_FLAG	(1 << 4) /* In */
 
 /*
+ * Flag passed into ioctl STATUS command to get table information
+ * or current status from the inactive table.
+ */
+#define DM_STATUS_INACTIVE_FLAG	(1 << 7) /* In */
+
+/*
  * Flags that indicate whether a table is present in either of
  * the two table slots that a device has.
  */