dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/super1-replace-hard-coded-values-with-bit-definition.patch

b7f731
From aa3131183661955de112fa7d9824207de63d9fa5 Mon Sep 17 00:00:00 2001
b7f731
From: Gioh Kim <gi-oh.kim@profitbricks.com>
b7f731
Date: Wed, 29 Mar 2017 11:40:33 +0200
b7f731
Subject: [RHEL7.5 PATCH 032/169] super1: replace hard-coded values with
b7f731
 bit definitions
b7f731
b7f731
Some hard-coded values for disk status are replaced
b7f731
with bit definitions.
b7f731
b7f731
Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
b7f731
Signed-off-by: Jes Sorensen <Jes.Sorensen@gmail.com>
b7f731
---
b7f731
 super1.c | 7 ++++---
b7f731
 1 file changed, 4 insertions(+), 3 deletions(-)
b7f731
b7f731
diff --git a/super1.c b/super1.c
b7f731
index e76f777..6f91611 100644
b7f731
--- a/super1.c
b7f731
+++ b/super1.c
b7f731
@@ -1040,7 +1040,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
b7f731
 		info->disk.state = 0; /* spare: not active, not sync, not faulty */
b7f731
 		break;
b7f731
 	case MD_DISK_ROLE_FAULTY:
b7f731
-		info->disk.state = 1; /* faulty */
b7f731
+		info->disk.state = (1 << MD_DISK_FAULTY); /* faulty */
b7f731
 		break;
b7f731
 	case MD_DISK_ROLE_JOURNAL:
b7f731
 		info->disk.state = (1 << MD_DISK_JOURNAL);
b7f731
@@ -1600,11 +1600,12 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
b7f731
 	}
b7f731
 
b7f731
 	dk_state = dk->state & ~(1<
b7f731
-	if ((dk_state & 6) == 6) /* active, sync */
b7f731
+	if ((dk_state & (1<
b7f731
+	    (dk_state & (1<
b7f731
 		*rp = __cpu_to_le16(dk->raid_disk);
b7f731
 	else if (dk_state & (1<
b7f731
                 *rp = MD_DISK_ROLE_JOURNAL;
b7f731
-	else if ((dk_state & ~2) == 0) /* active or idle -> spare */
b7f731
+	else if ((dk_state & ~(1<<MD_DISK_ACTIVE)) == 0) /* active or idle -> spare */
b7f731
 		*rp = MD_DISK_ROLE_SPARE;
b7f731
 	else
b7f731
 		*rp = MD_DISK_ROLE_FAULTY;
b7f731
-- 
b7f731
2.7.4
b7f731