Fix debugging output
PATCH 6/21 Fix debugging output
Implement a proper output function for libdevmapper which ties into our verbosity level. This allows us for a finer grained control about the error messages from libdevmapper and we get better debugging output to boot.
Signed-off-by Stefan Bader <[email protected]>
Signed-off-by Hannes Reinecke <[email protected]>
--- libmultipath/configure.c | 2 - libmultipath/debug.c | 2 +- libmultipath/debug.h | 2 +- libmultipath/devmapper.c | 60 ++++++++++++++++++++++++++++++++++--------- libmultipath/devmapper.h | 3 +- libmultipath/log_pthread.c | 2 +- libmultipath/log_pthread.h | 2 +- libmultipath/structs_vec.c | 32 ++++++++++++++--------- libmultipath/waiter.c | 9 +++--- multipath/main.c | 1 + multipathd/main.c | 3 ++ 11 files changed, 80 insertions(+), 38 deletions(-)
libmultipath/configure.c +0 -2
@@ -324,7 +324,6 @@ domap (struct multipath * mpp) mpp->alias);return DOMAP_RETRY ; } -dm_shut_log ();if (dm_map_present (mpp->alias))break ;
@@ -345,7 +344,6 @@ domap (struct multipath * mpp) }lock_multipath (mpp,0 ); -dm_restore_log ();break ;case ACT_RELOAD :
libmultipath/debug.c +1 -1
@@ -14,7 +14,7 @@#include "vector.h" #include "config.h" -void dlog (int sink,int prio,char * fmt, ...) +void dlog (int sink,int prio,const char * fmt, ...) {va_list ap;int thres;
libmultipath/debug.h +1 -1
@@ -1,4 +1,4 @@ -void dlog (int sink,int prio,char * fmt, ...) +void dlog (int sink,int prio,const char * fmt, ...) __attribute__((format (printf,3 ,4 )));#if DAEMON
libmultipath/devmapper.c +47 -13
83 lines not on this page · raw message
libmultipath/devmapper.h +1 -2
@@ -1,5 +1,4 @@ -void dm_shut_log (void ); -void dm_restore_log (void ); +void dm_init (void );int dm_prereq (char *);int dm_simplecmd (int ,const char *); int dm_addmap (int, const char *, const char *, const char *,
libmultipath/log_pthread.c +1 -1
@@ -12,7 +12,7 @@#include "log_pthread.h" #include "log.h" -void log_safe (int prio,char * fmt,va_list ap) +void log_safe (int prio,const char * fmt,va_list ap) {pthread_mutex_lock (logq_lock);//va_start(ap, fmt);
libmultipath/log_pthread.h +1 -1
@@ -7,7 +7,7 @@ pthread_mutex_t *logq_lock;pthread_mutex_t *logev_lock;pthread_cond_t *logev_cond; -void log_safe (int prio,char * fmt,va_list ap); +void log_safe (int prio,const char * fmt,va_list ap);void log_thread_start (void );void log_thread_stop (void );
libmultipath/structs_vec.c +20 -12
@@ -16,7 +16,6 @@#include "discovery.h" #include "waiter.h" -/* * creates or updates mpp->paths reading mpp->pg */
@@ -118,6 +117,8 @@ remove_map (struct multipath * mpp, stru {int i; +condlog (4 ,"%s: remove multipath map" , mpp->alias); +/* * stop the DM event waiter thread */
@@ -245,8 +246,17 @@ extern int setup_multipath (struct vectors * vecs, struct multipath * mpp) { retry: - if (dm_get_info(mpp->alias, &mpp->dmi)) + if (dm_get_info(mpp->alias, &mpp->dmi)) { + /* Error accessing table */ + condlog(3, "%s: cannot access table", mpp->alias); + goto out; + } + +if (!dm_map_present (mpp->alias)) { +/* Table has been removed */ +condlog (3 ,"%s: table does not exist" , mpp->alias); goto out; + }set_multipath_wwid (mpp); mpp->mpe =find_mpe (mpp->wwid);
@@ -270,6 +280,7 @@ retry:#endif goto retry; } +condlog (0 ,"%s: failed to setup multipath" , mpp->alias); goto out; }
@@ -282,7 +293,6 @@ retry:return 0 ; out: -condlog (0 ,"%s: failed to setup multipath" , mpp->alias);remove_map (mpp, vecs,NULL ,1 );return 1 ; }
@@ -390,18 +400,19 @@ int update_multipath (struct vectors *vestruct pathgroup *pgp;struct path *pp;int i, j; -int r =1 ; mpp =find_mp_by_alias (vecs->mpvec, mapname); -if (!mpp) - goto out; +if (!mpp) { +condlog (3 ,"%s: multipath map not found\n" , mapname); +return 2 ; + }free_pgvec (mpp->pg,KEEP_PATHS ); mpp->pg =NULL ;if (setup_multipath (vecs, mpp)) - goto out;/* mpp freed in setup_multipath */ +return 1 ;/* mpp freed in setup_multipath */ /* * compare checkers states with DM states
@@ -429,11 +440,8 @@ int update_multipath (struct vectors *ve } } } - r =0 ; -out: -if (r) -condlog (0 ,"failed to update multipath" ); -return r; + +return 0 ; }/*
libmultipath/waiter.c +4 -5
@@ -117,15 +117,11 @@ int waiteventloop (struct event_thread */* accept wait interruption */ set =unblock_signals (); -/* interruption spits messages */ -dm_shut_log (); -/* wait */ r =dm_task_run (waiter->dmt);/* wait is over : event or interrupt */ pthread_sigmask (SIG_SETMASK , &set,NULL ); -//dm_restore_log(); if (!r)/* wait interrupted by signal */ return -1 ;
@@ -157,8 +153,11 @@ int waiteventloop (struct event_thread * r =update_multipath (waiter->vecs, waiter->mapname);lock_cleanup_pop (waiter->vecs->lock); -if (r) +if (r) { +condlog (2 ,"%s: event checker exit" , + waiter->mapname);return -1 ;/* stop the thread */ + } event_nr =dm_geteventnr (waiter->mapname);
multipath/main.c +1 -0
@@ -401,6 +401,7 @@ main (int argc, char *argv[]) conf->dev_type =DEV_DEVMAP ; } +dm_init ();if (conf->remove ==FLUSH_ONE ) {if (conf->dev_type ==DEV_DEVMAP )
multipathd/main.c +3 -0
@@ -225,6 +225,8 @@ ev_add_map (char * devname, struct vectoint map_present;int r =1 ; +/* libsysfs seems to forget to terminate the string... */ +memset (dev_t,0 ,BLK_DEV_SIZE );if (sscanf (devname,"dm-%d" , &minor) ==1 && !sysfs_get_dev (sysfs_path, devname, dev_t,BLK_DEV_SIZE ) &&sscanf (dev_t,"%d:%d" , &major, &minor) ==2 )
@@ -1397,6 +1399,7 @@ main (int argc, char *argv[])int err; logsink =1 ; +dm_init ();if (getuid () !=0 ) {fprintf (stderr,"need to be root\n" );
Signature · 1 line
1.4.3.4