master - cleanup: poll better check for internal errors
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5c29b54d4dbf0a...
Commit: 5c29b54d4dbf0a94525172f5526fd5ff7996de48
Parent: cdcf4cc794827e61a1babd549f4a0ef4e6439165
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 13:31:31 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:25 2016 +0100
cleanup: poll better check for internal errors
---
tools/lvconvert.c | 37 ++++++++++++++-------------------
tools/polldaemon.c | 20 +++++++++---------
tools/pvmove.c | 57 +++++++++++++++++++++-------------------------------
3 files changed, 49 insertions(+), 65 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 23f3cf4..f6ea614 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -722,43 +722,40 @@ static struct poll_functions _lvconvert_thin_merge_fns = {
.finish_copy = lvconvert_merge_finish,
};
-static void _destroy_id(struct cmd_context *cmd, struct poll_operation_id *id)
-{
- if (!id)
- return;
-
- dm_pool_free(cmd->mem, (void *)id);
-}
-
static struct poll_operation_id *_create_id(struct cmd_context *cmd,
const char *vg_name,
const char *lv_name,
const char *uuid)
{
+ struct poll_operation_id *id;
char lv_full_name[NAME_LEN];
- struct poll_operation_id *id = dm_pool_alloc(cmd->mem, sizeof(struct poll_operation_id));
- if (!id) {
- log_error("Poll operation ID allocation failed.");
+
+ if (!vg_name || !lv_name || !uuid) {
+ log_error(INTERNAL_ERROR "Wrong params for lvconvert _create_id.");
return NULL;
}
if (dm_snprintf(lv_full_name, sizeof(lv_full_name), "%s/%s", vg_name, lv_name) < 0) {
log_error(INTERNAL_ERROR "Name \"%s/%s\" is too long.", vg_name, lv_name);
- _destroy_id(cmd, id);
return NULL;
}
- id->display_name = dm_pool_strdup(cmd->mem, lv_full_name);
- id->vg_name = vg_name ? dm_pool_strdup(cmd->mem, vg_name) : NULL;
- id->lv_name = id->display_name ? strchr(id->display_name, '/') + 1 : NULL;
- id->uuid = uuid ? dm_pool_strdup(cmd->mem, uuid) : NULL;
+ if (!(id = dm_pool_alloc(cmd->mem, sizeof(*id)))) {
+ log_error("Poll operation ID allocation failed.");
+ return NULL;
+ }
- if (!id->vg_name || !id->lv_name || !id->display_name || !id->uuid) {
+ if (!(id->display_name = dm_pool_strdup(cmd->mem, lv_full_name)) ||
+ !(id->lv_name = strchr(id->display_name, '/')) ||
+ !(id->vg_name = dm_pool_strdup(cmd->mem, vg_name)) ||
+ !(id->uuid = dm_pool_strdup(cmd->mem, uuid))) {
log_error("Failed to copy one or more poll operation ID members.");
- _destroy_id(cmd, id);
- id = NULL;
+ dm_pool_free(cmd->mem, id);
+ return NULL;
}
+ id->lv_name++; /* skip over '/' */
+
return id;
}
@@ -801,8 +798,6 @@ int lvconvert_poll(struct cmd_context *cmd, struct logical_volume *lv,
r = _lvconvert_poll_by_id(cmd, id, background, is_merging_origin, is_merging_origin_thin);
- _destroy_id(cmd, id);
-
return r;
}
diff --git a/tools/polldaemon.c b/tools/polldaemon.c
index e662e16..8f1ff90 100644
--- a/tools/polldaemon.c
+++ b/tools/polldaemon.c
@@ -242,22 +242,22 @@ static struct poll_operation_id *copy_poll_operation_id(struct dm_pool *mem,
{
struct poll_operation_id *copy;
- if (!id)
- return_NULL;
+ if (!id || !id->vg_name || !id->lv_name || !id->display_name || !id->uuid) {
+ log_error(INTERNAL_ERROR "Wrong params for copy_poll_operation_id.");
+ return NULL;
+ }
- copy = (struct poll_operation_id *) dm_pool_alloc(mem, sizeof(struct poll_operation_id));
- if (!copy) {
+ if (!(copy = dm_pool_alloc(mem, sizeof(*copy)))) {
log_error("Poll operation ID allocation failed.");
return NULL;
}
- copy->display_name = id->display_name ? dm_pool_strdup(mem, id->display_name) : NULL;
- copy->lv_name = id->lv_name ? dm_pool_strdup(mem, id->lv_name) : NULL;
- copy->vg_name = id->vg_name ? dm_pool_strdup(mem, id->vg_name) : NULL;
- copy->uuid = id->uuid ? dm_pool_strdup(mem, id->uuid) : NULL;
-
- if (!copy->display_name || !copy->lv_name || !copy->vg_name || !copy->uuid) {
+ if (!(copy->display_name = dm_pool_strdup(mem, id->display_name)) ||
+ !(copy->lv_name = dm_pool_strdup(mem, id->lv_name)) ||
+ !(copy->vg_name = dm_pool_strdup(mem, id->vg_name)) ||
+ !(copy->uuid = dm_pool_strdup(mem, id->uuid))) {
log_error("Failed to copy one or more poll_operation_id members.");
+ dm_pool_free(mem, copy);
return NULL;
}
diff --git a/tools/pvmove.c b/tools/pvmove.c
index b590745..b5df45a 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -751,35 +751,31 @@ static struct poll_functions _pvmove_fns = {
.finish_copy = pvmove_finish,
};
-static void _destroy_id(struct cmd_context *cmd, struct poll_operation_id *id)
+static struct poll_operation_id *_pvmove_create_id(struct cmd_context *cmd,
+ const char *pv_name,
+ const char *vg_name,
+ const char *lv_name,
+ const char *uuid)
{
- if (!id)
- return;
+ struct poll_operation_id *id;
- dm_pool_free(cmd->mem, id);
-}
+ if (!vg_name || !lv_name || !pv_name || !uuid) {
+ log_error(INTERNAL_ERROR "Wrong params for _pvmove_create_id.");
+ return NULL;
+ }
-static struct poll_operation_id *_create_id(struct cmd_context *cmd,
- const char *pv_name,
- const char *vg_name,
- const char *lv_name,
- const char *uuid)
-{
- struct poll_operation_id *id = dm_pool_alloc(cmd->mem, sizeof(struct poll_operation_id));
- if (!id) {
+ if (!(id = dm_pool_alloc(cmd->mem, sizeof(*id)))) {
log_error("Poll operation ID allocation failed.");
return NULL;
}
- id->vg_name = vg_name ? dm_pool_strdup(cmd->mem, vg_name) : NULL;
- id->lv_name = lv_name ? dm_pool_strdup(cmd->mem, lv_name) : NULL;
- id->display_name = pv_name ? dm_pool_strdup(cmd->mem, pv_name) : NULL;
- id->uuid = uuid ? dm_pool_strdup(cmd->mem, uuid) : NULL;
-
- if (!id->vg_name || !id->lv_name || !id->display_name || !id->uuid) {
+ if (!(id->vg_name = dm_pool_strdup(cmd->mem, vg_name)) ||
+ !(id->lv_name = dm_pool_strdup(cmd->mem, lv_name)) ||
+ !(id->display_name = dm_pool_strdup(cmd->mem, pv_name)) ||
+ !(id->uuid = dm_pool_strdup(cmd->mem, uuid))) {
log_error("Failed to copy one or more poll operation ID members.");
- _destroy_id(cmd, id);
- id = NULL;
+ dm_pool_free(cmd->mem, id);
+ return NULL;
}
return id;
@@ -789,25 +785,18 @@ int pvmove_poll(struct cmd_context *cmd, const char *pv_name,
const char *uuid, const char *vg_name,
const char *lv_name, unsigned background)
{
- int r;
struct poll_operation_id *id = NULL;
- if (uuid) {
- id = _create_id(cmd, pv_name, vg_name, lv_name, uuid);
- if (!id) {
- log_error("Failed to allocate poll identifier for pvmove.");
- return ECMD_FAILED;
- }
+ if (uuid &&
+ !(id = _pvmove_create_id(cmd, pv_name, vg_name, lv_name, uuid))) {
+ log_error("Failed to allocate poll identifier for pvmove.");
+ return ECMD_FAILED;
}
if (test_mode())
- r = ECMD_PROCESSED;
- else
- r = poll_daemon(cmd, background, PVMOVE, &_pvmove_fns, "Moved", id);
-
- _destroy_id(cmd, id);
+ return ECMD_PROCESSED;
- return r;
+ return poll_daemon(cmd, background, PVMOVE, &_pvmove_fns, "Moved", id);
}
int pvmove(struct cmd_context *cmd, int argc, char **argv)
8 years, 2 months
master - lvconvert: use lp->repair
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cdcf4cc794827e...
Commit: cdcf4cc794827e61a1babd549f4a0ef4e6439165
Parent: ec8a75a321fa96fd0fff6bf68e00599288c21ec4
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 15:12:17 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:25 2016 +0100
lvconvert: use lp->repair
Set variable for repair testing.
---
tools/lvconvert.c | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 10ee775..23f3cf4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -28,6 +28,7 @@ struct lvconvert_params {
int merge;
int merge_mirror;
int poolmetadataspare;
+ int repair;
int thin;
int uncache;
int yes;
@@ -194,7 +195,7 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
lp->lv_name = lp->lv_name_full;
if (!lp->merge_mirror &&
- !arg_count(cmd, repair_ARG) &&
+ !lp->repair &&
!arg_count(cmd, splitmirrors_ARG) &&
!strstr(lp->lv_name, "_tdata") &&
!strstr(lp->lv_name, "_tmeta") &&
@@ -383,14 +384,16 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
if (!_check_conversion_type(cmd, type_str))
return_0;
- if (arg_count(cmd, repair_ARG) &&
- arg_outside_list_is_set(cmd, "cannot be used with --repair",
- repair_ARG,
- alloc_ARG, usepolicies_ARG,
- stripes_long_ARG, stripesize_ARG,
- force_ARG, noudevsync_ARG, test_ARG,
- -1))
- return_0;
+ if (arg_count(cmd, repair_ARG)) {
+ if (arg_outside_list_is_set(cmd, "cannot be used with --repair",
+ repair_ARG,
+ alloc_ARG, usepolicies_ARG,
+ stripes_long_ARG, stripesize_ARG,
+ force_ARG, noudevsync_ARG, test_ARG,
+ -1))
+ return_0;
+ lp->repair = 1;
+ }
if (arg_is_set(cmd, mirrorlog_ARG) && arg_is_set(cmd, corelog_ARG)) {
log_error("--mirrorlog and --corelog are incompatible.");
@@ -436,7 +439,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
if ((_snapshot_type_requested(cmd, type_str) || arg_count(cmd, merge_ARG)) &&
(arg_count(cmd, mirrorlog_ARG) || _mirror_or_raid_type_requested(cmd, type_str) ||
- arg_count(cmd, repair_ARG) || arg_count(cmd, thinpool_ARG))) {
+ lp->repair || arg_count(cmd, thinpool_ARG))) {
log_error("--snapshot/--type snapshot or --merge argument "
"cannot be mixed with --mirrors/--type mirror/--type raid*, "
"--mirrorlog, --repair or --thinpool.");
@@ -445,7 +448,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,
if ((arg_count(cmd, stripes_long_ARG) || arg_count(cmd, stripesize_ARG)) &&
!(_mirror_or_raid_type_requested(cmd, type_str) ||
- arg_count(cmd, repair_ARG) ||
+ lp->repair ||
arg_count(cmd, thinpool_ARG))) {
log_error("--stripes or --stripesize argument is only valid "
"with --mirrors/--type mirror/--type raid*, --repair and --thinpool");
@@ -1143,7 +1146,6 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
uint32_t *new_mimage_count,
uint32_t *new_log_count)
{
- int repair = arg_count(cmd, repair_ARG);
*old_mimage_count = lv_mirror_count(lv);
*old_log_count = _get_log_count(lv);
@@ -1160,7 +1162,7 @@ static int _lvconvert_mirrors_parse_params(struct cmd_context *cmd,
*/
if (!arg_count(cmd, mirrors_ARG) && !arg_count(cmd, mirrorlog_ARG) &&
!arg_count(cmd, corelog_ARG) && !arg_count(cmd, regionsize_ARG) &&
- !arg_count(cmd, splitmirrors_ARG) && !repair) {
+ !arg_count(cmd, splitmirrors_ARG) && !lp->repair) {
*new_mimage_count = *old_mimage_count;
*new_log_count = *old_log_count;
@@ -1605,7 +1607,6 @@ static int _lvconvert_mirrors(struct cmd_context *cmd,
struct logical_volume *lv,
struct lvconvert_params *lp)
{
- int repair = arg_count(cmd, repair_ARG);
uint32_t old_mimage_count;
uint32_t old_log_count;
uint32_t new_mimage_count;
@@ -1651,10 +1652,10 @@ static int _lvconvert_mirrors(struct cmd_context *cmd,
/* Nothing to do? (Probably finishing collapse.) */
if ((old_mimage_count == new_mimage_count) &&
- (old_log_count == new_log_count) && !repair)
+ (old_log_count == new_log_count) && !lp->repair)
return 1;
- if (repair)
+ if (lp->repair)
return _lvconvert_mirrors_repair(cmd, lv, lp);
if (!_lvconvert_mirrors_aux(cmd, lv, lp, NULL,
@@ -1778,7 +1779,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if (arg_count(cmd, replace_ARG))
return lv_raid_replace(lv, lp->replace_pvh, lp->pvh);
- if (arg_count(cmd, repair_ARG)) {
+ if (lp->repair) {
if (!lv_is_active_exclusive_locally(lv_lock_holder(lv))) {
log_error("%s/%s must be active %sto perform this"
" operation.", lv->vg->name, lv->name,
@@ -3277,7 +3278,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (arg_count(cmd, repair_ARG)) {
+ if (lp->repair) {
if (lv_is_pool(lv)) {
if (lv_is_cache_pool(lv)) {
log_error("Repair for cache pool %s not yet implemented.",
@@ -3350,7 +3351,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return_ECMD_FAILED;
/* If repairing and using policies, remove missing PVs from VG */
- if (arg_count(cmd, repair_ARG) && arg_count(cmd, usepolicies_ARG))
+ if (lp->repair && arg_count(cmd, usepolicies_ARG))
_remove_missing_empty_pv(lv->vg, failed_pvs);
} else if (arg_count(cmd, mirrors_ARG) ||
arg_count(cmd, splitmirrors_ARG) ||
@@ -3365,7 +3366,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
return_ECMD_FAILED;
/* If repairing and using policies, remove missing PVs from VG */
- if (arg_count(cmd, repair_ARG) && arg_count(cmd, usepolicies_ARG))
+ if (lp->repair && arg_count(cmd, usepolicies_ARG))
_remove_missing_empty_pv(lv->vg, failed_pvs);
}
@@ -3425,7 +3426,7 @@ static int lvconvert_single(struct cmd_context *cmd, struct lvconvert_params *lp
int saved_ignore_suspended_devices = ignore_suspended_devices();
uint32_t lockd_state = 0;
- if (arg_count(cmd, repair_ARG)) {
+ if (lp->repair) {
init_ignore_suspended_devices(1);
cmd->handles_missing_pvs = 1;
}
8 years, 2 months
master - lvconvert: use more display_lvname
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ec8a75a321fa96...
Commit: ec8a75a321fa96fd0fff6bf68e00599288c21ec4
Parent: 86a651854f136b780d30e43a58c2390fa0d05e97
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 15:01:12 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:25 2016 +0100
lvconvert: use more display_lvname
---
tools/lvconvert.c | 48 +++++++++++++++++++++++++++---------------------
1 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 7fba48d..10ee775 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2005-2015 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -1446,7 +1446,7 @@ int mirror_remove_missing(struct cmd_context *cmd,
return_0;
if (force && _failed_mirrors_count(lv) == (int)lv_mirror_count(lv)) {
- log_error("No usable images left in %s.", lv->name);
+ log_error("No usable images left in %s.", display_lvname(lv));
return lv_remove_with_dependencies(cmd, lv, DONT_PROMPT, 0);
}
@@ -1503,7 +1503,8 @@ static int _lvconvert_mirrors_repair(struct cmd_context *cmd,
lv_check_transient(lv); /* TODO check this in lib for all commands? */
if (!(lv->status & PARTIAL_LV)) {
- log_print_unless_silent("%s is consistent. Nothing to repair.", lv->name);
+ log_print_unless_silent("Volume %s is consistent. Nothing to repair.",
+ display_lvname(lv));
return 1;
}
@@ -1558,11 +1559,13 @@ static int _lvconvert_mirrors_repair(struct cmd_context *cmd,
}
if (replace_mimages && lv_mirror_count(lv) != original_mimages)
- log_warn("WARNING: Failed to replace %d of %d images in volume %s",
- original_mimages - lv_mirror_count(lv), original_mimages, lv->name);
+ log_warn("WARNING: Failed to replace %d of %d images in volume %s.",
+ original_mimages - lv_mirror_count(lv), original_mimages,
+ display_lvname(lv));
if (replace_logs && _get_log_count(lv) != original_logs)
- log_warn("WARNING: Failed to replace %d of %d logs in volume %s",
- original_logs - _get_log_count(lv), original_logs, lv->name);
+ log_warn("WARNING: Failed to replace %d of %d logs in volume %s.",
+ original_logs - _get_log_count(lv), original_logs,
+ display_lvname(lv));
/* if (!arg_count(cmd, use_policies_ARG) && (lp->mirrors != old_mimage_count
|| log_count != old_log_count))
@@ -1577,18 +1580,18 @@ static int _lvconvert_validate_thin(struct logical_volume *lv,
if (!lv_is_thin_pool(lv) && !lv_is_thin_volume(lv))
return 1;
- log_error("Converting thin%s segment type for \"%s/%s\" to %s is not supported.",
+ log_error("Converting thin%s segment type for %s to %s is not supported.",
lv_is_thin_pool(lv) ? " pool" : "",
- lv->vg->name, lv->name, lp->segtype->name);
+ display_lvname(lv), lp->segtype->name);
if (lv_is_thin_volume(lv))
return 0;
/* Give advice for thin pool conversion */
- log_error("For pool data volume conversion use \"%s/%s\".",
- lv->vg->name, seg_lv(first_seg(lv), 0)->name);
- log_error("For pool metadata volume conversion use \"%s/%s\".",
- lv->vg->name, first_seg(lv)->metadata_lv->name);
+ log_error("For pool data volume conversion use %s.",
+ display_lvname(seg_lv(first_seg(lv), 0)));
+ log_error("For pool metadata volume conversion use %s.",
+ display_lvname(first_seg(lv)->metadata_lv));
return 0;
}
@@ -3217,18 +3220,19 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
struct dm_list *failed_pvs;
if (lv_is_locked(lv)) {
- log_error("Cannot convert locked LV %s", lv->name);
+ log_error("Cannot convert locked LV %s.", display_lvname(lv));
return ECMD_FAILED;
}
if (lv_is_cow(lv) && !lp->merge && !lp->splitsnapshot) {
- log_error("Can't convert snapshot logical volume \"%s\"",
- lv->name);
+ log_error("Cannot convert snapshot logical volume %s.",
+ display_lvname(lv));
return ECMD_FAILED;
}
if (lv_is_pvmove(lv)) {
- log_error("Unable to convert pvmove LV %s", lv->name);
+ log_error("Unable to convert pvmove LV %s.",
+ display_lvname(lv));
return ECMD_FAILED;
}
@@ -3287,8 +3291,8 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!lv_is_mirrored(lv) && !lv_is_raid(lv)) {
if (arg_count(cmd, usepolicies_ARG))
return ECMD_PROCESSED; /* nothing to be done here */
- log_error("Can't repair LV \"%s\" of segtype %s.",
- lv->name, lvseg_name(first_seg(lv)));
+ log_error("Cannot repair logical volume %s of segtype %s.",
+ display_lvname(lv), lvseg_name(first_seg(lv)));
return ECMD_FAILED;
}
}
@@ -3298,7 +3302,8 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, splitmirrors_ARG) && lv_is_cache_type(lv)
&& (origin = seg_lv(first_seg(lv), 0)) && lv_is_cache_origin(origin)) {
log_warn("WARNING: Selected operation does not work with cache-type LVs.");
- log_warn("Proceeding using the cache origin LV %s instead", origin->name);
+ log_warn("WARNING: Proceeding using the cache origin volume %s instead.",
+ display_lvname(origin));
lv = origin;
}
@@ -3319,7 +3324,8 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
if (lp->merge) {
if ((lv_is_thin_volume(lv) && !_lvconvert_merge_thin_snapshot(cmd, lv, lp)) ||
(!lv_is_thin_volume(lv) && !_lvconvert_merge_old_snapshot(cmd, lv, lp))) {
- log_print_unless_silent("Unable to merge LV \"%s\" into its origin.", lv->name);
+ log_print_unless_silent("Unable to merge volume %s into its origin.",
+ display_lvname(lv));
return ECMD_FAILED;
}
} else if (lp->snapshot) {
8 years, 2 months
master - lvconvert: simplify handler processing
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=86a651854f136b...
Commit: 86a651854f136b780d30e43a58c2390fa0d05e97
Parent: abd9618dd8b77ca1974074ae76fa6a08f1a687d9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 12:15:26 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:25 2016 +0100
lvconvert: simplify handler processing
Easier code for handler init.
Drop release of pool mem - not needed, as command pool get dropped just
later.
---
tools/lvconvert.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3ec6d59..7fba48d 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3503,15 +3503,13 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
struct convert_poll_id_list *idl;
struct lvconvert_params lp = {
.target_attr = ~0,
+ .idls = DM_LIST_HEAD_INIT(lp.idls),
};
- struct processing_handle *handle = NULL;
+ struct processing_handle *handle = init_processing_handle(cmd);
- dm_list_init(&lp.idls);
-
- if (!(handle = init_processing_handle(cmd))) {
+ if (!handle) {
log_error("Failed to initialize processing handle.");
- ret = ECMD_FAILED;
- goto out;
+ return ECMD_FAILED;
}
handle->custom_handle = &lp;
@@ -3537,10 +3535,10 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
}
out:
- if (!dm_list_empty(&lp.idls))
- dm_pool_free(cmd->mem, dm_list_item(dm_list_first(&lp.idls), struct convert_poll_id_list));
if (lp.policy_settings)
dm_config_destroy(lp.policy_settings);
+
destroy_processing_handle(cmd, handle);
+
return ret;
}
8 years, 2 months
master - lvconvert: fix vg parameter
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=abd9618dd8b77c...
Commit: abd9618dd8b77ca1974074ae76fa6a08f1a687d9
Parent: a68e601886e1c9b78345b4c33ce366451e2fe184
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 20:40:28 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:30:24 2016 +0100
lvconvert: fix vg parameter
Since we want to read env LVM_VG_NAME vg names,
we cannot just check LV names which do contain '/'.
So before the patch commands like:
> lvconvert --repair vg
Before:
Please provide a valid volume group name
After:
Path required for Logical Volume "vg".
Please provide a valid volume group name
> LVM_VG_NAME=vg lvconvert --repair vg
Before:
Please provide a valid volume group name
After:
Can't find LV vg in VG vg
---
WHATS_NEW | 1 +
tools/lvconvert.c | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 524fea4..250f3f1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.144 -
=====================================
+ Improve support for env LVM_VG_NAME for reference VG name in lvconvert.
Fix regresion when lvresize accepted zero sizes (2.02.141).
Always warn user about PV in use even when pvremove uses --force --force.
Use uninitilized pool header detection in all cases.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index e7394c0..3ec6d59 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -173,8 +173,7 @@ static int _lvconvert_name_params(struct lvconvert_params *lp,
if (!validate_restricted_lvname_param(cmd, &lp->vg_name, &lp->lv_split_name))
return_0;
- if (strchr(lp->lv_name_full, '/') &&
- (vg_name = extract_vgname(cmd, lp->lv_name_full)) &&
+ if ((vg_name = extract_vgname(cmd, lp->lv_name_full)) &&
lp->vg_name && strcmp(vg_name, lp->vg_name)) {
log_error("Please use a single volume group name "
"(\"%s\" or \"%s\")", vg_name, lp->vg_name);
8 years, 2 months
master - lvresize: fix regression with zero size arg
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a68e601886e1c9...
Commit: a68e601886e1c9b78345b4c33ce366451e2fe184
Parent: 172bad0d5679f6152281cdd3a69e2cf0a3288c1e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 25 22:44:31 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Feb 25 23:29:57 2016 +0100
lvresize: fix regression with zero size arg
Commit ca878a3426197b629c76e98cfc049948da470cd7 introduced an issue
that zero sized extesion suddenly started to be accepted and
missed to return error.
Properly check invalid input values for sizes.
---
WHATS_NEW | 1 +
tools/lvresize.c | 10 ++++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 378150c..524fea4 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.144 -
=====================================
+ Fix regresion when lvresize accepted zero sizes (2.02.141).
Always warn user about PV in use even when pvremove uses --force --force.
Use uninitilized pool header detection in all cases.
Fir read error detection when checking for uninitialized thin-pool header.
diff --git a/tools/lvresize.c b/tools/lvresize.c
index 2c2df36..a35a03d 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -47,6 +47,16 @@ static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
*/
lp->sizeargs = arg_count(cmd, extents_ARG) + arg_count(cmd, size_ARG);
+ if (arg_from_list_is_zero(cmd, "may not be zero",
+ chunksize_ARG, extents_ARG,
+ poolmetadatasize_ARG,
+ regionsize_ARG,
+ size_ARG,
+ stripes_ARG, stripesize_ARG,
+ virtualsize_ARG,
+ -1))
+ return_0;
+
if (arg_count(cmd, poolmetadatasize_ARG)) {
lp->poolmetadatasize = arg_uint64_value(cmd, poolmetadatasize_ARG, 0);
lp->poolmetadatasign = arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE);
8 years, 2 months
master - Use a common message for a used PV
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=172bad0d5679f6...
Commit: 172bad0d5679f6152281cdd3a69e2cf0a3288c1e
Parent: 66e175702af4cfb1ecad9316a8151c001933c190
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 25 14:12:08 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 25 14:23:41 2016 -0600
Use a common message for a used PV
Change some inconsistent messages and adopt
the new wording "PV %s is used by" in place
of "PV %s is marked as belonging to"
or "PV %s belongs to".
---
lib/metadata/metadata.c | 5 ++---
lib/metadata/pv_manip.c | 6 ++----
test/shell/pv-ext-flags.sh | 2 +-
test/shell/pvremove-usage.sh | 6 +++---
tools/pvchange.c | 2 +-
tools/toollib.c | 12 ++++++------
6 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index acdfdec..6ec0a0e 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -201,8 +201,7 @@ static int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
return_0;
if (used) {
- log_error("Physical volume '%s' is marked as belonging to a VG "
- "but its metadata is missing.", pv_name);
+ log_error("PV %s is used by a VG but its metadata is missing.", pv_name);
return 0;
}
}
@@ -1585,7 +1584,7 @@ static int _pvcreate_check(struct cmd_context *cmd, const char *name,
goto_out;
if (used && pp->force != DONT_PROMPT_OVERRIDE) {
- log_error("PV '%s' is marked as belonging to a VG but its metadata is missing.", name);
+ log_error("PV %s is used by a VG but its metadata is missing.", name);
log_error("Can't initialize PV '%s' without -ff.", name);
goto out;
}
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index f54111c..48706d1 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -733,8 +733,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name,
goto_out;
if (used) {
- log_warn("WARNING: PV '%s' is marked as belonging to a VG "
- "but its metadata is missing.", name);
+ log_warn("WARNING: PV %s is used by a VG but its metadata is missing.", name);
if (force_count < 2)
goto_bad;
@@ -745,8 +744,7 @@ static int pvremove_check(struct cmd_context *cmd, const char *name,
goto_bad;
}
} else {
- log_warn("WARNING: PV %s belongs to Volume Group %s "
- "(consider using vgreduce).", name, pv_vg_name(pv));
+ log_warn("WARNING: PV %s is used by VG %s (consider using vgreduce).", name, pv_vg_name(pv));
if (force_count < 2)
goto_bad;
diff --git a/test/shell/pv-ext-flags.sh b/test/shell/pv-ext-flags.sh
index cf2a8a1..d465497 100644
--- a/test/shell/pv-ext-flags.sh
+++ b/test/shell/pv-ext-flags.sh
@@ -17,7 +17,7 @@ SKIP_WITH_LVMPOLLD=1
aux prepare_devs 2
# PV_EXT_USED flag
-MARKED_AS_USED_MSG="marked as belonging to a VG but its metadata is missing"
+MARKED_AS_USED_MSG="is used by a VG but its metadata is missing"
######################################
### CHECK PV WITH 0 METADATA AREAS ###
diff --git a/test/shell/pvremove-usage.sh b/test/shell/pvremove-usage.sh
index 4fd26d1..e0f51bf 100644
--- a/test/shell/pvremove-usage.sh
+++ b/test/shell/pvremove-usage.sh
@@ -56,16 +56,16 @@ for mdacp in 0 1 2; do
# pvremove -f fails when pv in a vg (---metadatacopies $mdacp)
not pvremove -f "$dev1" 2>&1 | tee out
- grep "belongs" out
+ grep "is used" out
pvs "$dev1"
# pvremove -ff fails without confirmation when pv in a vg (---metadatacopies $mdacp)
not pvremove -ff "$dev1" 2>&1 | tee out
- grep "belongs" out
+ grep "is used" out
# pvremove -ff succeds with confirmation when pv in a vg (---metadatacopies $mdacp)
pvremove -ffy "$dev1" 2>&1 | tee out
- grep "belongs" out
+ grep "is used" out
not pvs "$dev1"
vgreduce --removemissing $vg
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 3c12c14..86c4ac4 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -60,7 +60,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
goto_bad;
if (used && (arg_count(cmd, force_ARG) != DONT_PROMPT_OVERRIDE)) {
- log_error("PV '%s' is marked as belonging to a VG but its metadata is missing.", pv_name);
+ log_error("PV %s is used by a VG but its metadata is missing.", pv_name);
log_error("Can't change PV '%s' without -ff.", pv_name);
goto bad;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index 3e48139..8029030 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -2962,7 +2962,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
pv_name = pv_dev_name(pv);
if (cmd->system_id && is_orphan(pv) && is_used_pv(pv)) {
- log_verbose("PV %s is marked as belonging to a VG but its metadata is missing.", pv_name);
+ log_verbose("PV %s is used by a VG but its metadata is missing.", pv_name);
log_verbose("Skipping PV %s because it's not possible to decide whether it matches system id.", pv_name);
continue;
}
@@ -3601,7 +3601,7 @@ static void _check_pvcreate_prompt(struct cmd_context *cmd,
prompt->answer = PROMPT_ANSWER_NO;
if (prompt->vg_name_unknown) {
- log_error("PV '%s' is marked as belonging to a VG but its metadata is missing.", pvname);
+ log_error("PV %s is used by a VG but its metadata is missing.", pvname);
log_error("Can't initialize PV '%s' without -ff.", pvname);
} else if (!strcmp(command_name(cmd), "pvcreate")) {
log_error("Can't initialize physical volume \"%s\" of volume group \"%s\" without -ff", pvname, vgname);
@@ -3626,15 +3626,15 @@ static void _check_pvcreate_prompt(struct cmd_context *cmd,
prompt->answer = PROMPT_ANSWER_NO;
if (prompt->vg_name_unknown)
- log_error("PV %s belongs to a VG but its metadata is missing.", pvname);
+ log_error("PV %s is used by a VG but its metadata is missing.", pvname);
else
- log_error("PV %s belongs to Volume Group %s so please use vgreduce first.", pvname, vgname);
+ log_error("PV %s is used by VG %s so please use vgreduce first.", pvname, vgname);
log_error("(If you are certain you need pvremove, then confirm by using --force twice.)");
} else if (pp->yes) {
- log_warn("WARNING: PV %s belongs to Volume Group %s", pvname, vgname);
+ log_warn("WARNING: PV %s is used by VG %s", pvname, vgname);
prompt->answer = PROMPT_ANSWER_YES;
} else if (ask) {
- log_warn("WARNING: PV %s belongs to Volume Group %s", pvname, vgname);
+ log_warn("WARNING: PV %s is used by VG %s", pvname, vgname);
if (yes_no_prompt("Really WIPE LABELS from physical volume \"%s\" of volume group \"%s\" [y/n]? ", pvname, vgname) == 'n') {
prompt->answer = PROMPT_ANSWER_NO;
log_error("%s: physical volume label not removed", pvname);
8 years, 2 months
master - pvcreate: fix setting uuid arg
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=66e175702af4cf...
Commit: 66e175702af4cfb1ecad9316a8151c001933c190
Parent: 79f259621542e62a2f9fb5982f473d2bb849b1b5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 25 11:56:24 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 25 12:00:53 2016 -0600
pvcreate: fix setting uuid arg
Commit 4de6caf5 ("redefine pvcreate structs") left
out setting the "idp" pointer to the "id" arg.
---
tools/pvcreate.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 85fed09..77f5969 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -49,6 +49,7 @@ static int pvcreate_restore_params_from_args(struct cmd_context *cmd, int argc,
pp->uuid_str = arg_str_value(cmd, uuidstr_ARG, "");
if (!id_read_format(&pp->pva.id, pp->uuid_str))
return 0;
+ pp->pva.idp = &pp->pva.id;
}
if (arg_sign_value(cmd, physicalvolumesize_ARG, SIGN_NONE) == SIGN_MINUS) {
8 years, 2 months
master - tests: add simple dmstats report tests
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=79f259621542e6...
Commit: 79f259621542e62a2f9fb5982f473d2bb849b1b5
Parent: 3d3b132d9ac845e31c316ad4b908466bb3837a4d
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Thu Feb 18 16:52:37 2016 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:59 2016 +0000
tests: add simple dmstats report tests
Add tests for the "dmstats report" command:
* report
* report --count
* report --histogram
So far the tests just check the command runs as expected when a
correctly configured stats region exists: validation of output
can be added later.
---
test/shell/dmstats-report.sh | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/test/shell/dmstats-report.sh b/test/shell/dmstats-report.sh
new file mode 100644
index 0000000..c36e3eb
--- /dev/null
+++ b/test/shell/dmstats-report.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+# Copyright (C) 2009-2011 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. lib/inittest
+
+# ensure we can create devices (uses dmsetup, etc)
+aux prepare_devs 1
+
+# prepare a stats region with a histogram
+dmstats create --bounds 10ms,20ms,30ms "$dev1"
+
+# basic dmstats report commands
+dmstats report
+dmstats report --count 1
+dmstats report --histogram
+
8 years, 2 months
master - tests: add dmstats create tests
by Bryn Reeves
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3d3b132d9ac845...
Commit: 3d3b132d9ac845e31c316ad4b908466bb3837a4d
Parent: 11fd7b7c645c0462cac95687c098019cf779cd58
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Fri Dec 11 17:16:23 2015 +0000
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Thu Feb 25 16:40:59 2016 +0000
tests: add dmstats create tests
Add tests for the "dmstats create" command:
* simple whole-device region
* region using --start/--len options
* region using --segments option
* region with precise timestamps (--precise)
* region with histogram bounds (--bounds)
---
test/shell/dmstats-create.sh | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/test/shell/dmstats-create.sh b/test/shell/dmstats-create.sh
index cb1671a..d5db79f 100644
--- a/test/shell/dmstats-create.sh
+++ b/test/shell/dmstats-create.sh
@@ -15,6 +15,13 @@
aux driver_at_least 4 33 || skip
# ensure we can create devices (uses dmsetup, etc)
-#aux prepare_devs 5
+aux prepare_devs 1
+
+# basic dmstats create commands
+
+dmstats create "$dev1"
+dmstats create --start 0 --len 1 "$dev1"
+dmstats create --segments "$dev1"
+dmstats create --precise "$dev1"
+dmstats create --bounds 10ms,20ms,30ms "$dev1"
-# FIXME: some actual tests here.
8 years, 2 months