getinfo_super now clears the 'info' structure before filling it in.

Some code currently clears 'info' before calling getinfo_super,
some code doesn't.

To be consistent, change it so no caller ever clears 'info',
but ever getinfo_super function must clear it.

Note that ->raid_disk may be meaningful if that 'map' is passed
non-NULL.  In that case it is copied out before the structure
is zeroed.

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2011-06-08 15:54:13 +10:00
parent 58b3c6976a
commit 95eeceeb32
8 changed files with 8 additions and 6 deletions

View File

@ -418,7 +418,6 @@ int Assemble(struct supertype *st, char *mddev,
int uuid[4]; int uuid[4];
content = &info; content = &info;
memset(content, 0, sizeof(*content));
tst->ss->getinfo_super(tst, content, NULL); tst->ss->getinfo_super(tst, content, NULL);
if (!parse_uuid(ident->container, uuid) || if (!parse_uuid(ident->container, uuid) ||
@ -484,7 +483,6 @@ int Assemble(struct supertype *st, char *mddev,
} else { } else {
content = &info; content = &info;
memset(content, 0, sizeof(*content));
tst->ss->getinfo_super(tst, content, NULL); tst->ss->getinfo_super(tst, content, NULL);
if (!ident_matches(ident, content, tst, if (!ident_matches(ident, content, tst,

View File

@ -658,8 +658,8 @@ int Create(struct supertype *st, char *mddev,
goto abort; goto abort;
total_slots = info.array.nr_disks; total_slots = info.array.nr_disks;
sysfs_init(&info, mdfd, 0);
st->ss->getinfo_super(st, &info, NULL); st->ss->getinfo_super(st, &info, NULL);
sysfs_init(&info, mdfd, 0);
if (did_default && verbose >= 0) { if (did_default && verbose >= 0) {
if (is_subarray(info.text_version)) { if (is_subarray(info.text_version)) {

View File

@ -202,7 +202,6 @@ int Incremental(char *devname, int verbose, int runstop,
} }
close (dfd); dfd = -1; close (dfd); dfd = -1;
memset(&info, 0, sizeof(info));
st->ss->getinfo_super(st, &info, NULL); st->ss->getinfo_super(st, &info, NULL);
/* 3/ Check if there is a match in mdadm.conf */ /* 3/ Check if there is a match in mdadm.conf */
@ -396,7 +395,6 @@ int Incremental(char *devname, int verbose, int runstop,
goto out; goto out;
} }
close(dfd2); close(dfd2);
memset(&info2, 0, sizeof(info2));
st2->ss->getinfo_super(st2, &info2, NULL); st2->ss->getinfo_super(st2, &info2, NULL);
st2->ss->free_super(st2); st2->ss->free_super(st2);
if (info.array.level != info2.array.level || if (info.array.level != info2.array.level ||
@ -1435,7 +1433,6 @@ static int Incremental_container(struct supertype *st, char *devname,
int suuid[4]; int suuid[4];
int sfd; int sfd;
memset(&info, 0, sizeof(info));
st->ss->getinfo_super(st, &info, NULL); st->ss->getinfo_super(st, &info, NULL);
if ((runstop > 0 && info.container_enough >= 0) || if ((runstop > 0 && info.container_enough >= 0) ||

View File

@ -616,6 +616,7 @@ extern struct superswitch {
* (raid_disk must already be set and correct) and it is filled * (raid_disk must already be set and correct) and it is filled
* with 1 for slots that are thought to be active and 0 for slots which * with 1 for slots that are thought to be active and 0 for slots which
* appear to be failed/missing. * appear to be failed/missing.
* *info is zeroed out before data is added.
*/ */
void (*getinfo_super)(struct supertype *st, struct mdinfo *info, char *map); void (*getinfo_super)(struct supertype *st, struct mdinfo *info, char *map);
struct mdinfo *(*getinfo_super_disks)(struct supertype *st); struct mdinfo *(*getinfo_super_disks)(struct supertype *st);

View File

@ -1341,6 +1341,7 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
getinfo_super_ddf_bvd(st, info, map); getinfo_super_ddf_bvd(st, info, map);
return; return;
} }
memset(info, 0, sizeof(*info));
info->array.raid_disks = __be16_to_cpu(ddf->phys->used_pdes); info->array.raid_disks = __be16_to_cpu(ddf->phys->used_pdes);
info->array.level = LEVEL_CONTAINER; info->array.level = LEVEL_CONTAINER;
@ -1406,6 +1407,7 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
struct dl *dl; struct dl *dl;
int map_disks = info->array.raid_disks; int map_disks = info->array.raid_disks;
memset(info, 0, sizeof(*info));
/* FIXME this returns BVD info - what if we want SVD ?? */ /* FIXME this returns BVD info - what if we want SVD ?? */
info->array.raid_disks = __be16_to_cpu(vc->conf.prim_elmnt_count); info->array.raid_disks = __be16_to_cpu(vc->conf.prim_elmnt_count);

View File

@ -1764,6 +1764,7 @@ static void getinfo_super_imsm_volume(struct supertype *st, struct mdinfo *info,
unsigned int component_size_alligment; unsigned int component_size_alligment;
int map_disks = info->array.raid_disks; int map_disks = info->array.raid_disks;
memset(info, 0, sizeof(*info));
if (prev_map) if (prev_map)
map_to_analyse = prev_map; map_to_analyse = prev_map;
@ -1972,6 +1973,7 @@ static void getinfo_super_imsm(struct supertype *st, struct mdinfo *info, char *
getinfo_super_imsm_volume(st, info, map); getinfo_super_imsm_volume(st, info, map);
return; return;
} }
memset(info, 0, sizeof(*info));
/* Set raid_disks to zero so that Assemble will always pull in valid /* Set raid_disks to zero so that Assemble will always pull in valid
* spares * spares

View File

@ -346,6 +346,7 @@ static void getinfo_super0(struct supertype *st, struct mdinfo *info, char *map)
int i; int i;
int map_disks = info->array.raid_disks; int map_disks = info->array.raid_disks;
memset(info, 0, sizeof(*info));
info->array.major_version = sb->major_version; info->array.major_version = sb->major_version;
info->array.minor_version = sb->minor_version; info->array.minor_version = sb->minor_version;
info->array.patch_version = sb->patch_version; info->array.patch_version = sb->patch_version;

View File

@ -566,6 +566,7 @@ static void getinfo_super1(struct supertype *st, struct mdinfo *info, char *map)
unsigned int role; unsigned int role;
unsigned int map_disks = info->array.raid_disks; unsigned int map_disks = info->array.raid_disks;
memset(info, 0, sizeof(*info));
info->array.major_version = 1; info->array.major_version = 1;
info->array.minor_version = st->minor_version; info->array.minor_version = st->minor_version;
info->array.patch_version = 0; info->array.patch_version = 0;