[SCM] CTDB repository - branch 2.5 updated - ctdb-2.5.3-139-g0bd495e

Amitay Isaacs amitay at samba.org
Mon Sep 8 19:37:42 MDT 2014


The branch, 2.5 has been updated
       via  0bd495ebafb5d423b98934e219a2c097603c005a (commit)
       via  a4a0110190db276a1f5b0b241c43bd0e2396e6d4 (commit)
       via  105ab9eb094b22e20a1fa608e73a9e1e27ed66ac (commit)
       via  7b1b3681ca5dcfc2ede1b67fc93c5209a5acfa3f (commit)
       via  b33ca5b8313b33ddab915783d24c78ff268268cf (commit)
       via  424b21f1120d3ff6a221825b8191c9e559642b1b (commit)
       via  9ab3de9ba5ed69c3885b3e96523118b70adfd41b (commit)
       via  2de35be0c54bd8d28344914ccf558dfeabe5d1a1 (commit)
       via  1351f1aef3fbb6074c5a796b3c261b7a0748f1ce (commit)
      from  3afcd643c86b50a2f88fb0800491295b5e4e29b8 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=2.5


- Log -----------------------------------------------------------------
commit 0bd495ebafb5d423b98934e219a2c097603c005a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Sep 2 16:10:20 2014 +1000

    call: Drop all deferred requests from older generation
    
    Deferring packets has a nasty interaction with recovery.  All deferred
    packets must be dropped when recovery happens, since those packets are
    tracked as pending requests and will be re-sent with new generation.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Fri Sep  5 09:30:50 CEST 2014 on sn-devel-104
    
    (Imported from commit 2c57cc9597cb9cfe5ab3a458df74d6b5cda45465)

commit a4a0110190db276a1f5b0b241c43bd0e2396e6d4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Aug 19 21:49:59 2014 +1000

    locking: Do not reset real-time priority for lock helpers
    
    When using TDB robust mutexes, the kernel wakes waiting processes one
    by one, in the priority list order.  To ensure that ctdb lock helper
    processes do not starve, lock helper processes need to run at a higher
    priority than smbd.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 6f072f85a138f595494dbec137bcf23d1e666acc)

commit 105ab9eb094b22e20a1fa608e73a9e1e27ed66ac
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 15 15:20:36 2014 +1000

    daemon: Defer all calls when processing dmaster packets
    
    When CTDB receives DMASTER_REQUEST or DMASTER_REPLY packet, the specified
    record needs to be updated as soon as possible to avoid inconsistent
    dmaster information between nodes.  During this time, queue up all calls
    for that record and process them only after dmaster request/reply has
    been processed.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit ef59f2e6bbd502f7cb58ad3a74a6448ccd1ebe59)

commit 7b1b3681ca5dcfc2ede1b67fc93c5209a5acfa3f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 15 13:33:24 2014 +1000

    daemon: Remove duplicate code with refactored function
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit deb7bb89b3844f209ef73cc5707fcb4673bf08d7)

commit b33ca5b8313b33ddab915783d24c78ff268268cf
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 15 13:22:29 2014 +1000

    common: Refactor code to convert TDB_DATA key to aligned uint32 array
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit bd133894672fcf3c79868605466ba7b527af3018)

commit 424b21f1120d3ff6a221825b8191c9e559642b1b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 15 13:31:37 2014 +1000

    include: Remove declaration of non-existent function
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 13d5af48ac514621a6a820ba800771a7fdb4fe75)

commit 9ab3de9ba5ed69c3885b3e96523118b70adfd41b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 11 17:10:23 2014 +1000

    locking: Remove unused function ctdb_free_lock_request_context
    
    There is no need for a special function to free lock request and
    corresponding lock context.  Freeing lock request will free lock
    context also.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 2592ae5a56e813bb7cb68789f93fc281b1822a82)

commit 2de35be0c54bd8d28344914ccf558dfeabe5d1a1
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 11 17:08:20 2014 +1000

    locking: Talloc lock request from client specified context
    
    This makes sure that when the client context is destroyed, the lock
    request goes away.  If the lock requests is already scheduled, then the
    lock child process will be terminated.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit 374cbc7b0ff68e04ee4e395935509c7df817b3c0)

