master - lvconvert: Set lp->segtype in only one place.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d0df1ff995f3270232ec5179057482c558119a92 Commit: d0df1ff995f3270232ec5179057482c558119a92 Parent: 1ce958bc5ea2827fdb945b2177616e8f253486a1 Author: Alasdair G Kergon <[email protected]> AuthorDate: Sat Jul 30 18:12:57 2016 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Sat Jul 30 18:20:04 2016 +0100
lvconvert: Set lp->segtype in only one place.
--- tools/lvconvert.c | 30 ++++++++++++++---------------- 1 files changed, 14 insertions(+), 16 deletions(-)
tools/lvconvert.c +14 -16
@@ -331,6 +331,7 @@ static int _read_pool_params(struct cmd_context *cmd, int *pargc, char ***pargv, {int cachepool =0 ;int thinpool =0 ; +struct segment_type *segtype;if ((lp->pool_data_name =arg_str_value (cmd, cachepool_ARG,NULL ))) { if (lp->type_str[0] &&
@@ -388,10 +389,10 @@ static int _read_pool_params(struct cmd_context *cmd, int *pargc, char ***pargv, splitmirrors_ARG, splitsnapshot_ARG, -1)) return_0; -if (!(lp->segtype =get_segtype_from_string (cmd, lp->type_str))) +if (!(segtype =get_segtype_from_string (cmd, lp->type_str))) return_0; - if (!get_pool_params(cmd, lp->segtype, &lp->passed_args, + if (!get_pool_params(cmd, segtype, &lp->passed_args, &lp->pool_metadata_size, &lp->poolmetadataspare, &lp->chunk_size, &lp->discards,
@@ -528,7 +529,6 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv, lp->type_str =SEG_TYPE_NAME_THIN ; } -/* May set lp->segtype */ if (!_read_pool_params (cmd, &argc, &argv, lp)) return_0;
@@ -797,17 +797,6 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv, lp->pv_count = argc; lp->pvs = argv; -/* If we have type_str, set up the segtype to match. */ -if (*lp->type_str && !(lp->segtype =get_segtype_from_string (cmd, lp->type_str))) - return_0; - -if (activation () && lp->segtype && lp->segtype->ops->target_present && - !lp->segtype->ops->target_present (cmd,NULL , &lp->target_attr)) { -log_error ("%s: Required device-mapper target(s) not " -"detected in your kernel." , lp->segtype->name); -return 0 ; - } -return 1 ; }
@@ -4372,9 +4361,18 @@ static int _lvconvert(struct cmd_context *cmd, struct logical_volume *lv, } } -/* If we don't have a specific new segtype to use, keep the existing one. */ -if (!lp->segtype) +/* Set up segtype either from type_str or else to match the existing one. */ +if (!*lp->type_str) lp->segtype = seg->segtype; +else if (!(lp->segtype =get_segtype_from_string (cmd, lp->type_str))) + return_0; + +if (activation () && lp->segtype && lp->segtype->ops->target_present && + !lp->segtype->ops->target_present (cmd,NULL , &lp->target_attr)) { +log_error ("%s: Required device-mapper target(s) not " +"detected in your kernel." , lp->segtype->name); +return 0 ; + }/* Process striping parameters */ /* FIXME This is incomplete */