Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305921
b: refs/heads/master
c: deb200d
h: refs/heads/master
i:
  305919: e19180d
v: v3
  • Loading branch information
NeilBrown committed May 20, 2012
1 parent 7e584ff commit 50a0d1d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 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: f8c9e74ff0832f2244d7991d2aea13851b20a622
refs/heads/master: deb200d08590622d987718135a1e6323f83154aa
67 changes: 49 additions & 18 deletions trunk/drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -3253,26 +3253,64 @@ static void calc_sectors(struct r10conf *conf, sector_t size)
}
}

enum geo_type {geo_new, geo_old, geo_start};
static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new)
{
int nc, fc, fo;
int layout, chunk, disks;
switch (new) {
case geo_old:
layout = mddev->layout;
chunk = mddev->chunk_sectors;
disks = mddev->raid_disks - mddev->delta_disks;
break;
case geo_new:
layout = mddev->new_layout;
chunk = mddev->new_chunk_sectors;
disks = mddev->raid_disks;
break;
default: /* avoid 'may be unused' warnings */
case geo_start: /* new when starting reshape - raid_disks not
* updated yet. */
layout = mddev->new_layout;
chunk = mddev->new_chunk_sectors;
disks = mddev->raid_disks + mddev->delta_disks;
break;
}
if (layout >> 17)
return -1;
if (chunk < (PAGE_SIZE >> 9) ||
!is_power_of_2(chunk))
return -2;
nc = layout & 255;
fc = (layout >> 8) & 255;
fo = layout & (1<<16);
geo->raid_disks = disks;
geo->near_copies = nc;
geo->far_copies = fc;
geo->far_offset = fo;
geo->chunk_mask = chunk - 1;
geo->chunk_shift = ffz(~chunk);
return nc*fc;
}

static struct r10conf *setup_conf(struct mddev *mddev)
{
struct r10conf *conf = NULL;
int nc, fc, fo;
int err = -EINVAL;
struct geom geo;
int copies;

copies = setup_geo(&geo, mddev, geo_new);

if (mddev->new_chunk_sectors < (PAGE_SIZE >> 9) ||
!is_power_of_2(mddev->new_chunk_sectors)) {
if (copies == -2) {
printk(KERN_ERR "md/raid10:%s: chunk size must be "
"at least PAGE_SIZE(%ld) and be a power of 2.\n",
mdname(mddev), PAGE_SIZE);
goto out;
}

nc = mddev->new_layout & 255;
fc = (mddev->new_layout >> 8) & 255;
fo = mddev->new_layout & (1<<16);

if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks ||
(mddev->new_layout >> 17)) {
if (copies < 2 || copies > mddev->raid_disks) {
printk(KERN_ERR "md/raid10:%s: unsupported raid10 layout: 0x%8x\n",
mdname(mddev), mddev->new_layout);
goto out;
Expand All @@ -3292,15 +3330,8 @@ static struct r10conf *setup_conf(struct mddev *mddev)
if (!conf->tmppage)
goto out;


conf->geo.raid_disks = mddev->raid_disks;
conf->geo.near_copies = nc;
conf->geo.far_copies = fc;
conf->copies = nc*fc;
conf->geo.far_offset = fo;
conf->geo.chunk_mask = mddev->new_chunk_sectors - 1;
conf->geo.chunk_shift = ffz(~mddev->new_chunk_sectors);

conf->geo = geo;
conf->copies = copies;
conf->r10bio_pool = mempool_create(NR_RAID10_BIOS, r10bio_pool_alloc,
r10bio_pool_free, conf);
if (!conf->r10bio_pool)
Expand Down

0 comments on commit 50a0d1d

Please sign in to comment.