mirror of https://gitee.com/openkylin/linux.git
md: merge reconfig and check_reshape methods.
The difference between these two methods is artificial. Both check that a pending reshape is valid, and perform any aspect of it that can be done immediately. 'reconfig' handles chunk size and layout. 'check_reshape' handles raid_disks. So make them just one method. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
597a711b69
commit
50ac168a6e
|
@ -255,7 +255,7 @@ static void status(struct seq_file *seq, mddev_t *mddev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int reconfig(mddev_t *mddev)
|
static int reshape(mddev_t *mddev)
|
||||||
{
|
{
|
||||||
int mode = mddev->new_layout & ModeMask;
|
int mode = mddev->new_layout & ModeMask;
|
||||||
int count = mddev->new_layout >> ModeShift;
|
int count = mddev->new_layout >> ModeShift;
|
||||||
|
@ -316,7 +316,7 @@ static int run(mddev_t *mddev)
|
||||||
md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
|
md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
|
||||||
mddev->private = conf;
|
mddev->private = conf;
|
||||||
|
|
||||||
reconfig(mddev);
|
reshape(mddev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -339,7 +339,7 @@ static struct mdk_personality faulty_personality =
|
||||||
.run = run,
|
.run = run,
|
||||||
.stop = stop,
|
.stop = stop,
|
||||||
.status = status,
|
.status = status,
|
||||||
.reconfig = reconfig,
|
.check_reshape = reshape,
|
||||||
.size = faulty_size,
|
.size = faulty_size,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2807,10 +2807,10 @@ layout_store(mddev_t *mddev, const char *buf, size_t len)
|
||||||
|
|
||||||
if (mddev->pers) {
|
if (mddev->pers) {
|
||||||
int err;
|
int err;
|
||||||
if (mddev->pers->reconfig == NULL)
|
if (mddev->pers->check_reshape == NULL)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
mddev->new_layout = n;
|
mddev->new_layout = n;
|
||||||
err = mddev->pers->reconfig(mddev);
|
err = mddev->pers->check_reshape(mddev);
|
||||||
if (err) {
|
if (err) {
|
||||||
mddev->new_layout = mddev->layout;
|
mddev->new_layout = mddev->layout;
|
||||||
return err;
|
return err;
|
||||||
|
@ -2885,10 +2885,10 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
|
||||||
|
|
||||||
if (mddev->pers) {
|
if (mddev->pers) {
|
||||||
int err;
|
int err;
|
||||||
if (mddev->pers->reconfig == NULL)
|
if (mddev->pers->check_reshape == NULL)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
mddev->new_chunk_sectors = n >> 9;
|
mddev->new_chunk_sectors = n >> 9;
|
||||||
err = mddev->pers->reconfig(mddev);
|
err = mddev->pers->check_reshape(mddev);
|
||||||
if (err) {
|
if (err) {
|
||||||
mddev->new_chunk_sectors = mddev->chunk_sectors;
|
mddev->new_chunk_sectors = mddev->chunk_sectors;
|
||||||
return err;
|
return err;
|
||||||
|
@ -5224,11 +5224,11 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
|
||||||
* we don't need to do anything at the md level, the
|
* we don't need to do anything at the md level, the
|
||||||
* personality will take care of it all.
|
* personality will take care of it all.
|
||||||
*/
|
*/
|
||||||
if (mddev->pers->reconfig == NULL)
|
if (mddev->pers->check_reshape == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
else {
|
else {
|
||||||
mddev->new_layout = info->layout;
|
mddev->new_layout = info->layout;
|
||||||
rv = mddev->pers->reconfig(mddev);
|
rv = mddev->pers->check_reshape(mddev);
|
||||||
if (rv)
|
if (rv)
|
||||||
mddev->new_layout = mddev->layout;
|
mddev->new_layout = mddev->layout;
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -6731,7 +6731,8 @@ void md_check_recovery(mddev_t *mddev)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (mddev->reshape_position != MaxSector) {
|
if (mddev->reshape_position != MaxSector) {
|
||||||
if (mddev->pers->check_reshape(mddev) != 0)
|
if (mddev->pers->check_reshape == NULL ||
|
||||||
|
mddev->pers->check_reshape(mddev) != 0)
|
||||||
/* Cannot proceed */
|
/* Cannot proceed */
|
||||||
goto unlock;
|
goto unlock;
|
||||||
set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
|
set_bit(MD_RECOVERY_RESHAPE, &mddev->recovery);
|
||||||
|
|
|
@ -326,7 +326,6 @@ struct mdk_personality
|
||||||
int (*check_reshape) (mddev_t *mddev);
|
int (*check_reshape) (mddev_t *mddev);
|
||||||
int (*start_reshape) (mddev_t *mddev);
|
int (*start_reshape) (mddev_t *mddev);
|
||||||
void (*finish_reshape) (mddev_t *mddev);
|
void (*finish_reshape) (mddev_t *mddev);
|
||||||
int (*reconfig) (mddev_t *mddev);
|
|
||||||
/* quiesce moves between quiescence states
|
/* quiesce moves between quiescence states
|
||||||
* 0 - fully active
|
* 0 - fully active
|
||||||
* 1 - no new requests allowed
|
* 1 - no new requests allowed
|
||||||
|
|
|
@ -4868,14 +4868,14 @@ static int check_stripe_cache(mddev_t *mddev)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int raid5_check_reshape(mddev_t *mddev)
|
static int check_reshape(mddev_t *mddev)
|
||||||
{
|
{
|
||||||
raid5_conf_t *conf = mddev->private;
|
raid5_conf_t *conf = mddev->private;
|
||||||
|
|
||||||
if (mddev->delta_disks == 0 &&
|
if (mddev->delta_disks == 0 &&
|
||||||
mddev->new_layout == mddev->layout &&
|
mddev->new_layout == mddev->layout &&
|
||||||
mddev->new_chunk_sectors == mddev->chunk_sectors)
|
mddev->new_chunk_sectors == mddev->chunk_sectors)
|
||||||
return -EINVAL; /* nothing to do */
|
return 0; /* nothing to do */
|
||||||
if (mddev->bitmap)
|
if (mddev->bitmap)
|
||||||
/* Cannot grow a bitmap yet */
|
/* Cannot grow a bitmap yet */
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
@ -5165,7 +5165,7 @@ static void *raid5_takeover_raid6(mddev_t *mddev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int raid5_reconfig(mddev_t *mddev)
|
static int raid5_check_reshape(mddev_t *mddev)
|
||||||
{
|
{
|
||||||
/* For a 2-drive array, the layout and chunk size can be changed
|
/* For a 2-drive array, the layout and chunk size can be changed
|
||||||
* immediately as not restriping is needed.
|
* immediately as not restriping is needed.
|
||||||
|
@ -5202,12 +5202,13 @@ static int raid5_reconfig(mddev_t *mddev)
|
||||||
set_bit(MD_CHANGE_DEVS, &mddev->flags);
|
set_bit(MD_CHANGE_DEVS, &mddev->flags);
|
||||||
md_wakeup_thread(mddev->thread);
|
md_wakeup_thread(mddev->thread);
|
||||||
}
|
}
|
||||||
return 0;
|
return check_reshape(mddev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int raid6_reconfig(mddev_t *mddev)
|
static int raid6_check_reshape(mddev_t *mddev)
|
||||||
{
|
{
|
||||||
int new_chunk = mddev->new_chunk_sectors;
|
int new_chunk = mddev->new_chunk_sectors;
|
||||||
|
|
||||||
if (mddev->new_layout >= 0 && !algorithm_valid_raid6(mddev->new_layout))
|
if (mddev->new_layout >= 0 && !algorithm_valid_raid6(mddev->new_layout))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (new_chunk > 0) {
|
if (new_chunk > 0) {
|
||||||
|
@ -5221,7 +5222,7 @@ static int raid6_reconfig(mddev_t *mddev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* They look valid */
|
/* They look valid */
|
||||||
return 0;
|
return check_reshape(mddev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *raid5_takeover(mddev_t *mddev)
|
static void *raid5_takeover(mddev_t *mddev)
|
||||||
|
@ -5312,12 +5313,11 @@ static struct mdk_personality raid6_personality =
|
||||||
.sync_request = sync_request,
|
.sync_request = sync_request,
|
||||||
.resize = raid5_resize,
|
.resize = raid5_resize,
|
||||||
.size = raid5_size,
|
.size = raid5_size,
|
||||||
.check_reshape = raid5_check_reshape,
|
.check_reshape = raid6_check_reshape,
|
||||||
.start_reshape = raid5_start_reshape,
|
.start_reshape = raid5_start_reshape,
|
||||||
.finish_reshape = raid5_finish_reshape,
|
.finish_reshape = raid5_finish_reshape,
|
||||||
.quiesce = raid5_quiesce,
|
.quiesce = raid5_quiesce,
|
||||||
.takeover = raid6_takeover,
|
.takeover = raid6_takeover,
|
||||||
.reconfig = raid6_reconfig,
|
|
||||||
};
|
};
|
||||||
static struct mdk_personality raid5_personality =
|
static struct mdk_personality raid5_personality =
|
||||||
{
|
{
|
||||||
|
@ -5340,7 +5340,6 @@ static struct mdk_personality raid5_personality =
|
||||||
.finish_reshape = raid5_finish_reshape,
|
.finish_reshape = raid5_finish_reshape,
|
||||||
.quiesce = raid5_quiesce,
|
.quiesce = raid5_quiesce,
|
||||||
.takeover = raid5_takeover,
|
.takeover = raid5_takeover,
|
||||||
.reconfig = raid5_reconfig,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct mdk_personality raid4_personality =
|
static struct mdk_personality raid4_personality =
|
||||||
|
|
Loading…
Reference in New Issue