Remove avail_disks arg from 'enough'.
It can easily be calculated from 'avail' and 'raid_disks', and we will soon have a case where we don't have it easily available to pass in. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
6ef89052d8
commit
de5a472ea3
16
Assemble.c
16
Assemble.c
|
@ -934,7 +934,7 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* If this devices thinks that 'most_recent' has failed, then
|
/* If this device thinks that 'most_recent' has failed, then
|
||||||
* we must reject this device.
|
* we must reject this device.
|
||||||
*/
|
*/
|
||||||
if (j != most_recent &&
|
if (j != most_recent &&
|
||||||
|
@ -965,7 +965,7 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
free(devmap);
|
free(devmap);
|
||||||
while (force && !enough(content->array.level, content->array.raid_disks,
|
while (force && !enough(content->array.level, content->array.raid_disks,
|
||||||
content->array.layout, 1,
|
content->array.layout, 1,
|
||||||
avail, okcnt)) {
|
avail)) {
|
||||||
/* Choose the newest best drive which is
|
/* Choose the newest best drive which is
|
||||||
* not up-to-date, update the superblock
|
* not up-to-date, update the superblock
|
||||||
* and add it.
|
* and add it.
|
||||||
|
@ -1132,7 +1132,7 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
if (force && !clean &&
|
if (force && !clean &&
|
||||||
!enough(content->array.level, content->array.raid_disks,
|
!enough(content->array.level, content->array.raid_disks,
|
||||||
content->array.layout, clean,
|
content->array.layout, clean,
|
||||||
avail, okcnt)) {
|
avail)) {
|
||||||
change += st->ss->update_super(st, content, "force-array",
|
change += st->ss->update_super(st, content, "force-array",
|
||||||
devices[chosen_drive].devname, verbose,
|
devices[chosen_drive].devname, verbose,
|
||||||
0, NULL);
|
0, NULL);
|
||||||
|
@ -1331,7 +1331,7 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
if (runstop == 1 ||
|
if (runstop == 1 ||
|
||||||
(runstop <= 0 &&
|
(runstop <= 0 &&
|
||||||
( enough(content->array.level, content->array.raid_disks,
|
( enough(content->array.level, content->array.raid_disks,
|
||||||
content->array.layout, clean, avail, okcnt) &&
|
content->array.layout, clean, avail) &&
|
||||||
(okcnt + rebuilding_cnt >= req_cnt || start_partial_ok)
|
(okcnt + rebuilding_cnt >= req_cnt || start_partial_ok)
|
||||||
))) {
|
))) {
|
||||||
/* This array is good-to-go.
|
/* This array is good-to-go.
|
||||||
|
@ -1437,13 +1437,13 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
mddev, strerror(errno));
|
mddev, strerror(errno));
|
||||||
|
|
||||||
if (!enough(content->array.level, content->array.raid_disks,
|
if (!enough(content->array.level, content->array.raid_disks,
|
||||||
content->array.layout, 1, avail, okcnt))
|
content->array.layout, 1, avail))
|
||||||
fprintf(stderr, Name ": Not enough devices to "
|
fprintf(stderr, Name ": Not enough devices to "
|
||||||
"start the array.\n");
|
"start the array.\n");
|
||||||
else if (!enough(content->array.level,
|
else if (!enough(content->array.level,
|
||||||
content->array.raid_disks,
|
content->array.raid_disks,
|
||||||
content->array.layout, clean,
|
content->array.layout, clean,
|
||||||
avail, okcnt))
|
avail))
|
||||||
fprintf(stderr, Name ": Not enough devices to "
|
fprintf(stderr, Name ": Not enough devices to "
|
||||||
"start the array while not clean "
|
"start the array while not clean "
|
||||||
"- consider --force.\n");
|
"- consider --force.\n");
|
||||||
|
@ -1471,12 +1471,12 @@ int Assemble(struct supertype *st, char *mddev,
|
||||||
if (sparecnt)
|
if (sparecnt)
|
||||||
fprintf(stderr, " and %d spare%s", sparecnt, sparecnt==1?"":"s");
|
fprintf(stderr, " and %d spare%s", sparecnt, sparecnt==1?"":"s");
|
||||||
if (!enough(content->array.level, content->array.raid_disks,
|
if (!enough(content->array.level, content->array.raid_disks,
|
||||||
content->array.layout, 1, avail, okcnt))
|
content->array.layout, 1, avail))
|
||||||
fprintf(stderr, " - not enough to start the array.\n");
|
fprintf(stderr, " - not enough to start the array.\n");
|
||||||
else if (!enough(content->array.level,
|
else if (!enough(content->array.level,
|
||||||
content->array.raid_disks,
|
content->array.raid_disks,
|
||||||
content->array.layout, clean,
|
content->array.layout, clean,
|
||||||
avail, okcnt))
|
avail))
|
||||||
fprintf(stderr, " - not enough to start the "
|
fprintf(stderr, " - not enough to start the "
|
||||||
"array while not clean - consider "
|
"array while not clean - consider "
|
||||||
"--force.\n");
|
"--force.\n");
|
||||||
|
|
4
Detail.c
4
Detail.c
|
@ -367,7 +367,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
|
||||||
if (avail_disks == array.raid_disks)
|
if (avail_disks == array.raid_disks)
|
||||||
st = "";
|
st = "";
|
||||||
else if (!enough(array.level, array.raid_disks,
|
else if (!enough(array.level, array.raid_disks,
|
||||||
array.layout, 1, avail, avail_disks))
|
array.layout, 1, avail))
|
||||||
st = ", FAILED";
|
st = ", FAILED";
|
||||||
else
|
else
|
||||||
st = ", degraded";
|
st = ", degraded";
|
||||||
|
@ -580,7 +580,7 @@ This is pretty boring
|
||||||
if (brief) printf("\n");
|
if (brief) printf("\n");
|
||||||
if (test &&
|
if (test &&
|
||||||
!enough(array.level, array.raid_disks, array.layout,
|
!enough(array.level, array.raid_disks, array.layout,
|
||||||
1, avail, avail_disks))
|
1, avail))
|
||||||
rv = 2;
|
rv = 2;
|
||||||
|
|
||||||
free(disks);
|
free(disks);
|
||||||
|
|
|
@ -486,7 +486,7 @@ int Incremental(char *devname, int verbose, int runstop,
|
||||||
active_disks = count_active(st, sra, mdfd, &avail, &info);
|
active_disks = count_active(st, sra, mdfd, &avail, &info);
|
||||||
if (enough(info.array.level, info.array.raid_disks,
|
if (enough(info.array.level, info.array.raid_disks,
|
||||||
info.array.layout, info.array.state & 1,
|
info.array.layout, info.array.state & 1,
|
||||||
avail, active_disks) == 0) {
|
avail) == 0) {
|
||||||
if (verbose >= 0)
|
if (verbose >= 0)
|
||||||
fprintf(stderr, Name
|
fprintf(stderr, Name
|
||||||
": %s attached to %s, not enough to start (%d).\n",
|
": %s attached to %s, not enough to start (%d).\n",
|
||||||
|
|
2
mdadm.h
2
mdadm.h
|
@ -1164,7 +1164,7 @@ extern char *fname_from_uuid(struct supertype *st,
|
||||||
struct mdinfo *info, char *buf, char sep);
|
struct mdinfo *info, char *buf, char sep);
|
||||||
extern unsigned long calc_csum(void *super, int bytes);
|
extern unsigned long calc_csum(void *super, int bytes);
|
||||||
extern int enough(int level, int raid_disks, int layout, int clean,
|
extern int enough(int level, int raid_disks, int layout, int clean,
|
||||||
char *avail, int avail_disks);
|
char *avail);
|
||||||
extern int enough_fd(int fd);
|
extern int enough_fd(int fd);
|
||||||
extern int ask(char *mesg);
|
extern int ask(char *mesg);
|
||||||
extern unsigned long long get_component_size(int fd);
|
extern unsigned long long get_component_size(int fd);
|
||||||
|
|
11
util.c
11
util.c
|
@ -311,10 +311,15 @@ int test_partition_from_id(dev_t id)
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int enough(int level, int raid_disks, int layout, int clean,
|
int enough(int level, int raid_disks, int layout, int clean, char *avail)
|
||||||
char *avail, int avail_disks)
|
|
||||||
{
|
{
|
||||||
int copies, first;
|
int copies, first;
|
||||||
|
int i;
|
||||||
|
int avail_disks = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < raid_disks; i++)
|
||||||
|
avail_disks += !!avail[i];
|
||||||
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case 10:
|
case 10:
|
||||||
/* This is the tricky one - we need to check
|
/* This is the tricky one - we need to check
|
||||||
|
@ -389,7 +394,7 @@ int enough_fd(int fd)
|
||||||
}
|
}
|
||||||
/* This is used on an active array, so assume it is clean */
|
/* This is used on an active array, so assume it is clean */
|
||||||
rv = enough(array.level, array.raid_disks, array.layout,
|
rv = enough(array.level, array.raid_disks, array.layout,
|
||||||
1, avail, avail_disks);
|
1, avail);
|
||||||
free(avail);
|
free(avail);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue