mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-18 10:04:20 +03:00
Refactor lvcreate mirror parameter validation.
This commit is contained in:
parent
479921f1ef
commit
f18ef24471
@ -240,31 +240,14 @@ static int _read_stripe_params(struct lvcreate_params *lp,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _read_mirror_params(struct lvcreate_params *lp,
|
/*
|
||||||
struct cmd_context *cmd,
|
* Generic mirror parameter checks.
|
||||||
int *pargc __attribute((unused)))
|
* FIXME: Should eventually be moved into lvm library.
|
||||||
|
*/
|
||||||
|
static int _validate_mirror_params(struct cmd_context *cmd,
|
||||||
|
struct lvcreate_params *lp)
|
||||||
{
|
{
|
||||||
int region_size;
|
|
||||||
int pagesize = lvm_getpagesize();
|
int pagesize = lvm_getpagesize();
|
||||||
const char *mirrorlog;
|
|
||||||
|
|
||||||
if (arg_count(cmd, regionsize_ARG)) {
|
|
||||||
if (arg_sign_value(cmd, regionsize_ARG, 0) == SIGN_MINUS) {
|
|
||||||
log_error("Negative regionsize is invalid");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
|
|
||||||
} else {
|
|
||||||
region_size = 2 * find_config_tree_int(cmd,
|
|
||||||
"activation/mirror_region_size",
|
|
||||||
DEFAULT_MIRROR_REGION_SIZE);
|
|
||||||
if (region_size < 0) {
|
|
||||||
log_error("Negative regionsize in configuration file "
|
|
||||||
"is invalid");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
lp->region_size = region_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lp->region_size & (lp->region_size - 1)) {
|
if (lp->region_size & (lp->region_size - 1)) {
|
||||||
log_error("Region size (%" PRIu32 ") must be a power of 2",
|
log_error("Region size (%" PRIu32 ") must be a power of 2",
|
||||||
@ -284,6 +267,16 @@ static int _read_mirror_params(struct lvcreate_params *lp,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _read_mirror_params(struct lvcreate_params *lp,
|
||||||
|
struct cmd_context *cmd,
|
||||||
|
int *pargc __attribute((unused)))
|
||||||
|
{
|
||||||
|
int region_size;
|
||||||
|
const char *mirrorlog;
|
||||||
|
|
||||||
if (arg_count(cmd, corelog_ARG))
|
if (arg_count(cmd, corelog_ARG))
|
||||||
lp->corelog = 1;
|
lp->corelog = 1;
|
||||||
|
|
||||||
@ -308,6 +301,27 @@ static int _read_mirror_params(struct lvcreate_params *lp,
|
|||||||
|
|
||||||
lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0;
|
lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0;
|
||||||
|
|
||||||
|
if (arg_count(cmd, regionsize_ARG)) {
|
||||||
|
if (arg_sign_value(cmd, regionsize_ARG, 0) == SIGN_MINUS) {
|
||||||
|
log_error("Negative regionsize is invalid");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
|
||||||
|
} else {
|
||||||
|
region_size = 2 * find_config_tree_int(cmd,
|
||||||
|
"activation/mirror_region_size",
|
||||||
|
DEFAULT_MIRROR_REGION_SIZE);
|
||||||
|
if (region_size < 0) {
|
||||||
|
log_error("Negative regionsize in configuration file "
|
||||||
|
"is invalid");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
lp->region_size = region_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_validate_mirror_params(cmd, lp))
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user