Skip to contentSkip to conversation

error messages bound to command

PATCH New Thomas Woerner 3 participants 7 messages Jul 7, 2009 – Jul 9, 2009

lore
Share & tools
lore
#0 lore raw

cover error messages bound to command

This patch series add functions to add an error message and the error code to the command context. This is needed for liblvm to be able to have handle specific error reporting.

The first patch add the needed functions and corrects some code to use a script to add the error code to all log_error and log_err functions. It replaces all log_err calls with log_error. The result is the second patch.

The script:

    find . -name "*.[hc]" -exec perl -pi -e "s/log_error\(\"/log_error\(0, \"/g" {} \;
    find . -name "*.[hc]" -exec perl -pi -e "s/log_err\(\"/log_error\(0, \"/g" {} \;
    find . -name "*.[hc]" -exec perl -pi -e "s/log_error\(no_space\)/log_error\(0, no_space\)/g" {} \;
    perl -pi -e "s/log_error\(bad,/log_error\(0, bad,/g" lib/format_text/import_vsn1.c

testsuite: pass

twoerner (2):
Add cmd logging for liblvm error reporting: All logging functions
have an additional argument: The error code This makes the functions incompatible with the old ones.
Add error code for all log_err and log_error calls. Replace log_err
with log_error.

 daemons/clvmd/clvmd-cman.c            |    8 +-
 daemons/clvmd/clvmd-command.c         |    2 +-
 daemons/clvmd/clvmd-gulm.c            |    4 +-
 daemons/clvmd/clvmd.c                 |   26 ++--
 daemons/clvmd/lvm-functions.c         |   15 ++-
 daemons/dmeventd/libdevmapper-event.c |   50 ++++----
 lib/activate/activate.c               |   26 ++--
 lib/activate/dev_manager.c            |   64 +++++-----
 lib/activate/fs.c                     |   24 ++--
 lib/cache/lvmcache.c                  |   70 +++++-----
 lib/commands/toolcontext.c            |  119 +++++++++--------
 lib/commands/toolcontext.h            |    6 +
 lib/config/config.c                   |   38 +++---
 lib/device/dev-cache.c                |   50 ++++----
 lib/device/dev-io.c                   |   22 ++--
 lib/device/dev-md.c                   |    8 +-
 lib/device/device.c                   |   12 +-
 lib/display/display.c                 |    4 +-
 lib/error/errseg.c                    |    2 +-
 lib/filters/filter-composite.c        |    4 +-
 lib/filters/filter-md.c               |    2 +-
 lib/filters/filter-persistent.c       |    6 +-
 lib/filters/filter-regex.c            |    4 +-
 lib/filters/filter-sysfs.c            |   10 +-
 lib/filters/filter.c                  |   10 +-
 lib/format1/disk-rep.c                |   30 ++--
 lib/format1/format1.c                 |   22 ++--
 lib/format1/import-export.c           |   22 ++--
 lib/format1/import-extents.c          |   24 ++--
 lib/format1/layout.c                  |   10 +-
 lib/format1/lvm1-label.c              |    4 +-
 lib/format_pool/disk_rep.c            |    4 +-
 lib/format_pool/format_pool.c         |   20 ++--
 lib/format_pool/import_export.c       |   14 +-
 lib/format_pool/pool_label.c          |    4 +-
 lib/format_text/archive.c             |   16 +-
 lib/format_text/archiver.c            |   32 +++---
 lib/format_text/export.c              |   12 +-
 lib/format_text/flags.c               |    8 +-
 lib/format_text/format-text.c         |   96 +++++++-------
 lib/format_text/import.c              |    2 +-
 lib/format_text/import_vsn1.c         |  120 ++++++++--------
 lib/format_text/tags.c                |    2 +-
 lib/format_text/text_label.c          |   16 +-
 lib/label/label.c                     |   14 +-
 lib/locking/cluster_locking.c         |   20 ++--
 lib/locking/external_locking.c        |    4 +-
 lib/locking/file_locking.c            |    6 +-
 lib/locking/locking.c                 |   18 ++--
 lib/locking/no_locking.c              |    2 +-
 lib/log/log.c                         |   44 ++++++-
 lib/log/log.h                         |   16 +-
 lib/log/lvm-logging.h                 |   11 +-
 lib/metadata/lv_manip.c               |  176 ++++++++++++------------
 lib/metadata/merge.c                  |   46 +++---
 lib/metadata/metadata.c               |  238 ++++++++++++++++----------------
 lib/metadata/mirror.c                 |  156 +++++++++++-----------
 lib/metadata/pv_manip.c               |   32 +++---
 lib/metadata/pv_map.c                 |    4 +-
 lib/metadata/segtype.c                |    2 +-
 lib/metadata/snapshot_manip.c         |    6 +-
 lib/mirror/mirrored.c                 |   34 +++---
 lib/misc/lvm-exec.c                   |    8 +-
 lib/misc/lvm-file.c                   |   16 +-
 lib/misc/lvm-string.c                 |    2 +-
 lib/misc/sharedlib.c                  |    4 +-
 lib/mm/memlock.c                      |    4 +-
 lib/report/report.c                   |   58 ++++----
 lib/snapshot/snapshot.c               |   14 +-
 lib/striped/striped.c                 |    8 +-
 lib/uuid/uuid.c                       |    8 +-
 lib/zero/zero.c                       |    2 +-
 libdm/ioctl/libdm-iface.c             |   94 +++++++-------
 libdm/libdevmapper.h                  |    4 +-
 libdm/libdm-common.c                  |   39 +++---
 libdm/libdm-deptree.c                 |  154 +++++++++++-----------
 libdm/libdm-file.c                    |    2 +-
 libdm/libdm-report.c                  |  104 +++++++-------
 libdm/misc/dm-logging.h               |    2 +-
 libdm/mm/dbg_malloc.c                 |   10 +-
 libdm/mm/pool-debug.c                 |    8 +-
 libdm/mm/pool-fast.c                  |    6 +-
 libdm/mm/pool.c                       |    6 +-
 libdm/regex/matcher.c                 |    4 +-
 libdm/regex/parse_rx.c                |   10 +-
 liblvm/Makefile.in                    |    2 +
 liblvm/lvm.h                          |    3 +
 liblvm/lvm_base.c                     |   19 +++-
 old-tests/datastruct/hash_t.c         |    4 +-
 old-tests/dev-mgr/dev_cache_t.c       |    6 +-
 old-tests/device/dev_cache_t.c        |    6 +-
 old-tests/device/random.c             |    4 +-
 old-tests/filters/pfilter_t.c         |    4 +-
 old-tests/filters/rfilter_t.c         |    2 +-
 tools/dmsetup.c                       |   42 +++---
 tools/lvchange.c                      |  100 +++++++-------
 tools/lvconvert.c                     |  112 ++++++++--------
 tools/lvcreate.c                      |  156 +++++++++++-----------
 tools/lvdisplay.c                     |    6 +-
 tools/lvm.c                           |   10 +-
 tools/lvmcmdlib.c                     |    8 +-
 tools/lvmcmdline.c                    |   57 +++++----
 tools/lvmdiskscan.c                   |   10 +-
 tools/lvremove.c                      |    2 +-
 tools/lvrename.c                      |   18 ++--
 tools/lvresize.c                      |   68 +++++-----
 tools/lvscan.c                        |    2 +-
 tools/polldaemon.c                    |   16 +-
 tools/pvchange.c                      |   47 +++----
 tools/pvcreate.c                      |   58 ++++----
 tools/pvdisplay.c                     |   10 +-
 tools/pvmove.c                        |   66 +++++-----
 tools/pvremove.c                      |   20 ++--
 tools/pvresize.c                      |   28 ++--
 tools/pvscan.c                        |    4 +-
 tools/reporter.c                      |   10 +-
 tools/stub.h                          |    8 +-
 tools/toollib.c                       |  116 ++++++++--------
 tools/vgcfgbackup.c                   |    8 +-
 tools/vgcfgrestore.c                  |   10 +-
 tools/vgchange.c                      |   66 +++++-----
 tools/vgconvert.c                     |   38 +++---
 tools/vgcreate.c                      |   14 +-
 tools/vgdisplay.c                     |    8 +-
 tools/vgexport.c                      |    6 +-
 tools/vgextend.c                      |    6 +-
 tools/vgimport.c                      |    8 +-
 tools/vgmerge.c                       |    6 +-
 tools/vgreduce.c                      |   58 ++++----
 tools/vgremove.c                      |    4 +-
 tools/vgrename.c                      |   14 +-
 tools/vgscan.c                        |    4 +-
 tools/vgsplit.c                       |   28 ++--
 133 files changed, 1910 insertions(+), 1832 deletions(-)
#1 lore raw

PATCH 1/2 Add cmd logging for liblvm error reporting: All logging functions have an additional argument: The error code This makes the functions incompatible with the old ones.

From: twoerner <[email protected]>

The error code and message is bound to the command and therefore can be used to have more accurate error conditions for dm, lvm and liblvm.

---
 daemons/clvmd/lvm-functions.c |    7 +++++-
 lib/commands/toolcontext.c    |   33 ++++++++++++++++++------------
 lib/commands/toolcontext.h    |    6 +++++
 lib/log/log.c                 |   44 ++++++++++++++++++++++++++++++++++++----
 lib/log/log.h                 |   16 +++++++-------
 lib/log/lvm-logging.h         |   11 +++++++--
 libdm/libdevmapper.h          |    4 +-
 libdm/libdm-common.c          |    3 +-
 libdm/misc/dm-logging.h       |    2 +-
 libdm/mm/dbg_malloc.c         |    2 +-
 liblvm/Makefile.in            |    2 +
 liblvm/lvm.h                  |    3 ++
 liblvm/lvm_base.c             |   17 ++++++++++++++-
 tools/lvmcmdline.c            |    5 ++++
 tools/pvchange.c              |    5 +--
 tools/pvmove.c                |    6 +---
 16 files changed, 122 insertions(+), 44 deletions(-)
daemons/clvmd/lvm-functions.c +6 -1
index 078afd4..ab90ea6 100644
@@ -788,7 +788,12 @@ void lvm_do_backup(const char *vgname)
 int init_lvm(int using_gulm)
 {
 	if (!(cmd = create_toolcontext(1, NULL))) {
-		log_error("Failed to allocate command context");
+		log_error(0, "Failed to allocate command context");
+		return 0;
+	}
+
+	if (lvm_error(cmd) != 0) {
+		log_error(0, "Failed to create command context");
 		return 0;
 	}
 
lib/commands/toolcontext.c +20 -13
index 4f6cf98..12b881b 100644
@@ -1031,6 +1031,9 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
 	dm_list_init(&cmd->tags);
 	dm_list_init(&cmd->config_files);
 
+	/* Log to command */
+	init_log_cmd(cmd);
+
 	/*
 	 * Environment variable LVM_SYSTEM_DIR overrides this below.
 	 */
@@ -1112,16 +1115,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
 	return cmd;
 
       error:
-	_destroy_tag_configs(cmd);
-	dev_cache_exit();
-	if (cmd->filter)
-		cmd->filter->destroy(cmd->filter);
-	if (cmd->mem)
-		dm_pool_destroy(cmd->mem);
-	if (cmd->libmem)
-		dm_pool_destroy(cmd->libmem);
-	dm_free(cmd);
-	return NULL;
+	return cmd;
 }
 
 static void _destroy_formats(struct dm_list *formats)
@@ -1240,12 +1234,15 @@ void destroy_toolcontext(struct cmd_context *cmd)
 	label_exit();
 	_destroy_segtypes(&cmd->segtypes);
 	_destroy_formats(&cmd->formats);
-	cmd->filter->destroy(cmd->filter);
-	dm_pool_destroy(cmd->mem);
+	if (cmd->filter)
+		cmd->filter->destroy(cmd->filter);
+	if (cmd->mem)
+		dm_pool_destroy(cmd->mem);
 	dev_cache_exit();
 	_destroy_tags(cmd);
 	_destroy_tag_configs(cmd);
-	dm_pool_destroy(cmd->libmem);
+	if (cmd->libmem)
+		dm_pool_destroy(cmd->libmem);
 	dm_free(cmd);
 
 	release_log_memory();
@@ -1253,3 +1250,13 @@ void destroy_toolcontext(struct cmd_context *cmd)
 	fin_log();
 	fin_syslog();
 }
+
+int cmd_error(struct cmd_context *cmd)
+{
+	return cmd->error;
+}
+
+const char *cmd_strerror(struct cmd_context *cmd)
+{
+	return cmd->err_string;
+}
lib/commands/toolcontext.h +6 -0
index b5d0e2e..1b01f65 100644
@@ -92,6 +92,9 @@ struct cmd_context {
 	char dev_dir[PATH_MAX];
 	char proc_dir[PATH_MAX];
 	char sysfs_dir[PATH_MAX];
+
+	int error;
+	char err_string[8192]; /* fixed size error srting */
 };
 
 /*
@@ -105,4 +108,7 @@ int refresh_toolcontext(struct cmd_context *cmd);
 int config_files_changed(struct cmd_context *cmd);
 int init_lvmcache_orphans(struct cmd_context *cmd);
 
+int cmd_error(struct cmd_context *cmd);
+const char *cmd_strerror(struct cmd_context *cmd);
+
 #endif
lib/log/log.c +39 -5

80 lines not on this page · raw message

lib/log/log.h +8 -8
index 09a75ad..a55fe84 100644
@@ -50,22 +50,22 @@
 #define _LOG_ERR 3
 #define _LOG_FATAL 2
 
-#define log_debug(x...) plog(_LOG_DEBUG, x)
-#define log_info(x...) plog(_LOG_INFO, x)
-#define log_notice(x...) plog(_LOG_NOTICE, x)
-#define log_warn(x...) plog(_LOG_WARN | _LOG_STDERR, x)
-#define log_err(x...) plog(_LOG_ERR, x)
-#define log_fatal(x...) plog(_LOG_FATAL, x)
+#define log_debug(x...) plog(_LOG_DEBUG, 0, x)
+#define log_info(x...) plog(_LOG_INFO, 0, x)
+#define log_notice(x...) plog(_LOG_NOTICE, 0, x)
+#define log_warn(x...) plog(_LOG_WARN | _LOG_STDERR, 0, x)
+#define log_err(c, x...) plog(_LOG_ERR, c, x)
+#define log_fatal(x...) plog(_LOG_FATAL, 0, x)
 
 #define stack log_debug("<backtrace>")	/* Backtrace on error */
 #define log_very_verbose(args...) log_info(args)
 #define log_verbose(args...) log_notice(args)
-#define log_print(args...) plog(_LOG_WARN, args)
+#define log_print(args...) plog(_LOG_WARN, 0, args)
 #define log_error(args...) log_err(args)
 
 /* System call equivalents */
 #define log_sys_error(x, y) \
-		log_err("%s: %s failed: %s", y, x, strerror(errno))
+		log_err(errno, "%s: %s failed: %s", y, x, strerror(errno))
 #define log_sys_very_verbose(x, y) \
 		log_info("%s: %s failed: %s", y, x, strerror(errno))
 #define log_sys_debug(x, y) \
lib/log/lvm-logging.h +8 -3
index 70693ea..d9202d8 100644
@@ -16,13 +16,15 @@
 #ifndef _LVM_LOGGING_H
 #define _LVM_LOGGING_H
 
-void print_log(int level, const char *file, int line, const char *format, ...)
-    __attribute__ ((format(printf, 4, 5)));
+void print_log(int level, const char *file, int line, int code, const char *format, ...)
+    __attribute__ ((format(printf, 5, 6)));
 
-#define plog(l, x...) print_log(l, __FILE__, __LINE__ , ## x)
+#define plog(l, c, x...) print_log(l, __FILE__, __LINE__ , c, ## x)
 
 #include "log.h"
 
+struct cmd_context;
+
 typedef void (*lvm2_log_fn_t) (int level, const char *file, int line,
 			       const char *message);
 
@@ -34,14 +36,17 @@ void init_msg_prefix(const char *prefix);
 void init_log_file(const char *log_file, int append);
 void init_log_direct(const char *log_file, int append);
 void init_log_while_suspended(int log_while_suspended);
+void init_log_cmd(struct cmd_context *cmd);
 
 void fin_log(void);
 void release_log_memory(void);
+void release_log_cmd(struct cmd_context *cmd);
 
 void init_syslog(int facility);
 void fin_syslog(void);
 
 int error_message_produced(void);
+void reset_log_cmd(struct cmd_context *cmd);
 
 /* Suppress messages to stdout/stderr (1) or everywhere (2) */
 /* Returns previous setting */