commit 1351f1aef3fbb6074c5a796b3c261b7a0748f1ce
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 11 16:43:07 2014 +1000

    locking: Run debug locks script only if the node is active
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    (Imported from commit d9e4622a446c9ed60771c508638fb89055320f03)

-----------------------------------------------------------------------

Summary of changes:
 common/ctdb_util.c        |   18 +++++
 include/ctdb_private.h    |   18 +++--
 server/ctdb_call.c        |  158 +++++++++++++++++++++++++++++++++++++++++----
 server/ctdb_daemon.c      |   10 +--
 server/ctdb_freeze.c      |    4 +-
 server/ctdb_lock.c        |   48 ++++++++------
 server/ctdb_lock_helper.c |    2 -
 server/ctdb_ltdb_server.c |   10 +++-
 8 files changed, 214 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index b9b0ad7..bdff425 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -490,3 +490,21 @@ void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate)
 			    runstate_to_string(runstate), runstate));
 	ctdb->runstate = runstate;
 }
+
+/* Convert arbitrary data to 4-byte boundary padded uint32 array */
+uint32_t *ctdb_key_to_idkey(TALLOC_CTX *mem_ctx, TDB_DATA key)
+{
+	uint32_t idkey_size, *k;
+
+	idkey_size = 1 + (key.dsize + sizeof(uint32_t)-1) / sizeof(uint32_t);
+
+	k = talloc_zero_array(mem_ctx, uint32_t, idkey_size);
+	if (k == NULL) {
+		return NULL;
+	}
+
+	k[0] = idkey_size;
+	memcpy(&k[1], key.dptr, key.dsize);
+
+	return k;
+}
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 36ebe70..ef9bd89 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -594,6 +594,7 @@ struct ctdb_db_context {
 	   so we can avoid sending duplicate fetch requests
 	*/
 	struct trbt_tree *deferred_fetch;
+	struct trbt_tree *defer_dmaster;
 
 	struct ctdb_db_statistics statistics;
 
@@ -731,7 +732,8 @@ int ctdb_parse_address(struct ctdb_context *ctdb,
 bool ctdb_same_ip(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
 bool ctdb_same_sockaddr(const ctdb_sock_addr *ip1, const ctdb_sock_addr *ip2);
 uint32_t ctdb_hash(const TDB_DATA *key);
-uint32_t ctdb_hash_string(const char *str);
+uint32_t *ctdb_key_to_idkey(TALLOC_CTX *mem_ctx, TDB_DATA key);
+
 void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
 void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
 void ctdb_request_message(struct ctdb_context *ctdb, struct ctdb_req_header *hdr);
@@ -1580,26 +1582,28 @@ struct lock_request;
 int ctdb_lockall_mark_prio(struct ctdb_context *ctdb, uint32_t priority);
 int ctdb_lockall_unmark_prio(struct ctdb_context *ctdb, uint32_t priority);
 
-void ctdb_lock_free_request_context(struct lock_request *lock_req);
-
-struct lock_request *ctdb_lock_record(struct ctdb_db_context *ctdb_db,
+struct lock_request *ctdb_lock_record(TALLOC_CTX *mem_ctx,
+				      struct ctdb_db_context *ctdb_db,
 				      TDB_DATA key,
 				      bool auto_mark,
 				      void (*callback)(void *, bool),
 				      void *private_data);
 
-struct lock_request *ctdb_lock_db(struct ctdb_db_context *ctdb_db,
+struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
+				  struct ctdb_db_context *ctdb_db,
 				  bool auto_mark,
 				  void (*callback)(void *, bool),
 				  void *private_data);
 
-struct lock_request *ctdb_lock_alldb_prio(struct ctdb_context *ctdb,
+struct lock_request *ctdb_lock_alldb_prio(TALLOC_CTX *mem_ctx,
+					  struct ctdb_context *ctdb,
 					  uint32_t priority,
 					  bool auto_mark,
 					  void (*callback)(void *, bool),
 					  void *private_data);
 
-struct lock_request *ctdb_lock_alldb(struct ctdb_context *ctdb,
+struct lock_request *ctdb_lock_alldb(TALLOC_CTX *mem_ctx,
+				     struct ctdb_context *ctdb,
 				     bool auto_mark,
 				     void (*callback)(void *, bool),
 				     void *private_data);
diff --git a/server/ctdb_call.c b/server/ctdb_call.c
index 901e585..391dfb1 100644
--- a/server/ctdb_call.c
+++ b/server/ctdb_call.c
@@ -281,16 +281,13 @@ ctdb_set_sticky_pindown(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_
 	uint32_t *k;
 	struct ctdb_sticky_record *sr;
 
-	k = talloc_zero_size(tmp_ctx, ((key.dsize + 3) & 0xfffffffc) + 4);
+	k = ctdb_key_to_idkey(tmp_ctx, key);
 	if (k == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to allocate key for sticky record\n"));
 		talloc_free(tmp_ctx);
 		return -1;
 	}
 
-	k[0] = (key.dsize + 3) / 4 + 1;
-	memcpy(&k[1], key.dptr, key.dsize);
-
 	sr = trbt_lookuparray32(ctdb_db->sticky_records, k[0], &k[0]);
 	if (sr == NULL) {
 		talloc_free(tmp_ctx);
@@ -412,7 +409,140 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
 	}
 }
 
+struct dmaster_defer_call {
+	struct dmaster_defer_call *next, *prev;
+	struct ctdb_context *ctdb;
+	struct ctdb_req_header *hdr;
+};
+
+struct dmaster_defer_queue {
+	struct ctdb_context *ctdb;
+	uint32_t generation;
+	struct dmaster_defer_call *deferred_calls;
+};
+
+static void dmaster_defer_reprocess(struct tevent_context *ev,
+				    struct tevent_timer *te,
+				    struct timeval t,
+				    void *private_data)
+{
+	struct dmaster_defer_call *call = talloc_get_type(
+		private_data, struct dmaster_defer_call);
+
+	ctdb_input_pkt(call->ctdb, call->hdr);
+	talloc_free(call);
+}
+
+static int dmaster_defer_queue_destructor(struct dmaster_defer_queue *ddq)
+{
+	/* Ignore requests, if database recovery happens in-between. */
+	if (ddq->generation != ddq->ctdb->vnn_map->generation) {
+		return 0;
+	}
+
+	while (ddq->deferred_calls != NULL) {
+		struct dmaster_defer_call *call = ddq->deferred_calls;
+
+		DLIST_REMOVE(ddq->deferred_calls, call);
+
+		talloc_steal(call->ctdb, call);
+		tevent_add_timer(call->ctdb->ev, call, timeval_zero(),
+				 dmaster_defer_reprocess, call);
+	}
+	return 0;
+}
+
+static void *insert_ddq_callback(void *parm, void *data)
+{
+	if (data) {
+		talloc_free(data);
+	}
+	return parm;
+}
 
+/**
+ * This function is used to reigster a key in database that needs to be updated.
+ * Any requests for that key should get deferred till this is completed.
+ */
+static int dmaster_defer_setup(struct ctdb_db_context *ctdb_db,
+			       struct ctdb_req_header *hdr,
+			       TDB_DATA key)
+{
+	uint32_t *k;
+	struct dmaster_defer_queue *ddq;
+
+	k = ctdb_key_to_idkey(hdr, key);
+	if (k == NULL) {
+		DEBUG(DEBUG_ERR, ("Failed to allocate key for dmaster defer setup\n"));
+		return -1;
+	}
+
+	/* Already exists */
+	ddq = trbt_lookuparray32(ctdb_db->defer_dmaster, k[0], k);
+	if (ddq != NULL) {
+		talloc_free(k);
+		return 0;
+	}
+
+	ddq = talloc(hdr, struct dmaster_defer_queue);
+	if (ddq == NULL) {
+		DEBUG(DEBUG_ERR, ("Failed to allocate dmaster defer queue\n"));
+		talloc_free(k);
+		return -1;
+	}
+	ddq->ctdb = ctdb_db->ctdb;
+	ddq->generation = hdr->generation;
+	ddq->deferred_calls = NULL;
+
+	trbt_insertarray32_callback(ctdb_db->defer_dmaster, k[0], k,
+				    insert_ddq_callback, ddq);
+	talloc_set_destructor(ddq, dmaster_defer_queue_destructor);
+
+	talloc_free(k);
+	return 0;
+}
+
+static int dmaster_defer_add(struct ctdb_db_context *ctdb_db,
+			     struct ctdb_req_header *hdr,
+			     TDB_DATA key)
+{
+	struct dmaster_defer_queue *ddq;
+	struct dmaster_defer_call *call;
+	uint32_t *k;
+
+	k = ctdb_key_to_idkey(hdr, key);
+	if (k == NULL) {
+		DEBUG(DEBUG_ERR, ("Failed to allocate key for dmaster defer add\n"));
+		return -1;
+	}
+
+	ddq = trbt_lookuparray32(ctdb_db->defer_dmaster, k[0], k);
+	if (ddq == NULL) {
+		talloc_free(k);
+		return -1;
+	}
+
+	talloc_free(k);
+
+	if (ddq->generation != hdr->generation) {
+		talloc_set_destructor(ddq, NULL);
+		talloc_free(ddq);
+		return -1;
+	}
+
+	call = talloc(ddq, struct dmaster_defer_call);
+	if (call == NULL) {
+		DEBUG(DEBUG_ERR, ("Failed to allocate dmaster defer call\n"));
+		return -1;
+	}
+
+	call->ctdb = ctdb_db->ctdb;
+	call->hdr = talloc_steal(call, hdr);
+
+	DLIST_ADD_END(ddq->deferred_calls, call, NULL);
+
+	return 0;
+}
 
 /*
   called when a CTDB_REQ_DMASTER packet comes in
@@ -448,7 +578,9 @@ void ctdb_request_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr
 				c->db_id);
 		return;
 	}
-	
+
+	dmaster_defer_setup(ctdb_db, hdr, key);
+
 	/* fetch the current record */
 	ret = ctdb_ltdb_lock_fetch_requeue(ctdb_db, key, &header, hdr, &data2,
 					   ctdb_call_input_pkt, ctdb, false);
@@ -538,16 +670,13 @@ ctdb_make_record_sticky(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_
 	uint32_t *k;
 	struct ctdb_sticky_record *sr;
 
-	k = talloc_zero_size(tmp_ctx, ((key.dsize + 3) & 0xfffffffc) + 4);
+	k = ctdb_key_to_idkey(tmp_ctx, key);
 	if (k == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to allocate key for sticky record\n"));
 		talloc_free(tmp_ctx);
 		return -1;
 	}
 
-	k[0] = (key.dsize + 3) / 4 + 1;
-	memcpy(&k[1], key.dptr, key.dsize);
-
 	sr = trbt_lookuparray32(ctdb_db->sticky_records, k[0], &k[0]);
 	if (sr != NULL) {
 		talloc_free(tmp_ctx);
@@ -621,16 +750,13 @@ ctdb_defer_pinned_down_request(struct ctdb_context *ctdb, struct ctdb_db_context
 	struct ctdb_sticky_record *sr;
 	struct pinned_down_deferred_call *pinned_down;
 
-	k = talloc_zero_size(tmp_ctx, ((key.dsize + 3) & 0xfffffffc) + 4);
+	k = ctdb_key_to_idkey(tmp_ctx, key);
 	if (k == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to allocate key for sticky record\n"));
 		talloc_free(tmp_ctx);
 		return -1;
 	}
 
-	k[0] = (key.dsize + 3) / 4 + 1;
-	memcpy(&k[1], key.dptr, key.dsize);
-
 	sr = trbt_lookuparray32(ctdb_db->sticky_records, k[0], &k[0]);
 	if (sr == NULL) {
 		talloc_free(tmp_ctx);
@@ -769,6 +895,10 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 		}
 	}
 
+	if (dmaster_defer_add(ctdb_db, hdr, call->key) == 0) {
+		talloc_free(call);
+		return;
+	}
 
 	/* determine if we are the dmaster for this key. This also
 	   fetches the record data (if any), thus avoiding a 2nd fetch of the data 
@@ -1119,6 +1249,8 @@ void ctdb_reply_dmaster(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
 		       sizeof(record_flags));
 	}
 
+	dmaster_defer_setup(ctdb_db, hdr, key);
+
 	ret = ctdb_ltdb_lock_requeue(ctdb_db, key, hdr,
 				     ctdb_call_input_pkt, ctdb, false);
 	if (ret == -2) {
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index da2f42e..a9a0b8d 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -504,15 +504,12 @@ static int setup_deferred_fetch_locks(struct ctdb_db_context *ctdb_db, struct ct
 	uint32_t *k;
 	struct ctdb_deferred_fetch_queue *dfq;
 
-	k = talloc_zero_size(call, ((call->key.dsize + 3) & 0xfffffffc) + 4);
+	k = ctdb_key_to_idkey(call, call->key);
 	if (k == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to allocate key for deferred fetch\n"));
 		return -1;
 	}
 
-	k[0] = (call->key.dsize + 3) / 4 + 1;
-	memcpy(&k[1], call->key.dptr, call->key.dsize);
-
 	dfq  = talloc(call, struct ctdb_deferred_fetch_queue);
 	if (dfq == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to allocate key for deferred fetch queue structure\n"));
@@ -543,15 +540,12 @@ static int requeue_duplicate_fetch(struct ctdb_db_context *ctdb_db, struct ctdb_
 	struct ctdb_deferred_fetch_queue *dfq;
 	struct ctdb_deferred_fetch_call *dfc;
 
-	k = talloc_zero_size(c, ((key.dsize + 3) & 0xfffffffc) + 4);
+	k = ctdb_key_to_idkey(c, key);
 	if (k == NULL) {
 		DEBUG(DEBUG_ERR,("Failed to allocate key for deferred fetch\n"));
 		return -1;
 	}
 
-	k[0] = (key.dsize + 3) / 4 + 1;
-	memcpy(&k[1], key.dptr, key.dsize);
-
 	dfq = trbt_lookuparray32(ctdb_db->deferred_fetch, k[0], &k[0]);
 	if (dfq == NULL) {
 		talloc_free(k);
diff --git a/server/ctdb_freeze.c b/server/ctdb_freeze.c
index 42a1285..d68b018 100644
--- a/server/ctdb_freeze.c
+++ b/server/ctdb_freeze.c
@@ -75,7 +75,6 @@ static int ctdb_freeze_handle_destructor(struct ctdb_freeze_handle *h)
 	ctdb->freeze_mode[h->priority]    = CTDB_FREEZE_NONE;
 	ctdb->freeze_handles[h->priority] = NULL;
 
-	ctdb_lock_free_request_context(h->lreq);
 	return 0;
 }
 
@@ -153,7 +152,8 @@ void ctdb_start_freeze(struct ctdb_context *ctdb, uint32_t priority)
 		h->priority = priority;
 		talloc_set_destructor(h, ctdb_freeze_handle_destructor);
 
-		h->lreq = ctdb_lock_alldb_prio(ctdb, priority, false, ctdb_freeze_lock_handler, h);
+		h->lreq = ctdb_lock_alldb_prio(h, ctdb, priority, false,
+					       ctdb_freeze_lock_handler, h);
 		CTDB_NO_MEMORY_FATAL(ctdb, h->lreq);
 		ctdb->freeze_handles[priority] = h;
 		ctdb->freeze_mode[priority] = CTDB_FREEZE_PENDING;
diff --git a/server/ctdb_lock.c b/server/ctdb_lock.c
index 8a239d8..2735d26 100644
--- a/server/ctdb_lock.c
+++ b/server/ctdb_lock.c
@@ -272,6 +272,9 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb);
  */
 static int ctdb_lock_context_destructor(struct lock_context *lock_ctx)
 {
+	if (lock_ctx->request) {
+		lock_ctx->request->lctx = NULL;
+	}
 	if (lock_ctx->child > 0) {
 		ctdb_kill(lock_ctx->ctdb, lock_ctx->child, SIGKILL);
 		if (lock_ctx->type == LOCK_RECORD) {
@@ -309,20 +312,10 @@ static int ctdb_lock_context_destructor(struct lock_context *lock_ctx)
  */
 static int ctdb_lock_request_destructor(struct lock_request *lock_request)
 {
-	lock_request->lctx->request = NULL;
+	TALLOC_FREE(lock_request->lctx);
 	return 0;
 }
 
-void ctdb_lock_free_request_context(struct lock_request *lock_req)
-{
-	struct lock_context *lock_ctx;
-
-	lock_ctx = lock_req->lctx;
-	talloc_free(lock_req);
-	talloc_free(lock_ctx);
-}
-
-
 /*
  * Process all the callbacks waiting for lock
  *
@@ -497,6 +490,10 @@ static void ctdb_lock_timeout_handler(struct tevent_context *ev,
 	lock_ctx = talloc_get_type_abort(private_data, struct lock_context);
 	ctdb = lock_ctx->ctdb;
 
+	/* If a node stopped/banned, don't spam the logs */
+	if (ctdb->nodes[ctdb->pnn]->flags & NODE_FLAGS_INACTIVE) {
+		return;
+	}
 	if (lock_ctx->ctdb_db) {
 		DEBUG(DEBUG_WARNING,
 		      ("Unable to get %s lock on database %s for %.0lf seconds\n",
@@ -854,7 +851,8 @@ static void ctdb_lock_schedule(struct ctdb_context *ctdb)
 /*
  * Lock record / db depending on type
  */
-static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
+static struct lock_request *ctdb_lock_internal(TALLOC_CTX *mem_ctx,
+					       struct ctdb_context *ctdb,
 					       struct ctdb_db_context *ctdb_db,
 					       TDB_DATA key,
 					       uint32_t priority,
@@ -877,7 +875,7 @@ static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
 		return NULL;
 	}
 
-	if ((request = talloc_zero(lock_ctx, struct lock_request)) == NULL) {
+	if ((request = talloc_zero(mem_ctx, struct lock_request)) == NULL) {
 		talloc_free(lock_ctx);
 		return NULL;
 	}
@@ -934,13 +932,15 @@ static struct lock_request *ctdb_lock_internal(struct ctdb_context *ctdb,
 /*
  * obtain a lock on a record in a database
  */
-struct lock_request *ctdb_lock_record(struct ctdb_db_context *ctdb_db,
+struct lock_request *ctdb_lock_record(TALLOC_CTX *mem_ctx,
+				      struct ctdb_db_context *ctdb_db,
 				      TDB_DATA key,
 				      bool auto_mark,
 				      void (*callback)(void *, bool),
 				      void *private_data)
 {
-	return ctdb_lock_internal(ctdb_db->ctdb,
+	return ctdb_lock_internal(mem_ctx,
+				  ctdb_db->ctdb,
 				  ctdb_db,
 				  key,
 				  0,
@@ -954,12 +954,14 @@ struct lock_request *ctdb_lock_record(struct ctdb_db_context *ctdb_db,
 /*
  * obtain a lock on a database
  */
-struct lock_request *ctdb_lock_db(struct ctdb_db_context *ctdb_db,
+struct lock_request *ctdb_lock_db(TALLOC_CTX *mem_ctx,
+				  struct ctdb_db_context *ctdb_db,
 				  bool auto_mark,
 				  void (*callback)(void *, bool),
 				  void *private_data)
 {
-	return ctdb_lock_internal(ctdb_db->ctdb,
+	return ctdb_lock_internal(mem_ctx,
+				  ctdb_db->ctdb,
 				  ctdb_db,
 				  tdb_null,
 				  0,
@@ -973,7 +975,8 @@ struct lock_request *ctdb_lock_db(struct ctdb_db_context *ctdb_db,
 /*
  * obtain locks on all databases of specified priority
  */
-struct lock_request *ctdb_lock_alldb_prio(struct ctdb_context *ctdb,
+struct lock_request *ctdb_lock_alldb_prio(TALLOC_CTX *mem_ctx,
+					  struct ctdb_context *ctdb,
 					  uint32_t priority,
 					  bool auto_mark,
 					  void (*callback)(void *, bool),
@@ -984,7 +987,8 @@ struct lock_request *ctdb_lock_alldb_prio(struct ctdb_context *ctdb,
 		return NULL;
 	}
 
-	return ctdb_lock_internal(ctdb,
+	return ctdb_lock_internal(mem_ctx,
+				  ctdb,
 				  NULL,
 				  tdb_null,
 				  priority,
@@ -998,12 +1002,14 @@ struct lock_request *ctdb_lock_alldb_prio(struct ctdb_context *ctdb,
 /*
  * obtain locks on all databases
  */
-struct lock_request *ctdb_lock_alldb(struct ctdb_context *ctdb,
+struct lock_request *ctdb_lock_alldb(TALLOC_CTX *mem_ctx,


-- 
CTDB repository


More information about the samba-cvs mailing list