Always update mdadm/map when starting an array.

We previously only updated /var/run/mdadm/map when starting an
array with --incremental.  However we now make more use of
that file (to pass the dev name to udev) so always update it.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2008-11-04 20:50:38 +11:00
parent 9180c81bd7
commit a04d576343
5 changed files with 29 additions and 4 deletions

View File

@ -144,6 +144,7 @@ int Assemble(struct supertype *st, char *mddev,
int nextspare = 0;
char *name;
int trustworthy;
char chosen_name[1024];
memset(&info, 0, sizeof(info));
@ -429,7 +430,8 @@ int Assemble(struct supertype *st, char *mddev,
trustworthy = FOREIGN;
break;
}
mdfd = create_mddev(mddev, name, ident->autof, trustworthy, NULL);
mdfd = create_mddev(mddev, name, ident->autof, trustworthy,
chosen_name);
if (mdfd < 0) {
st->ss->free_super(st);
free(devices);
@ -437,6 +439,7 @@ int Assemble(struct supertype *st, char *mddev,
goto try_again;
return 1;
}
mddev = chosen_name;
vers = md_get_version(mdfd);
if (vers < 9000) {
fprintf(stderr, Name ": Assemble requires driver version 0.90.0 or later.\n"
@ -899,6 +902,12 @@ int Assemble(struct supertype *st, char *mddev,
if (!old_linux) {
int rv;
/* First, fill in the map, so that udev can find our name
* as soon as we become active.
*/
map_update(NULL, fd2devnum(mdfd), info.text_version,
info.uuid, chosen_name);
rv = set_array_info(mdfd, st, &info);
if (rv) {
fprintf(stderr, Name ": failed to set array info for %s: %s\n",

View File

@ -60,6 +60,8 @@ int Build(char *mddev, int chunk, int level, int layout,
unsigned long long size = ~0ULL;
unsigned long long bitmapsize;
int mdfd;
char chosen_name[1024];
int uuid[4] = {0,0,0,0};
/* scan all devices, make sure they really are block devices */
for (dv = devlist; dv; dv=dv->next) {
@ -114,10 +116,13 @@ int Build(char *mddev, int chunk, int level, int layout,
}
/* We need to create the device. It can have no name. */
mdfd = create_mddev(mddev, NULL, autof, LOCAL, NULL);
mdfd = create_mddev(mddev, NULL, autof, LOCAL,
chosen_name);
if (mdfd < 0)
return 1;
map_update(NULL, fd2devnum(mdfd), "none", uuid, chosen_name);
vers = md_get_version(mdfd);
/* looks Ok, go for it */

View File

@ -79,6 +79,7 @@ int Create(struct supertype *st, char *mddev,
struct mdinfo info, *infos;
int did_default = 0;
unsigned long safe_mode_delay = 0;
char chosen_name[1024];
int major_num = BITMAP_MAJOR_HI;
@ -421,7 +422,7 @@ int Create(struct supertype *st, char *mddev,
}
/* We need to create the device */
mdfd = create_mddev(mddev, name, autof, LOCAL, NULL);
mdfd = create_mddev(mddev, name, autof, LOCAL, chosen_name);
if (mdfd < 0)
return 1;
@ -439,6 +440,7 @@ int Create(struct supertype *st, char *mddev,
goto abort;
}
}
/* Ok, lets try some ioctls */
info.array.level = level;
@ -559,6 +561,9 @@ int Create(struct supertype *st, char *mddev,
" %s metadata\n", info.text_version);
}
map_update(NULL, fd2devnum(mdfd), info.text_version,
info.uuid, chosen_name);
if (bitmap_file && vers < 9003) {
major_num = BITMAP_MAJOR_HOSTENDIAN;
#ifdef __BIG_ENDIAN

View File

@ -161,7 +161,8 @@ int map_update(struct map_ent **mpp, int devnum, char *metadata,
}
if (!mp)
map_add(&map, devnum, metadata, uuid, path);
*mpp = NULL;
if (mpp)
*mpp = NULL;
rv = map_write(map);
map_free(map);
return rv;

View File

@ -75,6 +75,11 @@ int create_mddev(char *dev, char *name, int autof/*unused*/, int trustworthy,
return open_mddev(dev, 0);
}
#endif
int map_update(struct map_ent **mpp, int devnum, char *metadata,
int *uuid, char *path)
{
return 0;
}
int rv;
int mdfd = -1;