Blame SOURCES/0069-Detail-adding-sync-status-for-cluster-device.patch

5bf14f
From 1c294b5d960abeeb9e0f188af294d019bc82b20e Mon Sep 17 00:00:00 2001
5bf14f
From: Lidong Zhong <lidong.zhong@suse.com>
5bf14f
Date: Tue, 14 Apr 2020 16:19:41 +0800
5bf14f
Subject: [RHEL7.9 PATCH 69/71] Detail: adding sync status for cluster device
5bf14f
5bf14f
On the node with /proc/mdstat is
5bf14f
5bf14f
Personalities : [raid1]
5bf14f
md0 : active raid1 sdb[4] sdc[3] sdd[2]
5bf14f
      1046528 blocks super 1.2 [3/2] [UU_]
5bf14f
        recover=REMOTE
5bf14f
      bitmap: 1/1 pages [4KB], 65536KB chunk
5bf14f
5bf14f
Let's change the 'State' of 'mdadm -Q -D' accordingly
5bf14f
State : clean, degraded
5bf14f
With this patch, it will be
5bf14f
State : clean, degraded, recovering (REMOTE)
5bf14f
5bf14f
Signed-off-by: Lidong Zhong <lidong.zhong@suse.com>
5bf14f
Acked-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
5bf14f
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
5bf14f
---
5bf14f
 Detail.c | 9 ++++++---
5bf14f
 mdadm.h  | 3 ++-
5bf14f
 mdstat.c | 2 ++
5bf14f
 3 files changed, 10 insertions(+), 4 deletions(-)
5bf14f
5bf14f
diff --git a/Detail.c b/Detail.c
5bf14f
index daec4f1..24eeba0 100644
5bf14f
--- a/Detail.c
5bf14f
+++ b/Detail.c
5bf14f
@@ -498,17 +498,20 @@ int Detail(char *dev, struct context *c)
5bf14f
 			} else
5bf14f
 				arrayst = "active";
5bf14f
 
5bf14f
-			printf("             State : %s%s%s%s%s%s \n",
5bf14f
+			printf("             State : %s%s%s%s%s%s%s \n",
5bf14f
 			       arrayst, st,
5bf14f
 			       (!e || (e->percent < 0 &&
5bf14f
 				       e->percent != RESYNC_PENDING &&
5bf14f
-				       e->percent != RESYNC_DELAYED)) ?
5bf14f
+				       e->percent != RESYNC_DELAYED &&
5bf14f
+				       e->percent != RESYNC_REMOTE)) ?
5bf14f
 			       "" : sync_action[e->resync],
5bf14f
 			       larray_size ? "": ", Not Started",
5bf14f
 			       (e && e->percent == RESYNC_DELAYED) ?
5bf14f
 			       " (DELAYED)": "",
5bf14f
 			       (e && e->percent == RESYNC_PENDING) ?
5bf14f
-			       " (PENDING)": "");
5bf14f
+			       " (PENDING)": "",
5bf14f
+			       (e && e->percent == RESYNC_REMOTE) ?
5bf14f
+			       " (REMOTE)": "");
5bf14f
 		} else if (inactive && !is_container) {
5bf14f
 			printf("             State : inactive\n");
5bf14f
 		}
5bf14f
diff --git a/mdadm.h b/mdadm.h
5bf14f
index d94569f..399478b 100644
5bf14f
--- a/mdadm.h
5bf14f
+++ b/mdadm.h
5bf14f
@@ -1815,7 +1815,8 @@ enum r0layout {
5bf14f
 #define RESYNC_NONE -1
5bf14f
 #define RESYNC_DELAYED -2
5bf14f
 #define RESYNC_PENDING -3
5bf14f
-#define RESYNC_UNKNOWN -4
5bf14f
+#define RESYNC_REMOTE  -4
5bf14f
+#define RESYNC_UNKNOWN -5
5bf14f
 
5bf14f
 /* When using "GET_DISK_INFO" it isn't certain how high
5bf14f
  * we need to check.  So we impose an absolute limit of
5bf14f
diff --git a/mdstat.c b/mdstat.c
5bf14f
index 7e600d0..20577a3 100644
5bf14f
--- a/mdstat.c
5bf14f
+++ b/mdstat.c
5bf14f
@@ -257,6 +257,8 @@ struct mdstat_ent *mdstat_read(int hold, int start)
5bf14f
 					ent->percent = RESYNC_DELAYED;
5bf14f
 				if (l > 8 && strcmp(w+l-8, "=PENDING") == 0)
5bf14f
 					ent->percent = RESYNC_PENDING;
5bf14f
+				if (l > 7 && strcmp(w+l-7, "=REMOTE") == 0)
5bf14f
+					ent->percent = RESYNC_REMOTE;
5bf14f
 			} else if (ent->percent == RESYNC_NONE &&
5bf14f
 				   w[0] >= '0' &&
5bf14f
 				   w[0] <= '9' &&
5bf14f
-- 
5bf14f
2.7.5
5bf14f