From 086829459b8767324ea98e8ef4f596da04f23790 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 11 May 2012 15:26:30 +0000 Subject: [PATCH] Refactor _has_matching_pv_tag to provide a fn that takes PV structs. --- lib/metadata/lv_manip.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index f8765a67a..727d3d9f3 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -1248,13 +1248,13 @@ static int _is_same_pv(struct pv_match *pvmatch __attribute((unused)), struct pv * Does PV area have a tag listed in allocation/cling_tag_list that * matches a tag of the PV of the existing segment? */ -static int _has_matching_pv_tag(struct pv_match *pvmatch, struct pv_segment *pvseg, struct pv_area *pva) +static int _pvs_have_matching_tag(const struct dm_config_node *cling_tag_list_cn, struct physical_volume *pv1, struct physical_volume *pv2) { const struct dm_config_value *cv; const char *str; const char *tag_matched; - for (cv = pvmatch->cling_tag_list_cn->v; cv; cv = cv->next) { + for (cv = cling_tag_list_cn->v; cv; cv = cv->next) { if (cv->type != DM_CFG_STRING) { log_error("Ignoring invalid string in config file entry " "allocation/cling_tag_list"); @@ -1283,21 +1283,21 @@ static int _has_matching_pv_tag(struct pv_match *pvmatch, struct pv_segment *pvs /* Wildcard matches any tag against any tag. */ if (!strcmp(str, "*")) { - if (!str_list_match_list(&pvseg->pv->tags, &pva->map->pv->tags, &tag_matched)) + if (!str_list_match_list(&pv1->tags, &pv2->tags, &tag_matched)) continue; else { log_debug("Matched allocation PV tag %s on existing %s with free space on %s.", - tag_matched, pv_dev_name(pvseg->pv), pv_dev_name(pva->map->pv)); + tag_matched, pv_dev_name(pv1), pv_dev_name(pv2)); return 1; } } - if (!str_list_match_item(&pvseg->pv->tags, str) || - !str_list_match_item(&pva->map->pv->tags, str)) + if (!str_list_match_item(&pv1->tags, str) || + !str_list_match_item(&pv2->tags, str)) continue; else { log_debug("Matched allocation PV tag %s on existing %s with free space on %s.", - str, pv_dev_name(pvseg->pv), pv_dev_name(pva->map->pv)); + str, pv_dev_name(pv1), pv_dev_name(pv2)); return 1; } } @@ -1305,6 +1305,11 @@ static int _has_matching_pv_tag(struct pv_match *pvmatch, struct pv_segment *pvs return 0; } +static int _has_matching_pv_tag(struct pv_match *pvmatch, struct pv_segment *pvseg, struct pv_area *pva) +{ + return _pvs_have_matching_tag(pvmatch->cling_tag_list_cn, pvseg->pv, pva->map->pv); +} + /* * Is PV area contiguous to PV segment? */ -- 2.43.5