All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] DM RAID: Use correct health status character when array is initializing
@ 2011-09-21 18:14 Jonathan Brassow
  2011-10-25 15:27 ` [PATCH - v2] DM RAID: Use correct health status character when array is initializing and rebuilding devices Jonathan Brassow
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Brassow @ 2011-09-21 18:14 UTC (permalink / raw)
  To: dm-devel

dm-raid: Device health characters of RAID arrays while sync'ing should be 'a'

When devices in a RAID array are not in-sync, they are supposed to be
reported as such in the status output via a 'a' character, which means
"alive, but not in-sync".  This was correct when rebuilding individual
devices, but not when the entire array was being built.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>

Index: linux-upstream/drivers/md/dm-raid.c
===================================================================
--- linux-upstream.orig/drivers/md/dm-raid.c
+++ linux-upstream/drivers/md/dm-raid.c
@@ -1017,30 +1017,47 @@ static int raid_status(struct dm_target 
 	struct raid_set *rs = ti->private;
 	unsigned raid_param_cnt = 1; /* at least 1 for chunksize */
 	unsigned sz = 0;
-	int i;
+	int i, array_in_sync = 0;
 	sector_t sync;
 
 	switch (type) {
 	case STATUSTYPE_INFO:
 		DMEMIT("%s %d ", rs->raid_type->name, rs->md.raid_disks);
 
-		for (i = 0; i < rs->md.raid_disks; i++) {
-			if (test_bit(Faulty, &rs->dev[i].rdev.flags))
-				DMEMIT("D");
-			else if (test_bit(In_sync, &rs->dev[i].rdev.flags))
-				DMEMIT("A");
-			else
-				DMEMIT("a");
-		}
-
 		if (test_bit(MD_RECOVERY_RUNNING, &rs->md.recovery))
 			sync = rs->md.curr_resync_completed;
 		else
 			sync = rs->md.recovery_cp;
 
-		if (sync > rs->md.resync_max_sectors)
+		if (sync >= rs->md.resync_max_sectors) {
+			array_in_sync = 1;
 			sync = rs->md.resync_max_sectors;
+		}
+
+		/*
+		 * Status characters:
+		 *  'D' = Dead/Failed device
+		 *  'a' = Alive but not in-sync
+		 *  'A' = Alive and in-sync
+		 */
+		for (i = 0; i < rs->md.raid_disks; i++) {
+			if (test_bit(Faulty, &rs->dev[i].rdev.flags))
+				DMEMIT("D");
+			else if (!array_in_sync ||
+				 !test_bit(In_sync, &rs->dev[i].rdev.flags))
+				DMEMIT("a");
+			else
+				DMEMIT("A");
+		}
 
+		/*
+		 * In-sync ratio:
+		 *  The in-sync ratio shows the progress of:
+		 *   - Initializing the array
+		 *   - Rebuilding a subset of devices of the array
+		 *  The user can distinguish between the two by referring
+		 *  to the status characters.
+		 */
 		DMEMIT(" %llu/%llu",
 		       (unsigned long long) sync,
 		       (unsigned long long) rs->md.resync_max_sectors);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-25 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-21 18:14 [PATCH] DM RAID: Use correct health status character when array is initializing Jonathan Brassow
2011-10-25 15:27 ` [PATCH - v2] DM RAID: Use correct health status character when array is initializing and rebuilding devices Jonathan Brassow

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.