]> sourceware.org Git - lvm2.git/commitdiff
Make clvmd use the command library rather than popen() to
authorPatrick Caulfield <pcaulfie@redhat.com>
Mon, 7 Feb 2005 10:04:27 +0000 (10:04 +0000)
committerPatrick Caulfield <pcaulfie@redhat.com>
Mon, 7 Feb 2005 10:04:27 +0000 (10:04 +0000)
preload the lock state.

Makefile.in
WHATS_NEW
configure
configure.in
daemons/clvmd/Makefile.in
daemons/clvmd/lvm-functions.c

index af63fc5d9ba2d827286ab833af6358404d6d47a9..e07d6074f3c83d2f5950ce3e528fc9bfc5ad93b5 100644 (file)
@@ -37,7 +37,7 @@ endif
 
 include make.tmpl
 
-daemons: lib
+daemons: lib tools
 lib: include
 tools: lib
 po: tools daemons
index 84e620ad0d45c3f608a947d4fdd9eabd30a89aea..8a16e0ed85ae94b939064ab7c965a597d5100995 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -4,6 +4,7 @@ Version 2.01.04 -
   Remove unused -f from pvmove.
   Gulm clvmd doesn't report "connection refused" errors.
   clvmd does a basic config file sanity check at startup.
+  clvmd now uses liblvm2cmd to preload the lock state rather than popen
 
 Version 2.01.03 - 1st February 2005
 ===================================
index 7a6cff5d6e93779cb7effc857c047c57996d11ac..c0a8906cc9089cc939e282fec28f5428aee8f905 100755 (executable)
--- a/configure
+++ b/configure
@@ -7413,7 +7413,8 @@ fi;
 echo "$as_me:$LINENO: result: $CMDLIB" >&5
 echo "${ECHO_T}$CMDLIB" >&6
 
-if test x$CMDLIB = xyes; then
+if test x$CMDLIB = xyes -o x$CLVMD != none; then
+       CMDLIB="yes"
        CFLAGS="$CFLAGS -DCMDLIB"
 fi
 
index 02ae9b891e3742ede05708589700450049546890..332dbd7bd99364b15c112149113265283dad5afd 100644 (file)
@@ -344,7 +344,8 @@ AC_ARG_ENABLE(cmdlib, [  --enable-cmdlib         Build shared command library],
 CMDLIB=$enableval, CMDLIB=no)
 AC_MSG_RESULT($CMDLIB)
 
-if test x$CMDLIB = xyes; then
+if test x$CMDLIB = xyes -o x$CLVMD != none; then
+       CMDLIB="yes"
        CFLAGS="$CFLAGS -DCMDLIB"
 fi
 
index 7ffd515696557b0013cfc1d28deed1e76944c263..81dd3fc4fd06bafe55153c9294b606cc975eec61 100644 (file)
@@ -52,7 +52,7 @@ TARGETS = \
 include $(top_srcdir)/make.tmpl
 
 CFLAGS += -D_REENTRANT -fno-strict-aliasing
-LIBS += -ldevmapper -llvm -lpthread
+LIBS += -L../../tools -ldevmapper -llvm -Wl,-Bstatic -llvm2cmd -Wl,-Bdynamic -lpthread
 
 INSTALL_TARGETS = \
        install_clvmd
index a3635d306cb03d413eb380b5ef06f632323b7ddb..59bdedd8e0e5b881306a11075c51c6605508d50b 100644 (file)
@@ -43,6 +43,7 @@
 #include "activate.h"
 #include "hash.h"
 #include "locking.h"
+#include "../tools/lvm2cmd.h"
 
 static struct cmd_context *cmd = NULL;
 static struct hash_table *lv_hash = NULL;
@@ -388,29 +389,19 @@ int do_check_lvm1(char *vgname)
        return status == 1 ? 0 : EBUSY;
 }
 
-/*
- * Ideally, clvmd should be started before any LVs are active
- * but this may not be the case...
- * I suppose this also comes in handy if clvmd crashes, not that it would!
- */
-static void *get_initial_state()
+static void cmdline_output(int level, const char *file, int line,
+                          const char *message)
 {
-       char lv[64], vg[64], flags[25];
-       char uuid[65];
-       char line[255];
-       FILE *lvs =
-           popen
-           ("/sbin/lvm lvs --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr",
-            "r");
-
-       if (!lvs)
-               return NULL;
+       DEBUGLOG("lvm2output: %d: %s\n", level, message);
+       if (level == LVM2_LOG_PRINT)
+       {
+               char lv[64], vg[64], flags[25];
+               char uuid[65];
 
-       while (fgets(line, sizeof(line), lvs)) {
-               if (sscanf(line, "%s %s %s\n", vg, lv, flags) == 3) {
+               if (sscanf(message, "%s %s %s\n", vg, lv, flags) == 3) {
 
                        /* States: s:suspended a:active S:dropped snapshot I:invalid snapshot */
-                       if (strlen(vg) == 38 &&                         /* is is a valid UUID ? */
+                       if (strlen(vg) == 38 &&                         /* is is a valid UUID ? */
                            (flags[4] == 'a' || flags[4] == 's')) {     /* is it active or suspended? */
                                /* Convert hyphen-separated UUIDs into one */
                                memcpy(&uuid[0], &vg[0], 6);
@@ -434,8 +425,32 @@ static void *get_initial_state()
                        }
                }
        }
-       fclose(lvs);
-       return NULL;
+}
+
+/*
+ * Ideally, clvmd should be started before any LVs are active
+ * but this may not be the case...
+ * I suppose this also comes in handy if clvmd crashes, not that it would!
+ */
+static void get_initial_state()
+{
+       void *lvm2_handle;
+
+       lvm2_handle = lvm2_init();
+       if (!lvm2_handle) {
+               syslog(LOG_ERR, "Cannot get lvm2 context to initialise lock state\n");
+               return;
+       }
+
+       lvm2_log_fn(cmdline_output);
+
+       /* This doesn't seem to do what I think it does */
+       lvm2_log_level(lvm2_handle, LVM2_LOG_PRINT);
+
+       DEBUGLOG("Getting currently active LVs for lock state\n");
+       lvm2_run(lvm2_handle, "lvs --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr");
+
+       lvm2_exit(lvm2_handle);
 }
 
 /* This checks some basic cluster-LVM configuration stuff */
This page took 0.058572 seconds and 5 git commands to generate.