Fix to preserve exclusive activation of mirror while up-converting.
PATCH 1/1 Fix to preserve exclusive activation of mirror while up-converting.
Fix to preserve exclusive activation of mirror while up-converting.
When an LVM mirror is up-converted (an additional image added), it creates a temporary mirror stack. The lower-level mirror in the stack that is created was not being activated exclusively - violating the exclusive nature of the original mirror. We now check for exclusive activation of a mirror before converting it, and if found, we ensure that the temporary mirror is also exclusively activated.
Signed-off-by Jonathan Brassow <[email protected]>
lib/metadata/lv_manip.c +14 -2
@@ -3096,11 +3096,13 @@ struct logical_volume *insert_layer_for_uint64_t status, const char *layer_suffix) { + int r;struct logical_volume *layer_lv;char *name;size_t len;struct segment_type *segtype;struct lv_segment *mapseg; +unsigned exclusive =0 ;/* create an empty layer LV */ len =strlen (lv_where->name) +32 ;
@@ -3122,6 +3124,9 @@ struct logical_volume *insert_layer_for_return NULL ; } +if (lv_is_active_exclusive_locally (lv_where)) + exclusive =1 ; +if (lv_is_active (lv_where) &&strstr (name,"_mimagetmp" )) {log_very_verbose ("Creating transient LV %s for mirror conversion in VG %s." , name, lv_where->vg->name);
@@ -3143,8 +3148,15 @@ struct logical_volume *insert_layer_for_return NULL ; } -if (!activate_lv (cmd, layer_lv)) { -log_error ("Failed to resume transient error LV %s for mirror conversion in VG %s." , name, lv_where->vg->name); +if (exclusive) + r =activate_lv_excl (cmd, layer_lv); +else + r =activate_lv (cmd, layer_lv); + +if (!r) { +log_error ("Failed to resume transient LV" +" %s for mirror conversion in VG %s." , + name, lv_where->vg->name);return NULL ; } }
lib/metadata/mirror.c +7 -2
@@ -419,8 +419,13 @@ static int _delete_lv(struct logical_vol } } -if (!activate_lv (cmd, lv)) - return_0; +if (lv_is_active_exclusive_locally (lv)) { +if (!activate_lv_excl (cmd, lv)) + return_0; + }else { +if (!activate_lv (cmd, lv)) + return_0; + }if (!deactivate_lv (cmd, lv)) return_0;