libdm/libdevmapper.h +2 -2
index 3cecf4c..6dd52a0 100644
@@ -44,8 +44,8 @@
  */
 
 typedef void (*dm_log_fn) (int level, const char *file, int line,
-			   const char *f, ...)
-    __attribute__ ((format(printf, 4, 5)));
+			   int code, const char *f, ...)
+    __attribute__ ((format(printf, 5, 6)));
 
 /*
  * The library user may wish to register their own
libdm/libdm-common.c +2 -1
index 9246923..291a1b5 100644
@@ -43,7 +43,8 @@ static int _verbose = 0;
  * function.
  */
 static void _default_log(int level, const char *file __attribute((unused)),
-			 int line __attribute((unused)), const char *f, ...)
+			 int line __attribute((unused)),
+			 int code __attribute((unused)), const char *f, ...)
 {
 	va_list ap;
 	int use_stderr = level & _LOG_STDERR;
libdm/misc/dm-logging.h +1 -1
index b25bc55..6505b03 100644
@@ -20,7 +20,7 @@
 
 extern dm_log_fn dm_log;
 
-#define plog(l, x...) dm_log(l, __FILE__, __LINE__, ## x)
+#define plog(l, c, x...) dm_log(l, __FILE__, __LINE__, c, ## x)
 
 #include "log.h"
 
libdm/mm/dbg_malloc.c +1 -1
index ef53fc5..add285a 100644
@@ -205,7 +205,7 @@ int dm_dump_memory_debug(void)
 		}
 		str[sizeof(str) - 1] = '\0';
 
-		dm_log(_LOG_INFO, mb->file, mb->line,
+		dm_log(_LOG_INFO, mb->file, mb->line, 0,
 		       "block %d at %p, size %" PRIsize_t "\t [%s]",
 		       mb->id, mb->magic, mb->length, str);
 		tot += mb->length;
liblvm/Makefile.in +2 -0
index fdd2ecc..3add2b3 100644
@@ -28,6 +28,8 @@ LIB_STATIC = $(LIB_NAME).a
 endif
 LIB_SHARED = $(LIB_NAME).so
 
+LDDEPS = $(top_srcdir)/libdm/libdevmapper.so $(top_srcdir)/lib/liblvm-internal.a
+
 CLEAN_TARGETS += liblvm.cflow
 
 include $(top_srcdir)/make.tmpl
liblvm/lvm.h +3 -0
index 3b60510..ef37b1e 100644
@@ -54,4 +54,7 @@ void lvm_destroy(lvm_t libh);
  */
 int lvm_reload_config(lvm_t libh);
 
+int lvm_error(lvm_t libh);
+const char *lvm_strerror(lvm_t libh);
+
 #endif /* _LIB_LVM_H */
liblvm/lvm_base.c +15 -2
index 213246a..6d27c4d 100644
@@ -29,6 +29,9 @@ lvm_t lvm_create(const char *system_dir)
 	cmd = create_toolcontext(1, system_dir);
 	if (!cmd)
 		return NULL;
+	if (cmd_error(cmd) != 0)
+		return (lvm_t) cmd;
+
 	/*
 	 * FIXME: if an non memory error occured, return the cmd (maybe some
 	 * cleanup needed).
@@ -52,11 +55,21 @@ lvm_t lvm_create(const char *system_dir)
 void lvm_destroy(lvm_t libh)
 {
 	/* FIXME: error handling */
-	destroy_toolcontext((struct cmd_context *)libh);
+	destroy_toolcontext((struct cmd_context *) libh);
 }
 
 int lvm_reload_config(lvm_t libh)
 {
 	/* FIXME: re-init locking needed here? */
-	return refresh_toolcontext((struct cmd_context *)libh);
+	return refresh_toolcontext((struct cmd_context *) libh);
+}
+
+int lvm_error(lvm_t libh)
+{
+	return cmd_error((struct cmd_context *) libh);
+}
+
+const char *lvm_strerror(lvm_t libh)
+{
+	return cmd_strerror((struct cmd_context *) libh);
 }
tools/lvmcmdline.c +5 -0
index 1ad14d0..555be8f 100644
@@ -1179,6 +1179,11 @@ struct cmd_context *init_lvm(void)
 	if (!(cmd = create_toolcontext(0, NULL)))
 		return_NULL;
 
+	if (cmd_error(cmd) != 0) {
+		destroy_toolcontext(cmd);
+		return_NULL;
+	}
+
 	return cmd;
 }
 
tools/pvchange.c +2 -3
index efc780b..def78cc 100644
@@ -64,9 +64,8 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
 		}
 
 		if (!(pvl = find_pv_in_vg(vg, pv_name))) {
-			log_error
-			    ("Unable to find \"%s\" in volume group \"%s\"",
-			     pv_name, vg->name);
+			log_error("Unable to find \"%s\" in volume group \"%s\"",
+				  pv_name, vg->name);
 			goto out;
 		}
 		if (tagarg && !(vg->fid->fmt->features & FMT_TAGS)) {
tools/pvmove.c +2 -4
index 65b7606..2490863 100644
@@ -400,15 +400,13 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
 			log_error("Ignoring remaining command line arguments");
 
 		if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
-			log_error
-			    ("ABORTING: Failed to generate list of moving LVs");
+			log_error("ABORTING: Failed to generate list of moving LVs");
 			goto out;
 		}
 
 		/* Ensure mirror LV is active */
 		if (!_activate_lv(cmd, lv_mirr, exclusive)) {
-			log_error
-			    ("ABORTING: Temporary mirror activation failed.");
+			log_error("ABORTING: Temporary mirror activation failed.");
 			goto out;
 		}
 
Signature · 1 line
1.6.2.5
#2 lore raw

PATCH 2/2 Add error code for all log_err and log_error calls. Replace log_err with log_error.

From: twoerner <[email protected]>

Fixed all log_error calls using the script.

---
 daemons/clvmd/clvmd-cman.c            |    8 +-
 daemons/clvmd/clvmd-command.c         |    2 +-
 daemons/clvmd/clvmd-gulm.c            |    4 +-
 daemons/clvmd/clvmd.c                 |   26 ++--
 daemons/clvmd/lvm-functions.c         |    8 +-
 daemons/dmeventd/libdevmapper-event.c |   50 ++++----
 lib/activate/activate.c               |   26 ++--
 lib/activate/dev_manager.c            |   64 +++++-----
 lib/activate/fs.c                     |   24 ++--
 lib/cache/lvmcache.c                  |   70 +++++-----
 lib/commands/toolcontext.c            |   86 ++++++------
 lib/config/config.c                   |   38 +++---
 lib/device/dev-cache.c                |   50 ++++----
 lib/device/dev-io.c                   |   22 ++--
 lib/device/dev-md.c                   |    8 +-
 lib/device/device.c                   |   12 +-
 lib/display/display.c                 |    4 +-
 lib/error/errseg.c                    |    2 +-
 lib/filters/filter-composite.c        |    4 +-
 lib/filters/filter-md.c               |    2 +-
 lib/filters/filter-persistent.c       |    6 +-
 lib/filters/filter-regex.c            |    4 +-
 lib/filters/filter-sysfs.c            |   10 +-
 lib/filters/filter.c                  |   10 +-
 lib/format1/disk-rep.c                |   30 ++--
 lib/format1/format1.c                 |   22 ++--
 lib/format1/import-export.c           |   22 ++--
 lib/format1/import-extents.c          |   24 ++--
 lib/format1/layout.c                  |   10 +-
 lib/format1/lvm1-label.c              |    4 +-
 lib/format_pool/disk_rep.c            |    4 +-
 lib/format_pool/format_pool.c         |   20 ++--
 lib/format_pool/import_export.c       |   14 +-
 lib/format_pool/pool_label.c          |    4 +-
 lib/format_text/archive.c             |   16 +-
 lib/format_text/archiver.c            |   32 +++---
 lib/format_text/export.c              |   12 +-
 lib/format_text/flags.c               |    8 +-
 lib/format_text/format-text.c         |   96 +++++++-------
 lib/format_text/import.c              |    2 +-
 lib/format_text/import_vsn1.c         |  120 ++++++++--------
 lib/format_text/tags.c                |    2 +-
 lib/format_text/text_label.c          |   16 +-
 lib/label/label.c                     |   14 +-
 lib/locking/cluster_locking.c         |   20 ++--
 lib/locking/external_locking.c        |    4 +-
 lib/locking/file_locking.c            |    6 +-
 lib/locking/locking.c                 |   18 ++--
 lib/locking/no_locking.c              |    2 +-
 lib/metadata/lv_manip.c               |  176 ++++++++++++------------
 lib/metadata/merge.c                  |   46 +++---
 lib/metadata/metadata.c               |  238 ++++++++++++++++----------------
 lib/metadata/mirror.c                 |  156 +++++++++++-----------
 lib/metadata/pv_manip.c               |   32 +++---
 lib/metadata/pv_map.c                 |    4 +-
 lib/metadata/segtype.c                |    2 +-
 lib/metadata/snapshot_manip.c         |    6 +-
 lib/mirror/mirrored.c                 |   34 +++---
 lib/misc/lvm-exec.c                   |    8 +-
 lib/misc/lvm-file.c                   |   16 +-
 lib/misc/lvm-string.c                 |    2 +-
 lib/misc/sharedlib.c                  |    4 +-
 lib/mm/memlock.c                      |    4 +-
 lib/report/report.c                   |   58 ++++----
 lib/snapshot/snapshot.c               |   14 +-
 lib/striped/striped.c                 |    8 +-
 lib/uuid/uuid.c                       |    8 +-
 lib/zero/zero.c                       |    2 +-
 libdm/ioctl/libdm-iface.c             |   94 +++++++-------
 libdm/libdm-common.c                  |   36 +++---
 libdm/libdm-deptree.c                 |  154 +++++++++++-----------
 libdm/libdm-file.c                    |    2 +-
 libdm/libdm-report.c                  |  104 +++++++-------
 libdm/mm/dbg_malloc.c                 |    8 +-
 libdm/mm/pool-debug.c                 |    8 +-
 libdm/mm/pool-fast.c                  |    6 +-
 libdm/mm/pool.c                       |    6 +-
 libdm/regex/matcher.c                 |    4 +-
 libdm/regex/parse_rx.c                |   10 +-
 liblvm/lvm_base.c                     |    2 +-
 old-tests/datastruct/hash_t.c         |    4 +-
 old-tests/dev-mgr/dev_cache_t.c       |    6 +-
 old-tests/device/dev_cache_t.c        |    6 +-
 old-tests/device/random.c             |    4 +-
 old-tests/filters/pfilter_t.c         |    4 +-
 old-tests/filters/rfilter_t.c         |    2 +-
 tools/dmsetup.c                       |   42 +++---
 tools/lvchange.c                      |  100 +++++++-------
 tools/lvconvert.c                     |  112 ++++++++--------
 tools/lvcreate.c                      |  156 +++++++++++-----------
 tools/lvdisplay.c                     |    6 +-
 tools/lvm.c                           |   10 +-
 tools/lvmcmdlib.c                     |    8 +-
 tools/lvmcmdline.c                    |   52 ++++----
 tools/lvmdiskscan.c                   |   10 +-
 tools/lvremove.c                      |    2 +-
 tools/lvrename.c                      |   18 ++--
 tools/lvresize.c                      |   68 +++++-----
 tools/lvscan.c                        |    2 +-
 tools/polldaemon.c                    |   16 +-
 tools/pvchange.c                      |   44 +++---
 tools/pvcreate.c                      |   58 ++++----
 tools/pvdisplay.c                     |   10 +-
 tools/pvmove.c                        |   64 +++++-----
 tools/pvremove.c                      |   20 ++--
 tools/pvresize.c                      |   28 ++--
 tools/pvscan.c                        |    4 +-
 tools/reporter.c                      |   10 +-
 tools/stub.h                          |    8 +-
 tools/toollib.c                       |  116 ++++++++--------
 tools/vgcfgbackup.c                   |    8 +-
 tools/vgcfgrestore.c                  |   10 +-
 tools/vgchange.c                      |   66 +++++-----
 tools/vgconvert.c                     |   38 +++---
 tools/vgcreate.c                      |   14 +-
 tools/vgdisplay.c                     |    8 +-
 tools/vgexport.c                      |    6 +-
 tools/vgextend.c                      |    6 +-
 tools/vgimport.c                      |    8 +-
 tools/vgmerge.c                       |    6 +-
 tools/vgreduce.c                      |   58 ++++----
 tools/vgremove.c                      |    4 +-
 tools/vgrename.c                      |   14 +-
 tools/vgscan.c                        |    4 +-
 tools/vgsplit.c                       |   28 ++--
 125 files changed, 1791 insertions(+), 1791 deletions(-)
daemons/clvmd/clvmd-cman.c +4 -4
index dec6331..b047095 100644
@@ -157,7 +157,7 @@ static int _cluster_send_message(const void *buf, int msglen, const char *csid,
 
 	if (cman_send_data(c_handle, buf, msglen, 0, CLUSTER_PORT_CLVMD, nodeid) <= 0)
 	{
-		log_error("%s", errtext);
+		log_error(0, "%s", errtext);
 	}
 	return msglen;
 }
@@ -310,7 +310,7 @@ static void get_members()
 
 	num_nodes = cman_get_node_count(c_handle);
 	if (num_nodes == -1) {
-		log_error("Unable to get node count");
+		log_error(0, "Unable to get node count");
 		return;
 	}
 
@@ -324,14 +324,14 @@ static void get_members()
 		count_nodes = num_nodes + 10; /* Overallocate a little */
 		nodes = malloc(count_nodes * sizeof(struct cman_node));
 		if (!nodes) {
-			log_error("Unable to allocate nodes array\n");
+			log_error(0, "Unable to allocate nodes array\n");
 			exit(5);
 		}
 	}
 
 	status = cman_get_nodes(c_handle, count_nodes, &retnodes, nodes);
 	if (status < 0) {
-		log_error("Unable to get node details");
+		log_error(0, "Unable to get node details");
 		exit(6);
 	}
 
daemons/clvmd/clvmd-command.c +1 -1
index 2266a2b..0b8aede 100644
@@ -291,7 +291,7 @@ int do_pre_command(struct local_client *client)
 		break;
 
 	default:
-		log_error("Unknown command %d received\n", header->cmd);
+		log_error(0, "Unknown command %d received\n", header->cmd);
 		status = EINVAL;
 	}
 	return status;
daemons/clvmd/clvmd-gulm.c +2 -2
index 4bb1b65..3d75733 100644
@@ -897,7 +897,7 @@ static int get_all_cluster_nodes()
     ctree = ccs_force_connect(NULL, 1);
     if (ctree < 0)
     {
-	log_error("Error connecting to CCS");
+	log_error(0, "Error connecting to CCS");
 	return -1;
     }
 
@@ -950,7 +950,7 @@ static int get_all_cluster_nodes()
 		}
 		else {
 			DEBUGLOG("Cannot resolve host name %s\n", nodename);
-			log_err("Cannot resolve host name %s\n", nodename);
+			log_error(0, "Cannot resolve host name %s\n", nodename);
 		}
 	}
 	free(nodename);
daemons/clvmd/clvmd.c +13 -13
index b6c4034..a07242a 100644
@@ -429,7 +429,7 @@ int main(int argc, char *argv[])
 
 	if (!clops) {
 		DEBUGLOG("Can't initialise cluster interface\n");
-		log_error("Can't initialise cluster interface\n");
+		log_error(0, "Can't initialise cluster interface\n");
 		child_init_signal(DFAIL_CLUSTER_IF);
 	}
 	DEBUGLOG("Cluster ready, doing some more initialisation\n");
@@ -915,11 +915,11 @@ static void be_daemon(int timeout)
 	if (dup2(devnull, 0) < 0 || dup2(devnull, 1) < 0
 	    || dup2(devnull, 2) < 0) {
 		perror("Error setting terminal FDs to /dev/null");
-		log_error("Error setting terminal FDs to /dev/null: %m");
+		log_error(0, "Error setting terminal FDs to /dev/null: %m");
 		exit(5);
 	}
 	if (chdir("/")) {
-		log_error("Error setting current directory to /: %m");
+		log_error(0, "Error setting current directory to /: %m");
 		exit(6);
 	}
 
@@ -1280,7 +1280,7 @@ static void process_remote_command(struct clvm_header *msg, int msglen, int fd,
 	if (msg->cmd == CLVMD_CMD_GOAWAY) {
 
 		DEBUGLOG("Told to go away by %s\n", nodename);
-		log_error("Told to go away by %s\n", nodename);
+		log_error(0, "Told to go away by %s\n", nodename);
 		exit(99);
 	}
 
@@ -1482,7 +1482,7 @@ static __attribute__ ((noreturn)) void *pre_and_post_thread(void *arg)
 			if (write_status < 0 &&
 			    (errno == EINTR || errno == EAGAIN))
 				continue;
-			log_error("Error sending to pipe: %m\n");
+			log_error(0, "Error sending to pipe: %m\n");
 			break;
 		} while(1);
 
@@ -1515,7 +1515,7 @@ static __attribute__ ((noreturn)) void *pre_and_post_thread(void *arg)
 			if (write_status < 0 &&
 			    (errno == EINTR || errno == EAGAIN))
 				continue;
-			log_error("Error sending to pipe: %m\n");
+			log_error(0, "Error sending to pipe: %m\n");
 			break;
 		} while(1);
 next_pre:
