]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
util.c: include poll.h instead of sys/poll.h
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index f1b0b952ab535c25f77236c8e9d020d0802c8091..96a806d4ee236d26d3a85908a768a5c186fdd885 100644 (file)
--- a/util.c
+++ b/util.c
@@ -24,7 +24,6 @@
 
 #include       "mdadm.h"
 #include       "md_p.h"
-#include       <sys/poll.h>
 #include       <sys/socket.h>
 #include       <sys/utsname.h>
 #include       <sys/wait.h>
@@ -32,6 +31,7 @@
 #include       <sys/resource.h>
 #include       <sys/vfs.h>
 #include       <linux/magic.h>
+#include       <poll.h>
 #include       <ctype.h>
 #include       <dirent.h>
 #include       <signal.h>
@@ -82,8 +82,15 @@ struct blkpg_partition {
    aren't permitted). */
 #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
 
-static struct dlm_hooks *dlm_hooks = NULL;
 static int is_dlm_hooks_ready = 0;
+
+int dlm_funs_ready(void)
+{
+       return is_dlm_hooks_ready ? 1 : 0;
+}
+
+#ifndef MDASSEMBLE
+static struct dlm_hooks *dlm_hooks = NULL;
 struct dlm_lock_resource *dlm_lock_res = NULL;
 static int ast_called = 0;
 
@@ -92,11 +99,6 @@ struct dlm_lock_resource {
        struct dlm_lksb lksb;
 };
 
-int dlm_funs_ready(void)
-{
-       return is_dlm_hooks_ready ? 1 : 0;
-}
-
 /* Using poll(2) to wait for and dispatch ASTs */
 static int poll_for_ast(dlm_lshandle_t ls)
 {
@@ -142,7 +144,7 @@ int cluster_get_dlmlock(int *lockid)
        dlm_lock_res->ls = dlm_hooks->create_lockspace(cluster_name, O_RDWR);
        if (!dlm_lock_res->ls) {
                pr_err("%s failed to create lockspace\n", cluster_name);
-                goto out;
+               return -ENOMEM;
        }
 
        /* Conversions need the lockid in the LKSB */
@@ -157,21 +159,15 @@ int cluster_get_dlmlock(int *lockid)
                          dlm_lock_res, NULL, NULL);
        if (ret) {
                pr_err("error %d when get PW mode on lock %s\n", errno, str);
-                goto out;
+               dlm_hooks->release_lockspace(cluster_name, dlm_lock_res->ls, 1);
+               return ret;
        }
 
        /* Wait for it to complete */
        poll_for_ast(dlm_lock_res->ls);
        *lockid = dlm_lock_res->lksb.sb_lkid;
 
-       errno = dlm_lock_res->lksb.sb_status;
-       if (errno) {
-               pr_err("error %d happened in ast with lock %s\n", errno, str);
-               goto out;
-       }
-
-out:
-       return ret;
+       return dlm_lock_res->lksb.sb_status;
 }
 
 int cluster_release_dlmlock(int lockid)
@@ -212,6 +208,16 @@ int cluster_release_dlmlock(int lockid)
 out:
        return ret;
 }
+#else
+int cluster_get_dlmlock(int *lockid)
+{
+       return -1;
+}
+int cluster_release_dlmlock(int lockid)
+{
+       return -1;
+}
+#endif
 
 /*
  * Parse a 128 bit uuid in 4 integers
@@ -1261,7 +1267,7 @@ struct supertype *guess_super_type(int fd, enum guess_types guess_type)
         */
        struct superswitch  *ss;
        struct supertype *st;
-       time_t besttime = 0;
+       unsigned int besttime = 0;
        int bestsuper = -1;
        int i;
 
@@ -2121,10 +2127,10 @@ void reopen_mddev(int mdfd)
                dup2(fd, mdfd);
 }
 
+#ifndef MDASSEMBLE
 static struct cmap_hooks *cmap_hooks = NULL;
 static int is_cmap_hooks_ready = 0;
 
-#ifndef MDASSEMBLE
 void set_cmap_hooks(void)
 {
        cmap_hooks = xmalloc(sizeof(struct cmap_hooks));