mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
thin: read paramaters in front
Fill paramaters into lvconvert_params - so we could use it independently on args()
This commit is contained in:
parent
82eee72019
commit
f572bf987e
@ -18,9 +18,12 @@
|
|||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
|
|
||||||
struct lvconvert_params {
|
struct lvconvert_params {
|
||||||
|
int force;
|
||||||
int snapshot;
|
int snapshot;
|
||||||
int merge;
|
int merge;
|
||||||
int merge_mirror;
|
int merge_mirror;
|
||||||
|
int thin;
|
||||||
|
int yes;
|
||||||
int zero;
|
int zero;
|
||||||
|
|
||||||
const char *origin;
|
const char *origin;
|
||||||
@ -97,12 +100,12 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
|
|||||||
|
|
||||||
if (lp->pool_data_lv_name) {
|
if (lp->pool_data_lv_name) {
|
||||||
if (*pargc) {
|
if (*pargc) {
|
||||||
if (!arg_count(cmd, thin_ARG)) {
|
if (!lp->thin) {
|
||||||
log_error("More then one logical volume name specified.");
|
log_error("More then one logical volume name specified.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (arg_count(cmd, thin_ARG)) {
|
if (lp->thin) {
|
||||||
log_error("External thin volume name is missing.");
|
log_error("External thin volume name is missing.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -219,6 +222,9 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg_count(cmd, thin_ARG))
|
||||||
|
lp->thin = 1;
|
||||||
|
|
||||||
if (arg_count(cmd, thinpool_ARG)) {
|
if (arg_count(cmd, thinpool_ARG)) {
|
||||||
if (arg_count(cmd, merge_ARG)) {
|
if (arg_count(cmd, merge_ARG)) {
|
||||||
log_error("--thinpool and --merge are mutually exlusive.");
|
log_error("--thinpool and --merge are mutually exlusive.");
|
||||||
@ -241,7 +247,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
lp->discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, THIN_DISCARDS_PASSDOWN);
|
lp->discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, THIN_DISCARDS_PASSDOWN);
|
||||||
} else if (arg_count(cmd, thin_ARG)) {
|
} else if (lp->thin) {
|
||||||
log_error("--thin is only valid with --thinpool.");
|
log_error("--thin is only valid with --thinpool.");
|
||||||
return 0;
|
return 0;
|
||||||
} else if (arg_count(cmd, discards_ARG)) {
|
} else if (arg_count(cmd, discards_ARG)) {
|
||||||
@ -488,6 +494,9 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
|||||||
return_0;
|
return_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lp->force = arg_count(cmd, force_ARG);
|
||||||
|
lp->yes = arg_count(cmd, yes_ARG);
|
||||||
|
|
||||||
if (activation() && lp->segtype && lp->segtype->ops->target_present &&
|
if (activation() && lp->segtype && lp->segtype->ops->target_present &&
|
||||||
!lp->segtype->ops->target_present(cmd, NULL, &lp->target_attr)) {
|
!lp->segtype->ops->target_present(cmd, NULL, &lp->target_attr)) {
|
||||||
log_error("%s: Required device-mapper target(s) not "
|
log_error("%s: Required device-mapper target(s) not "
|
||||||
@ -2001,7 +2010,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_count(cmd, thin_ARG)) {
|
if (lp->thin) {
|
||||||
external_lv = pool_lv;
|
external_lv = pool_lv;
|
||||||
if (!(pool_lv = find_lv(external_lv->vg, lp->pool_data_lv_name))) {
|
if (!(pool_lv = find_lv(external_lv->vg, lp->pool_data_lv_name))) {
|
||||||
log_error("Can't find pool LV %s/%s.",
|
log_error("Can't find pool LV %s/%s.",
|
||||||
@ -2072,7 +2081,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
|||||||
log_error("Aborting. Failed to deactivate thin metadata lv.");
|
log_error("Aborting. Failed to deactivate thin metadata lv.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!arg_count(cmd, yes_ARG) &&
|
if (!lp->yes &&
|
||||||
yes_no_prompt("Do you want to swap metadata of %s/%s pool with "
|
yes_no_prompt("Do you want to swap metadata of %s/%s pool with "
|
||||||
"volume %s/%s? [y/n]: ",
|
"volume %s/%s? [y/n]: ",
|
||||||
pool_lv->vg->name, pool_lv->name,
|
pool_lv->vg->name, pool_lv->name,
|
||||||
@ -2093,7 +2102,7 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
|
|||||||
if (!arg_count(cmd, chunksize_ARG))
|
if (!arg_count(cmd, chunksize_ARG))
|
||||||
lp->chunk_size = seg->chunk_size;
|
lp->chunk_size = seg->chunk_size;
|
||||||
else if ((lp->chunk_size != seg->chunk_size) &&
|
else if ((lp->chunk_size != seg->chunk_size) &&
|
||||||
!arg_count(cmd, force_ARG) &&
|
!lp->force &&
|
||||||
yes_no_prompt("Do you really want to change chunk size %s to %s for %s/%s "
|
yes_no_prompt("Do you really want to change chunk size %s to %s for %s/%s "
|
||||||
"pool volume? [y/n]: ", display_size(cmd, seg->chunk_size),
|
"pool volume? [y/n]: ", display_size(cmd, seg->chunk_size),
|
||||||
display_size(cmd, lp->chunk_size),
|
display_size(cmd, lp->chunk_size),
|
||||||
|
Loading…
Reference in New Issue
Block a user