Blame SOURCES/detail-show-consistency-policy.patch

dd3a91
commit 65884368cd42d79b567f12d3e84adc7009e12d72
dd3a91
Author: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
dd3a91
Date:   Wed Mar 29 11:54:16 2017 +0200
dd3a91
dd3a91
    Detail: show consistency policy
dd3a91
    
dd3a91
    Show the currently enabled consistency policy in the output from
dd3a91
    --detail. Add 3 spaces to all existing items in Detail output to align
dd3a91
    with "Consistency Policy : ".
dd3a91
    
dd3a91
    Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
dd3a91
    Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
dd3a91
dd3a91
diff --git a/Detail.c b/Detail.c
dd3a91
index 3d92855..136875b 100644
dd3a91
--- a/Detail.c
dd3a91
+++ b/Detail.c
dd3a91
@@ -402,24 +402,25 @@ int Detail(char *dev, struct context *c)
dd3a91
 		printf("%s:\n", dev);
dd3a91
 
dd3a91
 		if (container)
dd3a91
-			printf("      Container : %s, member %s\n", container, member);
dd3a91
+			printf("         Container : %s, member %s\n", container,
dd3a91
+			       member);
dd3a91
 		else {
dd3a91
 		if (sra && sra->array.major_version < 0)
dd3a91
-			printf("        Version : %s\n", sra->text_version);
dd3a91
+			printf("           Version : %s\n", sra->text_version);
dd3a91
 		else
dd3a91
-			printf("        Version : %d.%d\n",
dd3a91
+			printf("           Version : %d.%d\n",
dd3a91
 			       array.major_version, array.minor_version);
dd3a91
 		}
dd3a91
 
dd3a91
 		atime = array.ctime;
dd3a91
 		if (atime)
dd3a91
-			printf("  Creation Time : %.24s\n", ctime(&atime));
dd3a91
+			printf("     Creation Time : %.24s\n", ctime(&atime));
dd3a91
 		if (array.raid_disks == 0 && external)
dd3a91
 			str = "container";
dd3a91
 		if (str)
dd3a91
-			printf("     Raid Level : %s\n", str);
dd3a91
+			printf("        Raid Level : %s\n", str);
dd3a91
 		if (larray_size)
dd3a91
-			printf("     Array Size : %llu%s\n", (larray_size>>10),
dd3a91
+			printf("        Array Size : %llu%s\n", (larray_size>>10),
dd3a91
 			       human_size(larray_size));
dd3a91
 		if (array.level >= 1) {
dd3a91
 			if (sra)
dd3a91
@@ -428,38 +429,38 @@ int Detail(char *dev, struct context *c)
dd3a91
 			    (larray_size >= 0xFFFFFFFFULL|| array.size == 0)) {
dd3a91
 				unsigned long long dsize = get_component_size(fd);
dd3a91
 				if (dsize > 0)
dd3a91
-					printf("  Used Dev Size : %llu%s\n",
dd3a91
+					printf("     Used Dev Size : %llu%s\n",
dd3a91
 					       dsize/2,
dd3a91
 					 human_size((long long)dsize<<9));
dd3a91
 				else
dd3a91
-					printf("  Used Dev Size : unknown\n");
dd3a91
+					printf("     Used Dev Size : unknown\n");
dd3a91
 			} else
dd3a91
-				printf("  Used Dev Size : %lu%s\n",
dd3a91
+				printf("     Used Dev Size : %lu%s\n",
dd3a91
 				       (unsigned long)array.size,
dd3a91
 				       human_size((unsigned long long)array.size<<10));
dd3a91
 		}
dd3a91
 		if (array.raid_disks)
dd3a91
-			printf("   Raid Devices : %d\n", array.raid_disks);
dd3a91
-		printf("  Total Devices : %d\n", array.nr_disks);
dd3a91
+			printf("      Raid Devices : %d\n", array.raid_disks);
dd3a91
+		printf("     Total Devices : %d\n", array.nr_disks);
dd3a91
 		if (!container &&
dd3a91
 		    ((sra == NULL && array.major_version == 0) ||
dd3a91
 		     (sra && sra->array.major_version == 0)))
dd3a91
-			printf("Preferred Minor : %d\n", array.md_minor);
dd3a91
+			printf("   Preferred Minor : %d\n", array.md_minor);
dd3a91
 		if (sra == NULL || sra->array.major_version >= 0)
dd3a91
-			printf("    Persistence : Superblock is %spersistent\n",
dd3a91
+			printf("       Persistence : Superblock is %spersistent\n",
dd3a91
 			       array.not_persistent?"not ":"");
dd3a91
 		printf("\n");
dd3a91
 		/* Only try GET_BITMAP_FILE for 0.90.01 and later */
dd3a91
 		if (vers >= 9001 &&
dd3a91
 		    ioctl(fd, GET_BITMAP_FILE, &bmf) == 0 &&
dd3a91
 		    bmf.pathname[0]) {
dd3a91
-			printf("  Intent Bitmap : %s\n", bmf.pathname);
dd3a91
+			printf("     Intent Bitmap : %s\n", bmf.pathname);
dd3a91
 			printf("\n");
dd3a91
 		} else if (array.state & (1<
dd3a91
-			printf("  Intent Bitmap : Internal\n\n");
dd3a91
+			printf("     Intent Bitmap : Internal\n\n");
dd3a91
 		atime = array.utime;
dd3a91
 		if (atime)
dd3a91
-			printf("    Update Time : %.24s\n", ctime(&atime));
dd3a91
+			printf("       Update Time : %.24s\n", ctime(&atime));
dd3a91
 		if (array.raid_disks) {
dd3a91
 			static char *sync_action[] = {
dd3a91
 				", recovering",  ", resyncing",
dd3a91
@@ -473,7 +474,7 @@ int Detail(char *dev, struct context *c)
dd3a91
 			else
dd3a91
 				st = ", degraded";
dd3a91
 
dd3a91
-			printf("          State : %s%s%s%s%s%s \n",
dd3a91
+			printf("             State : %s%s%s%s%s%s \n",
dd3a91
 			       (array.state&(1<
dd3a91
 			       (!e || (e->percent < 0 && e->percent != RESYNC_PENDING &&
dd3a91
 			       e->percent != RESYNC_DELAYED)) ? "" : sync_action[e->resync],
dd3a91
@@ -481,27 +482,27 @@ int Detail(char *dev, struct context *c)
dd3a91
 			       (e && e->percent == RESYNC_DELAYED) ? " (DELAYED)": "",
dd3a91
 			       (e && e->percent == RESYNC_PENDING) ? " (PENDING)": "");
dd3a91
 		} else if (inactive) {
dd3a91
-			printf("          State : inactive\n");
dd3a91
+			printf("             State : inactive\n");
dd3a91
 		}
dd3a91
 		if (array.raid_disks)
dd3a91
-			printf(" Active Devices : %d\n", array.active_disks);
dd3a91
+			printf("    Active Devices : %d\n", array.active_disks);
dd3a91
 		if (array.working_disks > 0)
dd3a91
-			printf("Working Devices : %d\n", array.working_disks);
dd3a91
+			printf("   Working Devices : %d\n", array.working_disks);
dd3a91
 		if (array.raid_disks) {
dd3a91
-			printf(" Failed Devices : %d\n", array.failed_disks);
dd3a91
-			printf("  Spare Devices : %d\n", array.spare_disks);
dd3a91
+			printf("    Failed Devices : %d\n", array.failed_disks);
dd3a91
+			printf("     Spare Devices : %d\n", array.spare_disks);
dd3a91
 		}
dd3a91
 		printf("\n");
dd3a91
 		if (array.level == 5) {
dd3a91
 			str = map_num(r5layout, array.layout);
dd3a91
-			printf("         Layout : %s\n", str?str:"-unknown-");
dd3a91
+			printf("            Layout : %s\n", str?str:"-unknown-");
dd3a91
 		}
dd3a91
 		if (array.level == 6) {
dd3a91
 			str = map_num(r6layout, array.layout);
dd3a91
-			printf("         Layout : %s\n", str?str:"-unknown-");
dd3a91
+			printf("            Layout : %s\n", str?str:"-unknown-");
dd3a91
 		}
dd3a91
 		if (array.level == 10) {
dd3a91
-			printf("         Layout :");
dd3a91
+			printf("            Layout :");
dd3a91
 			print_r10_layout(array.layout);
dd3a91
 			printf("\n");
dd3a91
 		}
dd3a91
@@ -512,20 +513,35 @@ int Detail(char *dev, struct context *c)
dd3a91
 		case 10:
dd3a91
 		case 6:
dd3a91
 			if (array.chunk_size)
dd3a91
-				printf("     Chunk Size : %dK\n\n",
dd3a91
+				printf("        Chunk Size : %dK\n\n",
dd3a91
 				       array.chunk_size/1024);
dd3a91
 			break;
dd3a91
 		case -1:
dd3a91
-			printf("       Rounding : %dK\n\n", array.chunk_size/1024);
dd3a91
+			printf("          Rounding : %dK\n\n",
dd3a91
+			       array.chunk_size/1024);
dd3a91
 			break;
dd3a91
 		default: break;
dd3a91
 		}
dd3a91
 
dd3a91
+		if (array.raid_disks) {
dd3a91
+			struct mdinfo *mdi = sysfs_read(fd, NULL,
dd3a91
+							GET_CONSISTENCY_POLICY);
dd3a91
+			if (mdi) {
dd3a91
+				char *policy = map_num(consistency_policies,
dd3a91
+						       mdi->consistency_policy);
dd3a91
+				sysfs_free(mdi);
dd3a91
+				if (policy)
dd3a91
+					printf("Consistency Policy : %s\n\n",
dd3a91
+					       policy);
dd3a91
+			}
dd3a91
+		}
dd3a91
+
dd3a91
 		if (e && e->percent >= 0) {
dd3a91
 			static char *sync_action[] = {
dd3a91
 				"Rebuild", "Resync",
dd3a91
 				"Reshape", "Check"};
dd3a91
-			printf(" %7s Status : %d%% complete\n", sync_action[e->resync], e->percent);
dd3a91
+			printf("    %7s Status : %d%% complete\n",
dd3a91
+			       sync_action[e->resync], e->percent);
dd3a91
 			is_rebuilding = 1;
dd3a91
 		}
dd3a91
 		free_mdstat(ms);
dd3a91
@@ -533,39 +549,41 @@ int Detail(char *dev, struct context *c)
dd3a91
 		if ((st && st->sb) && (info && info->reshape_active)) {
dd3a91
 #if 0
dd3a91
 This is pretty boring
dd3a91
-			printf("  Reshape pos'n : %llu%s\n", (unsigned long long) info->reshape_progress<<9,
dd3a91
+			printf("     Reshape pos'n : %llu%s\n",
dd3a91
+			       (unsigned long long) info->reshape_progress<<9,
dd3a91
 			       human_size((unsigned long long)info->reshape_progress<<9));
dd3a91
 #endif
dd3a91
 			if (info->delta_disks != 0)
dd3a91
-				printf("  Delta Devices : %d, (%d->%d)\n",
dd3a91
+				printf("     Delta Devices : %d, (%d->%d)\n",
dd3a91
 				       info->delta_disks,
dd3a91
 				       array.raid_disks - info->delta_disks,
dd3a91
 				       array.raid_disks);
dd3a91
 			if (info->new_level != array.level) {
dd3a91
 				str = map_num(pers, info->new_level);
dd3a91
-				printf("      New Level : %s\n", str?str:"-unknown-");
dd3a91
+				printf("         New Level : %s\n", str?str:"-unknown-");
dd3a91
 			}
dd3a91
 			if (info->new_level != array.level ||
dd3a91
 			    info->new_layout != array.layout) {
dd3a91
 				if (info->new_level == 5) {
dd3a91
 					str = map_num(r5layout, info->new_layout);
dd3a91
-					printf("     New Layout : %s\n",
dd3a91
+					printf("        New Layout : %s\n",
dd3a91
 					       str?str:"-unknown-");
dd3a91
 				}
dd3a91
 				if (info->new_level == 6) {
dd3a91
 					str = map_num(r6layout, info->new_layout);
dd3a91
-					printf("     New Layout : %s\n",
dd3a91
+					printf("        New Layout : %s\n",
dd3a91
 					       str?str:"-unknown-");
dd3a91
 				}
dd3a91
 				if (info->new_level == 10) {
dd3a91
-					printf("     New Layout : near=%d, %s=%d\n",
dd3a91
+					printf("        New Layout : near=%d, %s=%d\n",
dd3a91
 					       info->new_layout&255,
dd3a91
 					       (info->new_layout&0x10000)?"offset":"far",
dd3a91
 					       (info->new_layout>>8)&255);
dd3a91
 				}
dd3a91
 			}
dd3a91
 			if (info->new_chunk != array.chunk_size)
dd3a91
-				printf("  New Chunksize : %dK\n", info->new_chunk/1024);
dd3a91
+				printf("     New Chunksize : %dK\n",
dd3a91
+				       info->new_chunk/1024);
dd3a91
 			printf("\n");
dd3a91
 		} else if (e && e->percent >= 0)
dd3a91
 			printf("\n");
dd3a91
@@ -580,7 +598,7 @@ This is pretty boring
dd3a91
 			DIR *dir = opendir("/sys/block");
dd3a91
 			struct dirent *de;
dd3a91
 
dd3a91
-			printf("  Member Arrays :");
dd3a91
+			printf("     Member Arrays :");
dd3a91
 
dd3a91
 			while (dir && (de = readdir(dir)) != NULL) {
dd3a91
 				char path[287];
dd3a91
diff --git a/super-ddf.c b/super-ddf.c
dd3a91
index cdd16a4..c6037c1 100644
dd3a91
--- a/super-ddf.c
dd3a91
+++ b/super-ddf.c
dd3a91
@@ -1742,10 +1742,10 @@ static void detail_super_ddf(struct supertype *st, char *homehost)
dd3a91
 	struct ddf_super *sb = st->sb;
dd3a91
 	int cnt = be16_to_cpu(sb->virt->populated_vdes);
dd3a91
 
dd3a91
-	printf(" Container GUID : "); print_guid(sb->anchor.guid, 1);
dd3a91
+	printf("    Container GUID : "); print_guid(sb->anchor.guid, 1);
dd3a91
 	printf("\n");
dd3a91
-	printf("            Seq : %08x\n", be32_to_cpu(sb->active->seq));
dd3a91
-	printf("  Virtual Disks : %d\n", cnt);
dd3a91
+	printf("               Seq : %08x\n", be32_to_cpu(sb->active->seq));
dd3a91
+	printf("     Virtual Disks : %d\n", cnt);
dd3a91
 	printf("\n");
dd3a91
 }
dd3a91
 #endif
dd3a91
diff --git a/super-intel.c b/super-intel.c
dd3a91
index 5d0f131..2d92c8e 100644
dd3a91
--- a/super-intel.c
dd3a91
+++ b/super-intel.c
dd3a91
@@ -1987,7 +1987,7 @@ static void detail_super_imsm(struct supertype *st, char *homehost)
dd3a91
 
dd3a91
 	getinfo_super_imsm(st, &info, NULL);
dd3a91
 	fname_from_uuid(st, &info, nbuf, ':');
dd3a91
-	printf("\n           UUID : %s\n", nbuf + 5);
dd3a91
+	printf("\n              UUID : %s\n", nbuf + 5);
dd3a91
 }
dd3a91
 
dd3a91
 static void brief_detail_super_imsm(struct supertype *st)
dd3a91
diff --git a/super0.c b/super0.c
dd3a91
index 7a555e3..10d9c40 100644
dd3a91
--- a/super0.c
dd3a91
+++ b/super0.c
dd3a91
@@ -353,7 +353,7 @@ err:
dd3a91
 static void detail_super0(struct supertype *st, char *homehost)
dd3a91
 {
dd3a91
 	mdp_super_t *sb = st->sb;
dd3a91
-	printf("           UUID : ");
dd3a91
+	printf("              UUID : ");
dd3a91
 	if (sb->minor_version >= 90)
dd3a91
 		printf("%08x:%08x:%08x:%08x", sb->set_uuid0, sb->set_uuid1,
dd3a91
 		       sb->set_uuid2, sb->set_uuid3);
dd3a91
@@ -367,7 +367,7 @@ static void detail_super0(struct supertype *st, char *homehost)
dd3a91
 		if (memcmp(&sb->set_uuid2, hash, 8)==0)
dd3a91
 			printf(" (local to host %s)", homehost);
dd3a91
 	}
dd3a91
-	printf("\n         Events : %d.%d\n\n", sb->events_hi, sb->events_lo);
dd3a91
+	printf("\n            Events : %d.%d\n\n", sb->events_hi, sb->events_lo);
dd3a91
 }
dd3a91
 
dd3a91
 static void brief_detail_super0(struct supertype *st)
dd3a91
diff --git a/super1.c b/super1.c
dd3a91
index 4a0f041..8df17a1 100644
dd3a91
--- a/super1.c
dd3a91
+++ b/super1.c
dd3a91
@@ -780,19 +780,20 @@ static void detail_super1(struct supertype *st, char *homehost)
dd3a91
 	int i;
dd3a91
 	int l = homehost ? strlen(homehost) : 0;
dd3a91
 
dd3a91
-	printf("           Name : %.32s", sb->set_name);
dd3a91
+	printf("              Name : %.32s", sb->set_name);
dd3a91
 	if (l > 0 && l < 32 &&
dd3a91
 	    sb->set_name[l] == ':' &&
dd3a91
 	    strncmp(sb->set_name, homehost, l) == 0)
dd3a91
 		printf("  (local to host %s)", homehost);
dd3a91
 	if (bms->nodes > 0 && (__le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET))
dd3a91
-	    printf("\n   Cluster Name : %-64s", bms->cluster_name);
dd3a91
-	printf("\n           UUID : ");
dd3a91
+	    printf("\n      Cluster Name : %-64s", bms->cluster_name);
dd3a91
+	printf("\n              UUID : ");
dd3a91
 	for (i=0; i<16; i++) {
dd3a91
 		if ((i&3)==0 && i != 0) printf(":");
dd3a91
 		printf("%02x", sb->set_uuid[i]);
dd3a91
 	}
dd3a91
-	printf("\n         Events : %llu\n\n", (unsigned long long)__le64_to_cpu(sb->events));
dd3a91
+	printf("\n            Events : %llu\n\n",
dd3a91
+	       (unsigned long long)__le64_to_cpu(sb->events));
dd3a91
 }
dd3a91
 
dd3a91
 static void brief_detail_super1(struct supertype *st)