Skip to contentSkip to conversation

master - RAID: Capture new RAID kernel sync_action status fields

PATCH Jonathan Brassow 1 participant 1 message Apr 8, 2013

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=38f8f4a958980c236bf19f6e58afd55fdcdd3312
Commit:        38f8f4a958980c236bf19f6e58afd55fdcdd3312
Parent:        c22e925ce4fa765b208670e851eae5103fb141f4
Author:        Jonathan Brassow <[email protected]>
AuthorDate:    Mon Apr 8 15:04:08 2013 -0500
Committer:     Jonathan Brassow <[email protected]>
CommitterDate: Mon Apr 8 15:04:08 2013 -0500

RAID: Capture new RAID kernel sync_action status fields

I've updated the dm_status_raid structure and dm_get_status_raid() function to make it handle the new kernel status fields that will be coming in dm-raid v1.5.0. It is backwards compatible with the old status line - initializing the new fields to '0'. The new structure is also more amenable to future changes. It includes a 'reserved' field that is currently initialized to zero but could be used to hold flags describing new features. It also now uses pointers for the character strings instead of attempting to allocate their space along with the structure (causing the size of the structure to be variable). This allows future fields to be appended.

The new fields that are available are:
- sync_action : shows what the sync thread in the kernel is doing (idle, frozen, resync, recover, check, repair, or reshape)
- mismatch_count: shows the number of discrepancies which were found or repaired by a "check" or "repair" process, respectively.

---
 lib/activate/activate.c    |    6 +++-
 lib/activate/dev_manager.c |    7 ++++-
 libdm/libdevmapper.h       |   14 +++++++++-
 libdm/libdm-deptree.c      |   55 ++++++++++++++++++++++++++++++++++++-------
 4 files changed, 68 insertions(+), 14 deletions(-)
lib/activate/activate.c +4 -2
index 26d357b..572383f 100644
@@ -809,8 +809,10 @@ int lv_raid_dev_health(const struct logical_volume *lv, char **dev_health)
 
 	if (!(r = dev_manager_raid_status(dm, lv, &status)) ||
 	    !(*dev_health = dm_pool_strdup(lv->vg->cmd->mem,
-					   status->dev_health)))
-		stack;
+					   status->dev_health))) {
+		dev_manager_destroy(dm);
+		return_0;
+	}
 
 	cached_dev_health = *dev_health;
 	dev_manager_destroy(dm);
lib/activate/dev_manager.c +6 -1
index 906f53a..4a77320 100644
@@ -1031,7 +1031,6 @@ int dev_manager_raid_status(struct dev_manager *dm,
 	char *params = NULL;
 	const char *layer = lv_layer(lv);
 
-	/* Build dlid for the thin pool layer */
 	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, layer)))
 		return_0;
 
@@ -1051,6 +1050,12 @@ int dev_manager_raid_status(struct dev_manager *dm,
 
 	dm_get_next_target(dmt, NULL, &start, &length, &type, &params);
 
+	if (!type || strcmp(type, "raid")) {
+		log_debug("Expected raid segment type but got %s instead",
+			  type ? type : "NULL");
+		goto out;
+	}
+
 	if (!dm_get_status_raid(dm->mem, params, status))
 		goto_out;
 
libdm/libdevmapper.h +12 -2
index 184615f..2f2c77d 100644
@@ -265,12 +265,22 @@ void *dm_get_next_target(struct dm_task *dmt,
  */
 struct dm_pool;
 
+/*
+ * dm_get_status_raid will allocate the dm_status_raid structure and
+ * the necessary character arrays from the mempool provided to the
+ * function.  If the mempool is from a dev_manager struct (dm->mem),
+ * then the caller does not need to free the memory - simply calling
+ * dev_manager_destroy will do.
+ */
 struct dm_status_raid {
+	uint64_t reserved;
 	uint64_t total_regions;
 	uint64_t insync_regions;
+	uint64_t mismatch_count;
 	int dev_count;
-	char raid_type[16];
-	char dev_health[0];
+	char *raid_type;
+	char *dev_health;
+	char *sync_action;
 };
 
 int dm_get_status_raid(struct dm_pool *mem, const char *params,
libdm/libdm-deptree.c +46 -9

80 lines not on this page · raw message