dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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