1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvconvert: use excl activation for conversion

Use properly exclusive activation when reactivating origin after
snapshot merge (since origin must have been previously also exlusively
activated).

Same applies when converting volumes to thin-pool or cache.

Previously used 'only' local activation incorrectly allowed local
activation of some targets (i.e. raid) - thus 'leaking' chance to
activate same device on another node - which can be a problem
for device types like raid.
This commit is contained in:
Zdenek Kabelac 2018-01-12 13:34:13 +01:00
parent c26458339e
commit e86910b052
4 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.178 - Version 2.02.178 -
===================================== =====================================
Preserve exclusive activation during thin snaphost merge.
Suppress some repeated reads of the same disk data at the device layer. Suppress some repeated reads of the same disk data at the device layer.
Avoid exceeding array bounds in allocation tag processing. Avoid exceeding array bounds in allocation tag processing.
Refactor metadata reading code to use callback functions. Refactor metadata reading code to use callback functions.

View File

@ -960,7 +960,7 @@ int wipe_cache_pool(struct logical_volume *cache_pool_lv)
} }
cache_pool_lv->status |= LV_TEMPORARY; cache_pool_lv->status |= LV_TEMPORARY;
if (!activate_lv_local(cache_pool_lv->vg->cmd, cache_pool_lv)) { if (!activate_lv_excl_local(cache_pool_lv->vg->cmd, cache_pool_lv)) {
log_error("Aborting. Failed to activate cache pool %s.", log_error("Aborting. Failed to activate cache pool %s.",
display_lvname(cache_pool_lv)); display_lvname(cache_pool_lv));
return 0; return 0;

View File

@ -526,7 +526,7 @@ int create_pool(struct logical_volume *pool_lv,
* or directly converted to invisible device via suspend/resume * or directly converted to invisible device via suspend/resume
*/ */
pool_lv->status |= LV_TEMPORARY; pool_lv->status |= LV_TEMPORARY;
if (!activate_lv_local(pool_lv->vg->cmd, pool_lv)) { if (!activate_lv_excl_local(pool_lv->vg->cmd, pool_lv)) {
log_error("Aborting. Failed to activate pool metadata %s.", log_error("Aborting. Failed to activate pool metadata %s.",
display_lvname(pool_lv)); display_lvname(pool_lv));
goto bad; goto bad;
@ -538,7 +538,7 @@ int create_pool(struct logical_volume *pool_lv,
} }
pool_lv->status &= ~LV_TEMPORARY; pool_lv->status &= ~LV_TEMPORARY;
/* Deactivates cleared metadata LV */ /* Deactivates cleared metadata LV */
if (!deactivate_lv_local(pool_lv->vg->cmd, pool_lv)) { if (!deactivate_lv(pool_lv->vg->cmd, pool_lv)) {
log_error("Aborting. Could not deactivate pool metadata %s.", log_error("Aborting. Could not deactivate pool metadata %s.",
display_lvname(pool_lv)); display_lvname(pool_lv));
return 0; return 0;
@ -660,7 +660,7 @@ static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg
return_0; return_0;
/* Spare LV should not be active */ /* Spare LV should not be active */
if (!deactivate_lv_local(vg->cmd, lv)) { if (!deactivate_lv(vg->cmd, lv)) {
log_error("Unable to deactivate pool metadata spare LV. " log_error("Unable to deactivate pool metadata spare LV. "
"Manual intervention required."); "Manual intervention required.");
return 0; return 0;

View File

@ -1970,14 +1970,14 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,
log_warn("WARNING: %s not zeroed.", snap_name); log_warn("WARNING: %s not zeroed.", snap_name);
else { else {
lv->status |= LV_TEMPORARY; lv->status |= LV_TEMPORARY;
if (!activate_lv_local(cmd, lv) || if (!activate_lv_excl_local(cmd, lv) ||
!wipe_lv(lv, (struct wipe_params) { .do_zero = 1 })) { !wipe_lv(lv, (struct wipe_params) { .do_zero = 1 })) {
log_error("Aborting. Failed to wipe snapshot exception store."); log_error("Aborting. Failed to wipe snapshot exception store.");
return 0; return 0;
} }
lv->status &= ~LV_TEMPORARY; lv->status &= ~LV_TEMPORARY;
/* Deactivates cleared metadata LV */ /* Deactivates cleared metadata LV */
if (!deactivate_lv_local(lv->vg->cmd, lv)) { if (!deactivate_lv(lv->vg->cmd, lv)) {
log_error("Failed to deactivate zeroed snapshot exception store."); log_error("Failed to deactivate zeroed snapshot exception store.");
return 0; return 0;
} }
@ -2170,7 +2170,7 @@ static int _lvconvert_merge_thin_snapshot(struct cmd_context *cmd,
log_print_unless_silent("Volume %s replaced origin %s.", log_print_unless_silent("Volume %s replaced origin %s.",
display_lvname(origin), display_lvname(lv)); display_lvname(origin), display_lvname(lv));
if (origin_is_active && !activate_lv(cmd, lv)) { if (origin_is_active && !activate_lv_excl_local(cmd, lv)) {
log_error("Failed to reactivate origin %s.", log_error("Failed to reactivate origin %s.",
display_lvname(lv)); display_lvname(lv));
return 0; return 0;
@ -2278,13 +2278,13 @@ static int _lvconvert_thin_pool_repair(struct cmd_context *cmd,
return 0; return 0;
} }
if (!activate_lv_local(cmd, pmslv)) { if (!activate_lv_excl_local(cmd, pmslv)) {
log_error("Cannot activate pool metadata spare volume %s.", log_error("Cannot activate pool metadata spare volume %s.",
pmslv->name); pmslv->name);
return 0; return 0;
} }
if (!activate_lv_local(cmd, mlv)) { if (!activate_lv_excl_local(cmd, mlv)) {
log_error("Cannot activate thin pool metadata volume %s.", log_error("Cannot activate thin pool metadata volume %s.",
mlv->name); mlv->name);
goto deactivate_pmslv; goto deactivate_pmslv;
@ -2476,13 +2476,13 @@ static int _lvconvert_cache_repair(struct cmd_context *cmd,
return 0; return 0;
} }
if (!activate_lv_local(cmd, pmslv)) { if (!activate_lv_excl_local(cmd, pmslv)) {
log_error("Cannot activate pool metadata spare volume %s.", log_error("Cannot activate pool metadata spare volume %s.",
pmslv->name); pmslv->name);
return 0; return 0;
} }
if (!activate_lv_local(cmd, mlv)) { if (!activate_lv_excl_local(cmd, mlv)) {
log_error("Cannot activate cache pool metadata volume %s.", log_error("Cannot activate cache pool metadata volume %s.",
mlv->name); mlv->name);
goto deactivate_pmslv; goto deactivate_pmslv;
@ -3130,7 +3130,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
if (zero_metadata) { if (zero_metadata) {
metadata_lv->status |= LV_TEMPORARY; metadata_lv->status |= LV_TEMPORARY;
if (!activate_lv_local(cmd, metadata_lv)) { if (!activate_lv_excl_local(cmd, metadata_lv)) {
log_error("Aborting. Failed to activate metadata lv."); log_error("Aborting. Failed to activate metadata lv.");
goto bad; goto bad;
} }