#define SIZE_BUF 128
/* TODO: unify stripe size validation across source code */
-static int _validate_stripesize(struct cmd_context *cmd,
- const struct volume_group *vg,
+static int _validate_stripesize(const struct volume_group *vg,
struct lvresize_params *lp)
{
if (lp->ac_stripesize_value > (STRIPE_SIZE_LIMIT * 2)) {
log_error("Stripe size cannot be larger than %s.",
- display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
+ display_size(vg->cmd, (uint64_t) STRIPE_SIZE_LIMIT));
return 0;
}
else if (lp->ac_stripesize_value > vg->extent_size) {
log_print_unless_silent("Reducing stripe size %s to maximum, "
"physical extent size %s.",
- display_size(cmd, lp->ac_stripesize_value),
- display_size(cmd, vg->extent_size));
+ display_size(vg->cmd, lp->ac_stripesize_value),
+ display_size(vg->cmd, vg->extent_size));
lp->stripe_size = vg->extent_size;
} else
lp->stripe_size = lp->ac_stripesize_value;
return 1;
}
-static int _request_confirmation(struct cmd_context *cmd,
- const struct volume_group *vg,
+static int _request_confirmation(const struct volume_group *vg,
const struct logical_volume *lv,
const struct lvresize_params *lp)
{
struct lvinfo info = { 0 };
- if (!lv_info(cmd, lv, 0, &info, 1, 0) && driver_version(NULL, 0)) {
+ if (!lv_info(vg->cmd, lv, 0, &info, 1, 0) && driver_version(NULL, 0)) {
log_error("lv_info failed: aborting");
return 0;
}
log_warn("WARNING: Reducing active%s logical volume to %s",
info.open_count ? " and open" : "",
- display_size(cmd, (uint64_t) lp->extents * vg->extent_size));
+ display_size(vg->cmd, (uint64_t) lp->extents * vg->extent_size));
log_warn("THIS MAY DESTROY YOUR DATA (filesystem etc.)");
return 1;
}
-static int _adjust_policy_params(struct cmd_context *cmd,
- struct logical_volume *lv, struct lvresize_params *lp)
+static int _adjust_policy_params(struct logical_volume *lv, struct lvresize_params *lp)
{
+ struct cmd_context *cmd = lv->vg->cmd;
dm_percent_t percent;
int policy_threshold, policy_amount;
return 0;
}
-static int _lvresize_poolmetadata_prepare(struct cmd_context *cmd,
- struct lvresize_params *lp,
- const struct logical_volume *pool_lv)
+static int _lvresize_poolmetadata_prepare(struct logical_volume *pool_lv,
+ struct lvresize_params *lp)
{
uint32_t extents;
struct logical_volume *lv = first_seg(pool_lv)->metadata_lv;
lp->poolmetadatasize += vg->extent_size -
(lp->poolmetadatasize % vg->extent_size);
log_print_unless_silent("Rounding pool metadata size to boundary between physical extents: %s",
- display_size(cmd, lp->poolmetadatasize));
+ display_size(vg->cmd, lp->poolmetadatasize));
}
if (!(extents = extents_from_size(vg->cmd, lp->poolmetadatasize,
/* FIXME Split here and move validation code earlier alongside rest of validation code */
if (extents == lv->le_count) {
log_print_unless_silent("Metadata volume %s has already %s.",
- lv->name, display_size(cmd, lv->size));
+ display_lvname(lv), display_size(vg->cmd, lv->size));
return 2;
}
return 1;
}
-static int _lvresize_poolmetadata(struct cmd_context *cmd, struct volume_group *vg,
+static int _lvresize_poolmetadata(struct logical_volume *pool_lv,
struct lvresize_params *lp,
- const struct logical_volume *pool_lv,
struct dm_list *pvh)
{
struct logical_volume *lv = first_seg(pool_lv)->metadata_lv;
+ struct volume_group *vg = lv->vg;
alloc_policy_t alloc = lp->ac_alloc ? : lv->alloc;
struct lv_segment *mseg = last_seg(lv);
uint32_t seg_mirrors = lv_mirror_count(lv);
return_0;
log_print_unless_silent("Extending logical volume %s to %s.",
- lv->name,
- display_size(cmd, (uint64_t) lp->poolmetadataextents *
+ display_lvname(lv),
+ display_size(vg->cmd, (uint64_t) lp->poolmetadataextents *
vg->extent_size));
if (!lv_extend(lv,
mseg->segtype,
return 1;
}
-static int _lvresize_check_lv(struct cmd_context *cmd, struct logical_volume *lv,
+static int _lvresize_check_lv(struct logical_volume *lv,
struct lvresize_params *lp)
{
struct volume_group *vg = lv->vg;
return 0;
}
- if (lp->ac_stripesize && !_validate_stripesize(cmd, vg, lp))
+ if (lp->ac_stripesize && !_validate_stripesize(vg, lp))
return_0;
if (lp->ac_stripes) {
return 1;
}
-static int _lvresize_check_type(struct cmd_context *cmd, const struct logical_volume *lv,
+static int _lvresize_check_type(const struct logical_volume *lv,
struct lvresize_params *lp)
{
if (lv_is_origin(lv)) {
/* Request confirmation before operations that are often mistakes. */
if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
- !_request_confirmation(cmd, vg, lv, lp))
+ !_request_confirmation(vg, lv, lp))
return_NULL;
if (lp->resizefs) {
int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
struct lvresize_params *lp, struct dm_list *pvh)
{
- if (!_lvresize_check_lv(cmd, lv, lp))
+ if (!_lvresize_check_lv(lv, lp))
return_0;
- if (lp->ac_policy && !_adjust_policy_params(cmd, lv, lp))
+ if (lp->ac_policy && !_adjust_policy_params(lv, lp))
return_0;
if (lp->size && !_lvresize_adjust_size(lv->vg, lp->size, lp->sign,
lp->poolmetadatasize = 0;
}
- if (lp->extents && !_lvresize_check_type(cmd, lv, lp))
+ if (lp->extents && !_lvresize_check_type(lv, lp))
return_0;
if (lp->poolmetadatasize &&
- !_lvresize_poolmetadata_prepare(cmd, lp, lv))
+ !_lvresize_poolmetadata_prepare(lv, lp))
return_0;
return 1;
return_0;
if (lp->poolmetadataextents) {
- if (!_lvresize_poolmetadata(cmd, vg, lp, lv, pvh))
+ if (!_lvresize_poolmetadata(lv, lp, pvh))
return_0;
lock_lv = lv;
}