]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-recoverd: Store recovery lock handle
authorMartin Schwenke <martin@meltin.net>
Mon, 3 Sep 2018 02:39:32 +0000 (12:39 +1000)
committerKarolin Seeger <kseeger@samba.org>
Thu, 20 Sep 2018 07:13:12 +0000 (09:13 +0200)
... not just cluster mutex handle.

This makes the recovery lock handle long-lived and with allow the
releasing code to cancel an in-progress attempt to take the recovery
lock.

The cluster mutex handle is now allocated off the recovery lock
handle.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13617

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit c52216740bd81b68876de06e104822bbbca86df9)

ctdb/server/ctdb_recoverd.c

index 341e4c82fb96a21d13e0a732f1633309e9eacb23..3df319bb02242b176c8f1dd74da42ad6b4042a90 100644 (file)
@@ -237,6 +237,8 @@ struct ctdb_banning_state {
        struct timeval last_reported_time;
 };
 
+struct ctdb_recovery_lock_handle;
+
 /*
   private state of recovery daemon
  */
@@ -258,7 +260,7 @@ struct ctdb_recoverd {
        uint32_t *force_rebalance_nodes;
        struct ctdb_node_capabilities *caps;
        bool frozen_on_inactive;
-       struct ctdb_cluster_mutex_handle *recovery_lock_handle;
+       struct ctdb_recovery_lock_handle *recovery_lock_handle;
 };
 
 #define CONTROL_TIMEOUT() timeval_current_ofs(ctdb->tunable.recover_timeout, 0)
@@ -883,6 +885,7 @@ struct ctdb_recovery_lock_handle {
        bool done;
        bool locked;
        double latency;
+       struct ctdb_cluster_mutex_handle *h;
 };
 
 static void take_reclock_handler(char status,
@@ -938,7 +941,7 @@ static bool ctdb_recovery_lock(struct ctdb_recoverd *rec)
                return false;
        };
 
-       h = ctdb_cluster_mutex(rec,
+       h = ctdb_cluster_mutex(s,
                               ctdb,
                               ctdb->recovery_lock,
                               0,
@@ -957,17 +960,15 @@ static bool ctdb_recovery_lock(struct ctdb_recoverd *rec)
 
        if (! s->locked) {
                talloc_free(s);
-               talloc_free(h);
                return false;
        }
 
-       rec->recovery_lock_handle = h;
+       rec->recovery_lock_handle = s;
+       s->h = h;
        ctdb_ctrl_report_recd_lock_latency(ctdb,
                                           CONTROL_TIMEOUT(),
                                           s->latency);
 
-       talloc_free(s);
-
        return true;
 }