1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

cleanup: add some dots and use display_lvname

Just some more VG/LV printing.
This commit is contained in:
Zdenek Kabelac 2016-11-25 14:08:39 +01:00
parent 1d58074d9f
commit 1a4f13eb6e
7 changed files with 62 additions and 59 deletions

View File

@ -424,7 +424,7 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
return_0; return_0;
if (!dm_task_run(dmt)) { if (!dm_task_run(dmt)) {
log_error("Failed to get state of snapshot or snapshot origin device"); log_error("Failed to get state of snapshot or snapshot origin device.");
goto out; goto out;
} }
@ -432,13 +432,13 @@ static int _ignore_suspended_snapshot_component(struct device *dev)
next = dm_get_next_target(dmt, next, &start, &length, &target_type, &params); next = dm_get_next_target(dmt, next, &start, &length, &target_type, &params);
if (!target_type || !strcmp(target_type, TARGET_NAME_SNAPSHOT)) { if (!target_type || !strcmp(target_type, TARGET_NAME_SNAPSHOT)) {
if (!params || sscanf(params, "%d:%d %d:%d", &major1, &minor1, &major2, &minor2) != 4) { if (!params || sscanf(params, "%d:%d %d:%d", &major1, &minor1, &major2, &minor2) != 4) {
log_error("Incorrect snapshot table found"); log_error("Incorrect snapshot table found.");
goto out; goto out;
} }
r = r || _device_is_suspended(major1, minor1) || _device_is_suspended(major2, minor2); r = r || _device_is_suspended(major1, minor1) || _device_is_suspended(major2, minor2);
} else if (!strcmp(target_type, TARGET_NAME_SNAPSHOT_ORIGIN)) { } else if (!strcmp(target_type, TARGET_NAME_SNAPSHOT_ORIGIN)) {
if (!params || sscanf(params, "%d:%d", &major1, &minor1) != 2) { if (!params || sscanf(params, "%d:%d", &major1, &minor1) != 2) {
log_error("Incorrect snapshot-origin table found"); log_error("Incorrect snapshot-origin table found.");
goto out; goto out;
} }
r = r || _device_is_suspended(major1, minor1); r = r || _device_is_suspended(major1, minor1);

View File

@ -736,11 +736,11 @@ int add_seg_to_segs_using_this_lv(struct logical_volume *lv,
} }
} }
log_very_verbose("Adding %s:%" PRIu32 " as an user of %s", log_very_verbose("Adding %s:" FMTu32 " as an user of %s.",
seg->lv->name, seg->le, lv->name); display_lvname(seg->lv), seg->le, display_lvname(lv));
if (!(sl = dm_pool_zalloc(lv->vg->vgmem, sizeof(*sl)))) { if (!(sl = dm_pool_zalloc(lv->vg->vgmem, sizeof(*sl)))) {
log_error("Failed to allocate segment list"); log_error("Failed to allocate segment list.");
return 0; return 0;
} }
@ -762,16 +762,16 @@ int remove_seg_from_segs_using_this_lv(struct logical_volume *lv,
if (sl->count > 1) if (sl->count > 1)
sl->count--; sl->count--;
else { else {
log_very_verbose("%s:%" PRIu32 " is no longer a user " log_very_verbose("%s:" FMTu32 " is no longer a user of %s.",
"of %s", seg->lv->name, seg->le, display_lvname(seg->lv), seg->le,
lv->name); display_lvname(lv));
dm_list_del(&sl->list); dm_list_del(&sl->list);
} }
return 1; return 1;
} }
log_error(INTERNAL_ERROR "Segment %s:%u is not a user of %s.", log_error(INTERNAL_ERROR "Segment %s:" FMTu32 " is not a user of %s.",
seg->lv->name, seg->le, lv->name); display_lvname(seg->lv), seg->le, display_lvname(lv));
return 0; return 0;
} }
@ -798,8 +798,9 @@ struct lv_segment *get_only_segment_using_this_lv(const struct logical_volume *l
if (sl->count != 1) { if (sl->count != 1) {
log_error("%s is expected to have only one segment using it, " log_error("%s is expected to have only one segment using it, "
"while %s:%" PRIu32 " uses it %d times.", "while %s:" FMTu32 " uses it %d times.",
display_lvname(lv), sl->seg->lv->name, sl->seg->le, sl->count); display_lvname(lv), display_lvname(sl->seg->lv),
sl->seg->le, sl->count);
return NULL; return NULL;
} }
@ -890,7 +891,7 @@ static uint32_t _round_to_stripe_boundary(struct volume_group *vg, uint32_t exte
/* Round up extents to stripe divisible amount */ /* Round up extents to stripe divisible amount */
if ((size_rest = extents % stripes)) { if ((size_rest = extents % stripes)) {
new_extents += extend ? stripes - size_rest : -size_rest; new_extents += extend ? stripes - size_rest : -size_rest;
log_print_unless_silent("Rounding size %s (%d extents) up to stripe boundary size %s (%d extents).", log_print_unless_silent("Rounding size %s (%u extents) up to stripe boundary size %s (%u extents).",
display_size(vg->cmd, (uint64_t) extents * vg->extent_size), extents, display_size(vg->cmd, (uint64_t) extents * vg->extent_size), extents,
display_size(vg->cmd, (uint64_t) new_extents * vg->extent_size), new_extents); display_size(vg->cmd, (uint64_t) new_extents * vg->extent_size), new_extents);
} }
@ -1017,8 +1018,8 @@ static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t
return 0; return 0;
} else { } else {
if (!lv_remove(lv)) { if (!lv_remove(lv)) {
log_error("Failed to remove RAID image %s", log_error("Failed to remove RAID image %s.",
lv->name); display_lvname(lv));
return 0; return 0;
} }
} }
@ -1027,8 +1028,8 @@ static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t
if (seg->meta_areas && seg_metalv(seg, s) && (area_reduction == seg->area_len)) { if (seg->meta_areas && seg_metalv(seg, s) && (area_reduction == seg->area_len)) {
if (!lv_reduce(seg_metalv(seg, s), if (!lv_reduce(seg_metalv(seg, s),
seg_metalv(seg, s)->le_count)) { seg_metalv(seg, s)->le_count)) {
log_error("Failed to remove RAID meta-device %s", log_error("Failed to remove RAID meta-device %s.",
seg_metalv(seg, s)->name); display_lvname(seg_metalv(seg, s)));
return 0; return 0;
} }
} }
@ -1036,13 +1037,14 @@ static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t
} }
if (area_reduction == seg->area_len) { if (area_reduction == seg->area_len) {
log_very_verbose("Remove %s:%" PRIu32 "[%" PRIu32 "] from " log_very_verbose("Remove %s:" FMTu32 "[" FMTu32 "] from "
"the top of LV %s:%" PRIu32, "the top of LV %s:" FMTu32 ".",
seg->lv->name, seg->le, s, display_lvname(seg->lv), seg->le, s,
lv->name, seg_le(seg, s)); display_lvname(lv), seg_le(seg, s));
if (!remove_seg_from_segs_using_this_lv(lv, seg)) if (!remove_seg_from_segs_using_this_lv(lv, seg))
return_0; return_0;
seg_lv(seg, s) = NULL; seg_lv(seg, s) = NULL;
seg_le(seg, s) = 0; seg_le(seg, s) = 0;
seg_type(seg, s) = AREA_UNASSIGNED; seg_type(seg, s) = AREA_UNASSIGNED;
@ -3480,7 +3482,7 @@ static struct lv_segment *_convert_seg_to_mirror(struct lv_segment *seg,
seg->area_count, seg->area_len, seg->area_count, seg->area_len,
seg->chunk_size, region_size, seg->chunk_size, region_size,
seg->extents_copied, NULL))) { seg->extents_copied, NULL))) {
log_error("Couldn't allocate converted LV segment"); log_error("Couldn't allocate converted LV segment.");
return NULL; return NULL;
} }
@ -3513,13 +3515,14 @@ int lv_add_segmented_mirror_image(struct alloc_handle *ah,
if (!lv_is_pvmove(lv)) { if (!lv_is_pvmove(lv)) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR
"Non-pvmove LV, %s, passed as argument", lv->name); "Non-pvmove LV, %s, passed as argument.",
display_lvname(lv));
return 0; return 0;
} }
if (seg_type(first_seg(lv), 0) != AREA_PV) { if (seg_type(first_seg(lv), 0) != AREA_PV) {
log_error(INTERNAL_ERROR log_error(INTERNAL_ERROR
"Bad segment type for first segment area"); "Bad segment type for first segment area.");
return 0; return 0;
} }
@ -3530,8 +3533,8 @@ int lv_add_segmented_mirror_image(struct alloc_handle *ah,
*/ */
dm_list_iterate_items(aa, &ah->alloced_areas[0]) { dm_list_iterate_items(aa, &ah->alloced_areas[0]) {
if (!(seg = find_seg_by_le(lv, current_le))) { if (!(seg = find_seg_by_le(lv, current_le))) {
log_error("Failed to find segment for %s extent %" log_error("Failed to find segment for %s extent " FMTu32 ".",
PRIu32, lv->name, current_le); display_lvname(lv), current_le);
return 0; return 0;
} }
@ -3539,7 +3542,8 @@ int lv_add_segmented_mirror_image(struct alloc_handle *ah,
if (aa[0].len < seg->area_len) { if (aa[0].len < seg->area_len) {
if (!lv_split_segment(lv, seg->le + aa[0].len)) { if (!lv_split_segment(lv, seg->le + aa[0].len)) {
log_error("Failed to split segment at %s " log_error("Failed to split segment at %s "
"extent %" PRIu32, lv->name, le); "extent " FMTu32 ".",
display_lvname(lv), le);
return 0; return 0;
} }
} }
@ -3549,8 +3553,8 @@ int lv_add_segmented_mirror_image(struct alloc_handle *ah,
current_le = le; current_le = le;
if (!insert_layer_for_lv(lv->vg->cmd, lv, PVMOVE, "_mimage_0")) { if (!insert_layer_for_lv(lv->vg->cmd, lv, PVMOVE, "_mimage_0")) {
log_error("Failed to build pvmove LV-type mirror, %s", log_error("Failed to build pvmove LV-type mirror %s.",
lv->name); display_lvname(lv));
return 0; return 0;
} }
orig_lv = seg_lv(first_seg(lv), 0); orig_lv = seg_lv(first_seg(lv), 0);
@ -3571,8 +3575,8 @@ int lv_add_segmented_mirror_image(struct alloc_handle *ah,
dm_list_iterate_items(aa, &ah->alloced_areas[0]) { dm_list_iterate_items(aa, &ah->alloced_areas[0]) {
if (!(seg = find_seg_by_le(orig_lv, current_le))) { if (!(seg = find_seg_by_le(orig_lv, current_le))) {
log_error("Failed to find segment for %s extent %" log_error("Failed to find segment for %s extent " FMTu32 ".",
PRIu32, lv->name, current_le); display_lvname(lv), current_le);
return 0; return 0;
} }

View File

@ -828,18 +828,18 @@ int vg_extend_each_pv(struct volume_group *vg, struct pvcreate_params *pp)
struct pv_list *pvl; struct pv_list *pvl;
unsigned int max_phys_block_size = 0; unsigned int max_phys_block_size = 0;
log_debug_metadata("Adding PVs to VG %s", vg->name); log_debug_metadata("Adding PVs to VG %s.", vg->name);
if (_vg_bad_status_bits(vg, RESIZEABLE_VG)) if (_vg_bad_status_bits(vg, RESIZEABLE_VG))
return_0; return_0;
dm_list_iterate_items(pvl, &pp->pvs) { dm_list_iterate_items(pvl, &pp->pvs) {
log_debug_metadata("Adding PV %s to VG %s", pv_dev_name(pvl->pv), vg->name); log_debug_metadata("Adding PV %s to VG %s.", pv_dev_name(pvl->pv), vg->name);
if (!(check_dev_block_size_for_vg(pvl->pv->dev, if (!(check_dev_block_size_for_vg(pvl->pv->dev,
(const struct volume_group *) vg, (const struct volume_group *) vg,
&max_phys_block_size))) { &max_phys_block_size))) {
log_error("PV %s has wrong block size", pv_dev_name(pvl->pv)); log_error("PV %s has wrong block size.", pv_dev_name(pvl->pv));
return 0; return 0;
} }

View File

@ -1860,24 +1860,24 @@ static int _alloc_and_add_rmeta_devs_for_lv(struct logical_volume *lv, struct dm
dm_list_init(&meta_lvs); dm_list_init(&meta_lvs);
log_debug_metadata("Allocating metadata LVs for %s", display_lvname(lv)); log_debug_metadata("Allocating metadata LVs for %s.", display_lvname(lv));
if (!_alloc_rmeta_devs_for_lv(lv, &meta_lvs, allocate_pvs, &seg_meta_areas)) { if (!_alloc_rmeta_devs_for_lv(lv, &meta_lvs, allocate_pvs, &seg_meta_areas)) {
log_error("Failed to allocate metadata LVs for %s", display_lvname(lv)); log_error("Failed to allocate metadata LVs for %s.", display_lvname(lv));
return 0; return 0;
} }
/* Metadata LVs must be cleared before being added to the array */ /* Metadata LVs must be cleared before being added to the array */
log_debug_metadata("Clearing newly allocated metadata LVs for %s", display_lvname(lv)); log_debug_metadata("Clearing newly allocated metadata LVs for %s.", display_lvname(lv));
if (!_clear_lvs(&meta_lvs)) { if (!_clear_lvs(&meta_lvs)) {
log_error("Failed to initialize metadata LVs for %s", display_lvname(lv)); log_error("Failed to initialize metadata LVs for %s.", display_lvname(lv));
return 0; return 0;
} }
/* Set segment areas for metadata sub_lvs */ /* Set segment areas for metadata sub_lvs */
seg->meta_areas = seg_meta_areas; seg->meta_areas = seg_meta_areas;
log_debug_metadata("Adding newly allocated metadata LVs to %s", display_lvname(lv)); log_debug_metadata("Adding newly allocated metadata LVs to %s.", display_lvname(lv));
if (!_add_image_component_list(seg, 1, 0, &meta_lvs, 0)) { if (!_add_image_component_list(seg, 1, 0, &meta_lvs, 0)) {
log_error("Failed to add newly allocated metadata LVs to %s", display_lvname(lv)); log_error("Failed to add newly allocated metadata LVs to %s.", display_lvname(lv));
return 0; return 0;
} }

View File

@ -1596,7 +1596,7 @@ static int _lvcreate_single(struct cmd_context *cmd, const char *vg_name,
} }
if (seg_is_thin_volume(lp)) if (seg_is_thin_volume(lp))
log_verbose("Making thin LV %s in pool %s in VG %s%s%s using segtype %s", log_verbose("Making thin LV %s in pool %s in VG %s%s%s using segtype %s.",
lp->lv_name ? : "with generated name", lp->lv_name ? : "with generated name",
lp->pool_name ? : "with generated name", lp->vg_name, lp->pool_name ? : "with generated name", lp->vg_name,
lp->snapshot ? " as snapshot of " : "", lp->snapshot ? " as snapshot of " : "",

View File

@ -451,17 +451,16 @@ static int _add_pe_range(struct dm_pool *mem, const char *pvname,
{ {
struct pe_range *per; struct pe_range *per;
log_debug("Adding PE range: start PE %" PRIu32 " length %" PRIu32 log_debug("Adding PE range: start PE " FMTu32 " length " FMTu32 " on %s.",
" on %s.", start, count, pvname); start, count, pvname);
/* Ensure no overlap with existing areas */ /* Ensure no overlap with existing areas */
dm_list_iterate_items(per, pe_ranges) { dm_list_iterate_items(per, pe_ranges) {
if (((start < per->start) && (start + count - 1 >= per->start)) || if (((start < per->start) && (start + count - 1 >= per->start)) ||
((start >= per->start) && ((start >= per->start) &&
(per->start + per->count - 1) >= start)) { (per->start + per->count - 1) >= start)) {
log_error("Overlapping PE ranges specified (%" PRIu32 log_error("Overlapping PE ranges specified (" FMTu32
"-%" PRIu32 ", %" PRIu32 "-%" PRIu32 ")" "-" FMTu32 ", " FMTu32 "-" FMTu32 ") on %s.",
" on %s.",
start, start + count - 1, per->start, start, start + count - 1, per->start,
per->start + per->count - 1, pvname); per->start + per->count - 1, pvname);
return 0; return 0;
@ -637,7 +636,7 @@ struct dm_list *create_pv_list(struct dm_pool *mem, struct volume_group *vg, int
/* Build up list of PVs */ /* Build up list of PVs */
if (!(r = dm_pool_alloc(mem, sizeof(*r)))) { if (!(r = dm_pool_alloc(mem, sizeof(*r)))) {
log_error("Allocation of list failed"); log_error("Allocation of list failed.");
return NULL; return NULL;
} }
dm_list_init(r); dm_list_init(r);

View File

@ -26,19 +26,19 @@ static int _remove_pv(struct volume_group *vg, struct pv_list *pvl, int silent)
char uuid[64] __attribute__((aligned(8))); char uuid[64] __attribute__((aligned(8)));
if (vg->pv_count == 1) { if (vg->pv_count == 1) {
log_error("Volume Groups must always contain at least one PV"); log_error("Volume Groups must always contain at least one PV.");
return 0; return 0;
} }
if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid)))
return_0; return_0;
log_verbose("Removing PV with UUID %s from VG %s", uuid, vg->name); log_verbose("Removing PV with UUID %s from VG %s.", uuid, vg->name);
if (pvl->pv->pe_alloc_count) { if (pvl->pv->pe_alloc_count) {
if (!silent) if (!silent)
log_error("LVs still present on PV with UUID %s: " log_error("LVs still present on PV with UUID %s: "
"Can't remove from VG %s", uuid, vg->name); "Can't remove from VG %s.", uuid, vg->name);
return 0; return 0;
} }
@ -183,33 +183,33 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
if (!argc && !repairing) { if (!argc && !repairing) {
log_error("Please give volume group name and " log_error("Please give volume group name and "
"physical volume paths"); "physical volume paths.");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (!argc) { /* repairing */ if (!argc) { /* repairing */
log_error("Please give volume group name"); log_error("Please give volume group name.");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (arg_is_set(cmd, mirrorsonly_ARG) && !repairing) { if (arg_is_set(cmd, mirrorsonly_ARG) && !repairing) {
log_error("--mirrorsonly requires --removemissing"); log_error("--mirrorsonly requires --removemissing.");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (argc == 1 && !arg_is_set(cmd, all_ARG) && !repairing) { if (argc == 1 && !arg_is_set(cmd, all_ARG) && !repairing) {
log_error("Please enter physical volume paths or option -a"); log_error("Please enter physical volume paths or option -a.");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (argc > 1 && arg_is_set(cmd, all_ARG)) { if (argc > 1 && arg_is_set(cmd, all_ARG)) {
log_error("Option -a and physical volume paths mutually " log_error("Option -a and physical volume paths mutually "
"exclusive"); "exclusive.");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
if (argc > 1 && repairing) { if (argc > 1 && repairing) {
log_error("Please only specify the volume group"); log_error("Please only specify the volume group.");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
@ -250,10 +250,10 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
0, handle, &_vgreduce_repair_single); 0, handle, &_vgreduce_repair_single);
if (vp.already_consistent) { if (vp.already_consistent) {
log_print_unless_silent("Volume group \"%s\" is already consistent", vg_name); log_print_unless_silent("Volume group \"%s\" is already consistent.", vg_name);
ret = ECMD_PROCESSED; ret = ECMD_PROCESSED;
} else if (vp.fixed) { } else if (vp.fixed) {
log_print_unless_silent("Wrote out consistent volume group %s", vg_name); log_print_unless_silent("Wrote out consistent volume group %s.", vg_name);
ret = ECMD_PROCESSED; ret = ECMD_PROCESSED;
} else } else
ret = ECMD_FAILED; ret = ECMD_FAILED;