diff options
author | Alexey Obitotskiy <aleksey.obitotskiy@intel.com> | 2017-05-09 12:25:46 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-05-09 20:18:36 +0200 |
commit | fbfdcb06dc5b1dcb227b0394f174faa2df734700 (patch) | |
tree | f7c3a01306d65df5eed6b797356704e37824ae94 /Incremental.c | |
parent | imsm: don't allow disks with different sector size in one array (diff) | |
download | mdadm-fbfdcb06dc5b1dcb227b0394f174faa2df734700.tar.xz mdadm-fbfdcb06dc5b1dcb227b0394f174faa2df734700.zip |
Allow more spare selection criteria
Disks can be moved across containers in order to be used as a spare
drive for reubild. At the moment the only requirement checked for such
disk is its size (if it matches donor expectations). In order to
introduce more criteria rename corresponding superswitch method to more
generic name and move function parameter to a structure. This change is
a big edit but it doesn't introduce any changes in code logic, it just
updates function naming and parameters.
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Signed-off-by: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'Incremental.c')
-rw-r--r-- | Incremental.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Incremental.c b/Incremental.c index 680d3185..fe9d6443 100644 --- a/Incremental.c +++ b/Incremental.c @@ -867,7 +867,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 = 0; + struct spare_criteria sc = {0}; if (is_subarray(mp->metadata)) continue; @@ -936,7 +936,8 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, } if (st3->ss->load_container && !st3->ss->load_container(st3, mdfd, mp->path)) { - component_size = st3->ss->min_acceptable_spare_size(st3); + if (st3->ss->get_spare_criteria) + st3->ss->get_spare_criteria(st3, &sc); st3->ss->free_super(st3); } free(st3); @@ -947,7 +948,7 @@ static int array_try_spare(char *devname, int *dfdp, struct dev_policy *pol, sra->devs ? sra->devs->data_offset : INVALID_SECTORS) < sra->component_size) || - (sra->component_size == 0 && devsize < component_size)) { + (sra->component_size == 0 && devsize < sc.min_size)) { if (verbose > 1) pr_err("not adding %s to %s as it is too small\n", devname, mp->path); @@ -1624,12 +1625,15 @@ static int Incremental_container(struct supertype *st, char *devname, struct supertype *sst = super_imsm.match_metadata_desc("imsm"); struct mdinfo *sinfo; - unsigned long long min_size = 0; - if (st->ss->min_acceptable_spare_size) - min_size = st->ss->min_acceptable_spare_size(st); + if (!sst->ss->load_container(sst, sfd, NULL)) { + struct spare_criteria sc = {0}; + + if (st->ss->get_spare_criteria) + st->ss->get_spare_criteria(st, &sc); + close(sfd); - sinfo = container_choose_spares(sst, min_size, + sinfo = container_choose_spares(sst, &sc, domains, NULL, st->ss->name, 0); sst->ss->free_super(sst); |