This is the mail archive of the
lvm2-cvs@sourceware.org
mailing list for the LVM2 project.
LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c ...
- From: pcaulfield at sourceware dot org
- To: lvm2-cvs at sourceware dot org
- Date: 5 Oct 2006 13:55:51 -0000
- Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: pcaulfield@sourceware.org 2006-10-05 13:55:50
Modified files:
. : WHATS_NEW
daemons/clvmd : clvmd-command.c clvmd.c lvm-functions.c
lvm-functions.h
Log message:
Vastly improve the errors returned to the user from clvmd.
It now captures the error messages that are generated and returns them
in the reply packet rather than just telling the user to check syslog.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.451&r2=1.452
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.h.diff?cvsroot=lvm2&r1=1.3&r2=1.4
--- LVM2/WHATS_NEW 2006/10/04 16:03:17 1.451
+++ LVM2/WHATS_NEW 2006/10/05 13:55:50 1.452
@@ -1,5 +1,6 @@
Version 2.02.11 -
=====================================
+ Capture error messages in clvmd and pass them back to the user.
Remove unused #defines from filter-md.c.
Make clvmd restart init script wait until clvmd has died before starting it.
Add -R to clvmd which tells running clvmds to reload their device cache.
--- LVM2/daemons/clvmd/clvmd-command.c 2006/10/04 08:22:16 1.9
+++ LVM2/daemons/clvmd/clvmd-command.c 2006/10/05 13:55:50 1.10
@@ -117,7 +117,7 @@
if (status == EIO) {
*retlen =
1 + snprintf(*buf, buflen,
- "Internal lvm error, check syslog");
+ get_last_lvm_error());
return EIO;
}
break;
--- LVM2/daemons/clvmd/clvmd.c 2006/10/04 08:22:16 1.27
+++ LVM2/daemons/clvmd/clvmd.c 2006/10/05 13:55:50 1.28
@@ -1689,6 +1689,7 @@
}
pthread_mutex_unlock(&lvm_thread_mutex);
}
+ return NULL;
}
/* Pass down some work to the LVM thread */
--- LVM2/daemons/clvmd/lvm-functions.c 2006/10/04 08:22:16 1.22
+++ LVM2/daemons/clvmd/lvm-functions.c 2006/10/05 13:55:50 1.23
@@ -50,12 +50,18 @@
static struct cmd_context *cmd = NULL;
static struct dm_hash_table *lv_hash = NULL;
static pthread_mutex_t lv_hash_lock;
+static char last_error[1024];
struct lv_info {
int lock_id;
int lock_mode;
};
+char *get_last_lvm_error()
+{
+ return last_error;
+}
+
/* Return the mode a lock is currently held at (or -1 if not held) */
static int get_current_lock(char *resource)
{
@@ -201,8 +207,17 @@
/* Try to get the lock if it's a clustered volume group */
if (lock_flags & LCK_CLUSTER_VG) {
status = hold_lock(resource, mode, LKF_NOQUEUE);
- if (status)
+ if (status) {
+ /* Return an LVM-sensible error for this.
+ * Forcing EIO makes the upper level return this text
+ * rather than the strerror text for EAGAIN.
+ */
+ if (errno == EAGAIN) {
+ sprintf(last_error, "Volume is busy on another node");
+ errno = EIO;
+ }
return errno;
+ }
}
/* If it's suspended then resume it */
@@ -512,6 +527,19 @@
return NULL;
}
+static void lvm2_log_fn(int level, const char *file, int line,
+ const char *message)
+{
+ /*
+ * Ignore non-error messages, but store the latest one for returning
+ * to the user.
+ */
+ if (level != _LOG_ERR && level != _LOG_FATAL)
+ return;
+
+ strcpy(last_error, message);
+}
+
/* This checks some basic cluster-LVM configuration stuff */
static void check_config()
{
@@ -564,5 +592,8 @@
get_initial_state();
+ /* Trap log messages so we can pass them back to the user */
+ init_log_fn(lvm2_log_fn);
+
return 1;
}
--- LVM2/daemons/clvmd/lvm-functions.h 2006/10/04 08:22:16 1.3
+++ LVM2/daemons/clvmd/lvm-functions.h 2006/10/05 13:55:50 1.4
@@ -32,5 +32,6 @@
extern int hold_unlock(char *resource);
extern int hold_lock(char *resource, int mode, int flags);
extern void unlock_all(void);
+extern char *get_last_lvm_error(void);
#endif