master - cleanup: drop setting lv_name
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=83d483269de367...
Commit: 83d483269de367facc14eee9072b79ffabdcaf82
Parent: e5b7ebcddabb885dd8a2f4cb5b5a0a32af834076
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 15 14:55:37 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:59:29 2016 +0200
cleanup: drop setting lv_name
lv_name arg is only used without known LV for resolving '*lv'.
Once we know *lv, never use lv_name ever again.
So setting it when passing *lv has not needed.
---
lib/locking/lvmlockd.c | 1 -
liblvm/lvm_lv.c | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index f9d215a..e025428 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -367,7 +367,6 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
{
struct logical_volume *lv = vg->sanlock_lv;
struct lvresize_params lp = {
- .lv_name = vg->sanlock_lv->name,
.sign = SIGN_NONE,
.size = lv->size + ((extend_mb * 1024 * 1024) / SECTOR_SIZE),
.percent = PERCENT_NONE,
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index ccdc340..05dd482 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -457,7 +457,6 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size)
{
int rc = 0;
struct lvresize_params lp = {
- .lv_name = lv->name,
.sign = SIGN_NONE,
.percent = PERCENT_NONE,
.resize = LV_ANY,
7 years, 10 months
master - cleanup: remove unused code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e5b7ebcddabb88...
Commit: e5b7ebcddabb885dd8a2f4cb5b5a0a32af834076
Parent: 5a919e48053079670e6318fe862783e720dd2aea
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 17 15:22:27 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:59:29 2016 +0200
cleanup: remove unused code
---
lib/metadata/lv_manip.c | 83 --------------------------------------
lib/metadata/metadata-exported.h | 1 -
2 files changed, 0 insertions(+), 84 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 46815e3..8f07267 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4549,89 +4549,6 @@ static uint32_t lvseg_get_stripes(struct lv_segment *seg, uint32_t *stripesize)
return 0;
}
-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;
- struct volume_group *vg = pool_lv->vg;
-
- lp->poolmetadataextents = 0;
-
- if (!thin_pool_feature_supported(pool_lv, THIN_FEATURE_METADATA_RESIZE)) {
- log_error("Support for online metadata resize not detected.");
- return 0;
- }
-
- if (lp->poolmetadata_size % vg->extent_size) {
- lp->poolmetadata_size += vg->extent_size -
- (lp->poolmetadata_size % vg->extent_size);
- log_print_unless_silent("Rounding pool metadata size to boundary between physical extents: %s",
- display_size(vg->cmd, lp->poolmetadata_size));
- }
-
- if (!(extents = extents_from_size(vg->cmd, lp->poolmetadata_size,
- vg->extent_size)))
- return_0;
-
- if (lp->poolmetadata_sign == SIGN_PLUS) {
- if (extents >= (MAX_EXTENT_COUNT - lv->le_count)) {
- log_error("Unable to extend %s by %u extents, exceeds limit (%u).",
- lv->name, lv->le_count, MAX_EXTENT_COUNT);
- return 0;
- }
- extents += lv->le_count;
- }
-
- if ((uint64_t)extents * vg->extent_size > DM_THIN_MAX_METADATA_SIZE) {
- log_print_unless_silent("Rounding size to maximum supported size 16GiB "
- "for metadata volume %s.", lv->name);
- extents = (DM_THIN_MAX_METADATA_SIZE + vg->extent_size - 1) /
- vg->extent_size;
- }
-
- /* 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.",
- display_lvname(lv), display_size(vg->cmd, lv->size));
- return 2;
- }
-
- lp->poolmetadataextents = extents;
-
- return 1;
-}
-
-static int _lvresize_poolmetadata(struct logical_volume *pool_lv,
- struct lvresize_params *lp,
- 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->alloc ? : lv->alloc;
- struct lv_segment *mseg = last_seg(lv);
- uint32_t seg_mirrors = lv_mirror_count(lv);
-
- if (!archive(vg))
- return_0;
-
- log_print_unless_silent("Extending logical volume %s to %s.",
- display_lvname(lv),
- display_size(vg->cmd, (uint64_t) lp->poolmetadataextents *
- vg->extent_size));
- if (!lv_extend(lv,
- mseg->segtype,
- mseg->area_count / seg_mirrors,
- mseg->stripe_size,
- seg_mirrors,
- mseg->region_size,
- lp->poolmetadataextents - lv->le_count,
- pvh, alloc, 0))
- return_0;
-
- return 1;
-}
-
static int _lvresize_check(struct logical_volume *lv,
struct lvresize_params *lp)
{
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index b8275d6..f47fa1d 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -609,7 +609,6 @@ struct lvresize_params {
uint64_t poolmetadata_size;
sign_t poolmetadata_sign;
- uint32_t poolmetadataextents;
/* Per LV applied parameters */
7 years, 10 months
master - cleanup: remove unused sizearg variable
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5a919e48053079...
Commit: 5a919e48053079670e6318fe862783e720dd2aea
Parent: 4de15aa58d2cd25075d3b17c3d3d9ad06b4bb493
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 17 13:25:56 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:59:29 2016 +0200
cleanup: remove unused sizearg variable
It's not used for anything now.
---
lib/locking/lvmlockd.c | 1 -
lib/metadata/lv_manip.c | 1 -
lib/metadata/metadata-exported.h | 1 -
liblvm/lvm_lv.c | 1 -
tools/lvresize.c | 1 -
5 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index e865c10..f9d215a 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -373,7 +373,6 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
.percent = PERCENT_NONE,
.resize = LV_EXTEND,
.force = 1,
- .sizeargs = 1,
};
if (!lv_resize(lv, &lp, &vg->pvs)) {
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 70969e8..46815e3 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5004,7 +5004,6 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
seg_size = lp->extents - existing_logical_extents; // Recalculate
if (lp->extents == existing_logical_extents) {
/* Signal that normal resizing is not required */
- lp->sizeargs = 0;
return 1;
}
}
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index d2c9db2..b8275d6 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -607,7 +607,6 @@ struct lvresize_params {
const struct segment_type *segtype;
- int sizeargs;
uint64_t poolmetadata_size;
sign_t poolmetadata_sign;
uint32_t poolmetadataextents;
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index d732ed7..ccdc340 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -463,7 +463,6 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size)
.resize = LV_ANY,
.size = new_size >> SECTOR_SHIFT,
.force = 1, /* Assume the user has a good backup? */
- .sizeargs = 1,
};
struct saved_env e = store_user_env(lv->vg->cmd);
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 1258f14..45d3558 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -55,7 +55,6 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
* If only --poolmetadatasize is specified with list of PVs,
* then metadata will be extended there.
*/
- lp->sizeargs = arg_is_set(cmd, extents_ARG) + arg_is_set(cmd, size_ARG);
if ((lp->extents = arg_uint_value(cmd, extents_ARG, 0))) {
lp->sign = arg_sign_value(cmd, extents_ARG, SIGN_NONE);
lp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
7 years, 10 months
master - lvresize: return 0/1
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4de15aa58d2cd2...
Commit: 4de15aa58d2cd25075d3b17c3d3d9ad06b4bb493
Parent: 7092c6ba1084dcc029ffef918c0419ebdd41b5f4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 17 11:29:28 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:59:29 2016 +0200
lvresize: return 0/1
Returning locking LV is no longer used from here, so return 1/0.
---
lib/metadata/lv_manip.c | 34 +++++++++++-----------------------
1 files changed, 11 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 17e44cc..70969e8 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5197,13 +5197,12 @@ static int _lvresize_check_type(const struct logical_volume *lv,
return 1;
}
-static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
- struct lvresize_params *lp,
- struct dm_list *pvh)
+static int _lvresize_volume(struct logical_volume *lv,
+ struct lvresize_params *lp,
+ struct dm_list *pvh)
{
struct volume_group *vg = lv->vg;
struct cmd_context *cmd = vg->cmd;
- struct logical_volume *lock_lv = NULL;
uint32_t old_extents;
int status;
alloc_policy_t alloc = lp->alloc ? : lv->alloc;
@@ -5214,14 +5213,14 @@ static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
/* Request confirmation before operations that are often mistakes. */
if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
!_request_confirmation(lv, lp))
- return_NULL;
+ return_0;
if (lp->resizefs) {
if (!lp->nofsck &&
!_fsadm_cmd(FSADM_CMD_CHECK, lv, 0, lp->force, &status)) {
if (status != FSADM_CHECK_FAILS_FOR_MOUNTED) {
log_error("Filesystem check failed.");
- return NULL;
+ return 0;
}
/* some filesystems support online resize */
}
@@ -5230,12 +5229,12 @@ static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
if ((lp->resize == LV_REDUCE) &&
!_fsadm_cmd(FSADM_CMD_RESIZE, lv, lp->extents, lp->force, NULL)) {
log_error("Filesystem resize failed.");
- return NULL;
+ return 0;
}
}
if (!archive(vg))
- return_NULL;
+ return_0;
old_extents = lv->le_count;
log_verbose("%sing logical volume %s to %s%s",
@@ -5245,18 +5244,18 @@ static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
if (lp->resize == LV_REDUCE) {
if (!lv_reduce(lv, lv->le_count - lp->extents))
- return_NULL;
+ return_0;
} else if ((lp->extents > lv->le_count) && /* Ensure we extend */
!lv_extend(lv, lp->segtype,
lp->stripes, lp->stripe_size,
lp->mirrors, first_seg(lv)->region_size,
lp->extents - lv->le_count,
pvh, alloc, lp->approx_alloc))
- return_NULL;
+ return_0;
/* Check for over provisioning only when lv_extend() passed,
* ATM this check does not fail */
else if (!pool_check_overprovisioning(lv))
- return_NULL;
+ return_0;
if (old_extents == lv->le_count)
log_print_unless_silent("Size of logical volume %s unchanged from %s (%" PRIu32 " extents).",
@@ -5268,18 +5267,7 @@ static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
display_size(cmd, (uint64_t) old_extents * vg->extent_size), old_extents,
display_size(cmd, (uint64_t) lv->le_count * vg->extent_size), lv->le_count);
- if (lock_lv) {
- /* If thin metadata, must suspend thin pool */
- } else if (lv_is_thin_pool_metadata(lv)) {
- if (!(lock_lv = find_pool_lv(lv)))
- return_NULL;
- /* If snapshot, must suspend all associated devices */
- } else if (lv_is_cow(lv))
- lock_lv = origin_from_cow(lv);
- else
- lock_lv = lv;
-
- return lock_lv;
+ return 1;
}
static int _lvresize_prepare(struct logical_volume **lv,
7 years, 10 months
master - lvresize: support more resized LVs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7092c6ba1084dc...
Commit: 7092c6ba1084dcc029ffef918c0419ebdd41b5f4
Parent: d44e653fe184a6c179a13998b41e13f737d4926c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 22 23:32:35 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:59:27 2016 +0200
lvresize: support more resized LVs
Add code to support more LVs to be resized through a same code path
using a single lvresize_params struct.
(Now it's used for thin-pool metadata resize,
next user will be snapshot virtual resize).
Update code to adjust percent amount resize for use_policies.
Properly activate inactive thin-pool in case of any pool resize
as the command should not 'deffer' this operation to next activation.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 221 +++++++++++++++++++++++++----------------------
2 files changed, 120 insertions(+), 102 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 5e2cb5a..a24325f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.158 -
=================================
+ Pool metadata lvresize uses now same code as resize of normal volume.
Log system error when locking dir cannot be accessed.
Preserve monitoring status when updating thin-pool metadata.
Rerurn 0 (inactive) when status cannot be queried in _lv_active().
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index e42a73c..17e44cc 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4439,7 +4439,7 @@ static int _fsadm_cmd(enum fsadm_cmd_e fcmd,
return exec_cmd(cmd, argv, status, 1);
}
-static int _adjust_amount(dm_percent_t percent, int policy_threshold, int *policy_amount)
+static uint32_t _adjust_amount(dm_percent_t percent, int policy_threshold, int policy_amount)
{
if (!(DM_PERCENT_0 < percent && percent <= DM_PERCENT_100) ||
percent <= (policy_threshold * DM_PERCENT_1))
@@ -4452,18 +4452,18 @@ static int _adjust_amount(dm_percent_t percent, int policy_threshold, int *polic
percent = (percent / policy_threshold + (DM_PERCENT_1 - 1) / 100) / (DM_PERCENT_1 / 100) - 100;
/* Use it if current policy amount is smaller */
- if (*policy_amount < percent)
- *policy_amount = percent;
-
- return 1;
+ return (policy_amount < percent) ? (uint32_t) policy_amount : (uint32_t) percent;
}
-static int _adjust_policy_params(struct logical_volume *lv, struct lvresize_params *lp)
+static int _lvresize_adjust_policy(const struct logical_volume *lv,
+ uint32_t *amount, uint32_t *meta_amount)
{
struct cmd_context *cmd = lv->vg->cmd;
dm_percent_t percent;
int policy_threshold, policy_amount;
+ *amount = *meta_amount = 0;
+
if (lv_is_thin_pool(lv)) {
policy_threshold =
find_config_tree_int(cmd, activation_thin_pool_autoextend_threshold_CFG,
@@ -4488,11 +4488,8 @@ static int _adjust_policy_params(struct logical_volume *lv, struct lvresize_para
}
}
- if (policy_threshold >= 100) {
- lp->extents = lp->poolmetadata_size = 0;
- lp->sizeargs = 0;
+ if (policy_threshold >= 100)
return 1; /* nothing to do */
- }
if (!policy_amount) {
log_error("Can't extend %s with %s autoextend percent set to 0%%.",
@@ -4509,16 +4506,9 @@ static int _adjust_policy_params(struct logical_volume *lv, struct lvresize_para
if (lv_is_thin_pool(lv)) {
if (!lv_thin_pool_percent(lv, 1, &percent))
return_0;
- if (_adjust_amount(percent, policy_threshold, &policy_amount)) {
- if (!thin_pool_feature_supported(lv, THIN_FEATURE_METADATA_RESIZE)) {
- log_error_once("Online metadata resize for %s is not supported.",
- display_lvname(lv));
- return 0;
- }
- lp->poolmetadata_size = (first_seg(lv)->metadata_lv->size *
- policy_amount + 99) / 100;
- lp->poolmetadata_sign = SIGN_PLUS;
- }
+
+ *meta_amount = _adjust_amount(percent, policy_threshold, policy_amount);
+
if (!lv_thin_pool_percent(lv, 0, &percent))
return_0;
} else {
@@ -4526,11 +4516,7 @@ static int _adjust_policy_params(struct logical_volume *lv, struct lvresize_para
return_0;
}
- if (!_adjust_amount(percent, policy_threshold, &policy_amount))
- return 1; /* nothing to do */
-
- lp->extents = policy_amount;
- lp->sizeargs = (lp->extents) ? 1 : 0;
+ *amount = _adjust_amount(percent, policy_threshold, policy_amount);
return 1;
}
@@ -4646,8 +4632,8 @@ static int _lvresize_poolmetadata(struct logical_volume *pool_lv,
return 1;
}
-static int _lvresize_check_lv(struct logical_volume *lv,
- struct lvresize_params *lp)
+static int _lvresize_check(struct logical_volume *lv,
+ struct lvresize_params *lp)
{
struct volume_group *vg = lv->vg;
@@ -4884,10 +4870,6 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
uint32_t new_extents;
int reducing = 0;
- if (lv_is_thin_pool(lv))
- /* Manipulate the thin data layer underneath */
- lv = seg_lv(first_seg(lv), 0);
-
seg_last = last_seg(lv);
/* FIXME Support LVs with mixed segment types */
@@ -5086,12 +5068,6 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
}
if (lp->extents == existing_logical_extents) {
- if (lp->poolmetadata_size || lp->use_policies) {
- /* Signal that normal resizing is not required */
- lp->sizeargs = 0;
- return 1;
- }
-
if (!lp->resizefs) {
log_error("New size (%d extents) matches existing size "
"(%d extents)", lp->extents, existing_logical_extents);
@@ -5192,8 +5168,9 @@ static int _lvresize_check_type(const struct logical_volume *lv,
}
if (lp->resize == LV_REDUCE) {
- if (lv_is_thin_pool(lv)) {
- log_error("Thin pool volumes cannot be reduced in size yet.");
+ if (lv_is_thin_pool_data(lv)) {
+ log_error("Thin pool volumes %s cannot be reduced in size yet.",
+ display_lvname(lv));
return 0;
}
if (lv_is_thin_pool_metadata(lv)) {
@@ -5201,6 +5178,13 @@ static int _lvresize_check_type(const struct logical_volume *lv,
return 0;
}
} else if (lp->resize == LV_EXTEND) {
+ if (lv_is_thin_pool_metadata(lv) &&
+ !thin_pool_feature_supported(find_pool_seg(first_seg(lv))->lv, THIN_FEATURE_METADATA_RESIZE)) {
+ log_error("Support for online metadata resize of %s not detected.",
+ display_lvname(lv));
+ return 0;
+ }
+
/* Validate thin target supports bigger size of thin volume then external origin */
if (lv_is_thin_volume(lv) && first_seg(lv)->external_lv &&
(lv->size > first_seg(lv)->external_lv->size) &&
@@ -5220,18 +5204,9 @@ static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
struct volume_group *vg = lv->vg;
struct cmd_context *cmd = vg->cmd;
struct logical_volume *lock_lv = NULL;
- struct lv_segment *seg = NULL;
uint32_t old_extents;
int status;
- alloc_policy_t alloc;
-
- if (lv_is_thin_pool(lv)) {
- lock_lv = lv;
- seg = first_seg(lv);
- /* Switch to layered LV resizing */
- lv = seg_lv(seg, 0);
- }
- alloc = lp->alloc ? : lv->alloc;
+ alloc_policy_t alloc = lp->alloc ? : lv->alloc;
if ((lp->resize == LV_REDUCE) && (pvh != &vg->pvs))
log_print_unless_silent("Ignoring PVs on command line when reducing.");
@@ -5307,81 +5282,106 @@ static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
return lock_lv;
}
-static int _lvresize_prepare(struct logical_volume *lv,
+static int _lvresize_prepare(struct logical_volume **lv,
struct lvresize_params *lp,
struct dm_list *pvh)
{
- if (!_lvresize_check_lv(lv, lp))
- return_0;
+ struct volume_group *vg = (*lv)->vg;
- if (lp->use_policies && !_adjust_policy_params(lv, lp))
- return_0;
+ if (lv_is_thin_pool(*lv))
+ *lv = seg_lv(first_seg(*lv), 0); /* switch to data LV */
- if (lp->size && !_lvresize_adjust_size(lv->vg, lp->size, lp->sign,
- &lp->extents))
- return_0;
- else if (lp->extents && !_lvresize_extents_from_percent(lv, lp, pvh))
+ /* Resolve extents from size */
+ if (lp->size && !_lvresize_adjust_size(vg, lp->size, lp->sign, &lp->extents))
return_0;
-
- if (lp->extents && !_lvresize_adjust_extents(lv, lp, pvh))
+ else if (lp->extents && !_lvresize_extents_from_percent(*lv, lp, pvh))
return_0;
- if ((lp->extents == lv->le_count) && lp->use_policies) {
- /* Nothing to do. */
- lp->sizeargs = 0;
- lp->poolmetadata_size = 0;
- }
-
- if (lp->extents && !_lvresize_check_type(lv, lp))
+ if (lp->extents && !_lvresize_adjust_extents(*lv, lp, pvh))
return_0;
- if (lp->poolmetadata_size &&
- !_lvresize_poolmetadata_prepare(lv, lp))
+ if (lp->extents && !_lvresize_check_type(*lv, lp))
return_0;
return 1;
}
+/* Set aux LV properties, we can't use those from command line */
+static struct logical_volume *_lvresize_setup_aux(struct logical_volume *lv,
+ struct lvresize_params *lp)
+{
+ struct lv_segment *mseg = last_seg(lv);
+
+ lp->alloc = lv->alloc;
+ lp->mirrors = seg_is_mirrored(mseg) ? lv_mirror_count(lv) : 0;
+ lp->resizefs = 0;
+ lp->stripes = lp->mirrors ? mseg->area_count / lp->mirrors : 0;
+ lp->stripe_size = mseg->stripe_size;
+
+ return lv;
+}
+
int lv_resize(struct logical_volume *lv,
struct lvresize_params *lp,
struct dm_list *pvh)
{
struct volume_group *vg = lv->vg;
struct cmd_context *cmd = vg->cmd;
- struct logical_volume *lock_lv = NULL;
- int inactive = 0;
+ struct logical_volume *lock_lv = (struct logical_volume*) lv_lock_holder(lv);
+ struct logical_volume *aux_lv = NULL; /* Note: aux_lv never resizes fs */
+ struct lvresize_params aux_lp;
+ int activated = 0;
+ int ret = 0;
- if (!_lvresize_prepare(lv, lp, pvh))
+ if (!_lvresize_check(lv, lp))
return_0;
- if (lv_is_cache_type(lv)) {
- log_error("Unable to resize logical volumes of cache type.");
- return 0;
+ if (lp->use_policies) {
+ lp->percent = SIGN_PLUS;
+ aux_lp = *lp;
+ if (!_lvresize_adjust_policy(lv, &lp->extents, &aux_lp.extents))
+ return_0;
+
+ if (!lp->extents) {
+ if (!aux_lp.extents)
+ return 1; /* Nothing to do */
+ /* Resize thin-pool metadata as mainlv */
+ lv = first_seg(lv)->metadata_lv; /* metadata LV */
+ lp->extents = aux_lp.extents;
+ } else if (aux_lp.extents) {
+ /* Also resize thin-pool metadata */
+ aux_lv = _lvresize_setup_aux(first_seg(lv)->metadata_lv, &aux_lp);
+ }
+ } else if (lp->poolmetadata_size) {
+ if (!lp->extents && !lp->size) {
+ /* When only --poolmetadatasize give and not --size
+ * swith directly to resize metadata LV */
+ lv = first_seg(lv)->metadata_lv;
+ lp->size = lp->poolmetadata_size;
+ lp->sign = lp->poolmetadata_sign;
+ } else {
+ aux_lp = *lp;
+ aux_lv = _lvresize_setup_aux(first_seg(lv)->metadata_lv, &aux_lp);
+ aux_lp.size = lp->poolmetadata_size;
+ aux_lp.sign = lp->poolmetadata_sign;
+ }
}
- /*
- * If the LV is locked from activation, this lock call is a no-op.
- * Otherwise, this acquires a transient lock on the lv (not PERSISTENT).
- */
- if (!lockd_lv(cmd, lv, "ex", 0))
+ if (aux_lv && !_lvresize_prepare(&aux_lv, &aux_lp, pvh))
return_0;
- if (lp->extents &&
- !(lock_lv = _lvresize_volume(lv, lp, pvh)))
+ if (!_lvresize_prepare(&lv, lp, pvh))
return_0;
- if (lp->poolmetadataextents) {
- if (!_lvresize_poolmetadata(lv, lp, pvh))
- return_0;
- lock_lv = lv;
- }
-
- if (!lock_lv)
- return 1; /* Nothing to do */
-
- if (lv_is_thin_pool(lock_lv) &&
- pool_is_active(lock_lv) &&
+ if (lv_is_thin_pool(lock_lv) && /* Lock holder is thin-pool */
!lv_is_active(lock_lv)) {
+
+ if (!activation()) {
+ log_error("Cannot resize %s without using "
+ "device-mapper kernel driver.",
+ display_lvname(lock_lv));
+ return 0;
+ }
/*
* Active 'hidden' -tpool can be waiting for resize, but the
* pool LV itself might be inactive.
@@ -5390,13 +5390,33 @@ int lv_resize(struct logical_volume *lv,
* then use suspend and resume and deactivate pool LV,
* instead of searching for an active thin volume.
*/
- inactive = 1;
if (!activate_lv_excl(cmd, lock_lv)) {
log_error("Failed to activate %s.", display_lvname(lock_lv));
return 0;
}
+
+ activated = 1;
}
+ /*
+ * If the LV is locked from activation, this lock call is a no-op.
+ * Otherwise, this acquires a transient lock on the lv (not PERSISTENT).
+ */
+ if (!lockd_lv(cmd, lock_lv, "ex", 0))
+ return_0;
+
+ if (aux_lv) {
+ if (!_lvresize_volume(aux_lv, &aux_lp, pvh))
+ goto_bad;
+
+ /* store vg on disk(s) */
+ if (!lv_update_and_reload(lock_lv))
+ goto_bad;
+ }
+
+ if (!_lvresize_volume(lv, lp, pvh))
+ goto_bad;
+
/* store vg on disk(s) */
if (!lv_update_and_reload(lock_lv))
goto_bad;
@@ -5411,11 +5431,6 @@ int lv_resize(struct logical_volume *lv,
goto_bad;
backup(vg);
-
- if (inactive && !deactivate_lv(cmd, lock_lv)) {
- log_error("Problem deactivating %s.", display_lvname(lock_lv));
- return 0;
- }
}
log_print_unless_silent("Logical volume %s successfully resized.",
@@ -5425,12 +5440,14 @@ int lv_resize(struct logical_volume *lv,
!_fsadm_cmd(FSADM_CMD_RESIZE, lv, lp->extents, lp->force, NULL))
return_0;
- return 1;
+ ret = 1;
bad:
- if (inactive && !deactivate_lv(cmd, lock_lv))
+ if (activated && !deactivate_lv(cmd, lock_lv)) {
log_error("Problem deactivating %s.", display_lvname(lock_lv));
+ ret = 0;
+ }
- return 0;
+ return ret;
}
char *generate_lv_name(struct volume_group *vg, const char *format,
7 years, 10 months
master - lvresize: do not pass struct cmd
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d44e653fe184a6...
Commit: d44e653fe184a6c179a13998b41e13f737d4926c
Parent: 5013999c8bd3f2b455ab6fe436df4884da6ebaf5
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 14 15:32:21 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:57:09 2016 +0200
lvresize: do not pass struct cmd
Use common API design and pass just LV pointer to lv_manip.c functions.
Read cmd struct via lv->vg->cmd when needed.
Also do not try to return EINVALID_CMD_LINE error when we
have already openned VG - this error code can only be returned before
locking VG.
---
lib/locking/lvmlockd.c | 3 +-
lib/metadata/lv_manip.c | 42 ++++++++++++++++++++++---------------
lib/metadata/metadata-exported.h | 7 ++---
liblvm/lvm_lv.c | 3 +-
tools/lvresize.c | 7 +-----
5 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index e2b3e25..e865c10 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -376,8 +376,7 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
.sizeargs = 1,
};
- if (!lv_resize_prepare(cmd, lv, &lp, &vg->pvs) ||
- !lv_resize(cmd, lv, &lp, &vg->pvs)) {
+ if (!lv_resize(lv, &lp, &vg->pvs)) {
log_error("Extend LV %s to size %s failed.",
display_lvname(lv), display_size(cmd, lp.size));
return 0;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 487d7f9..e42a73c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4336,10 +4336,10 @@ static int _validate_stripesize(const struct volume_group *vg,
return 1;
}
-static int _request_confirmation(const struct volume_group *vg,
- const struct logical_volume *lv,
+static int _request_confirmation(const struct logical_volume *lv,
const struct lvresize_params *lp)
{
+ const struct volume_group *vg = lv->vg;
struct lvinfo info = { 0 };
if (!lv_info(vg->cmd, lv, 0, &info, 1, 0) && driver_version(NULL, 0)) {
@@ -4766,10 +4766,11 @@ static int _lvresize_adjust_size(struct volume_group *vg,
/*
* If percent options were used, convert them into actual numbers of extents.
*/
-static int _lvresize_extents_from_percent(struct logical_volume *lv, struct lvresize_params *lp,
+static int _lvresize_extents_from_percent(const struct logical_volume *lv,
+ struct lvresize_params *lp,
struct dm_list *pvh)
{
- struct volume_group *vg = lv->vg;
+ const struct volume_group *vg = lv->vg;
uint32_t pv_extent_count;
uint32_t old_extents = lp->extents;
@@ -4859,10 +4860,12 @@ static uint32_t _lv_pe_count(struct logical_volume *lv)
}
/* FIXME Avoid having variables like lp->extents mean different things at different places */
-static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volume *lv,
- struct lvresize_params *lp, struct dm_list *pvh)
+static int _lvresize_adjust_extents(struct logical_volume *lv,
+ struct lvresize_params *lp,
+ struct dm_list *pvh)
{
struct volume_group *vg = lv->vg;
+ struct cmd_context *cmd = vg->cmd;
uint32_t logical_extents_used = 0;
uint32_t physical_extents_used = 0;
uint32_t seg_stripes = 0, seg_stripesize = 0;
@@ -5173,7 +5176,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
}
static int _lvresize_check_type(const struct logical_volume *lv,
- struct lvresize_params *lp)
+ const struct lvresize_params *lp)
{
if (lv_is_origin(lv)) {
if (lp->resize == LV_REDUCE) {
@@ -5210,12 +5213,12 @@ static int _lvresize_check_type(const struct logical_volume *lv,
return 1;
}
-static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
- struct logical_volume *lv,
+static struct logical_volume *_lvresize_volume(struct logical_volume *lv,
struct lvresize_params *lp,
struct dm_list *pvh)
{
struct volume_group *vg = lv->vg;
+ struct cmd_context *cmd = vg->cmd;
struct logical_volume *lock_lv = NULL;
struct lv_segment *seg = NULL;
uint32_t old_extents;
@@ -5235,7 +5238,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
/* Request confirmation before operations that are often mistakes. */
if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
- !_request_confirmation(vg, lv, lp))
+ !_request_confirmation(lv, lp))
return_NULL;
if (lp->resizefs) {
@@ -5304,8 +5307,9 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
return lock_lv;
}
-int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
- struct lvresize_params *lp, struct dm_list *pvh)
+static int _lvresize_prepare(struct logical_volume *lv,
+ struct lvresize_params *lp,
+ struct dm_list *pvh)
{
if (!_lvresize_check_lv(lv, lp))
return_0;
@@ -5319,7 +5323,7 @@ int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
else if (lp->extents && !_lvresize_extents_from_percent(lv, lp, pvh))
return_0;
- if (lp->extents && !_lvresize_adjust_extents(cmd, lv, lp, pvh))
+ if (lp->extents && !_lvresize_adjust_extents(lv, lp, pvh))
return_0;
if ((lp->extents == lv->le_count) && lp->use_policies) {
@@ -5338,14 +5342,18 @@ int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
return 1;
}
-/* lv_resize_prepare MUST be called before this */
-int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
- struct lvresize_params *lp, struct dm_list *pvh)
+int lv_resize(struct logical_volume *lv,
+ struct lvresize_params *lp,
+ struct dm_list *pvh)
{
struct volume_group *vg = lv->vg;
+ struct cmd_context *cmd = vg->cmd;
struct logical_volume *lock_lv = NULL;
int inactive = 0;
+ if (!_lvresize_prepare(lv, lp, pvh))
+ return_0;
+
if (lv_is_cache_type(lv)) {
log_error("Unable to resize logical volumes of cache type.");
return 0;
@@ -5359,7 +5367,7 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
return_0;
if (lp->extents &&
- !(lock_lv = _lvresize_volume(cmd, lv, lp, pvh)))
+ !(lock_lv = _lvresize_volume(lv, lp, pvh)))
return_0;
if (lp->poolmetadataextents) {
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index ddf51fc..d2c9db2 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -693,10 +693,9 @@ int vgs_are_compatible(struct cmd_context *cmd,
struct volume_group *vg_to);
uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname);
-int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
- struct lvresize_params *lp, struct dm_list *pvh);
-int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
- struct lvresize_params *lp, struct dm_list *pvh);
+int lv_resize(struct logical_volume *lv,
+ struct lvresize_params *lp,
+ struct dm_list *pvh);
/*
* Return a handle to VG metadata.
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 467a9d0..d732ed7 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -467,8 +467,7 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size)
};
struct saved_env e = store_user_env(lv->vg->cmd);
- if (!lv_resize_prepare(lv->vg->cmd, lv, &lp, &lv->vg->pvs) ||
- !lv_resize(lv->vg->cmd, lv, &lp, &lv->vg->pvs)) {
+ if (!lv_resize(lv, &lp, &lv->vg->pvs)) {
/* FIXME Improve msg */
log_error("LV resize failed.");
/* FIXME Define consistent symbolic return codes */
diff --git a/tools/lvresize.c b/tools/lvresize.c
index af2b3ac..1258f14 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -175,12 +175,7 @@ static int _lvresize_single(struct cmd_context *cmd, const char *vg_name,
if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc, lp->argv, 1) : &vg->pvs))
goto_out;
- if (!lv_resize_prepare(cmd, lv, lp, pvh)) {
- ret = EINVALID_CMD_LINE;
- goto_out;
- }
-
- if (!lv_resize(cmd, lv, lp, pvh))
+ if (!lv_resize(lv, lp, pvh))
goto_out;
ret = ECMD_PROCESSED;
7 years, 10 months
master - lvresize: pass only needed params to _fsadm_cmd
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5013999c8bd3f2...
Commit: 5013999c8bd3f2b455ab6fe436df4884da6ebaf5
Parent: d30c2cec880e22ac2ce6cb6a1ee09584f2dc6aae
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 15 15:46:03 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:57:09 2016 +0200
lvresize: pass only needed params to _fsadm_cmd
Do not pass whole lvresize_params into _fsadm_cmd,
and give it only needed args.
---
lib/metadata/lv_manip.c | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f4abc4f..487d7f9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4387,12 +4387,14 @@ enum fsadm_cmd_e { FSADM_CMD_CHECK, FSADM_CMD_RESIZE };
* FSADM_CMD --dry-run --verbose --force check lv_path
* FSADM_CMD --dry-run --verbose --force resize lv_path size
*/
-static int _fsadm_cmd(struct cmd_context *cmd,
- const struct volume_group *vg,
- const struct lvresize_params *lp,
- enum fsadm_cmd_e fcmd,
+static int _fsadm_cmd(enum fsadm_cmd_e fcmd,
+ struct logical_volume *lv,
+ uint32_t extents,
+ int force,
int *status)
{
+ struct volume_group *vg = lv->vg;
+ struct cmd_context *cmd = vg->cmd;
char lv_path[PATH_MAX];
char size_buf[SIZE_BUF];
const char *argv[FSADM_CMD_MAX_ARGS + 2];
@@ -4406,7 +4408,7 @@ static int _fsadm_cmd(struct cmd_context *cmd,
if (verbose_level() >= _LOG_NOTICE)
argv[i++] = "--verbose";
- if (lp->force)
+ if (force)
argv[i++] = "--force";
argv[i++] = (fcmd == FSADM_CMD_RESIZE) ? "resize" : "check";
@@ -4415,8 +4417,8 @@ static int _fsadm_cmd(struct cmd_context *cmd,
*status = -1;
if (dm_snprintf(lv_path, sizeof(lv_path), "%s%s/%s", cmd->dev_dir,
- vg->name, lp->lv_name) < 0) {
- log_error("Couldn't create LV path for %s", lp->lv_name);
+ vg->name, lv->name) < 0) {
+ log_error("Couldn't create LV path for %s.", display_lvname(lv));
return 0;
}
@@ -4424,8 +4426,8 @@ static int _fsadm_cmd(struct cmd_context *cmd,
if (fcmd == FSADM_CMD_RESIZE) {
if (dm_snprintf(size_buf, sizeof(size_buf), FMTu64 "K",
- (uint64_t) lp->extents * (vg->extent_size / 2)) < 0) {
- log_error("Couldn't generate new LV size string");
+ (uint64_t) extents * (vg->extent_size / 2)) < 0) {
+ log_error("Couldn't generate new LV size string.");
return 0;
}
@@ -5238,7 +5240,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
if (lp->resizefs) {
if (!lp->nofsck &&
- !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_CHECK, &status)) {
+ !_fsadm_cmd(FSADM_CMD_CHECK, lv, 0, lp->force, &status)) {
if (status != FSADM_CHECK_FAILS_FOR_MOUNTED) {
log_error("Filesystem check failed.");
return NULL;
@@ -5248,7 +5250,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
/* FIXME forks here */
if ((lp->resize == LV_REDUCE) &&
- !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL)) {
+ !_fsadm_cmd(FSADM_CMD_RESIZE, lv, lp->extents, lp->force, NULL)) {
log_error("Filesystem resize failed.");
return NULL;
}
@@ -5412,7 +5414,7 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
display_lvname(lv));
if (lp->resizefs && (lp->resize == LV_EXTEND) &&
- !_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL))
+ !_fsadm_cmd(FSADM_CMD_RESIZE, lv, lp->extents, lp->force, NULL))
return_0;
return 1;
7 years, 10 months
master - lvresize: check pvh list is vg->pvs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d30c2cec880e22...
Commit: d30c2cec880e22ac2ce6cb6a1ee09584f2dc6aae
Parent: f45b68940667563e1a8d3bbd5d30864c04381bdf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 16 14:39:26 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:57:09 2016 +0200
lvresize: check pvh list is vg->pvs
Instead of checking lp->argc for arg count, compare directly whether
passed pvh is vg->pvs.
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 562047c..f4abc4f 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4785,7 +4785,7 @@ static int _lvresize_extents_from_percent(struct logical_volume *lv, struct lvre
(lp->sign != SIGN_MINUS));
break;
case PERCENT_PVS:
- if (lp->argc) {
+ if (pvh != &vg->pvs) {
pv_extent_count = pv_list_extents_free(pvh);
lp->extents = percent_of_extents(lp->extents, pv_extent_count,
(lp->sign != SIGN_MINUS));
@@ -5228,7 +5228,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
}
alloc = lp->alloc ? : lv->alloc;
- if ((lp->resize == LV_REDUCE) && lp->argc)
+ if ((lp->resize == LV_REDUCE) && (pvh != &vg->pvs))
log_print_unless_silent("Ignoring PVs on command line when reducing.");
/* Request confirmation before operations that are often mistakes. */
7 years, 10 months
master - lvresize: update lvresize_params struct
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f45b6894066756...
Commit: f45b68940667563e1a8d3bbd5d30864c04381bdf
Parent: 698082e67875fe71970fb932ffe2170d777f2807
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jun 17 13:25:41 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:57:09 2016 +0200
lvresize: update lvresize_params struct
Reorganise struct lvresize_params to better fit lvresize needs to be
able to resize more then just a single LV.
---
lib/locking/lvmlockd.c | 2 +-
lib/metadata/lv_manip.c | 98 ++++++++++++++--------------
lib/metadata/metadata-exported.h | 52 +++++++---------
liblvm/lvm_lv.c | 2 +-
tools/lvresize.c | 128 +++++++++++++++----------------------
5 files changed, 126 insertions(+), 156 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 9eb7f92..e2b3e25 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -372,7 +372,7 @@ static int _extend_sanlock_lv(struct cmd_context *cmd, struct volume_group *vg,
.size = lv->size + ((extend_mb * 1024 * 1024) / SECTOR_SIZE),
.percent = PERCENT_NONE,
.resize = LV_EXTEND,
- .ac_force = 1,
+ .force = 1,
.sizeargs = 1,
};
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 9f0d06d..562047c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4314,23 +4314,19 @@ int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
static int _validate_stripesize(const struct volume_group *vg,
struct lvresize_params *lp)
{
-
- if (lp->ac_stripesize_value > (STRIPE_SIZE_LIMIT * 2)) {
+ if (lp->stripe_size > (STRIPE_SIZE_LIMIT * 2)) {
log_error("Stripe size cannot be larger than %s.",
display_size(vg->cmd, (uint64_t) STRIPE_SIZE_LIMIT));
return 0;
}
- if (!(vg->fid->fmt->features & FMT_SEGMENTS))
- log_print_unless_silent("Varied stripesize not supported. Ignoring.");
- else if (lp->ac_stripesize_value > vg->extent_size) {
+ if (lp->stripe_size > vg->extent_size) {
log_print_unless_silent("Reducing stripe size %s to maximum, "
"physical extent size %s.",
- display_size(vg->cmd, lp->ac_stripesize_value),
+ display_size(vg->cmd, lp->stripe_size),
display_size(vg->cmd, vg->extent_size));
lp->stripe_size = vg->extent_size;
- } else
- lp->stripe_size = lp->ac_stripesize_value;
+ }
if (lp->stripe_size & (lp->stripe_size - 1)) {
log_error("Stripe size must be power of 2.");
@@ -4370,7 +4366,7 @@ static int _request_confirmation(const struct volume_group *vg,
log_warn("THIS MAY DESTROY YOUR DATA (filesystem etc.)");
- if (!lp->ac_force) {
+ if (!lp->force) {
if (yes_no_prompt("Do you really want to reduce %s? [y/n]: ",
display_lvname(lv)) == 'n') {
log_error("Logical volume %s NOT reduced.",
@@ -4410,7 +4406,7 @@ static int _fsadm_cmd(struct cmd_context *cmd,
if (verbose_level() >= _LOG_NOTICE)
argv[i++] = "--verbose";
- if (lp->ac_force)
+ if (lp->force)
argv[i++] = "--force";
argv[i++] = (fcmd == FSADM_CMD_RESIZE) ? "resize" : "check";
@@ -4491,7 +4487,7 @@ static int _adjust_policy_params(struct logical_volume *lv, struct lvresize_para
}
if (policy_threshold >= 100) {
- lp->extents = lp->poolmetadatasize = 0;
+ lp->extents = lp->poolmetadata_size = 0;
lp->sizeargs = 0;
return 1; /* nothing to do */
}
@@ -4517,9 +4513,9 @@ static int _adjust_policy_params(struct logical_volume *lv, struct lvresize_para
display_lvname(lv));
return 0;
}
- lp->poolmetadatasize = (first_seg(lv)->metadata_lv->size *
- policy_amount + 99) / 100;
- lp->poolmetadatasign = SIGN_PLUS;
+ lp->poolmetadata_size = (first_seg(lv)->metadata_lv->size *
+ policy_amount + 99) / 100;
+ lp->poolmetadata_sign = SIGN_PLUS;
}
if (!lv_thin_pool_percent(lv, 0, &percent))
return_0;
@@ -4579,18 +4575,18 @@ static int _lvresize_poolmetadata_prepare(struct logical_volume *pool_lv,
return 0;
}
- if (lp->poolmetadatasize % vg->extent_size) {
- lp->poolmetadatasize += vg->extent_size -
- (lp->poolmetadatasize % vg->extent_size);
+ if (lp->poolmetadata_size % vg->extent_size) {
+ lp->poolmetadata_size += vg->extent_size -
+ (lp->poolmetadata_size % vg->extent_size);
log_print_unless_silent("Rounding pool metadata size to boundary between physical extents: %s",
- display_size(vg->cmd, lp->poolmetadatasize));
+ display_size(vg->cmd, lp->poolmetadata_size));
}
- if (!(extents = extents_from_size(vg->cmd, lp->poolmetadatasize,
+ if (!(extents = extents_from_size(vg->cmd, lp->poolmetadata_size,
vg->extent_size)))
return_0;
- if (lp->poolmetadatasign == SIGN_PLUS) {
+ if (lp->poolmetadata_sign == SIGN_PLUS) {
if (extents >= (MAX_EXTENT_COUNT - lv->le_count)) {
log_error("Unable to extend %s by %u extents, exceeds limit (%u).",
lv->name, lv->le_count, MAX_EXTENT_COUNT);
@@ -4624,7 +4620,7 @@ static int _lvresize_poolmetadata(struct logical_volume *pool_lv,
{
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;
+ alloc_policy_t alloc = lp->alloc ? : lv->alloc;
struct lv_segment *mseg = last_seg(lv);
uint32_t seg_mirrors = lv_mirror_count(lv);
@@ -4676,7 +4672,7 @@ static int _lvresize_check_lv(struct logical_volume *lv,
return 0;
}
- if (lp->ac_policy && !lv_is_cow(lv) && !lv_is_thin_pool(lv)) {
+ if (lp->use_policies && !lv_is_cow(lv) && !lv_is_thin_pool(lv)) {
log_error("Policy-based resize is supported only for snapshot and thin pool volumes.");
return 0;
}
@@ -4699,13 +4695,18 @@ static int _lvresize_check_lv(struct logical_volume *lv,
return 0;
}
- if (!lv_is_thin_pool(lv) && lp->poolmetadatasize) {
+ if (!lv_is_thin_pool(lv) && lp->poolmetadata_size) {
log_error("--poolmetadatasize can be used only with thin pools.");
return 0;
}
- if (lp->ac_stripesize && !_validate_stripesize(vg, lp))
- return_0;
+ if (lp->stripe_size) {
+ if (!(vg->fid->fmt->features & FMT_SEGMENTS)) {
+ log_print_unless_silent("Varied stripesize not supported. Ignoring.");
+ lp->stripe_size = lp->stripes = 0;
+ } else if (!_validate_stripesize(vg, lp))
+ return_0;
+ }
if (lp->resizefs &&
(lv_is_thin_pool(lv) ||
@@ -4718,18 +4719,16 @@ static int _lvresize_check_lv(struct logical_volume *lv,
lp->resizefs = 0;
}
- if (lp->ac_stripes) {
- if (!(vg->fid->fmt->features & FMT_SEGMENTS))
- log_print_unless_silent("Varied striping not supported. Ignoring.");
- else
- lp->stripes = lp->ac_stripes_value;
+ if (lp->stripes &&
+ !(vg->fid->fmt->features & FMT_SEGMENTS)) {
+ log_print_unless_silent("Varied striping not supported. Ignoring.");
+ lp->stripes = 0;
}
- if (lp->ac_mirrors) {
- if (!(vg->fid->fmt->features & FMT_SEGMENTS))
- log_print_unless_silent("Mirrors not supported. Ignoring.");
- else
- lp->mirrors = lp->ac_mirrors_value;
+ if (lp->mirrors &&
+ !(vg->fid->fmt->features & FMT_SEGMENTS)) {
+ log_print_unless_silent("Mirrors not supported. Ignoring.");
+ lp->mirrors = 0;
}
return 1;
@@ -4885,15 +4884,16 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
lv = seg_lv(first_seg(lv), 0);
seg_last = last_seg(lv);
- /* Use segment type of last segment */
- lp->segtype = seg_last->segtype;
/* FIXME Support LVs with mixed segment types */
- if (lp->segtype != get_segtype_from_string(cmd, lp->ac_type ? : lp->segtype->name)) {
+ if (lp->segtype && (lp->segtype != seg_last->segtype)) {
log_error("VolumeType does not match (%s).", lp->segtype->name);
return 0;
}
+ /* Use segment type of last segment */
+ lp->segtype = seg_last->segtype;
+
/* For virtual devices, just pretend the physical size matches. */
existing_physical_extents = saved_existing_physical_extents = _lv_pe_count(lv);
if (!existing_physical_extents) {
@@ -4913,10 +4913,10 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
if (!reducing) {
seg_mirrors = seg_is_mirrored(seg_last) ? lv_mirror_count(lv) : 0;
- if (!lp->ac_mirrors && seg_mirrors) {
+ if (!lp->mirrors && seg_mirrors) {
log_print_unless_silent("Extending %" PRIu32 " mirror images.", seg_mirrors);
lp->mirrors = seg_mirrors;
- } else if ((lp->ac_mirrors || seg_mirrors) && (lp->mirrors != seg_mirrors)) {
+ } else if ((lp->mirrors || seg_mirrors) && (lp->mirrors != seg_mirrors)) {
log_error("Cannot vary number of mirrors in LV yet.");
return 0;
}
@@ -5023,7 +5023,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
}
}
} else { /* If reducing, find stripes, stripesize & size of last segment */
- if (lp->ac_stripes || lp->ac_stripesize || lp->ac_mirrors)
+ if (lp->stripes || lp->stripe_size || lp->mirrors)
log_print_unless_silent("Ignoring stripes, stripesize and mirrors "
"arguments when reducing.");
@@ -5081,7 +5081,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
}
if (lp->extents == existing_logical_extents) {
- if (lp->poolmetadatasize || lp->ac_policy) {
+ if (lp->poolmetadata_size || lp->use_policies) {
/* Signal that normal resizing is not required */
lp->sizeargs = 0;
return 1;
@@ -5146,7 +5146,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
return 0;
}
lp->resize = LV_EXTEND;
- } else if ((lp->extents == existing_logical_extents) && !lp->ac_policy) {
+ } else if ((lp->extents == existing_logical_extents) && !lp->use_policies) {
if (!lp->resizefs) {
log_error("New size (%d extents) matches existing size "
"(%d extents)", lp->extents, existing_logical_extents);
@@ -5160,7 +5160,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
* extents of a mirror not to have an initial sync?
*/
if ((lp->extents > existing_logical_extents)) {
- if (seg_is_mirrored(first_seg(lv)) && lp->ac_no_sync)
+ if (seg_is_mirrored(first_seg(lv)) && lp->nosync)
lv->status |= LV_NOTSYNCED;
}
@@ -5226,7 +5226,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
/* Switch to layered LV resizing */
lv = seg_lv(seg, 0);
}
- alloc = lp->ac_alloc ? : lv->alloc;
+ alloc = lp->alloc ? : lv->alloc;
if ((lp->resize == LV_REDUCE) && lp->argc)
log_print_unless_silent("Ignoring PVs on command line when reducing.");
@@ -5308,7 +5308,7 @@ int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
if (!_lvresize_check_lv(lv, lp))
return_0;
- if (lp->ac_policy && !_adjust_policy_params(lv, lp))
+ if (lp->use_policies && !_adjust_policy_params(lv, lp))
return_0;
if (lp->size && !_lvresize_adjust_size(lv->vg, lp->size, lp->sign,
@@ -5320,16 +5320,16 @@ int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
if (lp->extents && !_lvresize_adjust_extents(cmd, lv, lp, pvh))
return_0;
- if ((lp->extents == lv->le_count) && lp->ac_policy) {
+ if ((lp->extents == lv->le_count) && lp->use_policies) {
/* Nothing to do. */
lp->sizeargs = 0;
- lp->poolmetadatasize = 0;
+ lp->poolmetadata_size = 0;
}
if (lp->extents && !_lvresize_check_type(lv, lp))
return_0;
- if (lp->poolmetadatasize &&
+ if (lp->poolmetadata_size &&
!_lvresize_poolmetadata_prepare(lv, lp))
return_0;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 5948404..ddf51fc 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -599,26 +599,20 @@ struct pvcreate_params {
};
struct lvresize_params {
+ int argc;
+ char **argv;
+
const char *vg_name; /* only-used when VG is not yet opened (in /tools) */
const char *lv_name;
- uint32_t stripes;
- uint32_t stripe_size;
- uint32_t mirrors;
-
const struct segment_type *segtype;
- /* size */
- uint32_t extents;
- uint64_t size;
int sizeargs;
- sign_t sign;
- uint64_t poolmetadatasize;
- sign_t poolmetadatasign;
+ uint64_t poolmetadata_size;
+ sign_t poolmetadata_sign;
uint32_t poolmetadataextents;
- int approx_alloc;
- int extents_are_pes; /* Is 'extents' counting PEs or LEs? */
- percent_type_t percent;
+
+ /* Per LV applied parameters */
enum {
LV_ANY = 0,
@@ -626,25 +620,25 @@ struct lvresize_params {
LV_EXTEND = 2
} resize;
- int resizefs;
+ int use_policies;
+
+ alloc_policy_t alloc;
+ int force;
+ int nosync;
int nofsck;
+ int resizefs;
- int argc;
- char **argv;
+ unsigned mirrors;
+ uint32_t stripes;
+ uint64_t stripe_size;
- /* FIXME Deal with meaningless 'ac' */
- /* Arg counts & values */
- alloc_policy_t ac_alloc;
- unsigned ac_force;
- unsigned ac_mirrors;
- uint32_t ac_mirrors_value;
- unsigned ac_no_sync;
- unsigned ac_policy;
- unsigned ac_stripes;
- uint32_t ac_stripes_value;
- unsigned ac_stripesize;
- uint64_t ac_stripesize_value;
- const char *ac_type;
+ uint32_t extents;
+ uint64_t size;
+ sign_t sign;
+ percent_type_t percent;
+
+ int approx_alloc;
+ int extents_are_pes; /* Is 'extents' counting PEs or LEs? */
};
void pvcreate_params_set_defaults(struct pvcreate_params *pp);
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index ee0d48b..467a9d0 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -462,7 +462,7 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size)
.percent = PERCENT_NONE,
.resize = LV_ANY,
.size = new_size >> SECTOR_SHIFT,
- .ac_force = 1, /* Assume the user has a good backup? */
+ .force = 1, /* Assume the user has a good backup? */
.sizeargs = 1,
};
struct saved_env e = store_user_env(lv->vg->cmd);
diff --git a/tools/lvresize.c b/tools/lvresize.c
index f7e17b8..af2b3ac 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -19,7 +19,10 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
struct lvresize_params *lp)
{
const char *cmd_name = command_name(cmd);
- char *st;
+ const char *type_str = arg_str_value(cmd, type_ARG, NULL);
+
+ if (type_str && (lp->segtype = get_segtype_from_string(cmd, type_str)))
+ return_0;
if (!strcmp(cmd_name, "lvreduce"))
lp->resize = LV_REDUCE;
@@ -28,9 +31,9 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
else
lp->resize = LV_ANY;
- lp->sign = lp->poolmetadatasign = SIGN_NONE;
+ lp->sign = lp->poolmetadata_sign = SIGN_NONE;
- if ((lp->ac_policy = arg_is_set(cmd, usepolicies_ARG))) {
+ if ((lp->use_policies = arg_is_set(cmd, usepolicies_ARG))) {
/* do nothing; _lvresize will handle --use-policies itself */
lp->extents = 0;
lp->sign = SIGN_PLUS;
@@ -53,6 +56,10 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
* then metadata will be extended there.
*/
lp->sizeargs = arg_is_set(cmd, extents_ARG) + arg_is_set(cmd, size_ARG);
+ if ((lp->extents = arg_uint_value(cmd, extents_ARG, 0))) {
+ lp->sign = arg_sign_value(cmd, extents_ARG, SIGN_NONE);
+ lp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
+ }
if (arg_from_list_is_zero(cmd, "may not be zero",
chunksize_ARG, extents_ARG,
@@ -64,39 +71,31 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
-1))
return_0;
- if (arg_is_set(cmd, poolmetadatasize_ARG)) {
- lp->poolmetadatasize = arg_uint64_value(cmd, poolmetadatasize_ARG, 0);
- lp->poolmetadatasign = arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE);
- if (lp->poolmetadatasign == SIGN_MINUS) {
+ if ((lp->poolmetadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG, 0))) {
+ lp->poolmetadata_sign = arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE);
+ if (lp->poolmetadata_sign == SIGN_MINUS) {
log_error("Can't reduce pool metadata size.");
return 0;
}
}
- if ((lp->sizeargs == 0) && (argc >= 2)) {
- lp->extents = 100;
- lp->percent = PERCENT_PVS;
- lp->sign = SIGN_PLUS;
- lp->sizeargs = !lp->poolmetadatasize ? 1 : 0;
- } else if ((lp->sizeargs != 1) &&
- ((lp->sizeargs == 2) ||
- !arg_is_set(cmd, poolmetadatasize_ARG))) {
- log_error("Please specify either size or extents but not "
- "both.");
- return 0;
+ if ((lp->size = arg_uint64_value(cmd, size_ARG, 0))) {
+ lp->sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
+ lp->percent = PERCENT_NONE;
}
- if (arg_is_set(cmd, extents_ARG)) {
- lp->extents = arg_uint_value(cmd, extents_ARG, 0);
- lp->sign = arg_sign_value(cmd, extents_ARG, SIGN_NONE);
- lp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
+ if (lp->size && lp->extents) {
+ log_error("Please specify either size or extents but not both.");
+ return 0;
}
- /* Size returned in kilobyte units; held in sectors */
- if (arg_is_set(cmd, size_ARG)) {
- lp->size = arg_uint64_value(cmd, size_ARG, 0);
- lp->sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
- lp->percent = PERCENT_NONE;
+ if (!lp->extents &&
+ !lp->size &&
+ !lp->poolmetadata_size &&
+ (argc >= 2)) {
+ lp->extents = 100;
+ lp->percent = PERCENT_PVS;
+ lp->sign = SIGN_PLUS;
}
}
@@ -106,77 +105,54 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
}
if (lp->resize == LV_REDUCE &&
- ((lp->sign == SIGN_PLUS) || (lp->poolmetadatasign == SIGN_PLUS))) {
+ ((lp->sign == SIGN_PLUS) ||
+ (lp->poolmetadata_sign == SIGN_PLUS))) {
log_error("Positive sign not permitted - use lvextend.");
return 0;
}
- lp->resizefs = arg_is_set(cmd, resizefs_ARG);
- lp->nofsck = arg_is_set(cmd, nofsck_ARG);
-
if (!argc) {
log_error("Please provide the logical volume name.");
return 0;
}
lp->lv_name = argv[0];
- argv++;
- argc--;
- if (!(lp->lv_name = skip_dev_dir(cmd, lp->lv_name, NULL)) ||
- !(lp->vg_name = extract_vgname(cmd, lp->lv_name))) {
- log_error("Please provide a volume group name");
- return 0;
- }
+ if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_name))
+ return_0;
- if (!validate_name(lp->vg_name)) {
- log_error("Volume group name %s has invalid characters",
- lp->vg_name);
+ /* Check for $LVM_VG_NAME */
+ if (!lp->vg_name && !(lp->vg_name = extract_vgname(cmd, NULL))) {
+ log_error("Please specify a logical volume path.");
return 0;
}
- if ((st = strrchr(lp->lv_name, '/')))
- lp->lv_name = st + 1;
-
- lp->argc = argc;
- lp->argv = argv;
-
- lp->ac_policy = arg_is_set(cmd, usepolicies_ARG);
- lp->ac_stripes = arg_is_set(cmd, stripes_ARG);
- if (lp->ac_stripes) {
- lp->ac_stripes_value = arg_uint_value(cmd, stripes_ARG, 1);
- } else {
- lp->ac_stripes_value = 0;
+ if ((lp->mirrors = arg_count(cmd, mirrors_ARG)) &&
+ (arg_sign_value(cmd, mirrors_ARG, SIGN_NONE) == SIGN_MINUS)) {
+ log_error("Mirrors argument may not be signed.");
+ return 0;
}
- lp->ac_mirrors = arg_is_set(cmd, mirrors_ARG);
-
- if (lp->ac_mirrors) {
- if (arg_sign_value(cmd, mirrors_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Mirrors argument may not be negative");
- return 0;
- }
-
- lp->ac_mirrors_value = arg_uint_value(cmd, mirrors_ARG, 1) + 1;
- } else {
- lp->ac_mirrors_value = 0;
+ if ((lp->stripes = arg_uint_value(cmd, stripes_ARG, 0)) &&
+ (arg_sign_value(cmd, stripes_ARG, SIGN_NONE) == SIGN_MINUS)) {
+ log_error("Stripes argument may not be negative.");
+ return 0;
}
- lp->ac_stripesize = arg_is_set(cmd, stripesize_ARG);
- if (lp->ac_stripesize) {
- if (arg_sign_value(cmd, stripesize_ARG, SIGN_NONE) == SIGN_MINUS) {
- log_error("Stripesize may not be negative.");
- return 0;
- }
-
- lp->ac_stripesize_value = arg_uint64_value(cmd, stripesize_ARG, 0);
+ if ((lp->stripe_size = arg_uint64_value(cmd, stripesize_ARG, 0)) &&
+ (arg_sign_value(cmd, stripesize_ARG, SIGN_NONE) == SIGN_MINUS)) {
+ log_error("Stripesize may not be negative.");
+ return 0;
}
- lp->ac_no_sync = arg_is_set(cmd, nosync_ARG);
- lp->ac_alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, 0);
+ lp->argc = --argc;
+ lp->argv = ++argv;
- lp->ac_type = arg_str_value(cmd, type_ARG, NULL);
- lp->ac_force = arg_count(cmd, force_ARG);
+ lp->alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, 0);
+ lp->force = arg_is_set(cmd, force_ARG);
+ lp->nofsck = arg_is_set(cmd, nofsck_ARG);
+ lp->nosync = arg_is_set(cmd, nosync_ARG);
+ lp->resizefs = arg_is_set(cmd, resizefs_ARG);
return 1;
}
7 years, 10 months
master - cleanup: use display_lvname
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=698082e67875fe...
Commit: 698082e67875fe71970fb932ffe2170d777f2807
Parent: 6268d0a080f61c85c2681b3dcfdd5b00f849ace1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jun 23 13:04:37 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jun 23 14:57:08 2016 +0200
cleanup: use display_lvname
---
lib/metadata/lv.c | 30 ++++++++++++-----------
lib/metadata/lv_manip.c | 57 ++++++++++++++++++++++++--------------------
lib/metadata/thin_manip.c | 6 +++-
3 files changed, 51 insertions(+), 42 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 06f47f4..cdf658e 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -1432,49 +1432,50 @@ int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
if (is_change_activating(activate) &&
!lockd_lv(cmd, lv, ay_with_mode, LDLV_PERSISTENT)) {
- log_error("Failed to lock logical volume %s/%s", lv->vg->name, lv->name);
+ log_error("Failed to lock logical volume %s.", display_lvname(lv));
return 0;
}
switch (activate) {
case CHANGE_AN:
deactivate:
- log_verbose("Deactivating logical volume \"%s\"", lv->name);
+ log_verbose("Deactivating logical volume %s.", display_lvname(lv));
if (!deactivate_lv(cmd, lv))
return_0;
break;
case CHANGE_ALN:
if (vg_is_clustered(lv->vg) && (needs_exclusive || _lv_is_exclusive(lv))) {
if (!lv_is_active_locally(lv)) {
- log_error("Cannot deactivate remotely exclusive device locally.");
+ log_error("Cannot deactivate remotely exclusive device %s locally.",
+ display_lvname(lv));
return 0;
}
/* Unlock whole exclusive activation */
goto deactivate;
}
- log_verbose("Deactivating logical volume \"%s\" locally.",
- lv->name);
+ log_verbose("Deactivating logical volume %s locally.",
+ display_lvname(lv));
if (!deactivate_lv_local(cmd, lv))
return_0;
break;
case CHANGE_ALY:
case CHANGE_AAY:
if (needs_exclusive || _lv_is_exclusive(lv)) {
- log_verbose("Activating logical volume \"%s\" exclusively locally.",
- lv->name);
+ log_verbose("Activating logical volume %s exclusively locally.",
+ display_lvname(lv));
if (!activate_lv_excl_local(cmd, lv))
return_0;
} else {
- log_verbose("Activating logical volume \"%s\" locally.",
- lv->name);
+ log_verbose("Activating logical volume %s locally.",
+ display_lvname(lv));
if (!activate_lv_local(cmd, lv))
return_0;
}
break;
case CHANGE_AEY:
exclusive:
- log_verbose("Activating logical volume \"%s\" exclusively.",
- lv->name);
+ log_verbose("Activating logical volume %s exclusively.",
+ display_lvname(lv));
if (!activate_lv_excl(cmd, lv))
return_0;
break;
@@ -1483,14 +1484,14 @@ exclusive:
default:
if (needs_exclusive || _lv_is_exclusive(lv))
goto exclusive;
- log_verbose("Activating logical volume \"%s\".", lv->name);
+ log_verbose("Activating logical volume %s.", display_lvname(lv));
if (!activate_lv(cmd, lv))
return_0;
}
if (!is_change_activating(activate) &&
!lockd_lv(cmd, lv, "un", LDLV_PERSISTENT))
- log_error("Failed to unlock logical volume %s/%s", lv->vg->name, lv->name);
+ log_error("Failed to unlock logical volume %s.", display_lvname(lv));
return 1;
}
@@ -1549,7 +1550,8 @@ const struct logical_volume *lv_lock_holder(const struct logical_volume *lv)
/* Find any active LV from the pool */
dm_list_iterate_items(sl, &lv->segs_using_this_lv)
if (lv_is_active(sl->seg->lv)) {
- log_debug("Thin volume \"%s\" is active.", sl->seg->lv->name);
+ log_debug_activation("Thin volume %s is active.",
+ display_lvname(lv));
return sl->seg->lv;
}
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6cf7323..9f0d06d 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5000,7 +5000,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
if (seg_size >= (MAX_EXTENT_COUNT - existing_logical_extents)) {
log_error("Unable to extend %s by %u logical extents: exceeds limit (%u).",
- lp->lv_name, seg_size, MAX_EXTENT_COUNT);
+ display_lvname(lv), seg_size, MAX_EXTENT_COUNT);
return 0;
}
@@ -5029,7 +5029,8 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
if (lp->sign == SIGN_MINUS) {
if (lp->extents >= existing_extents) {
- log_error("Unable to reduce %s below 1 extent.", lp->lv_name);
+ log_error("Unable to reduce %s below 1 extent.",
+ display_lvname(lv));
return 0;
}
new_extents = existing_extents - lp->extents;
@@ -5407,7 +5408,8 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- log_print_unless_silent("Logical volume %s successfully resized.", lp->lv_name);
+ log_print_unless_silent("Logical volume %s successfully resized.",
+ display_lvname(lv));
if (lp->resizefs && (lp->resize == LV_EXTEND) &&
!_fsadm_cmd(cmd, vg, lp, FSADM_CMD_RESIZE, NULL))
@@ -6068,19 +6070,22 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) &&
info.exists && info.live_table) {
if (!lv_snapshot_percent(lv, &snap_percent)) {
- log_error("Failed to obtain merging snapshot progress percentage for logical volume %s.",
- lv->name);
+ log_error("Failed to obtain merging snapshot progress "
+ "percentage for logical volume %s.",
+ display_lvname(lv));
return 0;
}
if ((snap_percent != DM_PERCENT_INVALID) &&
(snap_percent != LVM_PERCENT_MERGE_FAILED)) {
- log_error("Can't remove merging snapshot logical volume \"%s\"",
- lv->name);
+ log_error("Can't remove merging snapshot logical volume %s.",
+ display_lvname(lv));
return 0;
} else if ((snap_percent == LVM_PERCENT_MERGE_FAILED) &&
- (force == PROMPT) &&
- yes_no_prompt("Removing snapshot \"%s\" that failed to merge may leave origin \"%s\" inconsistent. "
- "Proceed? [y/n]: ", lv->name, origin_from_cow(lv)->name) == 'n')
+ (force == PROMPT) &&
+ yes_no_prompt("Removing snapshot %s that failed to merge "
+ "may leave origin %s inconsistent. Proceed? [y/n]: ",
+ display_lvname(lv),
+ display_lvname(origin_from_cow(lv))) == 'n')
goto no_remove;
}
} else if (!level && lv_is_virtual_origin(origin = origin_from_cow(lv)))
@@ -6108,22 +6113,22 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
if (lv_is_merging_origin(lv)) {
if (!deactivate_lv(cmd, lv)) {
- log_error("Unable to fully deactivate merging origin \"%s\".",
- lv->name);
+ log_error("Unable to fully deactivate merging origin %s.",
+ display_lvname(lv));
return 0;
}
if (!lv_remove_with_dependencies(cmd, find_snapshot(lv)->lv,
force, level + 1)) {
- log_error("Unable to remove merging origin \"%s\".",
- lv->name);
+ log_error("Unable to remove merging origin %s.",
+ display_lvname(lv));
return 0;
}
}
if (!level && lv_is_merging_thin_snapshot(lv)) {
/* Merged snapshot LV is no longer available for the user */
- log_error("Unable to remove \"%s\", volume is merged to \"%s\".",
- lv->name, first_seg(lv)->merge_lv->name);
+ log_error("Unable to remove %s, volume is merged to %s.",
+ display_lvname(lv), display_lvname(first_seg(lv)->merge_lv));
return 0;
}
@@ -6139,10 +6144,10 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
(force == PROMPT)) {
dm_list_iterate_items(lvl, &lv->vg->lvs)
if (lv_is_pool_metadata(lvl->lv)) {
- if (yes_no_prompt("Removal of pool metadata spare logical volume"
- " \"%s\" disables automatic recovery attempts"
- " after damage to a thin or cache pool."
- " Proceed? [y/n]: ", lv->name) == 'n')
+ if (yes_no_prompt("Removal of pool metadata spare logical volume "
+ "%s disables automatic recovery attempts "
+ "after damage to a thin or cache pool. "
+ "Proceed? [y/n]: ", display_lvname(lv)) == 'n')
goto no_remove;
break;
}
@@ -6151,7 +6156,7 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
return lv_remove_single(cmd, lv, force, 0);
no_remove:
- log_error("Logical volume \"%s\" not removed.", lv->name);
+ log_error("Logical volume %s not removed.", display_lvname(lv));
return 0;
}
@@ -6229,16 +6234,16 @@ static int _split_parent_area(struct lv_segment *seg, uint32_t s,
while (parent_area_len > 0) {
/* Find the layer segment pointed at */
if (!(spvs = _find_seg_pvs_by_le(layer_seg_pvs, layer_le))) {
- log_error("layer segment for %s:%" PRIu32 " not found",
- seg->lv->name, parent_le);
+ log_error("layer segment for %s:" FMTu32 " not found.",
+ display_lvname(seg->lv), parent_le);
return 0;
}
if (spvs->le != layer_le) {
log_error("Incompatible layer boundary: "
- "%s:%" PRIu32 "[%" PRIu32 "] on %s:%" PRIu32,
- seg->lv->name, parent_le, s,
- seg_lv(seg, s)->name, layer_le);
+ "%s:" FMTu32 "[" FMTu32 "] on %s:" FMTu32 ".",
+ display_lvname(seg->lv), parent_le, s,
+ display_lvname(seg_lv(seg, s)), layer_le);
return 0;
}
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 2f66675..06d4242 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -171,7 +171,8 @@ int pool_is_active(const struct logical_volume *lv)
const struct seg_list *sl;
if (!lv_is_thin_pool(lv)) {
- log_error(INTERNAL_ERROR "pool_is_active called with non-pool LV %s.", lv->name);
+ log_error(INTERNAL_ERROR "pool_is_active called with non-pool volume %s.",
+ display_lvname(lv));
return 0;
}
@@ -182,7 +183,8 @@ int pool_is_active(const struct logical_volume *lv)
dm_list_iterate_items(sl, &lv->segs_using_this_lv)
if (lv_is_active(sl->seg->lv)) {
- log_debug("Thin volume \"%s\" is active.", sl->seg->lv->name);
+ log_debug_activation("Pool's thin volume %s is active.",
+ display_lvname(sl->seg->lv));
return 1;
}
} else if (lv_info(lv->vg->cmd, lv, 1, &info, 0, 0) && info.exists)
7 years, 10 months