@@ -1577,7 +1577,7 @@ static int process_reply(const struct clvm_header *msg, int msglen, const char *
 	if (!client) {
 		DEBUGLOG("Got message for unknown client 0x%x\n",
 			 msg->clientid);
-		log_error("Got message for unknown client 0x%x\n",
+		log_error(0, "Got message for unknown client 0x%x\n",
 			  msg->clientid);
 		return -1;
 	}
@@ -1739,7 +1739,7 @@ static int send_message(void *buf, int msglen, const char *csid, int fd,
 			if (retry_cnt > MAX_RETRIES)
 			{
 				errno = saved_errno;
-				log_error("%s", errtext);
+				log_error(0, "%s", errtext);
 				errno = saved_errno;
 				break;
 			}
@@ -1763,7 +1763,7 @@ static int send_message(void *buf, int msglen, const char *csid, int fd,
 
 					continue;
 				}
-				log_error("%s", errtext);
+				log_error(0, "%s", errtext);
 				break;
 			}
 			ptr += len;
@@ -1856,7 +1856,7 @@ static int add_to_lvmqueue(struct local_client *client, struct clvm_header *msg,
 	if (msglen) {
 		cmd->msg = malloc(msglen);
 		if (!cmd->msg) {
-			log_error("Unable to allocate buffer space\n");
+			log_error(0, "Unable to allocate buffer space\n");
 			free(cmd);
 			return -1;
 		}
@@ -1924,7 +1924,7 @@ static int open_local_sock()
 		unlink(CLVMD_SOCKNAME);
 	local_socket = socket(PF_UNIX, SOCK_STREAM, 0);
 	if (local_socket < 0) {
-		log_error("Can't create local socket: %m");
+		log_error(0, "Can't create local socket: %m");
 		return -1;
 	}
 	/* Set Close-on-exec & non-blocking */
@@ -1935,12 +1935,12 @@ static int open_local_sock()
 	memcpy(sockaddr.sun_path, CLVMD_SOCKNAME, sizeof(CLVMD_SOCKNAME));
 	sockaddr.sun_family = AF_UNIX;
 	if (bind(local_socket, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
-		log_error("can't bind local socket: %m");
+		log_error(0, "can't bind local socket: %m");
 		close(local_socket);
 		return -1;
 	}
 	if (listen(local_socket, 1) != 0) {
-		log_error("listen local: %m");
+		log_error(0, "listen local: %m");
 		close(local_socket);
 		return -1;
 	}
daemons/clvmd/lvm-functions.c +4 -4
index ab90ea6..d29d390 100644
@@ -467,7 +467,7 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
 	if (!cmd->config_valid || config_files_changed(cmd)) {
 		/* Reinitialise various settings inc. logging, filters */
 		if (do_refresh_cache()) {
-			log_error("Updated config file invalid. Aborting.");
+			log_error(0, "Updated config file invalid. Aborting.");
 			return EINVAL;
 		}
 	}
@@ -755,10 +755,10 @@ static void check_config()
 		if (strstr(libname, "liblvm2clusterlock.so"))
 			return;
 
-		log_error("Incorrect LVM locking library specified in lvm.conf, cluster operations may not work.");
+		log_error(0, "Incorrect LVM locking library specified in lvm.conf, cluster operations may not work.");
 		return;
 	}
-	log_error("locking_type not set correctly in lvm.conf, cluster operations will not work.");
+	log_error(0, "locking_type not set correctly in lvm.conf, cluster operations will not work.");
 }
 
 /* Backups up the LVM metadata if it's changed */
@@ -776,7 +776,7 @@ void lvm_do_backup(const char *vgname)
 	if (vg && consistent)
 		check_current_backup(vg);
 	else
-		log_error("Error backing up metadata, can't find VG for group %s", vgname);
+		log_error(0, "Error backing up metadata, can't find VG for group %s", vgname);
 
 	vg_release(vg);
 	dm_pool_empty(cmd->mem);
daemons/dmeventd/libdevmapper-event.c +25 -25

190 lines not on this page · raw message

lib/activate/activate.c +13 -13
index aa75e5b..80df249 100644
@@ -41,7 +41,7 @@ int lvm1_present(struct cmd_context *cmd)
 
 	if (dm_snprintf(path, sizeof(path), "%s/lvm/global", cmd->proc_dir)
 	    < 0) {
-		log_error("LVM1 proc global snprintf failed");
+		log_error(0, "LVM1 proc global snprintf failed");
 		return 0;
 	}
 
@@ -60,7 +60,7 @@ int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
 
 	if (seg->segtype->ops->modules_needed &&
 	    !seg->segtype->ops->modules_needed(mem, seg, modules)) {
-		log_error("module string allocation failed");
+		log_error(0, "module string allocation failed");
 		return 0;
 	}
 
@@ -78,7 +78,7 @@ int list_segment_modules(struct dm_pool *mem, const struct lv_segment *seg,
 		if (snap_seg->segtype->ops->modules_needed &&
 		    !snap_seg->segtype->ops->modules_needed(mem, snap_seg,
 							    modules)) {
-			log_error("snap_seg module string allocation failed");
+			log_error(0, "snap_seg module string allocation failed");
 			return 0;
 		}
 	}
@@ -119,7 +119,7 @@ void set_activation(int act)
 	if (warned || !act)
 		return;
 
-	log_error("Compiled without libdevmapper support. "
+	log_error(0, "Compiled without libdevmapper support. "
 		  "Can't enable activation.");
 
 	warned = 1;
@@ -279,13 +279,13 @@ static int _passes_activation_filter(struct cmd_context *cmd,
 
 	for (cv = cn->v; cv; cv = cv->next) {
 		if (cv->type != CFG_STRING) {
-			log_error("Ignoring invalid string in config file "
+			log_error(0, "Ignoring invalid string in config file "
 				  "activation/volume_list");
 			continue;
 		}
 		str = cv->v.str;
 		if (!*str) {
-			log_error("Ignoring empty string in config file "
+			log_error(0, "Ignoring empty string in config file "
 				  "activation/volume_list");
 			continue;
 		}
@@ -294,7 +294,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,
 		if (*str == '@') {
 			str++;
 			if (!*str) {
-				log_error("Ignoring empty tag in config file "
+				log_error(0, "Ignoring empty tag in config file "
 					  "activation/volume_list");
 				continue;
 			}
@@ -324,7 +324,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,
 		/* vgname/lvname */
 		if (dm_snprintf(path, sizeof(path), "%s/%s", lv->vg->name,
 				 lv->name) < 0) {
-			log_error("dm_snprintf error from %s/%s", lv->vg->name,
+			log_error(0, "dm_snprintf error from %s/%s", lv->vg->name,
 				  lv->name);
 			continue;
 		}
@@ -400,7 +400,7 @@ int module_present(struct cmd_context *cmd, const char *target_name)
 	const char *argv[3];
 
 	if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
-		log_error("module_present module name too long: %s",
+		log_error(0, "module_present module name too long: %s",
 			  target_name);
 		return 0;
 	}
@@ -771,7 +771,7 @@ int monitor_dev_for_events(struct cmd_context *cmd,
 				continue;
 			if (!monitor_dev_for_events(cmd, seg_lv(seg, s),
 						    monitor)) {
-				log_error("Failed to %smonitor %s",
+				log_error(0, "Failed to %smonitor %s",
 					  monitor ? "" : "un",
 					  seg_lv(seg, s)->name);
 				r = 0;
@@ -814,7 +814,7 @@ int monitor_dev_for_events(struct cmd_context *cmd,
 
 		/* FIXME specify events */
 		if (!monitor_fn(seg, 0)) {
-			log_error("%s/%s: %s segment monitoring function failed.",
+			log_error(0, "%s/%s: %s segment monitoring function failed.",
 				  lv->vg->name, lv->name, seg->segtype->name);
 			return 0;
 		}
@@ -1002,7 +1002,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
 	}
 
 	if (info.open_count && lv_is_visible(lv)) {
-		log_error("LV %s/%s in use: not deactivating", lv->vg->name,
+		log_error(0, "LV %s/%s in use: not deactivating", lv->vg->name,
 			  lv->name);
 		goto out;
 	}
@@ -1073,7 +1073,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
 	}
 
 	if ((!lv->vg->cmd->partial_activation) && (lv->status & PARTIAL_LV)) {
-		log_error("Refusing activation of partial LV %s. Use --partial to override.",
+		log_error(0, "Refusing activation of partial LV %s. Use --partial to override.",
 			  lv->name);
 		goto_out;
 	}
lib/activate/dev_manager.c +32 -32

249 lines not on this page · raw message

lib/activate/fs.c +12 -12
index 6b83581..8b65935 100644
@@ -32,7 +32,7 @@ static int _mk_dir(const char *dev_dir, const char *vg_name)
 
 	if (dm_snprintf(vg_path, sizeof(vg_path), "%s%s",
 			 dev_dir, vg_name) == -1) {
-		log_error("Couldn't construct name of volume "
+		log_error(0, "Couldn't construct name of volume "
 			  "group directory.");
 		return 0;
 	}
@@ -55,7 +55,7 @@ static int _rm_dir(const char *dev_dir, const char *vg_name)
 
 	if (dm_snprintf(vg_path, sizeof(vg_path), "%s%s",
 			 dev_dir, vg_name) == -1) {
-		log_error("Couldn't construct name of volume "
+		log_error(0, "Couldn't construct name of volume "
 			  "group directory.");
 		return 0;
 	}
@@ -88,7 +88,7 @@ static void _rm_blks(const char *dir)
 			continue;
 
 		if (dm_snprintf(path, sizeof(path), "%s/%s", dir, name) == -1) {
-			log_error("Couldn't create path for %s", name);
+			log_error(0, "Couldn't create path for %s", name);
 			continue;
 		}
 
@@ -111,28 +111,28 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
 
 	if (dm_snprintf(vg_path, sizeof(vg_path), "%s%s",
 			 dev_dir, vg_name) == -1) {
-		log_error("Couldn't create path for volume group dir %s",
+		log_error(0, "Couldn't create path for volume group dir %s",
 			  vg_name);
 		return 0;
 	}
 
 	if (dm_snprintf(lv_path, sizeof(lv_path), "%s/%s", vg_path,
 			 lv_name) == -1) {
-		log_error("Couldn't create source pathname for "
+		log_error(0, "Couldn't create source pathname for "
 			  "logical volume link %s", lv_name);
 		return 0;
 	}
 
 	if (dm_snprintf(link_path, sizeof(link_path), "%s/%s",
 			 dm_dir(), dev) == -1) {
-		log_error("Couldn't create destination pathname for "
+		log_error(0, "Couldn't create destination pathname for "
 			  "logical volume link for %s", lv_name);
 		return 0;
 	}
 
 	if (dm_snprintf(lvm1_group_path, sizeof(lvm1_group_path), "%s/group",
 			 vg_path) == -1) {
-		log_error("Couldn't create pathname for LVM1 group file for %s",
+		log_error(0, "Couldn't create pathname for LVM1 group file for %s",
 			  vg_name);
 		return 0;
 	}
@@ -143,7 +143,7 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
 	 * (as well as any existing LVM2 symlink). */
 	if (!lstat(lvm1_group_path, &buf)) {
 		if (!S_ISCHR(buf.st_mode)) {
-			log_error("Non-LVM1 character device found at %s",
+			log_error(0, "Non-LVM1 character device found at %s",
 				  lvm1_group_path);
 		} else {
 			_rm_blks(vg_path);
@@ -156,7 +156,7 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
 
 	if (!lstat(lv_path, &buf)) {
 		if (!S_ISLNK(buf.st_mode) && !S_ISBLK(buf.st_mode)) {
-			log_error("Symbolic link %s not created: file exists",
+			log_error(0, "Symbolic link %s not created: file exists",
 				  link_path);
 			return 0;
 		}
@@ -190,14 +190,14 @@ static int _rm_link(const char *dev_dir, const char *vg_name,
 
 	if (dm_snprintf(lv_path, sizeof(lv_path), "%s%s/%s",
 			 dev_dir, vg_name, lv_name) == -1) {
-		log_error("Couldn't determine link pathname.");
+		log_error(0, "Couldn't determine link pathname.");
 		return 0;
 	}
 
 	if (lstat(lv_path, &buf) || !S_ISLNK(buf.st_mode)) {
 		if (errno == ENOENT)
 			return 1;
-		log_error("%s not symbolic link - not removing", lv_path);
+		log_error(0, "%s not symbolic link - not removing", lv_path);
 		return 0;
 	}
 
@@ -273,7 +273,7 @@ static int _stack_fs_op(fs_op_t type, const char *dev_dir, const char *vg_name,
 	char *pos;
 
 	if (!(fsp = dm_malloc(sizeof(*fsp) + len))) {
-		log_error("No space to stack fs operation");
+		log_error(0, "No space to stack fs operation");
 		return 0;
 	}
 
lib/cache/lvmcache.c +35 -35

270 lines not on this page · raw message

lib/commands/toolcontext.c +43 -43

328 lines not on this page · raw message

lib/config/config.c +19 -19
index 224f2ce..fb120eb 100644
@@ -90,7 +90,7 @@ static const int sep = '/';
 
 #define match(t) do {\
    if (!_match_aux(p, (t))) {\
-	log_error("Parse error at byte %" PRIptrdiff_t " (line %d): unexpected token", \
+	log_error(0, "Parse error at byte %" PRIptrdiff_t " (line %d): unexpected token", \
 		  p->tb - p->fb + 1, p->line); \
       return 0;\
    } \
@@ -115,12 +115,12 @@ struct config_tree *create_config_tree(const char *filename, int keep_open)
 	struct dm_pool *mem = dm_pool_create("config", 10 * 1024);
 
 	if (!mem) {
-		log_error("Failed to allocate config pool.");
+		log_error(0, "Failed to allocate config pool.");
 		return 0;
 	}
 
 	if (!(c = dm_pool_zalloc(mem, sizeof(*c)))) {
-		log_error("Failed to allocate config tree.");
+		log_error(0, "Failed to allocate config tree.");
 		dm_pool_destroy(mem);
 		return 0;
 	}
@@ -169,7 +169,7 @@ struct config_tree *create_config_tree_from_string(struct cmd_context *cmd __att
 
 	c = (struct cs *) cft;
 	if (!(p = dm_pool_alloc(c->mem, sizeof(*p)))) {
-		log_error("Failed to allocate config tree parser.");
+		log_error(0, "Failed to allocate config tree parser.");
 		destroy_config_tree(cft);
 		return NULL;
 	}
@@ -228,7 +228,7 @@ int read_config_fd(struct config_tree *cft, struct device *dev,
 	if (checksum_fn && checksum !=
 	    (checksum_fn(checksum_fn(INITIAL_CRC, p->fb, size),
 			 p->fb + size, size2))) {
-		log_error("%s: Checksum error", dev_name(dev));
+		log_error(0, "%s: Checksum error", dev_name(dev));
 		goto out;
 	}
 
@@ -266,7 +266,7 @@ int read_config_file(struct config_tree *cft)
 	}
 
 	if (!S_ISREG(info.st_mode)) {
-		log_error("%s is not a regular file", c->filename);
+		log_error(0, "%s is not a regular file", c->filename);
 		c->exists = 0;
 		return 0;
 	}
@@ -327,12 +327,12 @@ int config_file_changed(struct config_tree *cft)
 			goto reload;
 		}
 		log_sys_error("stat", c->filename);
-		log_error("Failed to reload configuration files");
+		log_error(0, "Failed to reload configuration files");
 		return 0;
 	}
 
 	if (!S_ISREG(info.st_mode)) {
-		log_error("Configuration file %s is not a regular file",
+		log_error(0, "Configuration file %s is not a regular file",
 			  c->filename);
 		goto reload;
 	}
@@ -349,7 +349,7 @@ int config_file_changed(struct config_tree *cft)
 static int _line_start(struct output_line *outline)
 {
 	if (!dm_pool_begin_object(outline->mem, 128)) {
-		log_error("dm_pool_begin_object failed for config line");
+		log_error(0, "dm_pool_begin_object failed for config line");
 		return 0;
 	}
 
@@ -367,13 +367,13 @@ static int _line_append(struct output_line *outline, const char *fmt, ...)
 	va_start(ap, fmt);
 	n = vsnprintf(&buf[0], sizeof buf - 1, fmt, ap);
 	if (n < 0 || n > (int) sizeof buf - 1) {
-		log_error("vsnprintf failed for config line");
+		log_error(0, "vsnprintf failed for config line");
 		return 0;
 	}
 	va_end(ap);
 
 	if (!dm_pool_grow_object(outline->mem, &buf[0], strlen(buf))) {
-		log_error("dm_pool_grow_object failed for config line");
+		log_error(0, "dm_pool_grow_object failed for config line");
 		return 0;
 	}
 
@@ -387,7 +387,7 @@ static int _line_end(struct output_line *outline)
 	const char *line;
 
 	if (!dm_pool_grow_object(outline->mem, "\0", 1)) {
-		log_error("dm_pool_grow_object failed for config line");
+		log_error(0, "dm_pool_grow_object failed for config line");
 		return 0;
 	}
 
@@ -407,7 +407,7 @@ static int _write_value(struct output_line *outline, struct config_value *v)
 	switch (v->type) {
 	case CFG_STRING:
 		if (!(buf = alloca(escaped_len(v->v.str)))) {
-			log_error("temporary stack allocation for a config "
+			log_error(0, "temporary stack allocation for a config "
 				  "string failed");
 			return 0;
 		}
@@ -427,7 +427,7 @@ static int _write_value(struct output_line *outline, struct config_value *v)
 		break;
 
 	default:
-		log_error("_write_value: Unknown value type: %d", v->type);
+		log_error(0, "_write_value: Unknown value type: %d", v->type);
 
 	}
 
@@ -507,17 +507,17 @@ int write_config_file(struct config_tree *cft, const char *file,
 	log_verbose("Dumping configuration to %s", file);
 	if (!argc) {
 		if (!_write_config(cft->root, 0, &outline, 0)) {
-			log_error("Failure while writing to %s", file);
+			log_error(0, "Failure while writing to %s", file);
 			r = 0;
 		}
 	} else while (argc--) {
 		if ((cn = find_config_node(cft->root, *argv))) {
 			if (!_write_config(cn, 1, &outline, 0)) {
-				log_error("Failure while writing to %s", file);
+				log_error(0, "Failure while writing to %s", file);
 				r = 0;
 			}
 		} else {
-			log_error("Configuration node %s not found", *argv);
+			log_error(0, "Configuration node %s not found", *argv);
 			r = 0;
 		}
 		argv++;
@@ -664,7 +664,7 @@ static struct config_value *_type(struct parser *p)
 		break;
 
 	default:
-		log_error("Parse error at byte %" PRIptrdiff_t " (line %d): expected a value",
+		log_error(0, "Parse error at byte %" PRIptrdiff_t " (line %d): expected a value",
 			  p->tb - p->fb + 1, p->line);
 		return 0;
 	}
@@ -876,7 +876,7 @@ static struct config_node *_find_config_node(const struct config_node *cn,
 				if (!cn_found)
 					cn_found = cn;
 				else
-					log_error("WARNING: Ignoring duplicate"
+					log_error(0, "WARNING: Ignoring duplicate"
 						  " config node: %s ("
 						  "seeking %s)", cn->key, path);
 			}
lib/device/dev-cache.c +25 -25

180 lines not on this page · raw message

lib/device/dev-io.c +11 -11
index 06675e2..c5bd56d 100644
@@ -64,7 +64,7 @@ static int _io(struct device_area *where, void *buffer, int should_write)
 	size_t total = 0;
 
 	if (fd < 0) {
-		log_error("Attempt to read an unopened device (%s).",
+		log_error(0, "Attempt to read an unopened device (%s).",
 			  dev_name(where->dev));
 		return 0;
 	}
@@ -76,12 +76,12 @@ static int _io(struct device_area *where, void *buffer, int should_write)
 		return 1;
 
 	if (where->size > SSIZE_MAX) {
-		log_error("Read size too large: %" PRIu64, where->size);
+		log_error(0, "Read size too large: %" PRIu64, where->size);
 		return 0;
 	}
 
 	if (lseek(fd, (off_t) where->start, SEEK_SET) < 0) {
-		log_error("%s: lseek %" PRIu64 " failed: %s",
+		log_error(0, "%s: lseek %" PRIu64 " failed: %s",
 			  dev_name(where->dev), (uint64_t) where->start,
 			  strerror(errno));
 		return 0;
@@ -95,7 +95,7 @@ static int _io(struct device_area *where, void *buffer, int should_write)
 		while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN)));
 
 		if (n < 0)
-			log_error("%s: %s failed after %" PRIu64 " of %" PRIu64
+			log_error(0, "%s: %s failed after %" PRIu64 " of %" PRIu64
 				  "@%" PRIu64 ": %s", dev_name(where->dev),
 				  should_write ? "write" : "read",
 				  (uint64_t) total,
@@ -186,7 +186,7 @@ static int _aligned_io(struct device_area *where, void *buffer,
 
 	/* Allocate a bounce buffer with an extra block */
 	if (!(bounce = alloca((size_t) widened.size + block_size))) {
-		log_error("Bounce buffer alloca failed");
+		log_error(0, "Bounce buffer alloca failed");
 		return 0;
 	}
 
@@ -392,7 +392,7 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
 	}
 
 	if (memlock())
-		log_error("WARNING: dev_open(%s) called while suspended",
+		log_error(0, "WARNING: dev_open(%s) called while suspended",
 			  dev_name(dev));
 
 	if (dev->flags & DEV_REGULAR)
@@ -406,7 +406,7 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
 			return 0;
 		}
 		if (buf.st_rdev != dev->dev) {
-			log_error("%s: device changed", name);
+			log_error(0, "%s: device changed", name);
 			return 0;
 		}
 	}
@@ -465,7 +465,7 @@ int dev_open_flags(struct device *dev, int flags, int direct, int quiet)
 
 	if (!(dev->flags & DEV_REGULAR) &&
 	    ((fstat(dev->fd, &buf) < 0) || (buf.st_rdev != dev->dev))) {
-		log_error("%s: fstat failed: Has device name changed?", name);
+		log_error(0, "%s: fstat failed: Has device name changed?", name);
 		dev_close_immediate(dev);
 		return 0;
 	}
@@ -544,7 +544,7 @@ static int _dev_close(struct device *dev, int immediate)
 	struct lvmcache_info *info;
 
 	if (dev->fd < 0) {
-		log_error("Attempt to close device '%s' "
+		log_error(0, "Attempt to close device '%s' "
 			  "which is not open.", dev_name(dev));
 		return 0;
 	}
@@ -617,7 +617,7 @@ int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
 		      uint64_t offset2, size_t len2, void *buf)
 {
 	if (!dev_read(dev, offset, len, buf)) {
-		log_error("Read from %s failed", dev_name(dev));
+		log_error(0, "Read from %s failed", dev_name(dev));
 		return 0;
 	}
 
@@ -629,7 +629,7 @@ int dev_read_circular(struct device *dev, uint64_t offset, size_t len,
 		return 1;
 
 	if (!dev_read(dev, offset2, len2, buf + len)) {
-		log_error("Circular read from %s failed",
+		log_error(0, "Circular read from %s failed",
 			  dev_name(dev));
 		return 0;
 	}
lib/device/dev-md.c +4 -4
index 618509d..31a1e5b 100644
@@ -142,7 +142,7 @@ static int _md_sysfs_attribute_snprintf(char *path, size_t size,
 	ret = dm_snprintf(path, size, "%s/dev/block/%d:%d/md/%s",
 	      sysfs_dir, MAJOR(dev->dev), MINOR(dev->dev), attribute);
 	if (ret < 0) {
-		log_error("dm_snprintf md %s failed", attribute);
+		log_error(0, "dm_snprintf md %s failed", attribute);
 		return ret;
 	}
 
@@ -151,7 +151,7 @@ static int _md_sysfs_attribute_snprintf(char *path, size_t size,
 		ret = dm_snprintf(path, size, "%s/block/md%d/md/%s",
 				  sysfs_dir, MINOR(dev->dev), attribute);
 		if (ret < 0) {
-			log_error("dm_snprintf old md %s failed", attribute);
+			log_error(0, "dm_snprintf old md %s failed", attribute);
 			return ret;
 		}
 	}
@@ -184,7 +184,7 @@ static int _md_sysfs_attribute_scanf(const char *sysfs_dir,
 	}
 
 	if ((ret = sscanf(buffer, attribute_fmt, attribute_value)) != 1) {
-		log_error("%s sysfs attr %s not in expected format: %s",
+		log_error(0, "%s sysfs attr %s not in expected format: %s",
 			  dev_name(dev), attribute_name, buffer);
 		goto out;
 	}
@@ -293,7 +293,7 @@ unsigned long dev_md_stripe_width(const char *sysfs_dir, struct device *dev)
 		data_disks = raid_disks - 2;
 		break;
 	default:
-		log_error("Device %s has an unknown md raid level: %d",
+		log_error(0, "Device %s has an unknown md raid level: %d",
 			  dev_name(dev), level);
 		return 0;
 	}
lib/device/device.c +6 -6
index 9d3c1cf..8963f10 100644
@@ -155,13 +155,13 @@ int partition_type_is_lvm(struct dev_mgr *dm, struct device *d)
 	}
 
 	if (is_whole_disk(dm, d)) {
-		log_error("%s: looks to possess partition table", d->name);
+		log_error(0, "%s: looks to possess partition table", d->name);
 		return 0;
 	}
 
 	/* check part type */
 	if (pt != LVM_PARTITION && pt != LVM_NEW_PARTITION) {
-		log_error("%s: invalid partition type 0x%x "
+		log_error(0, "%s: invalid partition type 0x%x "
 			  "(must be 0x%x)", d->name, pt, LVM_NEW_PARTITION);
 		return 0;
 	}
@@ -201,13 +201,13 @@ int _get_partition_type(struct dev_mgr *dm, struct device *d)
 	}
 
 	if (!(buffer = dm_malloc(SECTOR_SIZE))) {
-		log_error("Failed to allocate partition table buffer");
+		log_error(0, "Failed to allocate partition table buffer");
 		return 0;
 	}
 
 	/* Get partition table */
 	if ((pv_handle = open(primary->name, O_RDONLY)) < 0) {
-		log_error("%s: open failed: %s", primary->name,
+		log_error(0, "%s: open failed: %s", primary->name,
 			  strerror(errno));
 		return 0;
 	}
@@ -220,7 +220,7 @@ int _get_partition_type(struct dev_mgr *dm, struct device *d)
 		bytes_read = 0;
 
 		if (llseek(pv_handle, offset * SECTOR_SIZE, SEEK_SET) == -1) {
-			log_error("%s: llseek failed: %s",
+			log_error(0, "%s: llseek failed: %s",
 				  primary->name, strerror(errno));
 			return 0;
 		}
@@ -232,7 +232,7 @@ int _get_partition_type(struct dev_mgr *dm, struct device *d)
 			bytes_read += read_ret;
 
 		if (read_ret == -1) {
-			log_error("%s: read failed: %s", primary->name,
+			log_error(0, "%s: read failed: %s", primary->name,
 				  strerror(errno));
 			return 0;
 		}
lib/display/display.c +2 -2
index 0de0a8e..a8269ff 100644
@@ -142,7 +142,7 @@ alloc_policy_t get_alloc_from_string(const char *str)
 	if(!strcmp("next free", str))
 		return ALLOC_NORMAL;
 
-	log_error("Unrecognised allocation policy %s", str);
+	log_error(0, "Unrecognised allocation policy %s", str);
 	return ALLOC_INVALID;
 }
 
@@ -170,7 +170,7 @@ static const char *_display_size(const struct cmd_context *cmd,
 	};
 
 	if (!(size_buf = dm_pool_alloc(cmd->mem, SIZE_BUF))) {
-		log_error("no memory for size display buffer");
+		log_error(0, "no memory for size display buffer");
 		return "";
 	}
 
lib/error/errseg.c +1 -1
index fa90a8e..21a87de 100644
@@ -74,7 +74,7 @@ static int _errseg_modules_needed(struct dm_pool *mem,
 				  struct dm_list *modules)
 {
 	if (!str_list_add(mem, modules, "error")) {
-		log_error("error module string list allocation failed");
+		log_error(0, "error module string list allocation failed");
 		return 0;
 	}
 
lib/filters/filter-composite.c +2 -2
index d1606d3..e89317b 100644
@@ -54,7 +54,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters)
 		return_NULL;
 
 	if (!(filters_copy = dm_malloc(sizeof(*filters) * (n + 1)))) {
-		log_error("composite filters allocation failed");
+		log_error(0, "composite filters allocation failed");
 		return NULL;
 	}
 
@@ -62,7 +62,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters)
 	filters_copy[n] = NULL;
 
 	if (!(cft = dm_malloc(sizeof(*cft)))) {
-		log_error("compsoite filters allocation failed");
+		log_error(0, "compsoite filters allocation failed");
 		dm_free(filters_copy);
 		return NULL;
 	}
lib/filters/filter-md.c +1 -1
index c1ecff7..f7cf8ab 100644
@@ -53,7 +53,7 @@ struct dev_filter *md_filter_create(void)
 	struct dev_filter *f;
 
 	if (!(f = dm_malloc(sizeof(*f)))) {
-		log_error("md filter allocation failed");
+		log_error(0, "md filter allocation failed");
 		return NULL;
 	}
 
lib/filters/filter-persistent.c +3 -3
index b545a55..49b846d 100644
@@ -162,7 +162,7 @@ static void _write_array(struct pfilter *pf, FILE *fp, const char *path,
 
 		str = dm_hash_get_key(pf->devices, n);
 		if (!(buf = alloca(escaped_len(str)))) {
-			log_error("persistent filter device path stack "
+			log_error(0, "persistent filter device path stack "
 				  "allocation failed");
 			return;
 		}
@@ -249,7 +249,7 @@ int persistent_filter_dump(struct dev_filter *f)
 		goto_out;
 
 	if (rename(tmp_file, pf->file))
-		log_error("%s: rename to %s failed: %s", tmp_file, pf->file,
+		log_error(0, "%s: rename to %s failed: %s", tmp_file, pf->file,
 			  strerror(errno));
 
 	r = 1;
@@ -310,7 +310,7 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real,
 	pf->real = real;
 
 	if (!(_init_hash(pf))) {
-		log_error("Couldn't create hash table for persistent filter.");
+		log_error(0, "Couldn't create hash table for persistent filter.");
 		goto bad;
 	}
 
lib/filters/filter-regex.c +2 -2
index 1d415a4..0257211 100644
@@ -103,7 +103,7 @@ static int _build_matcher(struct rfilter *rf, struct config_value *val)
 	 */
 	for (v = val; v; v = v->next) {
 		if (v->type != CFG_STRING) {
-			log_error("filter patterns must be enclosed in quotes");
+			log_error(0, "filter patterns must be enclosed in quotes");
 			goto out;
 		}
 
@@ -128,7 +128,7 @@ static int _build_matcher(struct rfilter *rf, struct config_value *val)
 	 */
 	for (v = val, i = count - 1; v; v = v->next, i--)
 		if (!_extract_pattern(scratch, v->v.str, regex, rf->accept, i)) {
-			log_error("invalid filter pattern");
+			log_error(0, "invalid filter pattern");
 			goto out;
 		}
 
lib/filters/filter-sysfs.c +5 -5
index 1220b3a..30b85cd 100644
@@ -164,7 +164,7 @@ static int _parse_dev(const char *file, FILE *fp, dev_t *result)
 	char buffer[64];
 
 	if (!fgets(buffer, sizeof(buffer), fp)) {
-		log_error("Empty sysfs device file: %s", file);
+		log_error(0, "Empty sysfs device file: %s", file);
 		return 0;
 	}
 
@@ -219,14 +219,14 @@ static int _read_devs(struct dev_set *ds, const char *dir, unsigned sysfs_depth)
 
 		if (dm_snprintf(path, sizeof(path), "%s/%s", dir,
 				 d->d_name) < 0) {
-			log_error("sysfs path name too long: %s in %s",
+			log_error(0, "sysfs path name too long: %s in %s",
 				  d->d_name, dir);
 			continue;
 		}
 
 		/* devices have a "dev" file */
 		if (dm_snprintf(file, sizeof(file), "%s/dev", path) < 0) {
-			log_error("sysfs path name too long: %s in %s",
+			log_error(0, "sysfs path name too long: %s in %s",
 				  d->d_name, dir);
 			continue;
 		}
@@ -302,12 +302,12 @@ struct dev_filter *sysfs_filter_create(const char *sysfs_dir)
 		return NULL;
 
 	if (!(mem = dm_pool_create("sysfs", 256))) {
-		log_error("sysfs pool creation failed");
+		log_error(0, "sysfs pool creation failed");
 		return NULL;
 	}
 
 	if (!(ds = _dev_set_create(mem, sys_block, sysfs_depth))) {
-		log_error("sysfs dev_set creation failed");
+		log_error(0, "sysfs dev_set creation failed");
 		goto bad;
 	}
 
lib/filters/filter.c +5 -5
index bc07cb6..8bd3f88 100644
@@ -160,7 +160,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
 
 	if (dm_snprintf(proc_devices, sizeof(proc_devices),
 			 "%s/devices", proc) < 0) {
-		log_error("Failed to create /proc/devices string");
+		log_error(0, "Failed to create /proc/devices string");
 		return 0;
 	}
 
@@ -219,7 +219,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
 		/* Check devices/types for local variations */
 		for (cv = cn->v; cv; cv = cv->next) {
 			if (cv->type != CFG_STRING) {
-				log_error("Expecting string in devices/types "
+				log_error(0, "Expecting string in devices/types "
 					  "in config file");
 				if (fclose(pd))
 					log_sys_error("fclose", proc_devices);
@@ -229,7 +229,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
 			name = cv->v.str;
 			cv = cv->next;
 			if (!cv || cv->type != CFG_INT) {
-				log_error("Max partition count missing for %s "
+				log_error(0, "Max partition count missing for %s "
 					  "in devices/types in config file",
 					  name);
 				if (fclose(pd))
@@ -237,7 +237,7 @@ static int _scan_proc_dev(const char *proc, const struct config_node *cn)
 				return 0;
 			}
 			if (!cv->v.i) {
-				log_error("Zero partition count invalid for "
+				log_error(0, "Zero partition count invalid for "
 					  "%s in devices/types in config file",
 					  name);
 				if (fclose(pd))
@@ -270,7 +270,7 @@ struct dev_filter *lvm_type_filter_create(const char *proc,
 	struct dev_filter *f;
 
 	if (!(f = dm_malloc(sizeof(struct dev_filter)))) {
-		log_error("LVM type filter allocation failed");
+		log_error(0, "LVM type filter allocation failed");
 		return NULL;
 	}
 
lib/format1/disk-rep.c +15 -15
index 24a1629..8329665 100644
@@ -369,7 +369,7 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
 	}
 
 	if (!read_vgd(dl->dev, &dl->vgd, &dl->pvd)) {
-		log_error("Failed to read VG data from PV (%s)", name);
+		log_error(0, "Failed to read VG data from PV (%s)", name);
 		__update_lvmcache(fmt, dl, dev, fmt->orphan_vg_name, 0);
 		goto bad;
 	}
@@ -385,17 +385,17 @@ static struct disk_list *__read_disk(const struct format_type *fmt,
 			  dl->vgd.vg_status & VG_EXPORTED);
 
 	if (!_read_uuids(dl)) {
-		log_error("Failed to read PV uuid list from %s", name);
+		log_error(0, "Failed to read PV uuid list from %s", name);
 		goto bad;
 	}
 
 	if (!_read_lvs(dl)) {
-		log_error("Failed to read LV's from %s", name);
+		log_error(0, "Failed to read LV's from %s", name);
 		goto bad;
 	}
 
 	if (!_read_extents(dl)) {
-		log_error("Failed to read extents from %s", name);
+		log_error(0, "Failed to read extents from %s", name);
 		goto bad;
 	}
 
@@ -487,7 +487,7 @@ int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
 	}
 
 	if (!(iter = dev_iter_create(filter, 1))) {
-		log_error("read_pvs_in_vg: dev_iter_create failed");
+		log_error(0, "read_pvs_in_vg: dev_iter_create failed");
 		return 0;
 	}
 
@@ -530,7 +530,7 @@ static int _write_uuids(struct disk_list *data)
 
 	dm_list_iterate_items(ul, &data->uuids) {
 		if (pos >= end) {
-			log_error("Too many uuids to fit on %s",
+			log_error(0, "Too many uuids to fit on %s",
 				  dev_name(data->dev));
 			return 0;
 		}
@@ -571,7 +571,7 @@ static int _write_lvs(struct disk_list *data)
 	pos = data->pvd.lv_on_disk.base;
 
 	if (!dev_set(data->dev, pos, data->pvd.lv_on_disk.size, 0)) {
-		log_error("Couldn't zero lv area on device '%s'",
+		log_error(0, "Couldn't zero lv area on device '%s'",
 			  dev_name(data->dev));
 		return 0;
 	}
@@ -579,7 +579,7 @@ static int _write_lvs(struct disk_list *data)
 	dm_list_iterate_items(ll, &data->lvds) {
 		offset = sizeof(struct lv_disk) * ll->lvd.lv_number;
 		if (offset + sizeof(struct lv_disk) > data->pvd.lv_on_disk.size) {
-			log_error("lv_number %d too large", ll->lvd.lv_number);
+			log_error(0, "lv_number %d too large", ll->lvd.lv_number);
 			return 0;
 		}
 
@@ -616,7 +616,7 @@ static int _write_pvd(struct disk_list *data)
 	size_t size = data->pvd.pv_on_disk.size;
 
 	if (size < sizeof(struct pv_disk)) {
-		log_error("Invalid PV structure size.");
+		log_error(0, "Invalid PV structure size.");
 		return 0;
 	}
 
@@ -625,7 +625,7 @@ static int _write_pvd(struct disk_list *data)
 	   happy (idea from AED) */
 	buf = dm_malloc(size);
 	if (!buf) {
-		log_err("Couldn't allocate temporary PV buffer.");
+		log_error(0, "Couldn't allocate temporary PV buffer.");
 		return 0;
 	}
 
@@ -655,7 +655,7 @@ static int __write_all_pvd(const struct format_type *fmt __attribute((unused)),
 	const char *pv_name = dev_name(data->dev);
 
 	if (!_write_pvd(data)) {
-		log_error("Failed to write PV structure onto %s", pv_name);
+		log_error(0, "Failed to write PV structure onto %s", pv_name);
 		return 0;
 	}
 
@@ -674,22 +674,22 @@ static int __write_all_pvd(const struct format_type *fmt __attribute((unused)),
 	   fmt); */
 
 	if (!_write_vgd(data)) {
-		log_error("Failed to write VG data to %s", pv_name);
+		log_error(0, "Failed to write VG data to %s", pv_name);
 		return 0;
 	}
 
 	if (!_write_uuids(data)) {
-		log_error("Failed to write PV uuid list to %s", pv_name);
+		log_error(0, "Failed to write PV uuid list to %s", pv_name);
 		return 0;
 	}
 
 	if (!_write_lvs(data)) {
-		log_error("Failed to write LV's to %s", pv_name);
+		log_error(0, "Failed to write LV's to %s", pv_name);
 		return 0;
 	}
 
 	if (!_write_extents(data)) {
-		log_error("Failed to write extents to %s", pv_name);
+		log_error(0, "Failed to write extents to %s", pv_name);
 		return 0;
 	}
 
lib/format1/format1.c +11 -11
index c8f9519..b7a181d 100644
@@ -64,7 +64,7 @@ static int _check_vgs(struct dm_list *pvs)
 			first = dl;
 
 		else if (memcmp(&first->vgd, &dl->vgd, sizeof(first->vgd))) {
-			log_error("VG data differs between PVs %s and %s",
+			log_error(0, "VG data differs between PVs %s and %s",
 				  dev_name(first->dev), dev_name(dl->dev));
 			log_debug("VG data on %s: %s %s %" PRIu32 " %" PRIu32
 				  "  %" PRIu32 " %" PRIu32 " %" PRIu32 " %"
@@ -103,7 +103,7 @@ static int _check_vgs(struct dm_list *pvs)
 
 	/* On entry to fn, list known to be non-empty */
 	if (pv_count != first->vgd.pv_cur) {
-		log_error("%d PV(s) found for VG %s: expected %d",
+		log_error(0, "%d PV(s) found for VG %s: expected %d",
 			  pv_count, first->pvd.vg_name, first->vgd.pv_cur);
 	}
 
@@ -303,7 +303,7 @@ static int _format1_pv_setup(const struct format_type *fmt,
 	if (pv->size > MAX_PV_SIZE)
 		pv->size--;
 	if (pv->size > MAX_PV_SIZE) {
-		log_error("Physical volumes cannot be bigger than %s",
+		log_error(0, "Physical volumes cannot be bigger than %s",
 			  display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE));
 		return 0;
 	}
@@ -321,7 +321,7 @@ static int _format1_pv_setup(const struct format_type *fmt,
 	/* Retain existing extent locations exactly */
 	if (((pe_start || extent_count) && (pe_start != pv->pe_start)) ||
 	    (extent_count && (extent_count != pv->pe_count))) {
-		log_error("Metadata would overwrite physical extents");
+		log_error(0, "Metadata would overwrite physical extents");
 		return 0;
 	}
 
@@ -336,12 +336,12 @@ static int _format1_lv_setup(struct format_instance *fid, struct logical_volume
 		lvid_from_lvnum(&lv->lvid, &lv->vg->id, find_free_lvnum(lv));
 
 	if (lv->le_count > MAX_LE_TOTAL) {
-		log_error("logical volumes cannot contain more than "
+		log_error(0, "logical volumes cannot contain more than "
 			  "%d extents.", MAX_LE_TOTAL);
 		return 0;
 	}
 	if (lv->size > max_size) {
-		log_error("logical volumes cannot be larger than %s",
+		log_error(0, "logical volumes cannot be larger than %s",
 			  display_size(fid->fmt->cmd, max_size));
 		return 0;
 	}
@@ -413,7 +413,7 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
 		vg->max_pv = MAX_PV - 1;
 
 	if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
-		log_error("Extent size must be between %s and %s",
+		log_error(0, "Extent size must be between %s and %s",
 			  display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE),
 			  display_size(fid->fmt->cmd, (uint64_t) MAX_PE_SIZE));
 
@@ -421,14 +421,14 @@ static int _format1_vg_setup(struct format_instance *fid, struct volume_group *v
 	}
 
 	if (vg->extent_size % MIN_PE_SIZE) {
-		log_error("Extent size must be multiple of %s",
+		log_error(0, "Extent size must be multiple of %s",
 			  display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE));
 		return 0;
 	}
 
 	/* Redundant? */
 	if (vg->extent_size & (vg->extent_size - 1)) {
-		log_error("Extent size must be power of 2");
+		log_error(0, "Extent size must be power of 2");
 		return 0;
 	}
 
@@ -520,12 +520,12 @@ struct format_type *init_format(struct cmd_context *cmd)
 	fmt->private = NULL;
 
 	if (!(fmt->labeller = lvm1_labeller_create(fmt))) {
-		log_error("Couldn't create lvm1 label handler.");
+		log_error(0, "Couldn't create lvm1 label handler.");
 		return NULL;
 	}
 
 	if (!(label_register_handler(FMT_LVM1_NAME, fmt->labeller))) {
-		log_error("Couldn't register lvm1 label handler.");
+		log_error(0, "Couldn't register lvm1 label handler.");
 		return NULL;
 	}
 
lib/format1/import-export.c +11 -11
index c0a89c5..79ee87a 100644
@@ -64,7 +64,7 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
 	if (!*pvd->vg_name)
 		pv->vg_name = fmt->orphan_vg_name;
 	else if (!(pv->vg_name = dm_pool_strdup(mem, (char *)pvd->vg_name))) {
-		log_error("Volume Group name allocation failed.");
+		log_error(0, "Volume Group name allocation failed.");
 		return 0;
 	}
 
@@ -100,7 +100,7 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
 	/* Fix up pv size if missing or impossibly large */
 	if (!pv->size || pv->size > (1ULL << 62)) {
 		if (!dev_get_size(dev, &pv->size)) {
-			log_error("%s: Couldn't get size.", pv_dev_name(pv));
+			log_error(0, "%s: Couldn't get size.", pv_dev_name(pv));
 			return 0;
 		}
 		log_verbose("Fixing up missing format1 size (%s) "
@@ -110,7 +110,7 @@ int import_pv(const struct format_type *fmt, struct dm_pool *mem,
 			size = pv->pe_count * (uint64_t) vg->extent_size +
 			       pv->pe_start;
 			if (size > pv->size)
-				log_error("WARNING: Physical Volume %s is too "
+				log_error(0, "WARNING: Physical Volume %s is too "
 					  "large for underlying device",
 					  pv_dev_name(pv));
 		}
@@ -130,7 +130,7 @@ static int _system_id(struct cmd_context *cmd, char *s, const char *prefix)
 
 	if (dm_snprintf(s, NAME_LEN, "%s%s%lu",
 			 prefix, cmd->hostname, time(NULL)) < 0) {
-		log_error("Generated system_id too long");
+		log_error(0, "Generated system_id too long");
 		return 0;
 	}
 
@@ -170,7 +170,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute((unused))
 		}
 		if (strlen((char *)pvd->vg_name) + sizeof(EXPORTED_TAG) >
 		    sizeof(pvd->vg_name)) {
-			log_error("Volume group name %s too long to export",
+			log_error(0, "Volume group name %s too long to export",
 				  pvd->vg_name);
 			return 0;
 		}
@@ -402,13 +402,13 @@ int export_extents(struct disk_list *dl, uint32_t lv_num,
 	dm_list_iterate_items(seg, &lv->segments) {
 		for (s = 0; s < seg->area_count; s++) {
 			if (!(seg->segtype->flags & SEG_FORMAT1_SUPPORT)) {
-				log_error("Segment type %s in LV %s: "
+				log_error(0, "Segment type %s in LV %s: "
 					  "unsupported by format1",
 					  seg->segtype->name, lv->name);
 				return 0;
 			}
 			if (seg_type(seg, s) != AREA_PV) {
-				log_error("Non-PV stripe found in LV %s: "
+				log_error(0, "Non-PV stripe found in LV %s: "
 					  "unsupported by format1", lv->name);
 				return 0;
 			}
@@ -579,14 +579,14 @@ int import_snapshots(struct dm_pool *mem __attribute((unused)), struct volume_gr
 			lvnum = lvd->lv_number;
 
 			if (lvnum >= MAX_LV) {
-				log_err("Logical volume number "
+				log_error(0, "Logical volume number "
 					"out of bounds.");
 				return 0;
 			}
 
 			if (!lvs[lvnum] &&
 			    !(lvs[lvnum] = find_lv(vg, (char *)lvd->lv_name))) {
-				log_err("Couldn't find logical volume '%s'.",
+				log_error(0, "Couldn't find logical volume '%s'.",
 					lvd->lv_name);
 				return 0;
 			}
@@ -606,7 +606,7 @@ int import_snapshots(struct dm_pool *mem __attribute((unused)), struct volume_gr
 			lvnum = lvd->lv_number;
 			cow = lvs[lvnum];
 			if (!(org = lvs[lvd->lv_snapshot_minor])) {
-				log_err("Couldn't find origin logical volume "
+				log_error(0, "Couldn't find origin logical volume "
 					"for snapshot '%s'.", lvd->lv_name);
 				return 0;
 			}
@@ -619,7 +619,7 @@ int import_snapshots(struct dm_pool *mem __attribute((unused)), struct volume_gr
 			if (!vg_add_snapshot(org, cow, NULL,
 					     org->le_count,
 					     lvd->lv_chunk_size)) {
-				log_err("Couldn't add snapshot.");
+				log_error(0, "Couldn't add snapshot.");
 				return 0;
 			}
 		}
lib/format1/import-extents.c +12 -12
index ded0a8e..99617af 100644
@@ -50,7 +50,7 @@ static struct dm_hash_table *_create_lv_maps(struct dm_pool *mem,
 	struct lv_map *lvm;
 
 	if (!maps) {
-		log_err("Unable to create hash table for holding "
+		log_error(0, "Unable to create hash table for holding "
 			"extent maps.");
 		return NULL;
 	}
@@ -89,7 +89,7 @@ static int _fill_lv_array(struct lv_map **lvs,
 	dm_list_iterate_items(ll, &dl->lvds) {
 		if (!(lvm = dm_hash_lookup(maps, strrchr((char *)ll->lvd.lv_name, '/')
 					+ 1))) {
-			log_err("Physical volume (%s) contains an "
+			log_error(0, "Physical volume (%s) contains an "
 				"unknown logical volume (%s).",
 				dev_name(dl->dev), ll->lvd.lv_name);
 			return 0;
@@ -132,7 +132,7 @@ static int _fill_maps(struct dm_hash_table *maps, struct volume_group *vg,
 				lvm = lvms[lv_num];
 
 				if (!lvm) {
-					log_error("Invalid LV in extent map "
+					log_error(0, "Invalid LV in extent map "
 						  "(PV %s, PE %" PRIu32
 						  ", LV %" PRIu32
 						  ", LE %" PRIu32 ")",
@@ -144,13 +144,13 @@ static int _fill_maps(struct dm_hash_table *maps, struct volume_group *vg,
 				le = e[i].le_num;
 
 				if (le >= lvm->lv->le_count) {
-					log_err("logical extent number "
+					log_error(0, "logical extent number "
 						"out of bounds");
 					return 0;
 				}
 
 				if (lvm->map[le].pv) {
-					log_err("logical extent (%u) "
+					log_error(0, "logical extent (%u) "
 						"already mapped.", le);
 					return 0;
 				}
@@ -170,7 +170,7 @@ static int _check_single_map(struct lv_map *lvm)
 
 	for (i = 0; i < lvm->lv->le_count; i++) {
 		if (!lvm->map[i].pv) {
-			log_err("Logical volume (%s) contains an incomplete "
+			log_error(0, "Logical volume (%s) contains an incomplete "
 				"mapping table.", lvm->lv->name);
 			return 0;
 		}
@@ -220,7 +220,7 @@ static int _read_linear(struct cmd_context *cmd, struct lv_map *lvm)
 
 		if (!(seg = alloc_lv_segment(cmd->mem, segtype, lvm->lv, le,
 					     len, 0, 0, NULL, 1, len, 0, 0, 0))) {
-			log_error("Failed to allocate linear segment.");
+			log_error(0, "Failed to allocate linear segment.");
 			return 0;
 		}
 
@@ -267,7 +267,7 @@ static int _read_stripes(struct cmd_context *cmd, struct lv_map *lvm)
 	 * Work out overall striped length
 	 */
 	if (lvm->lv->le_count % lvm->stripes) {
-		log_error("Number of stripes (%u) incompatible "
+		log_error(0, "Number of stripes (%u) incompatible "
 			  "with logical extent count (%u) for %s",
 			  lvm->stripes, lvm->lv->le_count, lvm->lv->name);
 	}
@@ -294,7 +294,7 @@ static int _read_stripes(struct cmd_context *cmd, struct lv_map *lvm)
 					     0, lvm->stripe_size, NULL,
 					     lvm->stripes,
 					     area_len, 0, 0, 0))) {
-			log_error("Failed to allocate striped segment.");
+			log_error(0, "Failed to allocate striped segment.");
 			return 0;
 		}
 
@@ -346,12 +346,12 @@ int import_extents(struct cmd_context *cmd, struct volume_group *vg,
 		return_0;
 
 	if (!(maps = _create_lv_maps(scratch, vg))) {
-		log_err("Couldn't allocate logical volume maps.");
+		log_error(0, "Couldn't allocate logical volume maps.");
 		goto out;
 	}
 
 	if (!_fill_maps(maps, vg, pvds)) {
-		log_err("Couldn't fill logical volume maps.");
+		log_error(0, "Couldn't fill logical volume maps.");
 		goto out;
 	}
 
@@ -359,7 +359,7 @@ int import_extents(struct cmd_context *cmd, struct volume_group *vg,
 		goto_out;
 
 	if (!_build_all_segments(cmd, maps)) {
-		log_err("Couldn't build extent segments.");
+		log_error(0, "Couldn't build extent segments.");
 		goto out;
 	}
 	r = 1;
lib/format1/layout.c +5 -5
index de9b206..73c3e39 100644
@@ -76,14 +76,14 @@ static void _calc_simple_layout(struct pv_disk *pvd)
 static int _check_vg_limits(struct disk_list *dl)
 {
 	if (dl->vgd.lv_max > MAX_LV) {
-		log_error("MaxLogicalVolumes of %d exceeds format limit of %d "
+		log_error(0, "MaxLogicalVolumes of %d exceeds format limit of %d "
 			  "for VG '%s'", dl->vgd.lv_max, MAX_LV - 1,
 			  dl->pvd.vg_name);
 		return 0;
 	}
 
 	if (dl->vgd.pv_max > MAX_PV) {
-		log_error("MaxPhysicalVolumes of %d exceeds format limit of %d "
+		log_error(0, "MaxPhysicalVolumes of %d exceeds format limit of %d "
 			  "for VG '%s'", dl->vgd.pv_max, MAX_PV - 1,
 			  dl->pvd.vg_name);
 		return 0;
@@ -102,7 +102,7 @@ int calculate_layout(struct disk_list *dl)
 
 	_calc_simple_layout(pvd);
 	if (!_adjust_pe_on_disk(pvd)) {
-		log_error("Insufficient space for metadata and PE's.");
+		log_error(0, "Insufficient space for metadata and PE's.");
 		return 0;
 	}
 
@@ -136,7 +136,7 @@ int calculate_extent_count(struct physical_volume *pv, uint32_t extent_size,
 		pvd->pe_total = (pv->size / extent_size);
 
 	if (pvd->pe_total < PE_SIZE_PV_SIZE_REL) {
-		log_error("Too few extents on %s.  Try smaller extent size.",
+		log_error(0, "Too few extents on %s.  Try smaller extent size.",
 			  pv_dev_name(pv));
 		dm_free(pvd);
 		return 0;
@@ -157,7 +157,7 @@ int calculate_extent_count(struct physical_volume *pv, uint32_t extent_size,
 		 > pv->size);
 
 	if (pvd->pe_total > MAX_PE_TOTAL) {
-		log_error("Metadata extent limit (%u) exceeded for %s - "
+		log_error(0, "Metadata extent limit (%u) exceeded for %s - "
 			  "%u required", MAX_PE_TOTAL, pv_dev_name(pv),
 			  pvd->pe_total);
 		dm_free(pvd);
lib/format1/lvm1-label.c +2 -2
index 28b0840..d61e446 100644
@@ -26,7 +26,7 @@
 
 static void _not_supported(const char *op)
 {
-	log_err("The '%s' operation is not supported for the lvm1 labeller.",
+	log_error(0, "The '%s' operation is not supported for the lvm1 labeller.",
 		op);
 }
 
@@ -119,7 +119,7 @@ struct labeller *lvm1_labeller_create(struct format_type *fmt)
 	struct labeller *l;
 
 	if (!(l = dm_malloc(sizeof(*l)))) {
-		log_err("Couldn't allocate labeller object.");
+		log_error(0, "Couldn't allocate labeller object.");
 		return NULL;
 	}
 
lib/format_pool/disk_rep.c +2 -2
index 802bf52..c8b6cb5 100644
@@ -266,7 +266,7 @@ static int _read_vg_pds(const struct format_type *fmt, struct dm_pool *mem,
 			if (!(sp_devs =
 			      dm_pool_zalloc(tmpmem,
 					  sizeof(uint32_t) * sp_count))) {
-				log_error("Unable to allocate %d 32-bit uints",
+				log_error(0, "Unable to allocate %d 32-bit uints",
 					  sp_count);
 				dm_pool_destroy(tmpmem);
 				return 0;
@@ -353,7 +353,7 @@ struct pool_list *read_pool_disk(const struct format_type *fmt,
 		return_NULL;
 
 	if (!(pl = dm_pool_zalloc(mem, sizeof(*pl)))) {
-		log_error("Unable to allocate pool list structure");
+		log_error(0, "Unable to allocate pool list structure");
 		return 0;
 	}
 
lib/format_pool/format_pool.c +10 -10
index 3f31bba..249a8ad 100644
@@ -39,7 +39,7 @@ static struct user_subpool *_build_usp(struct dm_list *pls, struct dm_pool *mem,
 	dm_list_iterate_items(pl, pls) {
 		*sps = pl->pd.pl_subpools;
 		if (!usp && (!(usp = dm_pool_zalloc(mem, sizeof(*usp) * (*sps))))) {
-			log_error("Unable to allocate %d subpool structures",
+			log_error(0, "Unable to allocate %d subpool structures",
 				  *sps);
 			return 0;
 		}
@@ -59,7 +59,7 @@ static struct user_subpool *_build_usp(struct dm_list *pls, struct dm_pool *mem,
 		       dm_pool_zalloc(mem,
 				   sizeof(*usp->devs) * pl->pd.pl_sp_devs)))) {
 
-			log_error("Unable to allocate %d pool_device "
+			log_error(0, "Unable to allocate %d pool_device "
 				  "structures", pl->pd.pl_sp_devs);
 			return 0;
 		}
@@ -82,12 +82,12 @@ static int _check_usp(char *vgname, struct user_subpool *usp, int sp_count)
 
 	for (i = 0; i < sp_count; i++) {
 		if (!usp[i].initialized) {
-			log_error("Missing subpool %d in pool %s", i, vgname);
+			log_error(0, "Missing subpool %d in pool %s", i, vgname);
 			return 0;
 		}
 		for (j = 0; j < usp[i].num_devs; j++) {
 			if (!usp[i].devs[j].initialized) {
-				log_error("Missing device %u for subpool %d"
+				log_error(0, "Missing device %u for subpool %d"
 					  " in pool %s", j, i, vgname);
 				return 0;
 			}
@@ -108,7 +108,7 @@ static struct volume_group *_build_vg_from_pds(struct format_instance
 	int sp_count;
 
 	if (!(vg = dm_pool_zalloc(smem, sizeof(*vg)))) {
-		log_error("Unable to allocate volume group structure");
+		log_error(0, "Unable to allocate volume group structure");
 		return NULL;
 	}
 
@@ -254,7 +254,7 @@ static struct format_instance *_pool_create_instance(const struct format_type *f
 	struct metadata_area *mda;
 
 	if (!(fid = dm_pool_zalloc(fmt->cmd->mem, sizeof(*fid)))) {
-		log_error("Unable to allocate format instance structure for "
+		log_error(0, "Unable to allocate format instance structure for "
 			  "pool format");
 		return NULL;
 	}
@@ -264,7 +264,7 @@ static struct format_instance *_pool_create_instance(const struct format_type *f
 
 	/* Define a NULL metadata area */
 	if (!(mda = dm_pool_zalloc(fmt->cmd->mem, sizeof(*mda)))) {
-		log_error("Unable to allocate metadata area structure "
+		log_error(0, "Unable to allocate metadata area structure "
 			  "for pool format");
 		dm_pool_free(fmt->cmd->mem, fid);
 		return NULL;
@@ -307,7 +307,7 @@ struct format_type *init_format(struct cmd_context *cmd)
 	struct format_type *fmt = dm_malloc(sizeof(*fmt));
 
 	if (!fmt) {
-		log_error("Unable to allocate format type structure for pool "
+		log_error(0, "Unable to allocate format type structure for pool "
 			  "format");
 		return NULL;
 	}
@@ -321,12 +321,12 @@ struct format_type *init_format(struct cmd_context *cmd)
 	fmt->private = NULL;
 
 	if (!(fmt->labeller = pool_labeller_create(fmt))) {
-		log_error("Couldn't create pool label handler.");
+		log_error(0, "Couldn't create pool label handler.");
 		return NULL;
 	}
 
 	if (!(label_register_handler(FMT_POOL_NAME, fmt->labeller))) {
-		log_error("Couldn't register pool label handler.");
+		log_error(0, "Couldn't register pool label handler.");
 		return NULL;
 	}
 
lib/format_pool/import_export.c +7 -7
index 0ddf881..467cd5c 100644
@@ -60,7 +60,7 @@ int import_pool_lvs(struct volume_group *vg, struct dm_pool *mem, struct dm_list
 	struct logical_volume *lv;
 
 	if (!(lv = dm_pool_zalloc(mem, sizeof(*lv)))) {
-		log_error("Unable to allocate logical volume structure");
+		log_error(0, "Unable to allocate logical volume structure");
 		return 0;
 	}
 
@@ -118,11 +118,11 @@ int import_pool_pvs(const struct format_type *fmt, struct volume_group *vg,
 
 	dm_list_iterate_items(pl, pls) {
 		if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
-			log_error("Unable to allocate pv list structure");
+			log_error(0, "Unable to allocate pv list structure");
 			return 0;
 		}
 		if (!(pvl->pv = dm_pool_zalloc(mem, sizeof(*pvl->pv)))) {
-			log_error("Unable to allocate pv structure");
+			log_error(0, "Unable to allocate pv structure");
 			return 0;
 		}
 		if (!import_pool_pv(fmt, mem, vg, pvl->pv, pl)) {
@@ -150,7 +150,7 @@ int import_pool_pv(const struct format_type *fmt, struct dm_pool *mem,
 
 	pv->dev = pl->dev;
 	if (!(pv->vg_name = dm_pool_strdup(mem, pd->pl_pool_name))) {
-		log_error("Unable to duplicate vg_name string");
+		log_error(0, "Unable to duplicate vg_name string");
 		return 0;
 	}
 	if (vg != NULL)
@@ -195,7 +195,7 @@ static int _add_stripe_seg(struct dm_pool *mem,
 	uint32_t area_len;
 
 	if (usp->striping & (usp->striping - 1)) {
-		log_error("Stripe size must be a power of 2");
+		log_error(0, "Stripe size must be a power of 2");
 		return 0;
 	}
 
@@ -209,7 +209,7 @@ static int _add_stripe_seg(struct dm_pool *mem,
 				     area_len * usp->num_devs, 0,
 				     usp->striping, NULL, usp->num_devs,
 				     area_len, 0, 0, 0))) {
-		log_error("Unable to allocate striped lv_segment structure");
+		log_error(0, "Unable to allocate striped lv_segment structure");
 		return 0;
 	}
 
@@ -246,7 +246,7 @@ static int _add_linear_seg(struct dm_pool *mem,
 					     area_len, 0, usp->striping,
 					     NULL, 1, area_len,
 					     POOL_PE_SIZE, 0, 0))) {
-			log_error("Unable to allocate linear lv_segment "
+			log_error(0, "Unable to allocate linear lv_segment "
 				  "structure");
 			return 0;
 		}
lib/format_pool/pool_label.c +2 -2
index 5b43375..5022edc 100644
@@ -25,7 +25,7 @@
 
 static void _pool_not_supported(const char *op)
 {
-	log_error("The '%s' operation is not supported for the pool labeller.",
+	log_error(0, "The '%s' operation is not supported for the pool labeller.",
 		  op);
 }
 
@@ -96,7 +96,7 @@ struct labeller *pool_labeller_create(struct format_type *fmt)
 	struct labeller *l;
 
 	if (!(l = dm_malloc(sizeof(*l)))) {
-		log_error("Couldn't allocate labeller object.");
+		log_error(0, "Couldn't allocate labeller object.");
 		return NULL;
 	}
 
lib/format_text/archive.c +8 -8
index 0077f14..7a43206 100644
@@ -139,7 +139,7 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
 
 	/* Sort fails beyond 5-digit indexes */
 	if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) {
-		log_err("Couldn't scan the archive directory (%s).", dir);
+		log_error(0, "Couldn't scan the archive directory (%s).", dir);
 		return 0;
 	}
 
@@ -164,7 +164,7 @@ static struct dm_list *_scan_archive(struct dm_pool *mem,
 		 * Create a new archive_file.
 		 */
 		if (!(af = dm_pool_alloc(mem, sizeof(*af)))) {
-			log_err("Couldn't create new archive file.");
+			log_error(0, "Couldn't create new archive file.");
 			results = NULL;
 			goto out;
 		}
@@ -238,12 +238,12 @@ int archive_vg(struct volume_group *vg,
 	 */
 	if (!create_temp_name(dir, temp_file, sizeof(temp_file), &fd,
 			      &vg->cmd->rand_seed)) {
-		log_err("Couldn't create temporary archive name.");
+		log_error(0, "Couldn't create temporary archive name.");
 		return 0;
 	}
 
 	if (!(fp = fdopen(fd, "w"))) {
-		log_err("Couldn't create FILE object for archive.");
+		log_error(0, "Couldn't create FILE object for archive.");
 		if (close(fd))
 			log_sys_error("close", temp_file);
 		return 0;
@@ -274,7 +274,7 @@ int archive_vg(struct volume_group *vg,
 	for (i = 0; i < 10; i++) {
 		if (dm_snprintf(archive_name, sizeof(archive_name),
 				 "%s/%s_%05u.vg", dir, vg->name, ix) < 0) {
-			log_error("Archive file name too long.");
+			log_error(0, "Archive file name too long.");
 			return 0;
 		}
 
@@ -285,7 +285,7 @@ int archive_vg(struct volume_group *vg,
 	}
 
 	if (!renamed)
-		log_error("Archive rename failed for %s", temp_file);
+		log_error(0, "Archive rename failed for %s", temp_file);
 
 	_remove_expired(archives, dm_list_size(archives) + renamed, retain_days,
 			min_archive);
@@ -307,7 +307,7 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
 	if (!(context = create_text_context(cmd, af->path, NULL)) ||
 	    !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
 							 NULL, context))) {
-		log_error("Couldn't create text instance object.");
+		log_error(0, "Couldn't create text instance object.");
 		return;
 	}
 
@@ -356,7 +356,7 @@ int archive_list_file(struct cmd_context *cmd, const char *file)
 	af.path = (char *)file;
 
 	if (!path_exists(af.path)) {
-		log_err("Archive file %s not found.", af.path);
+		log_error(0, "Archive file %s not found.", af.path);
 		return 0;
 	}
 
lib/format_text/archiver.c +16 -16
index d80c0ba..a4d34ce 100644
@@ -42,7 +42,7 @@ int archive_init(struct cmd_context *cmd, const char *dir,
 {
 	if (!(cmd->archive_params = dm_pool_zalloc(cmd->libmem,
 						sizeof(*cmd->archive_params)))) {
-		log_error("archive_params alloc failed");
+		log_error(0, "archive_params alloc failed");
 		return 0;
 	}
 
@@ -52,7 +52,7 @@ int archive_init(struct cmd_context *cmd, const char *dir,
 		return 1;
 
 	if (!(cmd->archive_params->dir = dm_strdup(dir))) {
-		log_error("Couldn't copy archive directory name.");
+		log_error(0, "Couldn't copy archive directory name.");
 		return 0;
 	}
 
@@ -124,7 +124,7 @@ int archive(struct volume_group *vg)
 	log_verbose("Archiving volume group \"%s\" metadata (seqno %u).", vg->name,
 		    vg->seqno);
 	if (!__archive(vg)) {
-		log_error("Volume group \"%s\" metadata archive failed.",
+		log_error(0, "Volume group \"%s\" metadata archive failed.",
 			  vg->name);
 		return 0;
 	}
@@ -156,7 +156,7 @@ int backup_init(struct cmd_context *cmd, const char *dir,
 {
 	if (!(cmd->backup_params = dm_pool_zalloc(cmd->libmem,
 					       sizeof(*cmd->backup_params)))) {
-		log_error("backup_params alloc failed");
+		log_error(0, "backup_params alloc failed");
 		return 0;
 	}
 
@@ -165,7 +165,7 @@ int backup_init(struct cmd_context *cmd, const char *dir,
 		return 1;
 
 	if (!(cmd->backup_params->dir = dm_strdup(dir))) {
-		log_error("Couldn't copy backup directory name.");
+		log_error(0, "Couldn't copy backup directory name.");
 		return 0;
 	}
 	backup_enable(cmd, enabled);
@@ -195,7 +195,7 @@ static int __backup(struct volume_group *vg)
 
 	if (dm_snprintf(name, sizeof(name), "%s/%s",
 			 vg->cmd->backup_params->dir, vg->name) < 0) {
-		log_error("Failed to generate volume group metadata backup "
+		log_error(0, "Failed to generate volume group metadata backup "
 			  "filename.");
 		return 0;
 	}
@@ -224,7 +224,7 @@ int backup_locally(struct volume_group *vg)
 		return 0;
 
 	if (!__backup(vg)) {
-		log_error("Backup of volume group %s metadata failed.",
+		log_error(0, "Backup of volume group %s metadata failed.",
 			  vg->name);
 		return 0;
 	}
@@ -246,7 +246,7 @@ int backup_remove(struct cmd_context *cmd, const char *vg_name)
 
 	if (dm_snprintf(path, sizeof(path), "%s/%s",
 			 cmd->backup_params->dir, vg_name) < 0) {
-		log_err("Failed to generate backup filename (for removal).");
+		log_error(0, "Failed to generate backup filename (for removal).");
 		return 0;
 	}
 
@@ -269,7 +269,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
 					    cmd->cmd_line)) ||
 	    !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
 							 NULL, context))) {
-		log_error("Couldn't create text format object.");
+		log_error(0, "Couldn't create text format object.");
 		return NULL;
 	}
 
@@ -298,7 +298,7 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
 	/* Attempt to write out using currently active format */
 	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg->name,
 						       NULL, NULL))) {
-		log_error("Failed to allocate format instance");
+		log_error(0, "Failed to allocate format instance");
 		return 0;
 	}
 
@@ -306,19 +306,19 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
 	dm_list_iterate_items(pvl, &vg->pvs) {
 		pv = pvl->pv;
 		if (!(info = info_from_pvid(pv->dev->pvid, 0))) {
-			log_error("PV %s missing from cache",
+			log_error(0, "PV %s missing from cache",
 				  pv_dev_name(pv));
 			return 0;
 		}
 		if (cmd->fmt != info->fmt) {
-			log_error("PV %s is a different format (seqno %s)",
+			log_error(0, "PV %s is a different format (seqno %s)",
 				  pv_dev_name(pv), info->fmt->name);
 			return 0;
 		}
 		if (!vg->fid->fmt->ops->
 		    pv_setup(vg->fid->fmt, UINT64_C(0), 0, 0, 0, 0UL,
 			     UINT64_C(0), &vg->fid->metadata_areas, pv, vg)) {
-			log_error("Format-specific setup for %s failed",
+			log_error(0, "Format-specific setup for %s failed",
 				  pv_dev_name(pv));
 			return 0;
 		}
@@ -347,7 +347,7 @@ int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
 	if (missing_pvs == 0)
 		r = backup_restore_vg(cmd, vg);
 	else
-		log_error("Cannot restore Volume Group %s with %i PVs "
+		log_error(0, "Cannot restore Volume Group %s with %i PVs "
 			  "marked as missing.", vg->name, missing_pvs);
 
 	vg_release(vg);
@@ -360,7 +360,7 @@ int backup_restore(struct cmd_context *cmd, const char *vg_name)
 
 	if (dm_snprintf(path, sizeof(path), "%s/%s",
 			 cmd->backup_params->dir, vg_name) < 0) {
-		log_err("Failed to generate backup filename (for restore).");
+		log_error(0, "Failed to generate backup filename (for restore).");
 		return 0;
 	}
 
@@ -382,7 +382,7 @@ int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
 	if (!(context = create_text_context(cmd, file, desc)) ||
 	    !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
 							 NULL, context))) {
-		log_error("Couldn't create backup object.");
+		log_error(0, "Couldn't create backup object.");
 		return 0;
 	}
 
lib/format_text/export.c +6 -6
index 482eea9..9746b4a 100644
@@ -78,7 +78,7 @@ static void _init(void)
 		return;
 
 	if (uname(&_utsname)) {
-		log_error("uname failed: %s", strerror(errno));
+		log_error(0, "uname failed: %s", strerror(errno));
 		memset(&_utsname, 0, sizeof(_utsname));
 	}
 
@@ -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(0, "Internal error tracking indentation");
 		f->indent = 0;
 	}
 }
@@ -122,7 +122,7 @@ static int _extend_buffer(struct formatter *f)
 		  f->data.buf.size * 2);
 	if (!(newbuf = dm_realloc(f->data.buf.start,
 				   f->data.buf.size * 2))) {
-		log_error("Buffer reallocation failed.");
+		log_error(0, "Buffer reallocation failed.");
 		return 0;
 	}
 	f->data.buf.start = newbuf;
@@ -307,7 +307,7 @@ static int _print_header(struct formatter *f,
 	outnl(f);
 
 	if (!(buf = alloca(escaped_len(desc)))) {
-		log_error("temporary stack allocation for description"
+		log_error(0, "temporary stack allocation for description"
 			  "string failed");
 		return 0;
 	}
@@ -420,7 +420,7 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
 		outf(f, "id = \"%s\"", buffer);
 
 		if (!(buf = alloca(escaped_len(pv_dev_name(pv))))) {
-			log_error("temporary stack allocation for device name"
+			log_error(0, "temporary stack allocation for device name"
 				  "string failed");
 			return 0;
 		}
@@ -744,7 +744,7 @@ int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf)
 
 	f->data.buf.size = 65536;	/* Initial metadata limit */
 	if (!(f->data.buf.start = dm_malloc(f->data.buf.size))) {
-		log_error("text_export buffer allocation failed");
+		log_error(0, "text_export buffer allocation failed");
 		goto out;
 	}
 
lib/format_text/flags.c +4 -4
index 46bb95d..2e7a714 100644
@@ -82,7 +82,7 @@ static struct flag *_get_flags(int type)
 		return _lv_flags;
 	}
 
-	log_err("Unknown flag set requested.");
+	log_error(0, "Unknown flag set requested.");
 	return NULL;
 }
 
@@ -129,7 +129,7 @@ int print_flags(uint32_t status, int type, char *buffer, size_t size)
 		return 0;
 
 	if (status)
-		log_error("Metadata inconsistency: Not all flags successfully "
+		log_error(0, "Metadata inconsistency: Not all flags successfully "
 			  "exported.");
 
 	return 1;
@@ -149,7 +149,7 @@ int read_flags(uint32_t *status, int type, struct config_value *cv)
 
 	while (cv) {
 		if (cv->type != CFG_STRING) {
-			log_err("Status value is not a string.");
+			log_error(0, "Status value is not a string.");
 			return 0;
 		}
 
@@ -169,7 +169,7 @@ int read_flags(uint32_t *status, int type, struct config_value *cv)
 			 */
 			s |= PARTIAL_VG;
 		} else if (!flags[f].description && (type & STATUS_FLAG)) {
-			log_err("Unknown status flag '%s'.", cv->v.str);
+			log_error(0, "Unknown status flag '%s'.", cv->v.str);
 			return 0;
 		}
 
lib/format_text/format-text.c +48 -48

69 lines not on this page · raw message

lib/format_text/import.c +1 -1
index 3bd6828..4ed4ea0 100644

Lines of this file are not shown. View the raw message.

lib/format_text/import_vsn1.c +60 -60

120 lines not on this page · raw message

lib/format_text/tags.c +1 -1
index eeb0af7..debebc4 100644

Lines of this file are not shown. View the raw message.

lib/format_text/text_label.c +8 -8
index 110bc1d..e9344b0 100644

Lines of this file are not shown. View the raw message.

lib/label/label.c +7 -7
index 8924735..df6c60d 100644

Lines of this file are not shown. View the raw message.

lib/locking/cluster_locking.c +10 -10
index eb09241..f2beb94 100644

Lines of this file are not shown. View the raw message.

lib/locking/external_locking.c +2 -2
index 949d065..3958c5e 100644

Lines of this file are not shown. View the raw message.

lib/locking/file_locking.c +3 -3
index e205577..2e24c68 100644

Lines of this file are not shown. View the raw message.

lib/locking/locking.c +9 -9
index 5c04b4f..93807fb 100644

Lines of this file are not shown. View the raw message.

lib/locking/no_locking.c +1 -1
index 5eebafa..828cee8 100644

Lines of this file are not shown. View the raw message.

lib/metadata/lv_manip.c +88 -88

176 lines not on this page · raw message

lib/metadata/merge.c +23 -23

46 lines not on this page · raw message

lib/metadata/metadata.c +119 -119

238 lines not on this page · raw message

lib/metadata/mirror.c +78 -78

156 lines not on this page · raw message

lib/metadata/pv_manip.c +16 -16
index 1b0a457..64aa9c7 100644

Lines of this file are not shown. View the raw message.

lib/metadata/pv_map.c +2 -2
index 642629b..ad94096 100644

Lines of this file are not shown. View the raw message.

lib/metadata/segtype.c +1 -1
index b2d4ebf..378b6c7 100644

Lines of this file are not shown. View the raw message.

lib/metadata/snapshot_manip.c +3 -3
index 83bc385..1ca8c7b 100644

Lines of this file are not shown. View the raw message.

lib/mirror/mirrored.c +17 -17
index b243ebb..89e6b04 100644

Lines of this file are not shown. View the raw message.

lib/misc/lvm-exec.c +4 -4
index fffdc37..f0ed28e 100644

Lines of this file are not shown. View the raw message.

lib/misc/lvm-file.c +8 -8
index a5a5f2b..a68c80e 100644

Lines of this file are not shown. View the raw message.

lib/misc/lvm-string.c +1 -1
index c75a9a7..b961595 100644

Lines of this file are not shown. View the raw message.

lib/misc/sharedlib.c +2 -2
index cab2909..c2a6268 100644

Lines of this file are not shown. View the raw message.

lib/mm/memlock.c +2 -2
index 1386683..7b363d7 100644

Lines of this file are not shown. View the raw message.

lib/report/report.c +29 -29

58 lines not on this page · raw message

lib/snapshot/snapshot.c +7 -7
index d704ff9..d8138e7 100644

Lines of this file are not shown. View the raw message.

lib/striped/striped.c +4 -4
index 78129af..18fccd1 100644

Lines of this file are not shown. View the raw message.

lib/uuid/uuid.c +4 -4
index 1ded223..f85650d 100644

Lines of this file are not shown. View the raw message.

lib/zero/zero.c +1 -1
index 7b3e62e..0583e0d 100644

Lines of this file are not shown. View the raw message.

libdm/ioctl/libdm-iface.c +47 -47

94 lines not on this page · raw message

libdm/libdm-common.c +18 -18
index 291a1b5..2fd8c43 100644

Lines of this file are not shown. View the raw message.

libdm/libdm-deptree.c +77 -77

154 lines not on this page · raw message

libdm/libdm-file.c +1 -1
index 749ee4f..cde7144 100644

Lines of this file are not shown. View the raw message.

libdm/libdm-report.c +52 -52

104 lines not on this page · raw message

libdm/mm/dbg_malloc.c +4 -4
index add285a..8b53e5d 100644

Lines of this file are not shown. View the raw message.

libdm/mm/pool-debug.c +4 -4
index f775dea..c70f3b8 100644

Lines of this file are not shown. View the raw message.

libdm/mm/pool-fast.c +3 -3
index d34cd9a..425e368 100644

Lines of this file are not shown. View the raw message.

libdm/mm/pool.c +3 -3
index 35bfffa..fe96c1a 100644

Lines of this file are not shown. View the raw message.

libdm/regex/matcher.c +2 -2
index c2dda3e..869103a 100644

Lines of this file are not shown. View the raw message.

libdm/regex/parse_rx.c +5 -5
index fdea1a3..3f090f1 100644

Lines of this file are not shown. View the raw message.

liblvm/lvm_base.c +1 -1
index 6d27c4d..2841719 100644

Lines of this file are not shown. View the raw message.

old-tests/datastruct/hash_t.c +2 -2
index e977eab..4c83e2c 100644

Lines of this file are not shown. View the raw message.

old-tests/dev-mgr/dev_cache_t.c +3 -3
index 7cd2085..f4b25b9 100644

Lines of this file are not shown. View the raw message.

old-tests/device/dev_cache_t.c +3 -3
index f19a56f..63342d4 100644

Lines of this file are not shown. View the raw message.

old-tests/device/random.c +2 -2
index d2cac3b..e253119 100644

Lines of this file are not shown. View the raw message.

old-tests/filters/pfilter_t.c +2 -2
index e9f8af4..7c2b0fd 100644

Lines of this file are not shown. View the raw message.

old-tests/filters/rfilter_t.c +1 -1
index 6f0bb9d..4bb6dbf 100644

Lines of this file are not shown. View the raw message.

tools/dmsetup.c +21 -21

42 lines not on this page · raw message

tools/lvchange.c +50 -50

100 lines not on this page · raw message

tools/lvconvert.c +56 -56

112 lines not on this page · raw message

tools/lvcreate.c +78 -78

156 lines not on this page · raw message

tools/lvdisplay.c +3 -3
index f5531cb..d0efe71 100644

Lines of this file are not shown. View the raw message.

tools/lvm.c +5 -5
index e1f7900..1f4b1f8 100644

Lines of this file are not shown. View the raw message.

tools/lvmcmdlib.c +4 -4
index 5cde0c4..1815743 100644

Lines of this file are not shown. View the raw message.

tools/lvmcmdline.c +26 -26

52 lines not on this page · raw message

tools/lvmdiskscan.c +5 -5
index c91f5f2..328fc80 100644

Lines of this file are not shown. View the raw message.

tools/lvremove.c +1 -1
index be2107a..15299ad 100644

Lines of this file are not shown. View the raw message.

tools/lvrename.c +9 -9
index 7411854..f4725fe 100644

Lines of this file are not shown. View the raw message.

tools/lvresize.c +34 -34

68 lines not on this page · raw message

tools/lvscan.c +1 -1
index 21bf01c..e47c282 100644

Lines of this file are not shown. View the raw message.

tools/polldaemon.c +8 -8
index 4dcbc22..2429548 100644

Lines of this file are not shown. View the raw message.

tools/pvchange.c +22 -22

44 lines not on this page · raw message

tools/pvcreate.c +29 -29

58 lines not on this page · raw message

tools/pvdisplay.c +5 -5
index c8c4a88..2c24a2d 100644

Lines of this file are not shown. View the raw message.

tools/pvmove.c +32 -32

64 lines not on this page · raw message

tools/pvremove.c +10 -10
index 3d75480..172901d 100644

Lines of this file are not shown. View the raw message.

tools/pvresize.c +14 -14
index 964d6a5..60788e1 100644

Lines of this file are not shown. View the raw message.

tools/pvscan.c +2 -2
index 494af3d..fb7ee32 100644

Lines of this file are not shown. View the raw message.

tools/reporter.c +5 -5
index d1368d4..bcc8b14 100644

Lines of this file are not shown. View the raw message.

tools/stub.h +4 -4
index 1523797..2d19403 100644

Lines of this file are not shown. View the raw message.

tools/toollib.c +58 -58

116 lines not on this page · raw message

tools/vgcfgbackup.c +4 -4
index c8ae40c..9336eed 100644

Lines of this file are not shown. View the raw message.

tools/vgcfgrestore.c +5 -5
index 6ec20d1..6ed9077 100644

Lines of this file are not shown. View the raw message.

tools/vgchange.c +33 -33

66 lines not on this page · raw message

tools/vgconvert.c +19 -19
index 0996d95..baf9aee 100644

Lines of this file are not shown. View the raw message.

tools/vgcreate.c +7 -7
index 232b570..f840106 100644

Lines of this file are not shown. View the raw message.

tools/vgdisplay.c +4 -4
index bbabcee..d2e006e 100644

Lines of this file are not shown. View the raw message.

tools/vgexport.c +3 -3
index 59627b9..7ed293e 100644

Lines of this file are not shown. View the raw message.

tools/vgextend.c +3 -3
index 1000dc2..2690be8 100644

Lines of this file are not shown. View the raw message.

tools/vgimport.c +4 -4
index 864a700..7ceb8bf 100644

Lines of this file are not shown. View the raw message.

tools/vgmerge.c +3 -3
index 4a9e377..ff9874f 100644

Lines of this file are not shown. View the raw message.

tools/vgreduce.c +29 -29

58 lines not on this page · raw message

tools/vgremove.c +2 -2
index 5956075..102415c 100644

Lines of this file are not shown. View the raw message.

tools/vgrename.c +7 -7
index 57229e7..094bfb2 100644

Lines of this file are not shown. View the raw message.

tools/vgscan.c +2 -2
index 769c5cf..cb79159 100644

Lines of this file are not shown. View the raw message.

tools/vgsplit.c +14 -14
index 9cd90b8..9e8afc0 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.6.2.5

Part of the diff is not shown here. View the raw message.

#3 lore raw

PATCH 1/2 Add cmd logging for liblvm error reporting: All logging functions have an additional argument: The error code This makes the functions incompatible with the old ones.

In reply to Thomas Woerner

I'm taking a few more review passes and have a couple more comments - see below.

Quoted 6 lines
daemons/clvmd/lvm-functions.c +0 -0
@@ -788,7 +788,12 @@ void lvm_do_backup(const char *vgname)
 int init_lvm(int using_gulm)
 {
 	if (!(cmd = create_toolcontext(1, NULL))) {

daemons/clvmd/lvm-functions.c void lvm_do_backup(const char *vgname) · line 799

Quoted 10 lines
daemons/clvmd/lvm-functions.c +6 -1
-		log_error("Failed to allocate command context");
+		log_error(0, "Failed to allocate command context");
+		return 0;
+	}
+
+	if (lvm_error(cmd) != 0) {
+		log_error(0, "Failed to create command context");
 		return 0;
 	}
 

We need that non-zero error code in log_error() to catch create_toolcontext() errors.

Quoted 21 lines
lib/commands/toolcontext.c +3 -3
index 4f6cf98..12b881b 100644
@@ -1031,6 +1031,9 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
 	dm_list_init(&cmd->tags);
 	dm_list_init(&cmd->config_files);
 
+	/* Log to command */
+	init_log_cmd(cmd);
+
 	/*
 	 * Environment variable LVM_SYSTEM_DIR overrides this below.
 	 */
@@ -1112,16 +1115,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
 	return cmd;
 
       error:
-	_destroy_tag_configs(cmd);
-	dev_cache_exit();
-	if (cmd->filter)

lib/commands/toolcontext.c struct cmd_context *create_toolcontext(unsigned is_long_lived, · line 1120

Quoted 10 lines
lib/commands/toolcontext.c +1 -7
-		cmd->filter->destroy(cmd->filter);
-	if (cmd->mem)
-		dm_pool_destroy(cmd->mem);
-	if (cmd->libmem)
-		dm_pool_destroy(cmd->libmem);
-	dm_free(cmd);
-	return NULL;
+	return cmd;
 }
 

Ok, so this cleanup gets moved to destroy_toolcontext() and we always return a handle from create_toolcontext() (unless we could not allocate, in which case we return NULL).

Quoted 8 lines
lib/commands/toolcontext.c +1 -2
 static void _destroy_formats(struct dm_list *formats)
@@ -1240,12 +1234,15 @@ void destroy_toolcontext(struct cmd_context *cmd)
 	label_exit();
 	_destroy_segtypes(&cmd->segtypes);
 	_destroy_formats(&cmd->formats);
-	cmd->filter->destroy(cmd->filter);
-	dm_pool_destroy(cmd->mem);
+	if (cmd->filter)

lib/commands/toolcontext.c void destroy_toolcontext(struct cmd_context *cmd) · line 1246

Quoted 10 lines
lib/commands/toolcontext.c +5 -1
+		cmd->filter->destroy(cmd->filter);
+	if (cmd->mem)
+		dm_pool_destroy(cmd->mem);
 	dev_cache_exit();
 	_destroy_tags(cmd);
 	_destroy_tag_configs(cmd);
-	dm_pool_destroy(cmd->libmem);
+	if (cmd->libmem)
+		dm_pool_destroy(cmd->libmem);
 	dm_free(cmd);

Strange why the cleanup order is different in this function than create_toolcontext() but that is not an issue with your patch. Ok.

The bottom of this function looks a bit strange though it might be best to leave it:

	cmd->config_valid = 1;
	return cmd;

      error:
	return cmd;
Quoted 6 lines
lib/commands/toolcontext.c +0 -0
 }
tools/lvmcmdline.c +0 -0
index 1ad14d0..555be8f 100644

tools/lvmcmdline.c struct cmd_context *init_lvm(void) · line 1188

Quoted 10 lines
tools/lvmcmdline.c +5 -0
@@ -1179,6 +1179,11 @@ struct cmd_context *init_lvm(void)
 	if (!(cmd = create_toolcontext(0, NULL)))
 		return_NULL;
 
+	if (cmd_error(cmd) != 0) {
+		destroy_toolcontext(cmd);
+		return_NULL;
+	}
+
 	return cmd;
 }

This is another example of why we need the non-zero default. If you use 0 everywhere, we could get an error in create_toolcontext(), then never realize it and not cleanup properly.

Maybe we can add a couple tests to catch initialization problems and make sure certain error paths get hit.

Quoted 29 lines
tools/pvchange.c +2 -3
index efc780b..def78cc 100644
@@ -64,9 +64,8 @@ static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
 		}
 
 		if (!(pvl = find_pv_in_vg(vg, pv_name))) {
-			log_error
-			    ("Unable to find \"%s\" in volume group \"%s\"",
-			     pv_name, vg->name);
+			log_error("Unable to find \"%s\" in volume group \"%s\"",
+				  pv_name, vg->name);
 			goto out;
 		}
 		if (tagarg && !(vg->fid->fmt->features & FMT_TAGS)) {
tools/pvmove.c +1 -2
index 65b7606..2490863 100644
@@ -400,15 +400,13 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
 			log_error("Ignoring remaining command line arguments");
 
 		if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
-			log_error
-			    ("ABORTING: Failed to generate list of moving LVs");
+			log_error("ABORTING: Failed to generate list of moving LVs");
 			goto out;

tools/pvmove.c static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name, · line 412

Quoted 10 lines
tools/pvmove.c +1 -2
 		}
 
 		/* Ensure mirror LV is active */
 		if (!_activate_lv(cmd, lv_mirr, exclusive)) {
-			log_error
-			    ("ABORTING: Temporary mirror activation failed.");
+			log_error("ABORTING: Temporary mirror activation failed.");
 			goto out;
 		}
 

These probably belong in another tiny cleanup patch that can go in immediately.

I believe the convention in lvm source is to break long quoted strings into two quotes on two lines. For example:
log_error("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); log_error("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

	  "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

So if you find anything like that you can just checkin the fixup I believe.

#4 lore raw

PATCH 1/2 Add cmd logging for liblvm error reporting: All logging functions have an additional argument: The error code This makes the functions incompatible with the old ones.

In reply to Thomas Woerner

This is the first patch I was thinking of for libdevmapper to preserve compatibility.

Alasdair

Index: libdm/.exported_symbols
===================================================================
RCS file: /cvs/lvm2/LVM2/libdm/.exported_symbols,v retrieving revision 1.37

.exported_symbols +3 -0
diff -u -p -r1.37 .exported_symbols
@@ -6,6 +6,9 @@ dm_fclose
 dm_get_library_version
 dm_log
 dm_log_init
+dm_log_is_non_default
+dm_log_with_errno
+dm_log_with_errno_init
 dm_log_init_verbose
 dm_task_create
 dm_task_destroy

Index: libdm/libdevmapper.h
===================================================================
RCS file: /cvs/lvm2/LVM2/libdm/libdevmapper.h,v
retrieving revision 1.90

libdevmapper.h +29 -14

65 lines not on this page · raw message

Index: libdm/libdm-common.c
===================================================================
RCS file: /cvs/lvm2/LVM2/libdm/libdm-common.c,v
retrieving revision 1.65

libdm-common.c +45 -7

83 lines not on this page · raw message

Index: libdm/misc/dm-logging.h
===================================================================
RCS file: /cvs/lvm2/LVM2/libdm/misc/dm-logging.h,v retrieving revision 1.1

misc/dm-logging.h +8 -1
diff -u -p -r1.1 dm-logging.h
@@ -19,8 +19,15 @@
 #include "libdevmapper.h"
 
 extern dm_log_fn dm_log;
+extern dm_log_with_errno_fn dm_log_with_errno;
 
-#define plog(l, x...) dm_log(l, __FILE__, __LINE__, ## x)
+#define plog(l, x...) \
+	do { \
+		if (dm_log_is_non_default()) \
+			dm_log(l, __FILE__, __LINE__, ## x); \
+		else \
+			dm_log_with_errno(l, __FILE__, __LINE__, 0, ## x); \
+	} while (0)
 
 #include "log.h"
 
#5 lore raw

cover error messages bound to command

In reply to Thomas Woerner
Quoted 7 lines · Thomas Woerner

twoerner (2):
Add cmd logging for liblvm error reporting: All logging functions
have an additional argument: The error code This makes the functions incompatible with the old ones.
Add error code for all log_err and log_error calls. Replace log_err
with log_error.

Note: This second patch was 550k so I guess the mailing list choked on that. Not that interesting anyway - just script output really.

#6 lore raw

cover error messages bound to command

In reply to Thomas Woerner
Quoted 7 lines · Thomas Woerner

This patch series add functions to add an error message and the error code to the command context. This is needed for liblvm to be able to have handle specific error reporting.

The first patch add the needed functions and corrects some code to use a script to add the error code to all log_error and log_err functions. It replaces all log_err calls with log_error. The result is the second patch.

Quoted 7 lines

The script:

    find . -name "*.[hc]" -exec perl -pi -e "s/log_error\(\"/log_error\(0, \"/g" {} \;
    find . -name "*.[hc]" -exec perl -pi -e "s/log_err\(\"/log_error\(0, \"/g" {} \;
    find . -name "*.[hc]" -exec perl -pi -e "s/log_error\(no_space\)/log_error\(0, no_space\)/g" {} \;
    perl -pi -e "s/log_error\(bad,/log_error\(0, bad,/g" lib/format_text/import_vsn1.c

I think the default code for log_error should be nonzero right?

In your patches you have:
+ if (lvm_error(cmd) != 0) {
+ log_error(0, "Failed to create command context");

Maybe make it -1 for now?

Quoted 148 lines

testsuite: pass

twoerner (2):
Add cmd logging for liblvm error reporting: All logging functions
have an additional argument: The error code This makes the functions incompatible with the old ones.
Add error code for all log_err and log_error calls. Replace log_err
with log_error.

 daemons/clvmd/clvmd-cman.c            |    8 +-
 daemons/clvmd/clvmd-command.c         |    2 +-
 daemons/clvmd/clvmd-gulm.c            |    4 +-
 daemons/clvmd/clvmd.c                 |   26 ++--
 daemons/clvmd/lvm-functions.c         |   15 ++-
 daemons/dmeventd/libdevmapper-event.c |   50 ++++----
 lib/activate/activate.c               |   26 ++--
 lib/activate/dev_manager.c            |   64 +++++-----
 lib/activate/fs.c                     |   24 ++--
 lib/cache/lvmcache.c                  |   70 +++++-----
 lib/commands/toolcontext.c            |  119 +++++++++--------
 lib/commands/toolcontext.h            |    6 +
 lib/config/config.c                   |   38 +++---
 lib/device/dev-cache.c                |   50 ++++----
 lib/device/dev-io.c                   |   22 ++--
 lib/device/dev-md.c                   |    8 +-
 lib/device/device.c                   |   12 +-
 lib/display/display.c                 |    4 +-
 lib/error/errseg.c                    |    2 +-
 lib/filters/filter-composite.c        |    4 +-
 lib/filters/filter-md.c               |    2 +-
 lib/filters/filter-persistent.c       |    6 +-
 lib/filters/filter-regex.c            |    4 +-
 lib/filters/filter-sysfs.c            |   10 +-
 lib/filters/filter.c                  |   10 +-
 lib/format1/disk-rep.c                |   30 ++--
 lib/format1/format1.c                 |   22 ++--
 lib/format1/import-export.c           |   22 ++--
 lib/format1/import-extents.c          |   24 ++--
 lib/format1/layout.c                  |   10 +-
 lib/format1/lvm1-label.c              |    4 +-
 lib/format_pool/disk_rep.c            |    4 +-
 lib/format_pool/format_pool.c         |   20 ++--
 lib/format_pool/import_export.c       |   14 +-
 lib/format_pool/pool_label.c          |    4 +-
 lib/format_text/archive.c             |   16 +-
 lib/format_text/archiver.c            |   32 +++---
 lib/format_text/export.c              |   12 +-
 lib/format_text/flags.c               |    8 +-
 lib/format_text/format-text.c         |   96 +++++++-------
 lib/format_text/import.c              |    2 +-
 lib/format_text/import_vsn1.c         |  120 ++++++++--------
 lib/format_text/tags.c                |    2 +-
 lib/format_text/text_label.c          |   16 +-
 lib/label/label.c                     |   14 +-
 lib/locking/cluster_locking.c         |   20 ++--
 lib/locking/external_locking.c        |    4 +-
 lib/locking/file_locking.c            |    6 +-
 lib/locking/locking.c                 |   18 ++--
 lib/locking/no_locking.c              |    2 +-
 lib/log/log.c                         |   44 ++++++-
 lib/log/log.h                         |   16 +-
 lib/log/lvm-logging.h                 |   11 +-
 lib/metadata/lv_manip.c               |  176 ++++++++++++------------
 lib/metadata/merge.c                  |   46 +++---
 lib/metadata/metadata.c               |  238 ++++++++++++++++----------------
 lib/metadata/mirror.c                 |  156 +++++++++++-----------
 lib/metadata/pv_manip.c               |   32 +++---
 lib/metadata/pv_map.c                 |    4 +-
 lib/metadata/segtype.c                |    2 +-
 lib/metadata/snapshot_manip.c         |    6 +-
 lib/mirror/mirrored.c                 |   34 +++---
 lib/misc/lvm-exec.c                   |    8 +-
 lib/misc/lvm-file.c                   |   16 +-
 lib/misc/lvm-string.c                 |    2 +-
 lib/misc/sharedlib.c                  |    4 +-
 lib/mm/memlock.c                      |    4 +-
 lib/report/report.c                   |   58 ++++----
 lib/snapshot/snapshot.c               |   14 +-
 lib/striped/striped.c                 |    8 +-
 lib/uuid/uuid.c                       |    8 +-
 lib/zero/zero.c                       |    2 +-
 libdm/ioctl/libdm-iface.c             |   94 +++++++-------
 libdm/libdevmapper.h                  |    4 +-
 libdm/libdm-common.c                  |   39 +++---
 libdm/libdm-deptree.c                 |  154 +++++++++++-----------
 libdm/libdm-file.c                    |    2 +-
 libdm/libdm-report.c                  |  104 +++++++-------
 libdm/misc/dm-logging.h               |    2 +-
 libdm/mm/dbg_malloc.c                 |   10 +-
 libdm/mm/pool-debug.c                 |    8 +-
 libdm/mm/pool-fast.c                  |    6 +-
 libdm/mm/pool.c                       |    6 +-
 libdm/regex/matcher.c                 |    4 +-
 libdm/regex/parse_rx.c                |   10 +-
 liblvm/Makefile.in                    |    2 +
 liblvm/lvm.h                          |    3 +
 liblvm/lvm_base.c                     |   19 +++-
 old-tests/datastruct/hash_t.c         |    4 +-
 old-tests/dev-mgr/dev_cache_t.c       |    6 +-
 old-tests/device/dev_cache_t.c        |    6 +-
 old-tests/device/random.c             |    4 +-
 old-tests/filters/pfilter_t.c         |    4 +-
 old-tests/filters/rfilter_t.c         |    2 +-
 tools/dmsetup.c                       |   42 +++---
 tools/lvchange.c                      |  100 +++++++-------
 tools/lvconvert.c                     |  112 ++++++++--------
 tools/lvcreate.c                      |  156 +++++++++++-----------
 tools/lvdisplay.c                     |    6 +-
 tools/lvm.c                           |   10 +-
 tools/lvmcmdlib.c                     |    8 +-
 tools/lvmcmdline.c                    |   57 +++++----
 tools/lvmdiskscan.c                   |   10 +-
 tools/lvremove.c                      |    2 +-
 tools/lvrename.c                      |   18 ++--
 tools/lvresize.c                      |   68 +++++-----
 tools/lvscan.c                        |    2 +-
 tools/polldaemon.c                    |   16 +-
 tools/pvchange.c                      |   47 +++----
 tools/pvcreate.c                      |   58 ++++----
 tools/pvdisplay.c                     |   10 +-
 tools/pvmove.c                        |   66 +++++-----
 tools/pvremove.c                      |   20 ++--
 tools/pvresize.c                      |   28 ++--
 tools/pvscan.c                        |    4 +-
 tools/reporter.c                      |   10 +-
 tools/stub.h                          |    8 +-
 tools/toollib.c                       |  116 ++++++++--------
 tools/vgcfgbackup.c                   |    8 +-
 tools/vgcfgrestore.c                  |   10 +-
 tools/vgchange.c                      |   66 +++++-----
 tools/vgconvert.c                     |   38 +++---
 tools/vgcreate.c                      |   14 +-
 tools/vgdisplay.c                     |    8 +-
 tools/vgexport.c                      |    6 +-
 tools/vgextend.c                      |    6 +-
 tools/vgimport.c                      |    8 +-
 tools/vgmerge.c                       |    6 +-
 tools/vgreduce.c                      |   58 ++++----
 tools/vgremove.c                      |    4 +-
 tools/vgrename.c                      |   14 +-
 tools/vgscan.c                        |    4 +-
 tools/vgsplit.c                       |   28 ++--
 133 files changed, 1910 insertions(+), 1832 deletions(-)

--
lvm-devel mailing list
lvm-devel at redhat.com
https://www.redhat.com/mailman/listinfo/lvm-devel