master - cleanup: relocate function to vg.c
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=032cf8ade6904df38b25453d94169ae17fac003a Commit: 032cf8ade6904df38b25453d94169ae17fac003a Parent: acf7815acaceb32133bcdf8160260622c2df2f82 Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Feb 8 12:53:54 2016 +0100 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Thu Feb 11 18:35:06 2016 +0100
cleanup: relocate function to vg.c
--- lib/metadata/lv.c | 92 +++++++++++++++++++++++++++++++ lib/metadata/lv_manip.c | 137 ----------------------------------------------- lib/metadata/vg.c | 45 +++++++++++++++ 3 files changed, 137 insertions(+), 137 deletions(-)
lib/metadata/lv.c +92 -0
@@ -347,6 +347,98 @@ uint32_t lv_kernel_read_ahead(const struct logical_volume *lv)return info.read_ahead; } +struct pv_and_int { +struct physical_volume *pv; +int *i; +}; + +static int _lv_is_on_pv (struct logical_volume *lv,void *data) +{ +int *is_on_pv = ((struct pv_and_int *)data)->i; +struct physical_volume *pv = ((struct pv_and_int *)data)->pv; +uint32_t s; +struct physical_volume *pv2; +struct lv_segment *seg; + +if (!lv || !(first_seg (lv))) + return_0; + +/* +* If the LV has already been found to be on the PV, then +* we don't need to continue checking - just return. +*/ +if (*is_on_pv) +return 1 ; + + dm_list_iterate_items(seg, &lv->segments) { +for (s =0 ; s < seg->area_count; s++) { +if (seg_type (seg, s) !=AREA_PV ) +continue ; + + pv2 =seg_pv (seg, s); +if (id_equal (&pv->id, &pv2->id)) { + *is_on_pv =1 ; +return 1 ; + } +if (pv->dev && pv2->dev && + (pv->dev->dev == pv2->dev->dev)) { + *is_on_pv =1 ; +return 1 ; + } + } + } + +return 1 ; +} + +/* +* lv_is_on_pv +* @lv: +* @pv: +* +* If any of the component devices of the LV are on the given PV, 1 +* is returned; otherwise 0. For example if one of the images of a RAID +* (or its metadata device) is on the PV, 1 would be returned for the +* top-level LV. +* If you wish to check the images themselves, you should pass them. +* +* Returns: 1 if LV (or part of LV) is on PV, 0 otherwise +*/ +int lv_is_on_pv (struct logical_volume *lv,struct physical_volume *pv) +{ +int is_on_pv =0 ; +struct pv_and_int context = { pv, &is_on_pv }; + +if (!_lv_is_on_pv (lv, &context) || + !for_each_sub_lv (lv, _lv_is_on_pv, &context)) +/* Failure only happens if bad arguments are passed */ +log_error (INTERNAL_ERROR "for_each_sub_lv failure." ); + +log_debug_metadata ("%s is %son %s" , lv->name, + is_on_pv ?"" :"not " ,pv_dev_name (pv)); +return is_on_pv; +} + +/* +* lv_is_on_pvs +* @lv +* @pvs +* +* Returns 1 if the LV (or part of the LV) is on any of the pvs +* in the list, 0 otherwise. +*/ +int lv_is_on_pvs (struct logical_volume *lv,struct dm_list *pvs) +{ +struct pv_list *pvl; + + dm_list_iterate_items(pvl, pvs) +if (lv_is_on_pv (lv, pvl->pv)) +return 1 ; + +return 0 ; +} + +struct logical_volume *lv_origin_lv (const struct logical_volume *lv) {struct logical_volume *origin =NULL ;
lib/metadata/lv_manip.c +0 -137
161 lines not on this page · raw message
lib/metadata/vg.c +45 -0
51 lines not on this page · raw message