From b19719801b3f9bf1fdbc0decdd2edde3b8f203cf Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Tue, 16 Mar 2010 14:37:38 +0000 Subject: [PATCH] Introduce is_missing_pv(). --- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 1 + lib/metadata/metadata.c | 13 +++++++++---- lib/metadata/pv_map.c | 2 +- tools/lvconvert.c | 6 +++--- tools/toollib.c | 2 +- tools/vgreduce.c | 6 +++--- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 0350858e4..3ea1304c9 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.63 - ================================ + Introduce is_missing_pv(). Fix clvmd Makefile to not overwrite LIBS from template definition. Version 2.02.62 - 9th March 2010 diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 954028522..ecfe660cb 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -415,6 +415,7 @@ int move_pvs_used_by_lv(struct volume_group *vg_from, const char *lv_name); int is_orphan_vg(const char *vg_name); int is_orphan(const struct physical_volume *pv); +int is_missing_pv(const struct physical_volume *pv); int vgs_are_compatible(struct cmd_context *cmd, struct volume_group *vg_from, struct volume_group *vg_to); diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index f1b90a787..f7804308f 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -2068,7 +2068,7 @@ static int _lv_mark_if_partial_single(struct logical_volume *lv, void *data) dm_list_iterate_items(lvseg, &lv->segments) { for (s = 0; s < lvseg->area_count; ++s) { if (seg_type(lvseg, s) == AREA_PV) { - if (seg_pv(lvseg, s)->status & MISSING_PV) + if (is_missing_pv(seg_pv(lvseg, s))) lv->status |= PARTIAL_LV; } } @@ -2513,7 +2513,7 @@ int vg_missing_pv_count(const struct volume_group *vg) int ret = 0; struct pv_list *pvl; dm_list_iterate_items(pvl, &vg->pvs) { - if (pvl->pv->status & MISSING_PV) + if (is_missing_pv(pvl->pv)) ++ ret; } return ret; @@ -2525,7 +2525,7 @@ static void check_reappeared_pv(struct volume_group *correct_vg, struct pv_list *pvl; dm_list_iterate_items(pvl, &correct_vg->pvs) - if (pv->dev == pvl->pv->dev && pvl->pv->status & MISSING_PV) { + if (pv->dev == pvl->pv->dev && is_missing_pv(pvl->pv)) { log_warn("Missing device %s reappeared, updating " "metadata for VG %s to version %u.", pv_dev_name(pvl->pv), pv_vg_name(pvl->pv), @@ -2705,7 +2705,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd, correct_vg = NULL; } } else dm_list_iterate_items(pvl, &correct_vg->pvs) { - if (pvl->pv->status & MISSING_PV) + if (is_missing_pv(pvl->pv)) continue; if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) { log_debug("Cached VG %s had incorrect PV list", @@ -3275,6 +3275,11 @@ int is_pv(struct physical_volume *pv) { return (pv_field(pv, vg_name) ? 1 : 0); } + +int is_missing_pv(const struct physical_volume *pv) +{ + return pv_field(pv, status) & MISSING_PV ? 1 : 0; +} /* * Returns: diff --git a/lib/metadata/pv_map.c b/lib/metadata/pv_map.c index 642629b76..8ba7856ad 100644 --- a/lib/metadata/pv_map.c +++ b/lib/metadata/pv_map.c @@ -129,7 +129,7 @@ static int _create_maps(struct dm_pool *mem, struct dm_list *pvs, struct dm_list dm_list_iterate_items(pvl, pvs) { if (!(pvl->pv->status & ALLOCATABLE_PV)) continue; - if (pvl->pv->status & MISSING_PV) + if (is_missing_pv(pvl->pv)) continue; assert(pvl->pv->dev); diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 914b68173..1f78a77ee 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -527,7 +527,7 @@ static int _area_missing(struct lv_segment *lvseg, int s) if (seg_lv(lvseg, s)->status & PARTIAL_LV) return 1; } else if ((seg_type(lvseg, s) == AREA_PV) && - (seg_pv(lvseg, s)->status & MISSING_PV)) + (is_missing_pv(seg_pv(lvseg, s)))) return 1; return 0; @@ -564,7 +564,7 @@ static struct dm_list *_failed_pv_list(struct volume_group *vg) dm_list_init(failed_pvs); dm_list_iterate_items(pvl, &vg->pvs) { - if (!(pvl->pv->status & MISSING_PV)) + if (!is_missing_pv(pvl->pv)) continue; /* @@ -688,7 +688,7 @@ static void _remove_missing_empty_pv(struct volume_group *vg, struct dm_list *re dm_list_iterate_items(pvl, remove_pvs) { dm_list_iterate_items_safe(pvl_vg, pvlt, &vg->pvs) { if (!id_equal(&pvl->pv->id, &pvl_vg->pv->id) || - !(pvl_vg->pv->status & MISSING_PV) || + !is_missing_pv(pvl_vg->pv) || pvl_vg->pv->pe_alloc_count != 0) continue; diff --git a/tools/toollib.c b/tools/toollib.c index e4040f840..a975fa33c 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1001,7 +1001,7 @@ static int _create_pv_entry(struct dm_pool *mem, struct pv_list *pvl, return 1; } - if (allocatable_only && (pvl->pv->status & MISSING_PV)) { + if (allocatable_only && is_missing_pv(pvl->pv)) { log_error("Physical volume %s is missing", pvname); return 1; } diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 1ffd72b30..eb228a362 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -152,7 +152,7 @@ static int _consolidate_vg(struct cmd_context *cmd, struct volume_group *vg) } dm_list_iterate_items(pvl, &vg->pvs) { - if (pvl->pv->dev && !(pvl->pv->status & MISSING_PV)) + if (pvl->pv->dev && !is_missing_pv(pvl->pv)) continue; if (r && !_remove_pv(vg, pvl, 0)) return_0; @@ -193,7 +193,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) pv = seg_pv(seg, s); if (!pv || !pv_dev(pv) || - (pv->status & MISSING_PV)) { + is_missing_pv(pv)) { if (arg_count(cmd, mirrorsonly_ARG) && !(lv->status & MIRROR_IMAGE)) { log_error("Non-mirror-image LV %s found: can't remove.", lv->name); @@ -224,7 +224,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) */ dm_list_iterate_safe(pvh, pvht, &vg->pvs) { pvl = dm_list_item(pvh, struct pv_list); - if (pvl->pv->dev && !(pvl->pv->status & MISSING_PV)) + if (pvl->pv->dev && !is_missing_pv(pvl->pv)) continue; if (!_remove_pv(vg, pvl, 0)) return_0; -- 2.43.5