linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] super1: replace hard-coded values with bit definitions
@ 2017-03-29  9:40 Gioh Kim
  2017-03-29  9:40 ` [PATCH 2/2] mdadm.c: fix compile error "switch condition has boolean value" Gioh Kim
  2017-03-29 15:41 ` [PATCH 1/2] super1: replace hard-coded values with bit definitions jes.sorensen
  0 siblings, 2 replies; 8+ messages in thread
From: Gioh Kim @ 2017-03-29  9:40 UTC (permalink / raw)
  To: jes.sorensen; +Cc: neilb, linux-raid, linux-kernel, Gioh Kim

Some hard-coded values for disk status are replaced
with bit definitions.

Signed-off-by: Gioh Kim <gi-oh.kim@profitbricks.com>
---
 super1.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/super1.c b/super1.c
index f3520ac..e8b9f61 100644
--- a/super1.c
+++ b/super1.c
@@ -1010,7 +1010,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
 		info->disk.state = 0; /* spare: not active, not sync, not faulty */
 		break;
 	case MD_DISK_ROLE_FAULTY:
-		info->disk.state = 1; /* faulty */
+		info->disk.state = (1 << MD_DISK_FAULTY); /* faulty */
 		break;
 	case MD_DISK_ROLE_JOURNAL:
 		info->disk.state = (1 << MD_DISK_JOURNAL);
@@ -1503,11 +1503,12 @@ static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
 	}
 
 	dk_state = dk->state & ~(1<<MD_DISK_FAILFAST);
-	if ((dk_state & 6) == 6) /* active, sync */
+	if ((dk_state & (1<<MD_DISK_ACTIVE)) &&
+	    (dk_state & (1<<MD_DISK_SYNC)))/* active, sync */
 		*rp = __cpu_to_le16(dk->raid_disk);
 	else if (dk_state & (1<<MD_DISK_JOURNAL))
                 *rp = MD_DISK_ROLE_JOURNAL;
-	else if ((dk_state & ~2) == 0) /* active or idle -> spare */
+	else if ((dk_state & ~(1<<MD_DISK_ACTIVE)) == 0) /* active or idle -> spare */
 		*rp = MD_DISK_ROLE_SPARE;
 	else
 		*rp = MD_DISK_ROLE_FAULTY;
-- 
2.5.0


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

end of thread, other threads:[~2017-03-30 15:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-29  9:40 [PATCH 1/2] super1: replace hard-coded values with bit definitions Gioh Kim
2017-03-29  9:40 ` [PATCH 2/2] mdadm.c: fix compile error "switch condition has boolean value" Gioh Kim
2017-03-29 15:47   ` jes.sorensen
2017-03-29 15:50     ` Gioh Kim
2017-03-29 21:38     ` NeilBrown
2017-03-30  7:52       ` Gioh Kim
2017-03-30 15:53         ` Jes Sorensen
2017-03-29 15:41 ` [PATCH 1/2] super1: replace hard-coded values with bit definitions jes.sorensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).