Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1611747

[PATCH 1/2] super1: replace hard-coded values with bit definitions

From Gioh Kim <gi-oh.kim@profitbricks.com>
Newsgroups linux.kernel
Subject [PATCH 1/2] super1: replace hard-coded values with bit definitions
Date 2017-03-29 11:50 +0200
Message-ID <tqioO-51x-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] super1: replace hard-coded values with bit definitions Gioh Kim <gi-oh.kim@profitbricks.com> - 2017-03-29 11:50 +0200
  [PATCH 2/2] mdadm.c: fix compile error "switch condition has boolean value" Gioh Kim <gi-oh.kim@profitbricks.com> - 2017-03-29 11:50 +0200
    Re: [PATCH 2/2] mdadm.c: fix compile error "switch condition has boolean value" jes.sorensen@gmail.com - 2017-03-29 17:50 +0200
      Re: [PATCH 2/2] mdadm.c: fix compile error "switch condition has  boolean value" Gioh Kim <gi-oh.kim@profitbricks.com> - 2017-03-29 18:00 +0200
      Re: [PATCH 2/2] mdadm.c: fix compile error "switch condition has boolean value" NeilBrown <neilb@suse.com> - 2017-03-29 23:40 +0200
        Re: [PATCH 2/2] mdadm.c: fix compile error "switch condition has  boolean value" Gioh Kim <gi-oh.kim@profitbricks.com> - 2017-03-30 10:00 +0200
          Re: [PATCH 2/2] mdadm.c: fix compile error "switch condition has  boolean value" Jes Sorensen <jes.sorensen@gmail.com> - 2017-03-30 18:00 +0200
  Re: [PATCH 1/2] super1: replace hard-coded values with bit definitions jes.sorensen@gmail.com - 2017-03-29 17:50 +0200

csiph-web