mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
thin: fix lvconvert for active pool.
Prohibit conversion of pool device with active thin volumes. Properly restore active states only for active thin pool volume. Use new LV_NOSCAN when converting volume into thin pool's metadata.
This commit is contained in:
parent
48df36b8c5
commit
1b7631101b
@ -1,5 +1,6 @@
|
||||
Version 2.02.104
|
||||
===================================
|
||||
Fix lvconvert swap of poolmetadata volume for active thin pool.
|
||||
Check for open count with a timeout before removal/deactivation of an LV.
|
||||
Report RAID images split with tracking as out-of-sync ("I").
|
||||
Improve parsing of snapshot lv segment.
|
||||
|
@ -2275,6 +2275,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
||||
struct logical_volume *pool_metadata_lv;
|
||||
struct logical_volume *external_lv = NULL;
|
||||
char metadata_name[NAME_LEN], data_name[NAME_LEN];
|
||||
int activate_pool;
|
||||
|
||||
if (!lv_is_visible(pool_lv)) {
|
||||
log_error("Can't convert internal LV %s/%s.",
|
||||
@ -2303,6 +2304,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
if (lv_is_thin_pool(pool_lv)) {
|
||||
activate_pool = lv_is_active(pool_lv);
|
||||
r = 1; /* Already existing thin pool */
|
||||
goto out;
|
||||
}
|
||||
@ -2315,6 +2317,9 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allow to have only thinpool active and restore it's active state */
|
||||
activate_pool = lv_is_active(pool_lv);
|
||||
|
||||
/* We are changing target type, so deactivate first */
|
||||
if (!deactivate_lv(cmd, pool_lv)) {
|
||||
log_error("Aborting. Failed to deactivate logical volume %s/%s.",
|
||||
@ -2322,6 +2327,13 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pool_is_active(pool_lv)) {
|
||||
/* If any thin volume is also active - abort here */
|
||||
log_error("Cannot convert pool %s/%s with active thin volumes.",
|
||||
pool_lv->vg->name, pool_lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((dm_snprintf(metadata_name, sizeof(metadata_name), "%s_tmeta",
|
||||
pool_lv->name) < 0) ||
|
||||
(dm_snprintf(data_name, sizeof(data_name), "%s_tdata",
|
||||
@ -2423,6 +2435,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
||||
goto mda_write;
|
||||
}
|
||||
|
||||
metadata_lv->status |= LV_NOSCAN;
|
||||
if (!lv_is_active(metadata_lv) &&
|
||||
!activate_lv_local(cmd, metadata_lv)) {
|
||||
log_error("Aborting. Failed to activate thin metadata lv.");
|
||||
@ -2515,7 +2528,8 @@ mda_write:
|
||||
if (!vg_write(pool_lv->vg) || !vg_commit(pool_lv->vg))
|
||||
return_0;
|
||||
|
||||
if (!activate_lv_excl(cmd, pool_lv)) {
|
||||
if (activate_pool &&
|
||||
!activate_lv_excl(cmd, pool_lv)) {
|
||||
log_error("Failed to activate pool logical volume %s/%s.",
|
||||
pool_lv->vg->name, pool_lv->name);
|
||||
/* Deactivate subvolumes */
|
||||
|
Loading…
Reference in New Issue
Block a user