Store size arguments as sectors internally.
Version 2.02.29 -
==================================
+ Accept sizes with --readahead argument.
+ Store size arguments as sectors internally.
Attempt to remove incomplete LVs with lvcreate zeroing/activation problems.
Add read_ahead activation code.
Add activation/readahead configuration option and FMT_RESTRICTED_READAHEAD.
const void *data, void *private __attribute((unused)))
{
const struct logical_volume *lv = (const struct logical_volume *) data;
- uint64_t size;
if (lv->read_ahead == DM_READ_AHEAD_AUTO) {
dm_report_field_set_value(field, "auto", &_minusone);
return 1;
}
- size = (uint64_t) lv->read_ahead;
-
- return _size64_disp(rh, mem, field, &size, private);
+ return _size32_disp(rh, mem, field, &lv->read_ahead, private);
}
static int _lvkreadahead_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
- void *private __attribute((unused)))
+ void *private)
{
const struct logical_volume *lv = (const struct logical_volume *) data;
struct lvinfo info;
- if (lv_info(lv->vg->cmd, lv, &info, 0, 1) && info.exists)
- return dm_report_field_int(rh, field, &info.read_ahead);
+ if (!lv_info(lv->vg->cmd, lv, &info, 0, 1) || !info.exists)
+ return dm_report_field_uint64(rh, field, &_minusone);
- return dm_report_field_uint64(rh, field, &_minusone);
+ return _size32_disp(rh, mem, field, &info.read_ahead, private);
}
static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem,
log_error("Negative chunk size is invalid");
return 0;
}
- lp->chunk_size = 2 * arg_uint_value(cmd, chunksize_ARG, 8);
+ lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
(lp->chunk_size & (lp->chunk_size - 1))) {
log_error("Chunk size must be a power of 2 in the "
log_error("Negative regionsize is invalid");
return 0;
}
- lp->region_size = 2 * arg_uint_value(cmd,
- regionsize_ARG, 0);
+ lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
} else {
region_size = 2 * find_config_tree_int(cmd,
"activation/mirror_region_size",
log_error("Negative size is invalid");
return 0;
}
- lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)) * 2;
+ lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
lp->percent = PERCENT_NONE;
}
if (lp->stripes > 1 && !lp->stripe_size) {
lp->stripe_size = find_config_tree_int(cmd,
"metadata/stripesize",
- DEFAULT_STRIPESIZE) * 2;
+ DEFAULT_STRIPESIZE);
log_print("Using default stripesize %s",
display_size(cmd, (uint64_t) lp->stripe_size));
}
return 0;
}
/* Check to make sure we won't overflow lp->stripe_size */
- if(arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT) {
+ if(arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) {
log_error("Stripe size cannot be larger than %s",
display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
return 0;
}
- lp->stripe_size = 2 * arg_uint_value(cmd, stripesize_ARG, 0);
+ lp->stripe_size = arg_uint_value(cmd, stripesize_ARG, 0);
}
log_error("Negative regionsize is invalid");
return 0;
}
- lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
+ lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
} else {
region_size = 2 * find_config_tree_int(cmd,
"activation/mirror_region_size",
log_error("Negative chunk size is invalid");
return 0;
}
- lp->chunk_size = 2 * arg_uint_value(cmd, chunksize_ARG, 8);
+ lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
(lp->chunk_size & (lp->chunk_size - 1))) {
log_error("Chunk size must be a power of 2 in the "
return 1;
}
+/* Size stored in sectors */
static int _size_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a, int factor)
{
char *ptr;
while (i-- > 0)
v *= 1024;
+
+ v *= 2;
} else
v *= factor;
int size_kb_arg(struct cmd_context *cmd, struct arg *a)
{
- return _size_arg(cmd, a, 1);
+ return _size_arg(cmd, a, 2);
}
int size_mb_arg(struct cmd_context *cmd, struct arg *a)
{
- return _size_arg(cmd, a, 1024);
+ return _size_arg(cmd, a, 2048);
}
int int_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
*/
int readahead_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
{
- if (int_arg(cmd, a))
- return 1;
-
if (!strcasecmp(a->value, "auto")) {
a->ui_value = DM_READ_AHEAD_AUTO;
return 1;
return 1;
}
- return 0;
+ if (!_size_arg(cmd, a, 1))
+ return 0;
+
+ if (a->sign == SIGN_MINUS)
+ return 0;
+
+ return 1;
}
static void __alloc(int size)
return 0;
}
- if (arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT) {
+ if (arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) {
log_error("Stripe size cannot be larger than %s",
display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
return 0;
if (!(vg->fid->fmt->features & FMT_SEGMENTS))
log_warn("Varied stripesize not supported. Ignoring.");
- else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size) {
+ else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size * 2) {
log_error("Reducing stripe size %s to maximum, "
"physical extent size %s",
display_size(cmd,
- (uint64_t) arg_uint_value(cmd, stripesize_ARG, 0) * 2),
+ (uint64_t) arg_uint_value(cmd, stripesize_ARG, 0)),
display_size(cmd, (uint64_t) vg->extent_size));
lp->stripe_size = vg->extent_size;
} else
- lp->stripe_size = 2 * arg_uint_value(cmd,
- stripesize_ARG, 0);
+ lp->stripe_size = arg_uint_value(cmd, stripesize_ARG, 0);
if (lp->mirrors) {
log_error("Mirrors and striping cannot be combined yet.");
/* Size returned in kilobyte units; held in sectors */
if (arg_count(cmd, size_ARG)) {
- lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)) * 2;
+ lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
lp->sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
lp->percent = PERCENT_NONE;
}
log_error("Physical volume size may not be negative");
goto error;
}
- size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0)) * 2;
+ size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0));
if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) {
log_error("Metadata size may not be negative");
goto error;
}
- pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0))
- * 2;
+ pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0));
if (!pvmetadatasize)
pvmetadatasize = find_config_tree_int(cmd,
"metadata/pvmetadatasize",
}
params.new_size = arg_uint64_value(cmd, physicalvolumesize_ARG,
- UINT64_C(0)) * 2;
+ UINT64_C(0));
params.done = 0;
params.total = 0;
return EINVALID_CMD_LINE;
}
- extent_size = arg_uint_value(cmd, physicalextentsize_ARG, 0) * 2;
+ extent_size = arg_uint_value(cmd, physicalextentsize_ARG, 0);
if (!extent_size) {
log_error("Physical extent size may not be zero");
return EINVALID_CMD_LINE;
}
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG,
- UINT64_C(0)) * 2;
+ UINT64_C(0));
if (!pvmetadatasize)
pvmetadatasize =
find_config_tree_int(cmd,
/* Units of 512-byte sectors */
extent_size =
- arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
+ arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT);
if (!extent_size) {
log_error("Physical extent size may not be zero");