mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
vgreduce remove mirror images
adjust block_on_error version no detection for RHEL4U3
This commit is contained in:
parent
e7ab6006c5
commit
079ac15ece
@ -1,6 +1,7 @@
|
|||||||
Version 2.02.02 -
|
Version 2.02.02 -
|
||||||
====================================
|
====================================
|
||||||
Always print warning if activation is disabled.
|
Always print warning if activation is disabled.
|
||||||
|
vgreduce removes mirror images.
|
||||||
Add --mirrorsonly to vgreduce.
|
Add --mirrorsonly to vgreduce.
|
||||||
vgreduce replaces active LVs with error segment before removing them.
|
vgreduce replaces active LVs with error segment before removing them.
|
||||||
Set block_on_error parameter if available.
|
Set block_on_error parameter if available.
|
||||||
|
@ -326,7 +326,7 @@ static int _target_present(void)
|
|||||||
static int checked = 0;
|
static int checked = 0;
|
||||||
static int present = 0;
|
static int present = 0;
|
||||||
uint32_t maj, min, patchlevel;
|
uint32_t maj, min, patchlevel;
|
||||||
unsigned maj2, min2;
|
unsigned maj2, min2, patchlevel2;
|
||||||
char vsn[80];
|
char vsn[80];
|
||||||
|
|
||||||
if (!checked) {
|
if (!checked) {
|
||||||
@ -342,8 +342,8 @@ static int _target_present(void)
|
|||||||
maj == 1 &&
|
maj == 1 &&
|
||||||
(min >= 1 ||
|
(min >= 1 ||
|
||||||
(min == 0 && driver_version(vsn, sizeof(vsn)) &&
|
(min == 0 && driver_version(vsn, sizeof(vsn)) &&
|
||||||
sscanf(vsn, "%u.%u", &maj2, &min2) == 2 &&
|
sscanf(vsn, "%u.%u.%u", &maj2, &min2, &patchlevel2) == 3 &&
|
||||||
maj2 >= 4 && min2 >= 5))) /* RHEL4U3 */
|
maj2 == 4 && min2 == 5 && patchlevel2 == 0))) /* RHEL4U3 */
|
||||||
_block_on_error_available = 1;
|
_block_on_error_available = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ static int _remove_pv(struct volume_group *vg, struct pv_list *pvl)
|
|||||||
static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
|
static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
|
||||||
int *list_unsafe, struct list *lvs_changed)
|
int *list_unsafe, struct list *lvs_changed)
|
||||||
{
|
{
|
||||||
struct lv_segment *snap_seg;
|
struct lv_segment *snap_seg, *mirror_seg;
|
||||||
struct list *snh, *snht;
|
struct list *snh, *snht;
|
||||||
struct logical_volume *cow;
|
struct logical_volume *cow;
|
||||||
struct lv_list *lvl;
|
struct lv_list *lvl;
|
||||||
@ -113,6 +113,7 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
*/
|
*/
|
||||||
if (lv_info(cmd, lv, &info, 0) && info.exists) {
|
if (lv_info(cmd, lv, &info, 0) && info.exists) {
|
||||||
extents = lv->le_count;
|
extents = lv->le_count;
|
||||||
|
mirror_seg = first_seg(lv)->mirror_seg;
|
||||||
if (!lv_empty(lv)) {
|
if (!lv_empty(lv)) {
|
||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
@ -123,6 +124,10 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
|
|||||||
stack;
|
stack;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (mirror_seg) {
|
||||||
|
first_seg(lv)->status |= MIRROR_IMAGE;
|
||||||
|
first_seg(lv)->mirror_seg = mirror_seg;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl)))) {
|
if (!(lvl = dm_pool_alloc(cmd->mem, sizeof(*lvl)))) {
|
||||||
log_error("lv_list alloc failed");
|
log_error("lv_list alloc failed");
|
||||||
@ -147,11 +152,13 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
|||||||
struct list *pvh, *pvht;
|
struct list *pvh, *pvht;
|
||||||
struct list *lvh, *lvht;
|
struct list *lvh, *lvht;
|
||||||
struct pv_list *pvl;
|
struct pv_list *pvl;
|
||||||
struct lv_list *lvl;
|
struct lv_list *lvl, *lvl2, *lvlt;
|
||||||
struct logical_volume *lv;
|
struct logical_volume *lv;
|
||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
struct lv_segment *seg;
|
struct lv_segment *seg, *mirrored_seg;
|
||||||
|
struct lv_segment_area area;
|
||||||
unsigned int s;
|
unsigned int s;
|
||||||
|
uint32_t mimages;
|
||||||
int list_unsafe, only_mirror_images_found;
|
int list_unsafe, only_mirror_images_found;
|
||||||
LIST_INIT(lvs_changed);
|
LIST_INIT(lvs_changed);
|
||||||
only_mirror_images_found = 1;
|
only_mirror_images_found = 1;
|
||||||
@ -244,7 +251,44 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME If any lvs_changed belong to mirrors, reduce those mirrors */
|
/* Remove lost mirror images from mirrors */
|
||||||
|
list_iterate_items(lvl, &vg->lvs) {
|
||||||
|
mirrored_seg = first_seg(lvl->lv);
|
||||||
|
if (!seg_is_mirrored(mirrored_seg))
|
||||||
|
continue;
|
||||||
|
mimages = mirrored_seg->area_count;
|
||||||
|
for (s = 0; s < mirrored_seg->area_count; s++) {
|
||||||
|
list_iterate_items_safe(lvl2, lvlt, &lvs_changed) {
|
||||||
|
if (seg_type(mirrored_seg, s) != AREA_LV ||
|
||||||
|
lvl2->lv != seg_lv(mirrored_seg, s))
|
||||||
|
continue;
|
||||||
|
list_del(&lvl2->list);
|
||||||
|
area = mirrored_seg->areas[mimages - 1];
|
||||||
|
mirrored_seg->areas[mimages - 1] = mirrored_seg->areas[s];
|
||||||
|
mirrored_seg->areas[s] = area;
|
||||||
|
mimages--; /* FIXME Assumes uniqueness */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mimages != mirrored_seg->area_count) {
|
||||||
|
if (!remove_mirror_images(mirrored_seg, mimages, NULL, 0)) {
|
||||||
|
stack;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vg_write(vg)) {
|
||||||
|
log_error("Failed to write out updated "
|
||||||
|
"VG for %s", vg->name);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vg_commit(vg)) {
|
||||||
|
log_error("Failed to commit updated VG "
|
||||||
|
"for %s", vg->name);
|
||||||
|
vg_revert(vg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Deactivate error LVs */
|
/* Deactivate error LVs */
|
||||||
if (!test_mode()) {
|
if (!test_mode()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user