mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
#define an INTERNAL_ERROR macro and use it throughout LVM.
This commit is contained in:
parent
b1ebf028de
commit
550cae2340
@ -852,7 +852,7 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
|
||||
dm_tree_node_add_target_area(node, NULL, dlid,
|
||||
extent_size * seg_le(seg, s));
|
||||
} else {
|
||||
log_error("Internal error: Unassigned area found in LV %s.",
|
||||
log_error(INTERNAL_ERROR "Unassigned area found in LV %s.",
|
||||
seg->lv->name);
|
||||
return 0;
|
||||
}
|
||||
@ -911,7 +911,7 @@ static int _add_target_to_dtree(struct dev_manager *dm,
|
||||
uint64_t extent_size = seg->lv->vg->extent_size;
|
||||
|
||||
if (!seg->segtype->ops->add_target_line) {
|
||||
log_error("_emit_target: Internal error: Can't handle "
|
||||
log_error(INTERNAL_ERROR "_emit_target cannot handle "
|
||||
"segment type %s", seg->segtype->name);
|
||||
return 0;
|
||||
}
|
||||
|
12
lib/cache/lvmcache.c
vendored
12
lib/cache/lvmcache.c
vendored
@ -227,7 +227,7 @@ int lvmcache_verify_lock_order(const char *vgname)
|
||||
vgname2 = dm_hash_get_key(_lock_hash, n);
|
||||
|
||||
if (!_vgname_order_correct(vgname2, vgname)) {
|
||||
log_errno(EDEADLK, "Internal error: VG lock %s must "
|
||||
log_errno(EDEADLK, INTERNAL_ERROR "VG lock %s must "
|
||||
"be requested before %s, not after.",
|
||||
vgname, vgname2);
|
||||
return_0;
|
||||
@ -245,7 +245,7 @@ void lvmcache_lock_vgname(const char *vgname, int read_only __attribute((unused)
|
||||
}
|
||||
|
||||
if (dm_hash_lookup(_lock_hash, vgname))
|
||||
log_error("Internal error: Nested locking attempted on VG %s.",
|
||||
log_error(INTERNAL_ERROR "Nested locking attempted on VG %s.",
|
||||
vgname);
|
||||
|
||||
if (!dm_hash_insert(_lock_hash, vgname, (void *) 1))
|
||||
@ -268,7 +268,7 @@ int vgname_is_locked(const char *vgname)
|
||||
void lvmcache_unlock_vgname(const char *vgname)
|
||||
{
|
||||
if (!dm_hash_lookup(_lock_hash, vgname))
|
||||
log_error("Internal error: Attempt to unlock unlocked VG %s.",
|
||||
log_error(INTERNAL_ERROR "Attempt to unlock unlocked VG %s.",
|
||||
vgname);
|
||||
|
||||
_update_cache_lock_state(vgname, 0);
|
||||
@ -1102,7 +1102,7 @@ int lvmcache_update_vgname_and_id(struct lvmcache_info *info,
|
||||
uint32_t vgstatus, const char *creation_host)
|
||||
{
|
||||
if (!vgname && !info->vginfo) {
|
||||
log_error("Internal error: NULL vgname handed to cache");
|
||||
log_error(INTERNAL_ERROR "NULL vgname handed to cache");
|
||||
/* FIXME Remove this */
|
||||
vgname = info->fmt->orphan_vg_name;
|
||||
vgid = vgname;
|
||||
@ -1296,7 +1296,7 @@ static void _lvmcache_destroy_lockname(struct dm_hash_node *n)
|
||||
if (!strcmp(vgname, VG_GLOBAL))
|
||||
_vg_global_lock_held = 1;
|
||||
else
|
||||
log_error("Internal error: Volume Group %s was not unlocked",
|
||||
log_error(INTERNAL_ERROR "Volume Group %s was not unlocked",
|
||||
dm_hash_get_key(_lock_hash, n));
|
||||
}
|
||||
|
||||
@ -1333,7 +1333,7 @@ void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans)
|
||||
}
|
||||
|
||||
if (!dm_list_empty(&_vginfos))
|
||||
log_error("Internal error: _vginfos list should be empty");
|
||||
log_error(INTERNAL_ERROR "_vginfos list should be empty");
|
||||
dm_list_init(&_vginfos);
|
||||
|
||||
if (retain_orphans)
|
||||
|
@ -99,7 +99,7 @@ static void _inc_indent(struct formatter *f)
|
||||
static void _dec_indent(struct formatter *f)
|
||||
{
|
||||
if (!f->indent--) {
|
||||
log_error("Internal error tracking indentation");
|
||||
log_error(INTERNAL_ERROR "problem tracking indentation");
|
||||
f->indent = 0;
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ static int _text_write(struct label *label, void *buf)
|
||||
mda2 ? "s)" : "");
|
||||
|
||||
if (da1 < 0) {
|
||||
log_error("Internal error: %s label header currently requires "
|
||||
log_error(INTERNAL_ERROR "%s label header currently requires "
|
||||
"a data area.", dev_name(info->dev));
|
||||
return 0;
|
||||
}
|
||||
|
@ -349,12 +349,12 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
|
||||
assert(resource);
|
||||
|
||||
if (!*resource) {
|
||||
log_error("Internal error: Use of P_orphans is deprecated.");
|
||||
log_error(INTERNAL_ERROR "Use of P_orphans is deprecated.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*resource == '#' && (flags & LCK_CACHE)) {
|
||||
log_error("Internal error: P_%s referenced", resource);
|
||||
log_error(INTERNAL_ERROR "P_%s referenced", resource);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags)
|
||||
|
||||
|
||||
if (flags == LCK_NONE) {
|
||||
log_debug("Internal error: %s: LCK_NONE lock requested", vol);
|
||||
log_debug(INTERNAL_ERROR "%s: LCK_NONE lock requested", vol);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -184,8 +184,8 @@ void print_log(int level, const char *file, int line, int dm_errno,
|
||||
level &= ~_LOG_STDERR;
|
||||
|
||||
if (_abort_on_internal_errors &&
|
||||
!strncmp(format, "Internal error:",
|
||||
strlen("Internal error:")))
|
||||
!strncmp(format, INTERNAL_ERROR,
|
||||
strlen(INTERNAL_ERROR)))
|
||||
internal_error = 1;
|
||||
|
||||
if (_log_suppress == 2)
|
||||
|
@ -53,6 +53,7 @@
|
||||
#define _LOG_WARN 4
|
||||
#define _LOG_ERR 3
|
||||
#define _LOG_FATAL 2
|
||||
#define INTERNAL_ERROR "Internal error: "
|
||||
|
||||
#define log_debug(x...) LOG_LINE(_LOG_DEBUG, x)
|
||||
#define log_info(x...) LOG_LINE(_LOG_INFO, x)
|
||||
|
@ -2107,7 +2107,7 @@ int vg_validate(struct volume_group *vg)
|
||||
if (!id_write_format(&pvl->pv->id, uuid,
|
||||
sizeof(uuid)))
|
||||
stack;
|
||||
log_error("Internal error: Duplicate PV id "
|
||||
log_error(INTERNAL_ERROR "Duplicate PV id "
|
||||
"%s detected for %s in %s.",
|
||||
uuid, pv_dev_name(pvl->pv),
|
||||
vg->name);
|
||||
@ -2116,14 +2116,14 @@ int vg_validate(struct volume_group *vg)
|
||||
}
|
||||
|
||||
if (strcmp(pvl->pv->vg_name, vg->name)) {
|
||||
log_error("Internal error: VG name for PV %s is corrupted",
|
||||
log_error(INTERNAL_ERROR "VG name for PV %s is corrupted",
|
||||
pv_dev_name(pvl->pv));
|
||||
r = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!check_pv_segments(vg)) {
|
||||
log_error("Internal error: PV segments corrupted in %s.",
|
||||
log_error(INTERNAL_ERROR "PV segments corrupted in %s.",
|
||||
vg->name);
|
||||
r = 0;
|
||||
}
|
||||
@ -2159,7 +2159,7 @@ int vg_validate(struct volume_group *vg)
|
||||
*/
|
||||
if (((uint32_t) dm_list_size(&vg->lvs)) !=
|
||||
vg_visible_lvs(vg) + snapshot_count(vg) + hidden_lv_count) {
|
||||
log_error("Internal error: #internal LVs (%u) != #LVs (%"
|
||||
log_error(INTERNAL_ERROR "#internal LVs (%u) != #LVs (%"
|
||||
PRIu32 ") + #snapshots (%" PRIu32 ") + #internal LVs %u in VG %s",
|
||||
dm_list_size(&vg->lvs), vg_visible_lvs(vg),
|
||||
snapshot_count(vg), hidden_lv_count, vg->name);
|
||||
@ -2171,7 +2171,7 @@ int vg_validate(struct volume_group *vg)
|
||||
if (lvl == lvl2)
|
||||
break;
|
||||
if (!strcmp(lvl->lv->name, lvl2->lv->name)) {
|
||||
log_error("Internal error: Duplicate LV name "
|
||||
log_error(INTERNAL_ERROR "Duplicate LV name "
|
||||
"%s detected in %s.", lvl->lv->name,
|
||||
vg->name);
|
||||
r = 0;
|
||||
@ -2181,7 +2181,7 @@ int vg_validate(struct volume_group *vg)
|
||||
if (!id_write_format(&lvl->lv->lvid.id[1], uuid,
|
||||
sizeof(uuid)))
|
||||
stack;
|
||||
log_error("Internal error: Duplicate LV id "
|
||||
log_error(INTERNAL_ERROR "Duplicate LV id "
|
||||
"%s detected for %s and %s in %s.",
|
||||
uuid, lvl->lv->name, lvl2->lv->name,
|
||||
vg->name);
|
||||
@ -2192,7 +2192,7 @@ int vg_validate(struct volume_group *vg)
|
||||
|
||||
dm_list_iterate_items(lvl, &vg->lvs) {
|
||||
if (!check_lv_segments(lvl->lv, 1)) {
|
||||
log_error("Internal error: LV segments corrupted in %s.",
|
||||
log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
|
||||
lvl->lv->name);
|
||||
r = 0;
|
||||
}
|
||||
@ -2200,7 +2200,7 @@ int vg_validate(struct volume_group *vg)
|
||||
|
||||
if (!(vg->fid->fmt->features & FMT_UNLIMITED_VOLS) &&
|
||||
(!vg->max_lv || !vg->max_pv)) {
|
||||
log_error("Internal error: Volume group %s has limited PV/LV count"
|
||||
log_error(INTERNAL_ERROR "Volume group %s has limited PV/LV count"
|
||||
" but limit is not set.", vg->name);
|
||||
r = 0;
|
||||
}
|
||||
@ -2311,7 +2311,7 @@ int vg_commit(struct volume_group *vg)
|
||||
int failed = 0;
|
||||
|
||||
if (!vgname_is_locked(vg->name)) {
|
||||
log_error("Internal error: Attempt to write new VG metadata "
|
||||
log_error(INTERNAL_ERROR "Attempt to write new VG metadata "
|
||||
"without locking %s", vg->name);
|
||||
return cache_updated;
|
||||
}
|
||||
@ -2491,7 +2491,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
|
||||
|
||||
if (is_orphan_vg(vgname)) {
|
||||
if (use_precommitted) {
|
||||
log_error("Internal error: vg_read_internal requires vgname "
|
||||
log_error(INTERNAL_ERROR "vg_read_internal requires vgname "
|
||||
"with pre-commit.");
|
||||
return NULL;
|
||||
}
|
||||
@ -2802,7 +2802,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam
|
||||
return NULL;
|
||||
|
||||
if (!check_pv_segments(vg)) {
|
||||
log_error("Internal error: PV segments corrupted in %s.",
|
||||
log_error(INTERNAL_ERROR "PV segments corrupted in %s.",
|
||||
vg->name);
|
||||
vg_release(vg);
|
||||
return NULL;
|
||||
@ -2810,7 +2810,7 @@ struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgnam
|
||||
|
||||
dm_list_iterate_items(lvl, &vg->lvs) {
|
||||
if (!check_lv_segments(lvl->lv, 1)) {
|
||||
log_error("Internal error: LV segments corrupted in %s.",
|
||||
log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
|
||||
lvl->lv->name);
|
||||
vg_release(vg);
|
||||
return NULL;
|
||||
@ -2826,7 +2826,7 @@ void vg_release(struct volume_group *vg)
|
||||
return;
|
||||
|
||||
if (vg->cmd && vg->vgmem == vg->cmd->mem)
|
||||
log_error("Internal error: global memory pool used for VG %s",
|
||||
log_error(INTERNAL_ERROR "global memory pool used for VG %s",
|
||||
vg->name);
|
||||
|
||||
dm_pool_destroy(vg->vgmem);
|
||||
@ -3520,6 +3520,7 @@ uint32_t vg_lock_newname(struct cmd_context *cmd, const char *vgname)
|
||||
|
||||
/* Found vgname so cannot reserve. */
|
||||
unlock_vg(cmd, vgname);
|
||||
log_error("A volume group called '%s' already exists.", vg_name);
|
||||
return FAILED_EXIST;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ void memlock_inc(void)
|
||||
void memlock_dec(void)
|
||||
{
|
||||
if (!_memlock_count)
|
||||
log_error("Internal error: _memlock_count has dropped below 0.");
|
||||
log_error(INTERNAL_ERROR "_memlock_count has dropped below 0.");
|
||||
--_memlock_count;
|
||||
_unlock_mem_if_possible();
|
||||
log_debug("memlock_count dec to %d", _memlock_count);
|
||||
@ -167,7 +167,7 @@ void memlock_inc_daemon(void)
|
||||
void memlock_dec_daemon(void)
|
||||
{
|
||||
if (!_memlock_count_daemon)
|
||||
log_error("Internal error: _memlock_count_daemon has dropped below 0.");
|
||||
log_error(INTERNAL_ERROR "_memlock_count_daemon has dropped below 0.");
|
||||
--_memlock_count_daemon;
|
||||
_unlock_mem_if_possible();
|
||||
log_debug("memlock_count_daemon dec to %d", _memlock_count_daemon);
|
||||
|
@ -168,7 +168,7 @@ static int _striped_add_target_line(struct dev_manager *dm,
|
||||
uint32_t *pvmove_mirror_count __attribute((unused)))
|
||||
{
|
||||
if (!seg->area_count) {
|
||||
log_error("Internal error: striped add_target_line called "
|
||||
log_error(INTERNAL_ERROR "striped add_target_line called "
|
||||
"with no areas for %s.", seg->lv->name);
|
||||
return 0;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
|
||||
argv[0]);
|
||||
|
||||
if ((ret != ECMD_PROCESSED) && !error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_debug(INTERNAL_ERROR "Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
_write_history();
|
||||
|
@ -1243,7 +1243,7 @@ static int _run_script(struct cmd_context *cmd, int argc, char **argv)
|
||||
ret = lvm_run_command(cmd, argc, argv);
|
||||
if (ret != ECMD_PROCESSED) {
|
||||
if (!error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_debug(INTERNAL_ERROR "Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
break;
|
||||
@ -1368,7 +1368,7 @@ int lvm2_main(int argc, char **argv)
|
||||
log_error("No such command. Try 'help'.");
|
||||
|
||||
if ((ret != ECMD_PROCESSED) && !error_message_produced()) {
|
||||
log_debug("Internal error: Failed command did not use log_error");
|
||||
log_debug(INTERNAL_ERROR "Failed command did not use log_error");
|
||||
log_error("Command failed with status code %d.", ret);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user