diff options
author | Shaohua Li <shli@fb.com> | 2017-01-04 19:10:19 -0500 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2017-01-05 14:45:18 -0500 |
commit | 394ed8e4743b0cfc5496fe49059fbfc2bc8eae35 (patch) | |
tree | 65412c7b017be0fc1a2316f4a0778328421a0f4c | |
parent | 99f17890f04cff0262de7393c60a2f6d9c9c7e71 (diff) |
md: cleanup mddev flag clear for takeover
Commit 6995f0b (md: takeover should clear unrelated bits) clear
unrelated bits, but it's quite fragile. To avoid error in the future,
define a macro for unsupported mddev flags for each raid type and use it
to clear unsupported mddev flags. This should be less error-prone.
Suggested-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
-rw-r--r-- | drivers/md/md.h | 8 | ||||
-rw-r--r-- | drivers/md/raid0.c | 12 | ||||
-rw-r--r-- | drivers/md/raid1.c | 8 | ||||
-rw-r--r-- | drivers/md/raid5.c | 5 |
4 files changed, 26 insertions, 7 deletions
diff --git a/drivers/md/md.h b/drivers/md/md.h index e38936d05df1..2a514036a83d 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -212,6 +212,7 @@ extern int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors, | |||
212 | int is_new); | 212 | int is_new); |
213 | struct md_cluster_info; | 213 | struct md_cluster_info; |
214 | 214 | ||
215 | /* change UNSUPPORTED_MDDEV_FLAGS for each array type if new flag is added */ | ||
215 | enum mddev_flags { | 216 | enum mddev_flags { |
216 | MD_ARRAY_FIRST_USE, /* First use of array, needs initialization */ | 217 | MD_ARRAY_FIRST_USE, /* First use of array, needs initialization */ |
217 | MD_CLOSING, /* If set, we are closing the array, do not open | 218 | MD_CLOSING, /* If set, we are closing the array, do not open |
@@ -702,4 +703,11 @@ static inline int mddev_is_clustered(struct mddev *mddev) | |||
702 | { | 703 | { |
703 | return mddev->cluster_info && mddev->bitmap_info.nodes > 1; | 704 | return mddev->cluster_info && mddev->bitmap_info.nodes > 1; |
704 | } | 705 | } |
706 | |||
707 | /* clear unsupported mddev_flags */ | ||
708 | static inline void mddev_clear_unsupported_flags(struct mddev *mddev, | ||
709 | unsigned long unsupported_flags) | ||
710 | { | ||
711 | mddev->flags &= ~unsupported_flags; | ||
712 | } | ||
705 | #endif /* _MD_MD_H */ | 713 | #endif /* _MD_MD_H */ |
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index a162fedeb51a..848365d474f3 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -26,6 +26,11 @@ | |||
26 | #include "raid0.h" | 26 | #include "raid0.h" |
27 | #include "raid5.h" | 27 | #include "raid5.h" |
28 | 28 | ||
29 | #define UNSUPPORTED_MDDEV_FLAGS \ | ||
30 | ((1L << MD_HAS_JOURNAL) | \ | ||
31 | (1L << MD_JOURNAL_CLEAN) | \ | ||
32 | (1L << MD_FAILFAST_SUPPORTED)) | ||
33 | |||
29 | static int raid0_congested(struct mddev *mddev, int bits) | 34 | static int raid0_congested(struct mddev *mddev, int bits) |
30 | { | 35 | { |
31 | struct r0conf *conf = mddev->private; | 36 | struct r0conf *conf = mddev->private; |
@@ -539,8 +544,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev) | |||
539 | mddev->delta_disks = -1; | 544 | mddev->delta_disks = -1; |
540 | /* make sure it will be not marked as dirty */ | 545 | /* make sure it will be not marked as dirty */ |
541 | mddev->recovery_cp = MaxSector; | 546 | mddev->recovery_cp = MaxSector; |
542 | clear_bit(MD_HAS_JOURNAL, &mddev->flags); | 547 | mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); |
543 | clear_bit(MD_JOURNAL_CLEAN, &mddev->flags); | ||
544 | 548 | ||
545 | create_strip_zones(mddev, &priv_conf); | 549 | create_strip_zones(mddev, &priv_conf); |
546 | 550 | ||
@@ -583,7 +587,7 @@ static void *raid0_takeover_raid10(struct mddev *mddev) | |||
583 | mddev->degraded = 0; | 587 | mddev->degraded = 0; |
584 | /* make sure it will be not marked as dirty */ | 588 | /* make sure it will be not marked as dirty */ |
585 | mddev->recovery_cp = MaxSector; | 589 | mddev->recovery_cp = MaxSector; |
586 | clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); | 590 | mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); |
587 | 591 | ||
588 | create_strip_zones(mddev, &priv_conf); | 592 | create_strip_zones(mddev, &priv_conf); |
589 | return priv_conf; | 593 | return priv_conf; |
@@ -626,7 +630,7 @@ static void *raid0_takeover_raid1(struct mddev *mddev) | |||
626 | mddev->raid_disks = 1; | 630 | mddev->raid_disks = 1; |
627 | /* make sure it will be not marked as dirty */ | 631 | /* make sure it will be not marked as dirty */ |
628 | mddev->recovery_cp = MaxSector; | 632 | mddev->recovery_cp = MaxSector; |
629 | clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); | 633 | mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS); |
630 | 634 | ||
631 | create_strip_zones(mddev, &priv_conf); | 635 | create_strip_zones(mddev, &priv_conf); |
632 | return priv_conf; | 636 | return priv_conf; |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 14422407e520..7b0f647bcccb 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -42,6 +42,10 @@ | |||
42 | #include "raid1.h" | 42 | #include "raid1.h" |
43 | #include "bitmap.h" | 43 | #include "bitmap.h" |
44 | 44 | ||
45 | #define UNSUPPORTED_MDDEV_FLAGS \ | ||
46 | ((1L << MD_HAS_JOURNAL) | \ | ||
47 | (1L << MD_JOURNAL_CLEAN)) | ||
48 | |||
45 | /* | 49 | /* |
46 | * Number of guaranteed r1bios in case of extreme VM load: | 50 | * Number of guaranteed r1bios in case of extreme VM load: |
47 | */ | 51 | */ |
@@ -3257,8 +3261,8 @@ static void *raid1_takeover(struct mddev *mddev) | |||
3257 | if (!IS_ERR(conf)) { | 3261 | if (!IS_ERR(conf)) { |
3258 | /* Array must appear to be quiesced */ | 3262 | /* Array must appear to be quiesced */ |
3259 | conf->array_frozen = 1; | 3263 | conf->array_frozen = 1; |
3260 | clear_bit(MD_HAS_JOURNAL, &mddev->flags); | 3264 | mddev_clear_unsupported_flags(mddev, |
3261 | clear_bit(MD_JOURNAL_CLEAN, &mddev->flags); | 3265 | UNSUPPORTED_MDDEV_FLAGS); |
3262 | } | 3266 | } |
3263 | return conf; | 3267 | return conf; |
3264 | } | 3268 | } |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 06d7279bdd04..7b1da6e95a56 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -62,6 +62,8 @@ | |||
62 | #include "raid0.h" | 62 | #include "raid0.h" |
63 | #include "bitmap.h" | 63 | #include "bitmap.h" |
64 | 64 | ||
65 | #define UNSUPPORTED_MDDEV_FLAGS (1L << MD_FAILFAST_SUPPORTED) | ||
66 | |||
65 | #define cpu_to_group(cpu) cpu_to_node(cpu) | 67 | #define cpu_to_group(cpu) cpu_to_node(cpu) |
66 | #define ANY_GROUP NUMA_NO_NODE | 68 | #define ANY_GROUP NUMA_NO_NODE |
67 | 69 | ||
@@ -7830,7 +7832,8 @@ static void *raid5_takeover_raid1(struct mddev *mddev) | |||
7830 | 7832 | ||
7831 | ret = setup_conf(mddev); | 7833 | ret = setup_conf(mddev); |
7832 | if (!IS_ERR_VALUE(ret)) | 7834 | if (!IS_ERR_VALUE(ret)) |
7833 | clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); | 7835 | mddev_clear_unsupported_flags(mddev, |
7836 | UNSUPPORTED_MDDEV_FLAGS); | ||
7834 | return ret; | 7837 | return ret; |
7835 | } | 7838 | } |
7836 | 7839 | ||