Skip to content

Commit

Permalink
md: remove unnecessary arguments from ->reconfig method.
Browse files Browse the repository at this point in the history
Passing the new layout and chunksize as args is not necessary as
the mddev has fields for new_check and new_layout.

This is preparation for combining the check_reshape and reconfig
methods

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed Jun 17, 2009
1 parent 01ee22b commit 597a711
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
13 changes: 7 additions & 6 deletions drivers/md/faulty.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ static void status(struct seq_file *seq, mddev_t *mddev)
}


static int reconfig(mddev_t *mddev, int layout, int chunk_size)
static int reconfig(mddev_t *mddev)
{
int mode = layout & ModeMask;
int count = layout >> ModeShift;
int mode = mddev->new_layout & ModeMask;
int count = mddev->new_layout >> ModeShift;
conf_t *conf = mddev->private;

if (chunk_size != -1)
return -EINVAL;
if (mddev->new_layout < 0)
return 0;

/* new layout */
if (mode == ClearFaults)
Expand All @@ -279,6 +279,7 @@ static int reconfig(mddev_t *mddev, int layout, int chunk_size)
atomic_set(&conf->counters[mode], count);
} else
return -EINVAL;
mddev->new_layout = -1;
mddev->layout = -1; /* makes sure further changes come through */
return 0;
}
Expand Down Expand Up @@ -315,7 +316,7 @@ static int run(mddev_t *mddev)
md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
mddev->private = conf;

reconfig(mddev, mddev->layout, -1);
reconfig(mddev);

return 0;
}
Expand Down
23 changes: 17 additions & 6 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -2809,9 +2809,12 @@ layout_store(mddev_t *mddev, const char *buf, size_t len)
int err;
if (mddev->pers->reconfig == NULL)
return -EBUSY;
err = mddev->pers->reconfig(mddev, n, -1);
if (err)
mddev->new_layout = n;
err = mddev->pers->reconfig(mddev);
if (err) {
mddev->new_layout = mddev->layout;
return err;
}
} else {
mddev->new_layout = n;
if (mddev->reshape_position == MaxSector)
Expand Down Expand Up @@ -2884,9 +2887,12 @@ chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
int err;
if (mddev->pers->reconfig == NULL)
return -EBUSY;
err = mddev->pers->reconfig(mddev, -1, n);
if (err)
mddev->new_chunk_sectors = n >> 9;
err = mddev->pers->reconfig(mddev);
if (err) {
mddev->new_chunk_sectors = mddev->chunk_sectors;
return err;
}
} else {
mddev->new_chunk_sectors = n >> 9;
if (mddev->reshape_position == MaxSector)
Expand Down Expand Up @@ -5220,8 +5226,13 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
*/
if (mddev->pers->reconfig == NULL)
return -EINVAL;
else
return mddev->pers->reconfig(mddev, info->layout, -1);
else {
mddev->new_layout = info->layout;
rv = mddev->pers->reconfig(mddev);
if (rv)
mddev->new_layout = mddev->layout;
return rv;
}
}
if (info->size >= 0 && mddev->dev_sectors / 2 != info->size)
rv = update_size(mddev, (sector_t)info->size * 2);
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/md.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ struct mdk_personality
int (*check_reshape) (mddev_t *mddev);
int (*start_reshape) (mddev_t *mddev);
void (*finish_reshape) (mddev_t *mddev);
int (*reconfig) (mddev_t *mddev, int layout, int chunk_size);
int (*reconfig) (mddev_t *mddev);
/* quiesce moves between quiescence states
* 0 - fully active
* 1 - no new requests allowed
Expand Down
42 changes: 16 additions & 26 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -5165,72 +5165,62 @@ static void *raid5_takeover_raid6(mddev_t *mddev)
}


static int raid5_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
static int raid5_reconfig(mddev_t *mddev)
{
/* For a 2-drive array, the layout and chunk size can be changed
* immediately as not restriping is needed.
* For larger arrays we record the new value - after validation
* to be used by a reshape pass.
*/
raid5_conf_t *conf = mddev->private;
int new_chunk = mddev->new_chunk_sectors;

if (new_layout >= 0 && !algorithm_valid_raid5(new_layout))
if (mddev->new_layout >= 0 && !algorithm_valid_raid5(mddev->new_layout))
return -EINVAL;
if (new_chunk > 0) {
if (!is_power_of_2(new_chunk))
return -EINVAL;
if (new_chunk < PAGE_SIZE)
if (new_chunk < (PAGE_SIZE>>9))
return -EINVAL;
if (mddev->array_sectors & ((new_chunk>>9)-1))
if (mddev->array_sectors & (new_chunk-1))
/* not factor of array size */
return -EINVAL;
}

/* They look valid */

if (mddev->raid_disks == 2) {

if (new_layout >= 0) {
conf->algorithm = new_layout;
mddev->layout = mddev->new_layout = new_layout;
/* can make the change immediately */
if (mddev->new_layout >= 0) {
conf->algorithm = mddev->new_layout;
mddev->layout = mddev->new_layout;
}
if (new_chunk > 0) {
conf->chunk_sectors = new_chunk >> 9;
mddev->new_chunk_sectors = new_chunk >> 9;
mddev->chunk_sectors = new_chunk >> 9;
conf->chunk_sectors = new_chunk ;
mddev->chunk_sectors = new_chunk;
}
set_bit(MD_CHANGE_DEVS, &mddev->flags);
md_wakeup_thread(mddev->thread);
} else {
if (new_layout >= 0)
mddev->new_layout = new_layout;
if (new_chunk > 0)
mddev->new_chunk_sectors = new_chunk >> 9;
}
return 0;
}

static int raid6_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
static int raid6_reconfig(mddev_t *mddev)
{
if (new_layout >= 0 && !algorithm_valid_raid6(new_layout))
int new_chunk = mddev->new_chunk_sectors;
if (mddev->new_layout >= 0 && !algorithm_valid_raid6(mddev->new_layout))
return -EINVAL;
if (new_chunk > 0) {
if (!is_power_of_2(new_chunk))
return -EINVAL;
if (new_chunk < PAGE_SIZE)
if (new_chunk < (PAGE_SIZE >> 9))
return -EINVAL;
if (mddev->array_sectors & ((new_chunk>>9)-1))
if (mddev->array_sectors & (new_chunk-1))
/* not factor of array size */
return -EINVAL;
}

/* They look valid */

if (new_layout >= 0)
mddev->new_layout = new_layout;
if (new_chunk > 0)
mddev->new_chunk_sectors = new_chunk >> 9;

return 0;
}

Expand Down

0 comments on commit 597a711

Please sign in to comment.