[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] #define and use INTERNAL_ERROR



Hi,

patch attached to #define an INTERNAL_ERROR macro and use it throughout
LVM. There's a couple of internal errors in libdm as well, and it seems
that the log_error used by libdm actually comes from lib/ (i.e. LVM) so
it may make sense to convert those as well.

Yours,
    Petr.

? hint.diff
? source-tree-root
? tools/vgreduce.c.fix
Index: lib/activate/dev_manager.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/activate/dev_manager.c,v
retrieving revision 1.163
diff -u -p -r1.163 dev_manager.c
--- lib/activate/dev_manager.c	4 Nov 2009 14:56:35 -0000	1.163
+++ lib/activate/dev_manager.c	1 Dec 2009 14:15:44 -0000
@@ -852,7 +852,7 @@ int add_areas_line(struct dev_manager *d
 			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 d
 	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;
 	}
Index: lib/cache/lvmcache.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/cache/lvmcache.c,v
retrieving revision 1.73
diff -u -p -r1.73 lvmcache.c
--- lib/cache/lvmcache.c	24 Nov 2009 16:11:37 -0000	1.73
+++ lib/cache/lvmcache.c	1 Dec 2009 14:15:44 -0000
@@ -227,7 +227,7 @@ int lvmcache_verify_lock_order(const cha
 		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 *vg
 	}
 
 	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
 				  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(s
 	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
 	}
 
 	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)
Index: lib/format_text/export.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/format_text/export.c,v
retrieving revision 1.72
diff -u -p -r1.72 export.c
--- lib/format_text/export.c	24 Nov 2009 22:55:56 -0000	1.72
+++ lib/format_text/export.c	1 Dec 2009 14:15:44 -0000
@@ -99,7 +99,7 @@ static void _inc_indent(struct formatter
 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;
 	}
 }
Index: lib/format_text/text_label.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/format_text/text_label.c,v
retrieving revision 1.26
diff -u -p -r1.26 text_label.c
--- lib/format_text/text_label.c	24 Nov 2009 22:55:56 -0000	1.26
+++ lib/format_text/text_label.c	1 Dec 2009 14:15:45 -0000
@@ -137,7 +137,7 @@ static int _text_write(struct label *lab
 		  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;
 	}
Index: lib/locking/locking.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/locking/locking.c,v
retrieving revision 1.67
diff -u -p -r1.67 locking.c
--- lib/locking/locking.c	23 Nov 2009 10:55:14 -0000	1.67
+++ lib/locking/locking.c	1 Dec 2009 14:15:45 -0000
@@ -353,12 +353,12 @@ static int _lock_vol(struct cmd_context 
 	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;
 	}
 
@@ -398,7 +398,7 @@ int lock_vol(struct cmd_context *cmd, co
 
 
 	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;
 	}
 
Index: lib/log/log.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/log/log.c,v
retrieving revision 1.54
diff -u -p -r1.54 log.c
--- lib/log/log.c	1 Dec 2009 13:54:27 -0000	1.54
+++ lib/log/log.c	1 Dec 2009 14:15:45 -0000
@@ -184,8 +184,8 @@ void print_log(int level, const char *fi
 	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)
Index: lib/log/log.h
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/log/log.h,v
retrieving revision 1.46
diff -u -p -r1.46 log.h
--- lib/log/log.h	16 Jul 2009 13:13:33 -0000	1.46
+++ lib/log/log.h	1 Dec 2009 14:15:45 -0000
@@ -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)
Index: lib/metadata/metadata.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/metadata/metadata.c,v
retrieving revision 1.299
diff -u -p -r1.299 metadata.c
--- lib/metadata/metadata.c	24 Nov 2009 22:55:56 -0000	1.299
+++ lib/metadata/metadata.c	1 Dec 2009 14:15:45 -0000
@@ -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;
 	}
@@ -2490,7 +2490,7 @@ static struct volume_group *_vg_read(str
 
 	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;
 		}
@@ -2789,7 +2789,7 @@ struct volume_group *vg_read_internal(st
 		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;
@@ -2797,7 +2797,7 @@ struct volume_group *vg_read_internal(st
 
 	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;
@@ -2813,7 +2813,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);
Index: lib/mm/memlock.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/mm/memlock.c,v
retrieving revision 1.14
diff -u -p -r1.14 memlock.c
--- lib/mm/memlock.c	19 Nov 2009 01:11:57 -0000	1.14
+++ lib/mm/memlock.c	1 Dec 2009 14:15:45 -0000
@@ -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);
Index: lib/striped/striped.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/striped/striped.c,v
retrieving revision 1.29
diff -u -p -r1.29 striped.c
--- lib/striped/striped.c	28 Sep 2009 16:23:46 -0000	1.29
+++ lib/striped/striped.c	1 Dec 2009 14:15:45 -0000
@@ -168,7 +168,7 @@ static int _striped_add_target_line(stru
 				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;
 	}
Index: tools/lvm.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/lvm.c,v
retrieving revision 1.110
diff -u -p -r1.110 lvm.c
--- tools/lvm.c	18 Dec 2008 05:27:18 -0000	1.110
+++ tools/lvm.c	1 Dec 2009 14:15:46 -0000
@@ -237,7 +237,7 @@ int lvm_shell(struct cmd_context *cmd, s
 				  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();
Index: tools/lvmcmdline.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/lvmcmdline.c,v
retrieving revision 1.108
diff -u -p -r1.108 lvmcmdline.c
--- tools/lvmcmdline.c	3 Nov 2009 15:50:44 -0000	1.108
+++ tools/lvmcmdline.c	1 Dec 2009 14:15:46 -0000
@@ -1243,7 +1243,7 @@ static int _run_script(struct cmd_contex
 		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);
 	}
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]