diff options
author | Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com> | 2010-12-26 22:38:42 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-12-26 22:38:42 +1100 |
commit | 4886570497e369550608666bd7c1d4638e47a8c1 (patch) | |
tree | 8540e0b6683effcafd8c0c9319463993cd6530c1 /Incremental.c | |
parent | b6b3f0f7ebb00c264421fb09e5634fd28994e0e7 (diff) |
Validate size of potential spare disk for external metadata (with containers)
mdinfo read with sysfs_read do not contain information about the space
needed to store data of all volumes created in that container, so that
spare can be used as replacement for existing subarrays in the future.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Incremental.c')
-rw-r--r-- | Incremental.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/Incremental.c b/Incremental.c index 2b6ba91c..90fc3739 100644 --- a/Incremental.c +++ b/Incremental.c @@ -888,6 +888,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, struct domainlist *dl = NULL; struct mdinfo *sra; unsigned long long devsize; + unsigned long long component_size; if (is_subarray(mp->metadata)) continue; @@ -946,7 +947,25 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, sra->array.failed_disks = container_members_max_degradation(map, mp); get_dev_size(dfd, NULL, &devsize); - if (st2->ss->avail_size(st2, devsize) < sra->component_size) { + if (sra->component_size == 0) { + /* true for containers, here we must read superblock + * to obtain minimum spare size */ + struct supertype *st3 = dup_super(st2); + int mdfd = open_dev(mp->devnum); + if (!mdfd) + goto next; + if (st3->ss->load_container && + !st3->ss->load_container(st3, mdfd, mp->path)) { + component_size = st3->ss->min_acceptable_spare_size(st3); + st3->ss->free_super(st3); + } + free(st3); + close(mdfd); + } + if ((sra->component_size > 0 && + st2->ss->avail_size(st2, devsize) < sra->component_size) + || + (sra->component_size == 0 && devsize < component_size)) { if (verbose > 1) fprintf(stderr, Name ": not adding %s to %s as it is too small\n", devname, mp->path); |