ctdb-recoverd: Store recovery lock handle
authorMartin Schwenke <martin@meltin.net>
Mon, 3 Sep 2018 02:39:32 +0000 (12:39 +1000)
committerMartin Schwenke <martins@samba.org>
Mon, 17 Sep 2018 20:58:20 +0000 (22:58 +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>
ctdb/server/ctdb_recoverd.c

index 4655dcc496af1e1fe99dbdbf06bb26394e757ccf..46357b6ed690905ae2fe05f39b566397f473495f 100644 (file)
@@ -239,6 +239,8 @@ struct ctdb_banning_state {
        struct timeval last_reported_time;
 };
 
+struct ctdb_recovery_lock_handle;
+
 /*
   private state of recovery daemon
  */
@@ -260,7 +262,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)
@@ -885,6 +887,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,
@@ -940,7 +943,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,
@@ -959,17 +962,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;
 }