Commit 394ed8e4 authored by Shaohua Li's avatar Shaohua Li

md: cleanup mddev flag clear for takeover

Commit 6995f0b2 (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: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
parent 99f17890
...@@ -212,6 +212,7 @@ extern int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors, ...@@ -212,6 +212,7 @@ extern int rdev_clear_badblocks(struct md_rdev *rdev, sector_t s, int sectors,
int is_new); int is_new);
struct md_cluster_info; struct md_cluster_info;
/* change UNSUPPORTED_MDDEV_FLAGS for each array type if new flag is added */
enum mddev_flags { enum mddev_flags {
MD_ARRAY_FIRST_USE, /* First use of array, needs initialization */ MD_ARRAY_FIRST_USE, /* First use of array, needs initialization */
MD_CLOSING, /* If set, we are closing the array, do not open 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,4 +703,11 @@ static inline int mddev_is_clustered(struct mddev *mddev)
{ {
return mddev->cluster_info && mddev->bitmap_info.nodes > 1; return mddev->cluster_info && mddev->bitmap_info.nodes > 1;
} }
/* clear unsupported mddev_flags */
static inline void mddev_clear_unsupported_flags(struct mddev *mddev,
unsigned long unsupported_flags)
{
mddev->flags &= ~unsupported_flags;
}
#endif /* _MD_MD_H */ #endif /* _MD_MD_H */
...@@ -26,6 +26,11 @@ ...@@ -26,6 +26,11 @@
#include "raid0.h" #include "raid0.h"
#include "raid5.h" #include "raid5.h"
#define UNSUPPORTED_MDDEV_FLAGS \
((1L << MD_HAS_JOURNAL) | \
(1L << MD_JOURNAL_CLEAN) | \
(1L << MD_FAILFAST_SUPPORTED))
static int raid0_congested(struct mddev *mddev, int bits) static int raid0_congested(struct mddev *mddev, int bits)
{ {
struct r0conf *conf = mddev->private; struct r0conf *conf = mddev->private;
...@@ -539,8 +544,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev) ...@@ -539,8 +544,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev)
mddev->delta_disks = -1; mddev->delta_disks = -1;
/* make sure it will be not marked as dirty */ /* make sure it will be not marked as dirty */
mddev->recovery_cp = MaxSector; mddev->recovery_cp = MaxSector;
clear_bit(MD_HAS_JOURNAL, &mddev->flags); mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS);
clear_bit(MD_JOURNAL_CLEAN, &mddev->flags);
create_strip_zones(mddev, &priv_conf); create_strip_zones(mddev, &priv_conf);
...@@ -583,7 +587,7 @@ static void *raid0_takeover_raid10(struct mddev *mddev) ...@@ -583,7 +587,7 @@ static void *raid0_takeover_raid10(struct mddev *mddev)
mddev->degraded = 0; mddev->degraded = 0;
/* make sure it will be not marked as dirty */ /* make sure it will be not marked as dirty */
mddev->recovery_cp = MaxSector; mddev->recovery_cp = MaxSector;
clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS);
create_strip_zones(mddev, &priv_conf); create_strip_zones(mddev, &priv_conf);
return priv_conf; return priv_conf;
...@@ -626,7 +630,7 @@ static void *raid0_takeover_raid1(struct mddev *mddev) ...@@ -626,7 +630,7 @@ static void *raid0_takeover_raid1(struct mddev *mddev)
mddev->raid_disks = 1; mddev->raid_disks = 1;
/* make sure it will be not marked as dirty */ /* make sure it will be not marked as dirty */
mddev->recovery_cp = MaxSector; mddev->recovery_cp = MaxSector;
clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); mddev_clear_unsupported_flags(mddev, UNSUPPORTED_MDDEV_FLAGS);
create_strip_zones(mddev, &priv_conf); create_strip_zones(mddev, &priv_conf);
return priv_conf; return priv_conf;
......
...@@ -42,6 +42,10 @@ ...@@ -42,6 +42,10 @@
#include "raid1.h" #include "raid1.h"
#include "bitmap.h" #include "bitmap.h"
#define UNSUPPORTED_MDDEV_FLAGS \
((1L << MD_HAS_JOURNAL) | \
(1L << MD_JOURNAL_CLEAN))
/* /*
* Number of guaranteed r1bios in case of extreme VM load: * Number of guaranteed r1bios in case of extreme VM load:
*/ */
...@@ -3257,8 +3261,8 @@ static void *raid1_takeover(struct mddev *mddev) ...@@ -3257,8 +3261,8 @@ static void *raid1_takeover(struct mddev *mddev)
if (!IS_ERR(conf)) { if (!IS_ERR(conf)) {
/* Array must appear to be quiesced */ /* Array must appear to be quiesced */
conf->array_frozen = 1; conf->array_frozen = 1;
clear_bit(MD_HAS_JOURNAL, &mddev->flags); mddev_clear_unsupported_flags(mddev,
clear_bit(MD_JOURNAL_CLEAN, &mddev->flags); UNSUPPORTED_MDDEV_FLAGS);
} }
return conf; return conf;
} }
......
...@@ -62,6 +62,8 @@ ...@@ -62,6 +62,8 @@
#include "raid0.h" #include "raid0.h"
#include "bitmap.h" #include "bitmap.h"
#define UNSUPPORTED_MDDEV_FLAGS (1L << MD_FAILFAST_SUPPORTED)
#define cpu_to_group(cpu) cpu_to_node(cpu) #define cpu_to_group(cpu) cpu_to_node(cpu)
#define ANY_GROUP NUMA_NO_NODE #define ANY_GROUP NUMA_NO_NODE
...@@ -7830,7 +7832,8 @@ static void *raid5_takeover_raid1(struct mddev *mddev) ...@@ -7830,7 +7832,8 @@ static void *raid5_takeover_raid1(struct mddev *mddev)
ret = setup_conf(mddev); ret = setup_conf(mddev);
if (!IS_ERR_VALUE(ret)) if (!IS_ERR_VALUE(ret))
clear_bit(MD_FAILFAST_SUPPORTED, &mddev->flags); mddev_clear_unsupported_flags(mddev,
UNSUPPORTED_MDDEV_FLAGS);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment