diff options
author | NeilBrown <neilb@suse.de> | 2010-12-16 09:07:52 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-12-16 09:07:52 +1100 |
commit | 7d469585fc55f042ab95ea6edad24ec9e9e15cb1 (patch) | |
tree | e1771091f0125c52bcce9521ec6ac73a1c3e4604 /Grow.c | |
parent | 76266030d68d35a2342b7d0f7517daa6401bc5af (diff) |
Grow: fix calculation of stripe_cache_size when reshaping.
The two places that this was done were different. The original was
most correct, thought it used odisks rather than odata.
So fix that and make them both use the same calculation.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Grow.c')
-rw-r--r-- | Grow.c | 20 |
1 files changed, 16 insertions, 4 deletions
@@ -663,6 +663,9 @@ static int reshape_container_raid_disks(char *container, int raid_disks) struct mdinfo *sub; unsigned int cache; int level, takeover_delta = 0; + int parity_disks = 1; + unsigned int odata; + unsigned long blocks; if (!is_container_member(e, container)) continue; @@ -692,13 +695,22 @@ static int reshape_container_raid_disks(char *container, int raid_disks) default: rv = -1; break; + case 6: + parity_disks++; case 4: case 5: - case 6: - sub = sysfs_read(-1, e->devnum, GET_CHUNK|GET_CACHE); + sub = sysfs_read(-1, e->devnum, GET_CHUNK|GET_CACHE|GET_DISKS); if (!sub) break; cache = (sub->array.chunk_size / 4096) * 4; + odata = sub->array.raid_disks - parity_disks; + blocks = compute_backup_blocks(sub->array.chunk_size, + sub->array.chunk_size, + raid_disks - parity_disks, + odata); + if (cache < blocks / 8 / odata + 16) + /* Make it big enough to hold 'blocks' */ + cache = blocks / 8 / odata + 16; if (cache > sub->cache_size) rv = subarray_set_num(container, sub, "stripe_cache_size", cache); @@ -1791,9 +1803,9 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file, cache = (nchunk < ochunk) ? ochunk : nchunk; cache = cache * 4 / 4096; - if (cache < blocks / 8 / odisks + 16) + if (cache < blocks / 8 / odata + 16) /* Make it big enough to hold 'blocks' */ - cache = blocks / 8 / odisks + 16; + cache = blocks / 8 / odata + 16; if (sra->cache_size < cache) sysfs_set_num(sra, NULL, "stripe_cache_size", cache+1); |