Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139927
b: refs/heads/master
c: b354603
h: refs/heads/master
i:
  139925: 668be71
  139923: 2d3cb18
  139919: 2883b2c
v: v3
  • Loading branch information
NeilBrown committed Mar 31, 2009
1 parent 5e55586 commit ac81610
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d562b0c4313e3ddea402a400371afa47ddf679f9
refs/heads/master: b3546035277847028df650b147469fc943cf5c71
37 changes: 24 additions & 13 deletions trunk/drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -2771,12 +2771,18 @@ layout_store(mddev_t *mddev, const char *buf, size_t len)
if (!*buf || (*e && *e != '\n'))
return -EINVAL;

if (mddev->pers)
return -EBUSY;

mddev->new_layout = n;
if (mddev->reshape_position == MaxSector)
mddev->layout = n;
if (mddev->pers) {
int err;
if (mddev->pers->reconfig == NULL)
return -EBUSY;
err = mddev->pers->reconfig(mddev, n, -1);
if (err)
return err;
} else {
mddev->new_layout = n;
if (mddev->reshape_position == MaxSector)
mddev->layout = n;
}
return len;
}
static struct md_sysfs_entry md_layout =
Expand Down Expand Up @@ -2833,19 +2839,24 @@ chunk_size_show(mddev_t *mddev, char *page)
static ssize_t
chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
{
/* can only set chunk_size if array is not yet active */
char *e;
unsigned long n = simple_strtoul(buf, &e, 10);

if (!*buf || (*e && *e != '\n'))
return -EINVAL;

if (mddev->pers)
return -EBUSY;

mddev->new_chunk = n;
if (mddev->reshape_position == MaxSector)
mddev->chunk_size = n;
if (mddev->pers) {
int err;
if (mddev->pers->reconfig == NULL)
return -EBUSY;
err = mddev->pers->reconfig(mddev, -1, n);
if (err)
return err;
} else {
mddev->new_chunk = n;
if (mddev->reshape_position == MaxSector)
mddev->chunk_size = n;
}
return len;
}
static struct md_sysfs_entry md_chunk_size =
Expand Down
42 changes: 42 additions & 0 deletions trunk/drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -4913,6 +4913,47 @@ static void *raid5_takeover_raid1(mddev_t *mddev)
}


static int raid5_reconfig(mddev_t *mddev, int new_layout, int new_chunk)
{
/* Currently the layout and chunk size can only be changed
* for a 2-drive raid array, as in that case no data shuffling
* is required.
* Later we might validate these and set new_* so a reshape
* can complete the change.
*/
raid5_conf_t *conf = mddev_to_conf(mddev);

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

/* They look valid */

if (mddev->raid_disks != 2)
return -EINVAL;

if (new_layout >= 0) {
conf->algorithm = new_layout;
mddev->layout = mddev->new_layout = new_layout;
}
if (new_chunk > 0) {
conf->chunk_size = new_chunk;
mddev->chunk_size = mddev->new_chunk = new_chunk;
}
set_bit(MD_CHANGE_DEVS, &mddev->flags);
md_wakeup_thread(mddev->thread);
return 0;
}

static void *raid5_takeover(mddev_t *mddev)
{
/* raid5 can take over:
Expand Down Expand Up @@ -5023,6 +5064,7 @@ static struct mdk_personality raid5_personality =
#endif
.quiesce = raid5_quiesce,
.takeover = raid5_takeover,
.reconfig = raid5_reconfig,
};

static struct mdk_personality raid4_personality =
Expand Down

0 comments on commit ac81610

Please sign in to comment.