#include "mdadm.h"
#include <ctype.h>
-static int name_matches(char *found, char *required, char *homehost)
+static int name_matches(char *found, char *required, char *homehost, int require_homehost)
{
/* See if the name found matches the required name, possibly
* prefixed with 'homehost'
*/
- char fnd[33];
+ char *sep;
+ unsigned int l;
- strncpy(fnd, found, 32);
- fnd[32] = 0;
if (strcmp(found, required)==0)
return 1;
- if (homehost) {
- int l = strlen(homehost);
- if (l < 32 && fnd[l] == ':' &&
- strcmp(fnd+l+1, required)==0)
+ sep = strchr(found, ':');
+ if (!sep)
+ return 0;
+ l = sep - found;
+ if (strncmp(found, "any:", 4) == 0 ||
+ (homehost && strcmp(homehost, "any") == 0) ||
+ !require_homehost ||
+ (homehost && strlen(homehost) == l &&
+ strncmp(found, homehost, l) == 0)) {
+ /* matching homehost */
+ if (strcmp(sep+1, required) == 0)
return 1;
}
return 0;
static int ident_matches(struct mddev_ident *ident,
struct mdinfo *content,
struct supertype *tst,
- char *homehost,
+ char *homehost, int require_homehost,
char *update, char *devname)
{
return 0;
}
if (ident->name[0] && (!update || strcmp(update, "name")!= 0) &&
- name_matches(content->name, ident->name, homehost)==0) {
+ name_matches(content->name, ident->name, homehost, require_homehost)==0) {
if (devname)
pr_err("%s has wrong name.\n", devname);
return 0;
pr_err("no recogniseable superblock on %s\n",
devname);
tmpdev->used = 2;
- } else if (tst->ss->load_super(tst,dfd, NULL)) {
+ } else if ((tst->ignore_hw_compat = 0),
+ tst->ss->load_super(tst, dfd,
+ report_mismatch ? devname : NULL)) {
if (report_mismatch)
pr_err("no RAID superblock on %s\n",
devname);
content = content->next) {
if (!ident_matches(ident, content, tst,
- c->homehost, c->update,
+ c->homehost, c->require_homehost,
+ c->update,
report_mismatch ? devname : NULL))
/* message already printed */;
else if (is_member_busy(content->text_version)) {
tst->ss->getinfo_super(tst, content, NULL);
if (!ident_matches(ident, content, tst,
- c->homehost, c->update,
+ c->homehost, c->require_homehost,
+ c->update,
report_mismatch ? devname : NULL))
goto loop;
goto loop;
}
if (match && !ident_matches(match, content, tst,
- c->homehost, c->update,
+ c->homehost, c->require_homehost,
+ c->update,
report_mismatch ? devname : NULL))
/* Array exists in mdadm.conf but some
* details don't match, so reject it
if (strcmp(c->update, "byteorder") == 0)
err = 0;
- else
+ else if (strcmp(c->update, "home-cluster") == 0) {
+ tst->cluster_name = c->homecluster;
+ err = tst->ss->write_bitmap(tst, dfd, NameUpdate);
+ } else if (strcmp(c->update, "nodes") == 0) {
+ tst->nodes = c->nodes;
+ err = tst->ss->write_bitmap(tst, dfd, NodeNumUpdate);
+ } else
err = tst->ss->update_super(tst, content, c->update,
devname, c->verbose,
ident->uuid_set,
/* might need to increase the size
* of the stripe cache - default is 256
*/
- if (256 < 4 * (content->array.chunk_size/4096)) {
+ int chunk_size = content->array.chunk_size;
+ if (content->reshape_active &&
+ content->new_chunk > chunk_size)
+ chunk_size = content->new_chunk;
+ if (256 < 4 * ((chunk_size+4065)/4096)) {
struct mdinfo *sra = sysfs_read(mdfd, NULL, 0);
if (sra)
sysfs_set_num(sra, NULL,
"stripe_cache_size",
- (4 * content->array.chunk_size / 4096) + 1);
+ (4 * chunk_size / 4096) + 1);
sysfs_free(sra);
}
}
mddev ? mddev : "further assembly");
content = &info;
- if (st)
+ if (st && c->force)
st->ignore_hw_compat = 1;
num_devs = select_devices(devlist, ident, &st, &content, c,
inargv, auto_assem);
*/
if (map_lock(&map))
pr_err("failed to get exclusive lock on mapfile - continue anyway...\n");
- mp = map_by_uuid(&map, content->uuid);
+ if (c->update && strcmp(c->update,"uuid") == 0)
+ mp = NULL;
+ else
+ mp = map_by_uuid(&map, content->uuid);
if (mp) {
struct mdinfo *dv;
/* array already exists. */