]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
util: fix wrong return value of cluster_get_dlmlock
authorGuoqing Jiang <gqjiang@suse.com>
Wed, 20 Jan 2016 08:21:25 +0000 (16:21 +0800)
committerNeilBrown <neilb@suse.com>
Wed, 27 Jan 2016 00:43:02 +0000 (11:43 +1100)
Actually lksb.sb_status means that a node got the lock
or not instead of the return value of dlm_lock.

Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
util.c

diff --git a/util.c b/util.c
index f1b0b952ab535c25f77236c8e9d020d0802c8091..cf9572bedb628dcf112696fa9f1a1f5b96bb9882 100644 (file)
--- a/util.c
+++ b/util.c
@@ -142,7 +142,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 +157,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)