From 9332d2cb9d64a8a07f0d46988935902979c4e34f Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Fri, 28 Mar 2008 19:08:23 +0000 Subject: [PATCH] Add find_lv_in_lv_list() and find_pv_in_pv_list(). Update _add_pvs() to call find_pv_in_pv_list(). --- WHATS_NEW | 1 + lib/metadata/lv_manip.c | 3 +-- lib/metadata/metadata.c | 22 ++++++++++++++++++++++ lib/metadata/metadata.h | 6 ++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index d51303d2b..2296e5567 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Add find_lv_in_lv_list() and find_pv_in_pv_list(). Fix uninitialised variable in clvmd that could cause odd hangs. Add vgmerge tests. Add pvseg_is_allocated() for identifying a PV segment allocated to a LV. diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 40597ae54..0dc9ed4c8 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -1875,8 +1875,7 @@ static int _add_pvs(struct cmd_context *cmd, struct pv_segment *peg, struct pv_list *pvl; /* Don't add again if it's already on list. */ - list_iterate_items(pvl, &spvs->pvs) - if (pvl->pv == peg->pv) + if (find_pv_in_pv_list(&spvs->pvs, peg->pv)) return 1; if (!(pvl = dm_pool_alloc(cmd->mem, sizeof(*pvl)))) { diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 6632197dc..225f39899 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -868,6 +868,17 @@ static struct pv_list *_find_pv_in_vg(const struct volume_group *vg, return NULL; } +struct pv_list *find_pv_in_pv_list(const struct list *pl, + const struct physical_volume *pv) +{ + struct pv_list *pvl; + + list_iterate_items(pvl, pl) + if (pvl->pv == pv) + return pvl; + return NULL; +} + int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv) { struct pv_list *pvl; @@ -929,6 +940,17 @@ struct lv_list *find_lv_in_vg(const struct volume_group *vg, return NULL; } +struct lv_list *find_lv_in_lv_list(const struct list *ll, + const struct logical_volume *lv) +{ + struct lv_list *lvl; + + list_iterate_items(lvl, ll) + if (lvl->lv == lv) + return lvl; + return NULL; +} + struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg, const union lvid *lvid) { diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index a07d95c20..53ae9ba56 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -257,6 +257,9 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name, struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg, const union lvid *lvid); +struct lv_list *find_lv_in_lv_list(const struct list *ll, + const struct logical_volume *lv); + /* Return the VG that contains a given LV (based on path given in lv_name) */ /* or environment var */ struct volume_group *find_vg_with_lv(const char *lv_name); @@ -269,6 +272,9 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, /* FIXME Merge these functions with ones above */ struct physical_volume *find_pv(struct volume_group *vg, struct device *dev); +struct pv_list *find_pv_in_pv_list(const struct list *pl, + const struct physical_volume *pv); + /* Find LV segment containing given LE */ struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le);