FIX: delta_disk can have UnSet value
Delta_disk can be set to UnSet value. This can a cause to pass wrong parameter to reshape_super(). To avoid such situations raid_disks and delta_disks parameters have to be passed to reshape_super() separately. It will be up to reshape_super() function validation and usage of this parameters to avoid not valid values. Signed-off-by: Adam Kwolek <adam.kwolek@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
196b0d4497
commit
41784c88f3
15
Grow.c
15
Grow.c
|
@ -565,7 +565,8 @@ static void wait_reshape(struct mdinfo *sra)
|
||||||
|
|
||||||
static int reshape_super(struct supertype *st, long long size, int level,
|
static int reshape_super(struct supertype *st, long long size, int level,
|
||||||
int layout, int chunksize, int raid_disks,
|
int layout, int chunksize, int raid_disks,
|
||||||
char *backup_file, char *dev, int verbose)
|
int delta_disks, char *backup_file, char *dev,
|
||||||
|
int verbose)
|
||||||
{
|
{
|
||||||
/* nothing extra to check in the native case */
|
/* nothing extra to check in the native case */
|
||||||
if (!st->ss->external)
|
if (!st->ss->external)
|
||||||
|
@ -578,7 +579,8 @@ static int reshape_super(struct supertype *st, long long size, int level,
|
||||||
}
|
}
|
||||||
|
|
||||||
return st->ss->reshape_super(st, size, level, layout, chunksize,
|
return st->ss->reshape_super(st, size, level, layout, chunksize,
|
||||||
raid_disks, backup_file, dev, verbose);
|
raid_disks, delta_disks, backup_file, dev,
|
||||||
|
verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sync_metadata(struct supertype *st)
|
static void sync_metadata(struct supertype *st)
|
||||||
|
@ -1416,7 +1418,8 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
|
||||||
if (size >= 0 && (size == 0 || size != array.size)) {
|
if (size >= 0 && (size == 0 || size != array.size)) {
|
||||||
long long orig_size = array.size;
|
long long orig_size = array.size;
|
||||||
|
|
||||||
if (reshape_super(st, size, UnSet, UnSet, 0, 0, NULL, devname, !quiet)) {
|
if (reshape_super(st, size, UnSet, UnSet, 0, 0, UnSet, NULL,
|
||||||
|
devname, !quiet)) {
|
||||||
rv = 1;
|
rv = 1;
|
||||||
goto release;
|
goto release;
|
||||||
}
|
}
|
||||||
|
@ -1438,7 +1441,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
|
||||||
|
|
||||||
/* restore metadata */
|
/* restore metadata */
|
||||||
if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0,
|
if (reshape_super(st, orig_size, UnSet, UnSet, 0, 0,
|
||||||
NULL, devname, !quiet) == 0)
|
UnSet, NULL, devname, !quiet) == 0)
|
||||||
sync_metadata(st);
|
sync_metadata(st);
|
||||||
fprintf(stderr, Name ": Cannot set device size for %s: %s\n",
|
fprintf(stderr, Name ": Cannot set device size for %s: %s\n",
|
||||||
devname, strerror(err));
|
devname, strerror(err));
|
||||||
|
@ -1575,7 +1578,7 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
|
||||||
|
|
||||||
if (reshape_super(st, info.component_size, info.new_level,
|
if (reshape_super(st, info.component_size, info.new_level,
|
||||||
info.new_layout, info.new_chunk,
|
info.new_layout, info.new_chunk,
|
||||||
info.array.raid_disks + info.delta_disks,
|
info.array.raid_disks, info.delta_disks,
|
||||||
backup_file, devname, quiet)) {
|
backup_file, devname, quiet)) {
|
||||||
rv = 1;
|
rv = 1;
|
||||||
goto release;
|
goto release;
|
||||||
|
@ -2123,7 +2126,7 @@ int reshape_container(char *container, int cfd, char *devname,
|
||||||
*/
|
*/
|
||||||
if (reshape_super(st, -1, info->new_level,
|
if (reshape_super(st, -1, info->new_level,
|
||||||
info->new_layout, info->new_chunk,
|
info->new_layout, info->new_chunk,
|
||||||
info->array.raid_disks + info->delta_disks,
|
info->array.raid_disks, info->delta_disks,
|
||||||
backup_file, devname, quiet)) {
|
backup_file, devname, quiet)) {
|
||||||
unfreeze(st);
|
unfreeze(st);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
3
mdadm.h
3
mdadm.h
|
@ -719,7 +719,8 @@ extern struct superswitch {
|
||||||
*/
|
*/
|
||||||
int (*reshape_super)(struct supertype *st, long long size, int level,
|
int (*reshape_super)(struct supertype *st, long long size, int level,
|
||||||
int layout, int chunksize, int raid_disks,
|
int layout, int chunksize, int raid_disks,
|
||||||
char *backup, char *dev, int verbose); /* optional */
|
int delta_disks, char *backup, char *dev,
|
||||||
|
int verbose); /* optional */
|
||||||
int (*manage_reshape)( /* optional */
|
int (*manage_reshape)( /* optional */
|
||||||
int afd, struct mdinfo *sra, struct reshape *reshape,
|
int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||||
struct supertype *st, unsigned long blocks,
|
struct supertype *st, unsigned long blocks,
|
||||||
|
|
|
@ -7053,7 +7053,8 @@ int imsm_takeover(struct supertype *st, struct geo_params *geo)
|
||||||
|
|
||||||
static int imsm_reshape_super(struct supertype *st, long long size, int level,
|
static int imsm_reshape_super(struct supertype *st, long long size, int level,
|
||||||
int layout, int chunksize, int raid_disks,
|
int layout, int chunksize, int raid_disks,
|
||||||
char *backup, char *dev, int verbose)
|
int delta_disks, char *backup, char *dev,
|
||||||
|
int verbose)
|
||||||
{
|
{
|
||||||
int ret_val = 1;
|
int ret_val = 1;
|
||||||
struct geo_params geo;
|
struct geo_params geo;
|
||||||
|
@ -7069,6 +7070,8 @@ static int imsm_reshape_super(struct supertype *st, long long size, int level,
|
||||||
geo.layout = layout;
|
geo.layout = layout;
|
||||||
geo.chunksize = chunksize;
|
geo.chunksize = chunksize;
|
||||||
geo.raid_disks = raid_disks;
|
geo.raid_disks = raid_disks;
|
||||||
|
if (delta_disks != UnSet)
|
||||||
|
geo.raid_disks += delta_disks;
|
||||||
|
|
||||||
dprintf("\tfor level : %i\n", geo.level);
|
dprintf("\tfor level : %i\n", geo.level);
|
||||||
dprintf("\tfor raid_disks : %i\n", geo.raid_disks);
|
dprintf("\tfor raid_disks : %i\n", geo.raid_disks);
|
||||||
|
|
Loading…
Reference in New Issue