Lines Matching refs:vg

21 static int _remove_pv(struct volume_group *vg, struct pv_list *pvl, int silent)  in _remove_pv()  argument
25 if (vg->pv_count == 1) { in _remove_pv()
33 log_verbose("Removing PV with UUID %s from VG %s", uuid, vg->name); in _remove_pv()
38 "Can't remove from VG %s", uuid, vg->name); in _remove_pv()
42 vg->free_count -= pvl->pv->pe_count; in _remove_pv()
43 vg->extent_count -= pvl->pv->pe_count; in _remove_pv()
44 vg->pv_count--; in _remove_pv()
62 "dependencies)", lv->vg->name, lv->name); in _remove_lv()
98 lv->vg->name); in _remove_lv()
128 log_verbose("Removing LV %s from VG %s", lv->name, lv->vg->name); in _remove_lv()
136 static int _consolidate_vg(struct cmd_context *cmd, struct volume_group *vg) in _consolidate_vg() argument
142 dm_list_iterate_items(lvl, &vg->lvs) in _consolidate_vg()
151 log_warn("WARNING: There are still partial LVs in VG %s.", vg->name); in _consolidate_vg()
156 dm_list_iterate_items(pvl, &vg->pvs) { in _consolidate_vg()
159 if (r && !_remove_pv(vg, pvl, 0)) in _consolidate_vg()
166 static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg) in _make_vg_consistent() argument
185 dm_list_iterate_safe(lvh, lvht, &vg->lvs) { in _make_vg_consistent()
227 dm_list_iterate_safe(pvh, pvht, &vg->pvs) { in _make_vg_consistent()
231 if (!_remove_pv(vg, pvl, 0)) in _make_vg_consistent()
238 if (!vg_write(vg)) { in _make_vg_consistent()
240 vg->name); in _make_vg_consistent()
248 vg_revert(vg); in _make_vg_consistent()
253 if (!vg_commit(vg)) { in _make_vg_consistent()
255 vg->name); in _make_vg_consistent()
256 vg_revert(vg); in _make_vg_consistent()
269 dm_list_iterate_items(lvl, &vg->lvs) { in _make_vg_consistent()
294 get_segtype_from_string(vg->cmd, "error"))) { in _make_vg_consistent()
296 vg->name, mirrored_seg->lv->name); in _make_vg_consistent()
302 vg->name, mirrored_seg->lv->name); in _make_vg_consistent()
314 if (!vg_write(vg)) { in _make_vg_consistent()
316 "VG for %s", vg->name); in _make_vg_consistent()
320 if (!vg_commit(vg)) { in _make_vg_consistent()
322 "for %s", vg->name); in _make_vg_consistent()
323 vg_revert(vg); in _make_vg_consistent()
369 lvl->lv->vg->name); in _make_vg_consistent()
371 if (find_lv_in_vg(vg, lvl->lv->name) && in _make_vg_consistent()
381 static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg, in _vgreduce_single() argument
395 if (vg->pv_count == 1) { in _vgreduce_single()
397 "volume group \"%s\"", name, vg->name); in _vgreduce_single()
406 pvl = find_pv_in_vg(vg, name); in _vgreduce_single()
408 if (!archive(vg)) in _vgreduce_single()
411 log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name); in _vgreduce_single()
416 pv->vg_name = vg->fid->fmt->orphan_vg_name; in _vgreduce_single()
424 vg->pv_count--; in _vgreduce_single()
425 vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv); in _vgreduce_single()
426 vg->extent_count -= pv_pe_count(pv); in _vgreduce_single()
428 orphan_vg = vg_read_for_update(cmd, vg->fid->fmt->orphan_vg_name, in _vgreduce_single()
434 if (!vg_split_mdas(cmd, vg, orphan_vg) || !vg->pv_count) { in _vgreduce_single()
436 name, vg->name); in _vgreduce_single()
440 if (!vg_write(vg) || !vg_commit(vg)) { in _vgreduce_single()
442 "\"%s\" failed", name, vg->name); in _vgreduce_single()
449 "after removal from \"%s\"", name, vg->name); in _vgreduce_single()
453 backup(vg); in _vgreduce_single()
455 log_print("Removed \"%s\" from volume group \"%s\"", name, vg->name); in _vgreduce_single()
464 struct volume_group *vg; in vgreduce() local
514 vg = vg_read_for_update(cmd, vg_name, NULL, READ_ALLOW_EXPORTED); in vgreduce()
515 if (vg_read_error(vg) == FAILED_ALLOCATION || in vgreduce()
516 vg_read_error(vg) == FAILED_NOTFOUND) in vgreduce()
520 if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY in vgreduce()
525 if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) { in vgreduce()
532 vg_release(vg); in vgreduce()
535 vg = vg_read_for_update(cmd, vg_name, NULL, in vgreduce()
539 if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY in vgreduce()
540 && vg_read_error(vg) != FAILED_INCONSISTENT) in vgreduce()
543 if (!archive(vg)) in vgreduce()
547 if (!_make_vg_consistent(cmd, vg)) in vgreduce()
550 fixed = _consolidate_vg(cmd, vg); in vgreduce()
552 if (!vg_write(vg) || !vg_commit(vg)) { in vgreduce()
557 backup(vg); in vgreduce()
567 if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE | RESIZEABLE_VG)) in vgreduce()
572 ret = process_each_pv(cmd, argc, argv, vg, READ_FOR_UPDATE, 0, NULL, in vgreduce()
578 unlock_and_release_vg(cmd, vg, vg_name); in vgreduce()