mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmlockd: fix lvconvert to thin-pool
This commit is contained in:
parent
696ee52ffd
commit
6ca97e6e62
@ -3077,7 +3077,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
struct lv_segment *seg;
|
struct lv_segment *seg;
|
||||||
unsigned int target_attr = ~0;
|
unsigned int target_attr = ~0;
|
||||||
unsigned int activate_pool;
|
unsigned int activate_pool;
|
||||||
unsigned int lock_active_pool;
|
|
||||||
unsigned int lock_active_pool_done = 0;
|
unsigned int lock_active_pool_done = 0;
|
||||||
unsigned int zero_metadata;
|
unsigned int zero_metadata;
|
||||||
uint64_t meta_size;
|
uint64_t meta_size;
|
||||||
@ -3126,12 +3125,10 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
is_active = lv_is_active(lv);
|
is_active = lv_is_active(lv);
|
||||||
|
|
||||||
activate_pool = to_thinpool && is_active;
|
activate_pool = to_thinpool && is_active;
|
||||||
lock_active_pool = (to_thinpool || to_thin) && is_active;
|
|
||||||
|
|
||||||
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
|
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
|
||||||
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
|
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
|
||||||
|
|
||||||
/* An existing LV needs to have its lock freed once it becomes a data LV. */
|
|
||||||
if (vg_is_shared(vg) && lv->lock_args) {
|
if (vg_is_shared(vg) && lv->lock_args) {
|
||||||
lockd_data_args = dm_pool_strdup(vg->vgmem, lv->lock_args);
|
lockd_data_args = dm_pool_strdup(vg->vgmem, lv->lock_args);
|
||||||
lockd_data_name = dm_pool_strdup(vg->vgmem, lv->name);
|
lockd_data_name = dm_pool_strdup(vg->vgmem, lv->name);
|
||||||
@ -3441,11 +3438,11 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
goto_bad;
|
goto_bad;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new lock for a thin pool LV. A cache pool LV has no lock.
|
* If the input LV is being converted to a thin pool, the input LV lock
|
||||||
* Locks are removed from existing LVs that are being converted to
|
* is used for the thin pool LV. If the input LV is being converted to
|
||||||
* data and meta LVs (they are unlocked and deleted below.)
|
* a thin LV, a new lock is created for the thin pool and the lock from
|
||||||
* Acquire the new thin pool lock if the pool will remain active at
|
* the input LV is freed. A cache pool LV has no lock, so the lock for
|
||||||
* the end of the command.
|
* the input LV is freed.
|
||||||
*/
|
*/
|
||||||
if (vg_is_shared(vg)) {
|
if (vg_is_shared(vg)) {
|
||||||
lv->lock_args = NULL;
|
lv->lock_args = NULL;
|
||||||
@ -3453,18 +3450,25 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
data_lv->lock_args = NULL;
|
data_lv->lock_args = NULL;
|
||||||
metadata_lv->lock_args = NULL;
|
metadata_lv->lock_args = NULL;
|
||||||
|
|
||||||
if (!to_cachepool) {
|
if (to_thin) {
|
||||||
if (!lockd_init_lv_args(cmd, vg, pool_lv, vg->lock_type, &pool_lv->lock_args)) {
|
if (!lockd_init_lv_args(cmd, vg, pool_lv, vg->lock_type, &pool_lv->lock_args)) {
|
||||||
log_error("Cannot allocate lock for new pool LV.");
|
log_error("Cannot allocate lock for new pool LV.");
|
||||||
goto_bad;
|
goto_bad;
|
||||||
}
|
}
|
||||||
if (lock_active_pool) {
|
} else if (to_thinpool) {
|
||||||
if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
|
pool_lv->lock_args = lockd_data_args;
|
||||||
log_error("Failed to lock new pool LV %s.", display_lvname(pool_lv));
|
/* Don't free this lock below. */
|
||||||
goto_bad;
|
lockd_data_args = NULL;
|
||||||
}
|
lockd_data_name = NULL;
|
||||||
lock_active_pool_done = 1;
|
}
|
||||||
|
|
||||||
|
/* Acquire the thin pool lock if the pool will remain active. */
|
||||||
|
if ((to_thin || to_thinpool) && is_active) {
|
||||||
|
if (!lockd_lv(cmd, pool_lv, "ex", LDLV_PERSISTENT)) {
|
||||||
|
log_error("Failed to lock new pool LV %s.", display_lvname(pool_lv));
|
||||||
|
goto_bad;
|
||||||
}
|
}
|
||||||
|
lock_active_pool_done = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3506,8 +3510,7 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unlock and free the locks from existing LVs that became pool data
|
* Unlock and free locks that are no longer used.
|
||||||
* and meta LVs.
|
|
||||||
*/
|
*/
|
||||||
if (lockd_data_name) {
|
if (lockd_data_name) {
|
||||||
if (!lockd_lv_name(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args, "un", lockd_data_flags)) {
|
if (!lockd_lv_name(cmd, vg, lockd_data_name, &lockd_data_id, lockd_data_args, "un", lockd_data_flags)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user