Make child_monitor a candidate for ->manage_reshape
Child_monitor was design to perform 'manage_reshape' for native arrays. So change the signature for ->manage_reshape to match child_monitor and move the all to the same place that child_monitor is called from. Also give super-intel a manage_reshape handler which simple calls child_monitor. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
da8100ca48
commit
999b497251
61
Grow.c
61
Grow.c
|
@ -867,30 +867,6 @@ unsigned long compute_backup_blocks(int nchunk, int ochunk,
|
|||
return blocks;
|
||||
}
|
||||
|
||||
/* 'struct reshape' records the intermediate states
|
||||
* a general reshape.
|
||||
* The starting geometry is converted to the 'before' geometry
|
||||
* by at most an atomic level change. They could be the same.
|
||||
* Similarly the 'after' geometry is converted to the final
|
||||
* geometry by at most a level change.
|
||||
* Note that 'before' and 'after' must have the same level.
|
||||
* 'blocks' is the minimum number of sectors for a reshape unit.
|
||||
* This will be a multiple of the stripe size in each of the
|
||||
* 'before' and 'after' geometries.
|
||||
* If 'blocks' is 0, no restriping is necessary.
|
||||
*/
|
||||
struct reshape {
|
||||
int level;
|
||||
int parity; /* number of parity blocks/devices */
|
||||
struct {
|
||||
int layout;
|
||||
int data_disks;
|
||||
} before, after;
|
||||
unsigned long long backup_blocks;
|
||||
unsigned long long stripes; /* number of old stripes that comprise 'blocks'*/
|
||||
unsigned long long new_size; /* New size of array in sectors */
|
||||
};
|
||||
|
||||
char *analyse_change(struct mdinfo *info, struct reshape *re)
|
||||
{
|
||||
/* Based on the current array state in info->array and
|
||||
|
@ -1277,11 +1253,6 @@ static int reshape_container(char *container, int cfd, char *devname,
|
|||
int force,
|
||||
char *backup_file,
|
||||
int quiet);
|
||||
static int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||
struct supertype *st, unsigned long stripes,
|
||||
int *fds, unsigned long long *offsets,
|
||||
int dests, int *destfd, unsigned long long *destoffsets);
|
||||
|
||||
|
||||
int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
|
||||
long long size,
|
||||
|
@ -1944,14 +1915,6 @@ static int reshape_array(char *container, int fd, char *devname,
|
|||
}
|
||||
|
||||
start_reshape(sra);
|
||||
if (st->ss->external) {
|
||||
/* metadata handler takes it from here */
|
||||
ping_manager(container);
|
||||
st->ss->manage_reshape(st, backup_file);
|
||||
frozen = 0;
|
||||
goto release;
|
||||
}
|
||||
|
||||
|
||||
/* Now we just need to kick off the reshape and watch, while
|
||||
* handling backups of the data...
|
||||
|
@ -1968,9 +1931,19 @@ static int reshape_array(char *container, int fd, char *devname,
|
|||
|
||||
odisks = reshape.before.data_disks + reshape.parity;
|
||||
|
||||
done = child_monitor(fd, sra, &reshape, st, blocks,
|
||||
fdlist, offsets,
|
||||
d - odisks, fdlist+odisks, offsets+odisks);
|
||||
if (st->ss->external) {
|
||||
/* metadata handler takes it from here */
|
||||
done = st->ss->manage_reshape(
|
||||
fd, sra, &reshape, st, blocks,
|
||||
fdlist, offsets,
|
||||
d - odisks, fdlist+odisks,
|
||||
offsets+odisks);
|
||||
} else
|
||||
done = child_monitor(
|
||||
fd, sra, &reshape, st, blocks,
|
||||
fdlist, offsets,
|
||||
d - odisks, fdlist+odisks,
|
||||
offsets+odisks);
|
||||
|
||||
if (backup_file && done)
|
||||
unlink(backup_file);
|
||||
|
@ -2692,10 +2665,10 @@ static void validate(int afd, int bfd, unsigned long long offset)
|
|||
}
|
||||
}
|
||||
|
||||
static int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||
struct supertype *st, unsigned long blocks,
|
||||
int *fds, unsigned long long *offsets,
|
||||
int dests, int *destfd, unsigned long long *destoffsets)
|
||||
int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||
struct supertype *st, unsigned long blocks,
|
||||
int *fds, unsigned long long *offsets,
|
||||
int dests, int *destfd, unsigned long long *destoffsets)
|
||||
{
|
||||
/* Monitor a reshape where backup is being performed using
|
||||
* 'native' mechanism - either to a backup file, or
|
||||
|
|
36
mdadm.h
36
mdadm.h
|
@ -521,6 +521,31 @@ extern char *map_dev(int major, int minor, int create);
|
|||
struct active_array;
|
||||
struct metadata_update;
|
||||
|
||||
|
||||
/* 'struct reshape' records the intermediate states
|
||||
* a general reshape.
|
||||
* The starting geometry is converted to the 'before' geometry
|
||||
* by at most an atomic level change. They could be the same.
|
||||
* Similarly the 'after' geometry is converted to the final
|
||||
* geometry by at most a level change.
|
||||
* Note that 'before' and 'after' must have the same level.
|
||||
* 'blocks' is the minimum number of sectors for a reshape unit.
|
||||
* This will be a multiple of the stripe size in each of the
|
||||
* 'before' and 'after' geometries.
|
||||
* If 'blocks' is 0, no restriping is necessary.
|
||||
*/
|
||||
struct reshape {
|
||||
int level;
|
||||
int parity; /* number of parity blocks/devices */
|
||||
struct {
|
||||
int layout;
|
||||
int data_disks;
|
||||
} before, after;
|
||||
unsigned long long backup_blocks;
|
||||
unsigned long long stripes; /* number of old stripes that comprise 'blocks'*/
|
||||
unsigned long long new_size; /* New size of array in sectors */
|
||||
};
|
||||
|
||||
/* A superswitch provides entry point the a metadata handler.
|
||||
*
|
||||
* The super_switch primarily operates on some "metadata" that
|
||||
|
@ -693,7 +718,11 @@ extern struct superswitch {
|
|||
int (*reshape_super)(struct supertype *st, long long size, int level,
|
||||
int layout, int chunksize, int raid_disks,
|
||||
char *backup, char *dev, int verbose); /* optional */
|
||||
int (*manage_reshape)(struct supertype *st, char *backup); /* optional */
|
||||
int (*manage_reshape)( /* optional */
|
||||
int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||
struct supertype *st, unsigned long blocks,
|
||||
int *fds, unsigned long long *offsets,
|
||||
int dests, int *destfd, unsigned long long *destoffsets);
|
||||
|
||||
/* for mdmon */
|
||||
int (*open_new)(struct supertype *c, struct active_array *a,
|
||||
|
@ -1141,6 +1170,11 @@ extern int check_env(char *name);
|
|||
extern __u32 random32(void);
|
||||
extern int start_mdmon(int devnum);
|
||||
|
||||
extern int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||
struct supertype *st, unsigned long stripes,
|
||||
int *fds, unsigned long long *offsets,
|
||||
int dests, int *destfd, unsigned long long *destoffsets);
|
||||
|
||||
extern char *devnum2devname(int num);
|
||||
extern void fmt_devname(char *name, int num);
|
||||
extern int devname2devnum(char *name);
|
||||
|
|
9
mdmon.c
9
mdmon.c
|
@ -517,3 +517,12 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover)
|
|||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Some stub functions so super-* can link with us */
|
||||
int child_monitor(int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||
struct supertype *st, unsigned long blocks,
|
||||
int *fds, unsigned long long *offsets,
|
||||
int dests, int *destfd, unsigned long long *destoffsets)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -6633,6 +6633,18 @@ exit_imsm_reshape_super:
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
static int imsm_manage_reshape(
|
||||
int afd, struct mdinfo *sra, struct reshape *reshape,
|
||||
struct supertype *st, unsigned long stripes,
|
||||
int *fds, unsigned long long *offsets,
|
||||
int dests, int *destfd, unsigned long long *destoffsets)
|
||||
{
|
||||
/* Just use child_monitor for now */
|
||||
return child_monitor(
|
||||
afd, sra, reshape, st, stripes,
|
||||
fds, offsets, dests, destfd, destoffsets);
|
||||
}
|
||||
|
||||
struct superswitch super_imsm = {
|
||||
#ifndef MDASSEMBLE
|
||||
.examine_super = examine_super_imsm,
|
||||
|
@ -6670,6 +6682,7 @@ struct superswitch super_imsm = {
|
|||
.default_geometry = default_geometry_imsm,
|
||||
.get_disk_controller_domain = imsm_get_disk_controller_domain,
|
||||
.reshape_super = imsm_reshape_super,
|
||||
.manage_reshape = imsm_manage_reshape,
|
||||
|
||||
.external = 1,
|
||||
.name = "imsm",
|
||||
|
|
Loading…
Reference in New Issue