summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Incremental.c82
-rw-r--r--config.c26
-rw-r--r--mapfile.c4
-rw-r--r--mdadm.h5
4 files changed, 26 insertions, 91 deletions
diff --git a/Incremental.c b/Incremental.c
index 98a3a746..b5d3e025 100644
--- a/Incremental.c
+++ b/Incremental.c
@@ -47,11 +47,6 @@ static int Incremental_container(struct supertype *st, char *devname,
int verbose, int runstop, int autof,
int freeze_reshape);
-static struct mddev_ident *search_mdstat(struct supertype *st,
- struct mdinfo *info,
- char *devname,
- int verbose, int *rvp);
-
int Incremental(char *devname, int verbose, int runstop,
struct supertype *st, char *homehost, int require_homehost,
int autof, int freeze_reshape)
@@ -213,7 +208,7 @@ int Incremental(char *devname, int verbose, int runstop,
st->ss->getinfo_super(st, &info, NULL);
/* 3/ Check if there is a match in mdadm.conf */
- match = search_mdstat(st, &info, devname, verbose, &rv);
+ match = conf_match(st, &info, devname, verbose, &rv);
if (!match && rv == 2)
goto out;
@@ -591,79 +586,6 @@ out_unlock:
goto out;
}
-static struct mddev_ident *search_mdstat(struct supertype *st,
- struct mdinfo *info,
- char *devname,
- int verbose, int *rvp)
-{
- struct mddev_ident *array_list, *match;
- array_list = conf_get_ident(NULL);
- match = NULL;
- for (; array_list; array_list = array_list->next) {
- if (array_list->uuid_set &&
- same_uuid(array_list->uuid, info->uuid, st->ss->swapuuid)
- == 0) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": UUID differs from %s.\n",
- array_list->devname);
- continue;
- }
- if (array_list->name[0] &&
- strcasecmp(array_list->name, info->name) != 0) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": Name differs from %s.\n",
- array_list->devname);
- continue;
- }
- if (array_list->devices &&
- !match_oneof(array_list->devices, devname)) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": Not a listed device for %s.\n",
- array_list->devname);
- continue;
- }
- if (array_list->super_minor != UnSet &&
- array_list->super_minor != info->array.md_minor) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": Different super-minor to %s.\n",
- array_list->devname);
- continue;
- }
- if (!array_list->uuid_set &&
- !array_list->name[0] &&
- !array_list->devices &&
- array_list->super_minor == UnSet) {
- if (verbose >= 2 && array_list->devname)
- fprintf(stderr, Name
- ": %s doesn't have any identifying information.\n",
- array_list->devname);
- continue;
- }
- /* FIXME, should I check raid_disks and level too?? */
-
- if (match) {
- if (verbose >= 0) {
- if (match->devname && array_list->devname)
- fprintf(stderr, Name
- ": we match both %s and %s - cannot decide which to use.\n",
- match->devname, array_list->devname);
- else
- fprintf(stderr, Name
- ": multiple lines in mdadm.conf match\n");
- }
- *rvp = 2;
- match = NULL;
- break;
- }
- match = array_list;
- }
- return match;
-}
-
static void find_reject(int mdfd, struct supertype *st, struct mdinfo *sra,
int number, __u64 events, int verbose,
char *array_name)
@@ -1460,7 +1382,7 @@ static int Incremental_container(struct supertype *st, char *devname,
return 0;
}
- match = search_mdstat(st, &info, devname, verbose, &rv);
+ match = conf_match(st, &info, devname, verbose, &rv);
if (match == NULL && rv == 2)
return rv;
diff --git a/config.c b/config.c
index c0a6baaf..597e0460 100644
--- a/config.c
+++ b/config.c
@@ -1019,11 +1019,12 @@ int conf_name_is_free(char *name)
return 1;
}
-struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
+struct mddev_ident *conf_match(struct supertype *st,
+ struct mdinfo *info,
+ char *devname,
+ int verbose, int *rvp)
{
struct mddev_ident *array_list, *match;
- int verbose = 0;
- char *devname = NULL;
array_list = conf_get_ident(NULL);
match = NULL;
for (; array_list; array_list = array_list->next) {
@@ -1044,7 +1045,7 @@ struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
array_list->devname);
continue;
}
- if (array_list->devices && devname &&
+ if (array_list->devices &&
!match_oneof(array_list->devices, devname)) {
if (verbose >= 2 && array_list->devname)
fprintf(stderr, Name
@@ -1066,7 +1067,8 @@ struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
array_list->super_minor == UnSet) {
if (verbose >= 2 && array_list->devname)
fprintf(stderr, Name
- ": %s doesn't have any identifying information.\n",
+ ": %s doesn't have any identifying"
+ " information.\n",
array_list->devname);
continue;
}
@@ -1076,13 +1078,19 @@ struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st)
if (verbose >= 0) {
if (match->devname && array_list->devname)
fprintf(stderr, Name
- ": we match both %s and %s - cannot decide which to use.\n",
- match->devname, array_list->devname);
+ ": we match both %s and %s - "
+ "cannot decide which to use.\n",
+ match->devname,
+ array_list->devname);
else
fprintf(stderr, Name
- ": multiple lines in mdadm.conf match\n");
+ ": multiple lines in mdadm.conf"
+ " match\n");
}
- return NULL;
+ if (rvp)
+ *rvp = 2;
+ match = NULL;
+ break;
}
match = array_list;
}
diff --git a/mapfile.c b/mapfile.c
index 997f0954..0bfecd05 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -431,7 +431,9 @@ void RebuildMap(void)
* find a unique name based on metadata name.
*
*/
- struct mddev_ident *match = conf_match(info, st);
+ struct mddev_ident *match = conf_match(st, info,
+ NULL, 0,
+ NULL);
struct stat stb;
if (match && match->devname && match->devname[0] == '/') {
path = match->devname;
diff --git a/mdadm.h b/mdadm.h
index 6dbc5ead..e5dac79c 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1146,7 +1146,10 @@ extern char *conf_line(FILE *file);
extern char *conf_word(FILE *file, int allow_key);
extern int conf_name_is_free(char *name);
extern int devname_matches(char *name, char *match);
-extern struct mddev_ident *conf_match(struct mdinfo *info, struct supertype *st);
+extern struct mddev_ident *conf_match(struct supertype *st,
+ struct mdinfo *info,
+ char *devname,
+ int verbose, int *rvp);
extern int experimental(void);
extern void free_line(char *line);