[SCM] CTDB repository - branch 1.0.82 updated - ctdb-1.0.82-52-gb09f54e

Ronnie Sahlberg sahlberg at samba.org
Tue Oct 13 03:59:20 MDT 2009


The branch, 1.0.82 has been updated
       via  b09f54e0ad5ad3a9a495ab25e56a84422b8679b5 (commit)
       via  05e809e791dfcdf3bf7f8382171e8ebde6c0165b (commit)
       via  0ca3f46f11502a1a53c86fcbcd6cc9c5b3cfb2cd (commit)
       via  621dd1f8ed03bbda68a5d9a32b6e49db12f82751 (commit)
       via  b8aaa7ee2ff36267c2af386ae5eb18003c588d0d (commit)
       via  827ad3adb59814a16ce543632d52eaeb728cd61d (commit)
       via  653d5d16605679a751ba0eec7e9ab59ce9862519 (commit)
       via  9bd5815d67a2866ef7dbff4bcaa39df174ec10af (commit)
       via  75caa0051e78b9e71a62c77e4cf04d4ed767d1e2 (commit)
      from  5b470e788f9c40f5b510e62fbfd1b990779f2c57 (commit)

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


- Log -----------------------------------------------------------------
commit b09f54e0ad5ad3a9a495ab25e56a84422b8679b5
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:58:40 2009 +1100

    version 1.0.82-12

commit 05e809e791dfcdf3bf7f8382171e8ebde6c0165b
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:57:03 2009 +1100

    From Volker L
    
    A less intrusive deadlock prevention workaround

commit 0ca3f46f11502a1a53c86fcbcd6cc9c5b3cfb2cd
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:56:08 2009 +1100

    Revert "add a control to set a database priority. Let newly created databases default to priority 1."
    
    This reverts commit 808b4a6ed9f6122a958146ef6ac6665f0e75fe32.

commit 621dd1f8ed03bbda68a5d9a32b6e49db12f82751
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:56:00 2009 +1100

    Revert "add a control to read the db priority from a database"
    
    This reverts commit 17516689570e352d5df1b5a6bae3d7c7e4bb5662.

commit b8aaa7ee2ff36267c2af386ae5eb18003c588d0d
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:55:52 2009 +1100

    Revert "during recovery, update all remote nodes so they use the same priorities"
    
    This reverts commit 9bbce3e37e213080e974afea551e9147a43a44af.

commit 827ad3adb59814a16ce543632d52eaeb728cd61d
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:55:43 2009 +1100

    Revert "uptade the freeze/thaw commands to be able to send the requested database priority to freeze/thaw to the daemon."
    
    This reverts commit a92210bc9572851df327862b325376d56470823c.

commit 653d5d16605679a751ba0eec7e9ab59ce9862519
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:55:36 2009 +1100

    Revert "initial attempt at freezing databases in priority order"
    
    This reverts commit 499e781b065f5195e021f33d428503b59b2189b8.

commit 9bd5815d67a2866ef7dbff4bcaa39df174ec10af
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:55:28 2009 +1100

    Revert "allow setting the recmode even when not completely frozen."
    
    This reverts commit 575210997f7e9aebc721d584b00bf7def15ab600.

commit 75caa0051e78b9e71a62c77e4cf04d4ed767d1e2
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Tue Oct 13 20:55:18 2009 +1100

    Revert "new version 1.0.82-11"
    
    This reverts commit 5b470e788f9c40f5b510e62fbfd1b990779f2c57.

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

Summary of changes:
 client/ctdb_client.c      |   92 ++------------------
 include/ctdb.h            |   15 +---
 include/ctdb_private.h    |   17 +---
 packaging/RPM/ctdb.spec   |    8 +-
 server/ctdb_control.c     |   26 +-----
 server/ctdb_daemon.c      |    2 +-
 server/ctdb_freeze.c      |  209 +++++++++++++++++----------------------------
 server/ctdb_ltdb_server.c |   24 -----
 server/ctdb_monitor.c     |    9 +--
 server/ctdb_recover.c     |  106 +++++++++++------------
 server/ctdb_recoverd.c    |   93 ++++----------------
 tools/ctdb.c              |  108 ++++-------------------
 12 files changed, 191 insertions(+), 518 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index e60a72e..fa6a990 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -1943,9 +1943,9 @@ int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t
   async freeze send control
  */
 struct ctdb_client_control_state *
-ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t priority)
+ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode)
 {
-	return ctdb_control_send(ctdb, destnode, priority, 
+	return ctdb_control_send(ctdb, destnode, 0, 
 			   CTDB_CONTROL_FREEZE, 0, tdb_null, 
 			   mem_ctx, &timeout, NULL);
 }
@@ -1968,43 +1968,30 @@ int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct
 }
 
 /*
-  freeze databases of a certain priority
+  freeze a node
  */
-int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority)
+int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
 {
 	TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
 	struct ctdb_client_control_state *state;
 	int ret;
 
-	state = ctdb_ctrl_freeze_send(ctdb, tmp_ctx, timeout, destnode, priority);
+	state = ctdb_ctrl_freeze_send(ctdb, tmp_ctx, timeout, destnode);
 	ret = ctdb_ctrl_freeze_recv(ctdb, tmp_ctx, state);
 	talloc_free(tmp_ctx);
 
 	return ret;
 }
 
-/* Freeze all databases */
-int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
-{
-	int i;
-
-	for (i=1; i<=NUM_DB_PRIORITIES; i++) {
-		if (ctdb_ctrl_freeze_priority(ctdb, timeout, destnode, i) != 0) {
-			return -1;
-		}
-	}
-	return 0;
-}
-
 /*
-  thaw databases of a certain priority
+  thaw a node
  */
-int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority)
+int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
 {
 	int ret;
 	int32_t res;
 
-	ret = ctdb_control(ctdb, destnode, priority, 
+	ret = ctdb_control(ctdb, destnode, 0, 
 			   CTDB_CONTROL_THAW, 0, tdb_null, 
 			   NULL, NULL, &res, &timeout, NULL);
 	if (ret != 0 || res != 0) {
@@ -2015,12 +2002,6 @@ int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, u
 	return 0;
 }
 
-/* thaw all databases */
-int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
-{
-	return ctdb_ctrl_thaw_priority(ctdb, timeout, destnode, 0);
-}
-
 /*
   get pnn of a node, or -1
  */
@@ -2414,7 +2395,7 @@ int ctdb_ctrl_modflags(struct ctdb_context *ctdb, struct timeval timeout, uint32
 	nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
 
 	if (ctdb_client_async_control(ctdb, CTDB_CONTROL_MODIFY_FLAGS,
-					nodes, 0,
+					nodes,
 					timeout, false, data,
 					NULL, NULL,
 					NULL) != 0) {
@@ -2907,7 +2888,6 @@ int ctdb_client_async_wait(struct ctdb_context *ctdb, struct client_async_data *
 int ctdb_client_async_control(struct ctdb_context *ctdb,
 				enum ctdb_controls opcode,
 				uint32_t *nodes,
-				uint64_t srvid,
 				struct timeval timeout,
 				bool dont_log_errors,
 				TDB_DATA data,
@@ -2933,7 +2913,7 @@ int ctdb_client_async_control(struct ctdb_context *ctdb,
 	for (j=0; j<num_nodes; j++) {
 		uint32_t pnn = nodes[j];
 
-		state = ctdb_control_send(ctdb, pnn, srvid, opcode, 
+		state = ctdb_control_send(ctdb, pnn, 0, opcode, 
 					  0, data, async_data, &timeout, NULL);
 		if (state == NULL) {
 			DEBUG(DEBUG_ERR,(__location__ " Failed to call async control %u\n", (unsigned)opcode));
@@ -3656,55 +3636,3 @@ int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval
 
 	return 0;
 }
-
-int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio)
-{
-	int ret;
-	int32_t res;
-	TDB_DATA data;
-	TALLOC_CTX *tmp_ctx = talloc_new(NULL);
-
-	data.dptr = (uint8_t*)db_prio;
-	data.dsize = sizeof(*db_prio);
-
-	ret = ctdb_control(ctdb, destnode, 0, 
-			   CTDB_CONTROL_SET_DB_PRIORITY, 0, data,
-			   tmp_ctx, NULL, &res, &timeout, NULL);
-	if (ret != 0 || res != 0) {
-		DEBUG(DEBUG_ERR,(__location__ " ctdb_control for set_db_priority failed\n"));
-		talloc_free(tmp_ctx);
-		return -1;
-	}
-
-	talloc_free(tmp_ctx);
-
-	return 0;
-}
-
-int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority)
-{
-	int ret;
-	int32_t res;
-	TDB_DATA data;
-	TALLOC_CTX *tmp_ctx = talloc_new(NULL);
-
-	data.dptr = (uint8_t*)&db_id;
-	data.dsize = sizeof(db_id);
-
-	ret = ctdb_control(ctdb, destnode, 0, 
-			   CTDB_CONTROL_GET_DB_PRIORITY, 0, data,
-			   tmp_ctx, NULL, &res, &timeout, NULL);
-	if (ret != 0 || res < 0) {
-		DEBUG(DEBUG_ERR,(__location__ " ctdb_control for set_db_priority failed\n"));
-		talloc_free(tmp_ctx);
-		return -1;
-	}
-
-	if (priority) {
-		*priority = res;
-	}
-
-	talloc_free(tmp_ctx);
-
-	return 0;
-}
diff --git a/include/ctdb.h b/include/ctdb.h
index 34d3080..866ba76 100644
--- a/include/ctdb.h
+++ b/include/ctdb.h
@@ -453,18 +453,14 @@ int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t
 
 int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, 
 			uint32_t destnode);
-int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, 
-			      uint32_t destnode, uint32_t priority);
 
 struct ctdb_client_control_state *
 ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
-		      struct timeval timeout, uint32_t destnode,
-		      uint32_t priority);
+			struct timeval timeout, uint32_t destnode);
 
 int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, 
 			struct ctdb_client_control_state *state);
 
-int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority);
 int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
 
 int ctdb_ctrl_getpnn(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode);
@@ -640,13 +636,4 @@ int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
 		    TALLOC_CTX *mem_ctx, struct ctdb_monitoring_wire **script_status);
 
 
-
-struct ctdb_db_priority {
-	uint32_t db_id;
-	uint32_t priority;
-};
-
-int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio);
-int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority);
-
 #endif
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index b033949..2e3b472 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -364,7 +364,6 @@ enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN
 /* This capability is set if CTDB_LVS_PUBLIC_IP is set */
 #define CTDB_CAP_LVS			0x00000004
 
-#define NUM_DB_PRIORITIES 3
 /* main state of the ctdb daemon */
 struct ctdb_context {
 	struct event_context *ev;
@@ -375,10 +374,8 @@ struct ctdb_context {
 	TALLOC_CTX *tickle_update_context;
 	TALLOC_CTX *keepalive_ctx;
 	struct ctdb_tunable tunable;
-	enum ctdb_freeze_mode freeze_mode[NUM_DB_PRIORITIES+1];
-	struct ctdb_freeze_handle *freeze_handles[NUM_DB_PRIORITIES+1];
-	bool freeze_transaction_started;
-	uint32_t freeze_transaction_id;
+	enum ctdb_freeze_mode freeze_mode;
+	struct ctdb_freeze_handle *freeze_handle;
 	struct ctdb_address address;
 	const char *name;
 	const char *db_directory;
@@ -437,7 +434,6 @@ struct ctdb_db_context {
 	struct ctdb_db_context *next, *prev;
 	struct ctdb_context *ctdb;
 	uint32_t db_id;
-	uint32_t priority;
 	bool persistent;
 	const char *db_name;
 	const char *db_path;
@@ -579,8 +575,6 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
 		    CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS = 96,
 		    CTDB_CONTROL_TRAVERSE_KILL		 = 97,
 		    CTDB_CONTROL_RECD_RECLOCK_LATENCY    = 98,
-		    CTDB_CONTROL_SET_DB_PRIORITY         = 111,
-		    CTDB_CONTROL_GET_DB_PRIORITY         = 112,
 };	
 
 /*
@@ -1175,7 +1169,7 @@ void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_contr
 				TDB_DATA *outdata, int32_t status, const char *errormsg);
 
 int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply);
-int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority);
+int32_t ctdb_control_thaw(struct ctdb_context *ctdb);
 
 int ctdb_start_recoverd(struct ctdb_context *ctdb);
 void ctdb_stop_recoverd(struct ctdb_context *ctdb);
@@ -1314,7 +1308,7 @@ int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
 			       uint32_t destnode,
 			       struct ctdb_tunable *tunables);
 
-int ctdb_start_freeze(struct ctdb_context *ctdb, uint32_t priority);
+void ctdb_start_freeze(struct ctdb_context *ctdb);
 
 bool parse_ip_mask(const char *s, const char *iface, ctdb_sock_addr *addr, unsigned *mask);
 bool parse_ip_port(const char *s, ctdb_sock_addr *addr);
@@ -1409,7 +1403,6 @@ int ctdb_client_async_wait(struct ctdb_context *ctdb, struct client_async_data *
 int ctdb_client_async_control(struct ctdb_context *ctdb,
 				enum ctdb_controls opcode,
 				uint32_t *nodes,
-			      	uint64_t srvid,
 				struct timeval timeout,
 				bool dont_log_errors,
 				TDB_DATA data,
@@ -1456,6 +1449,4 @@ int ctdb_ctrl_report_recd_lock_latency(struct ctdb_context *ctdb, struct timeval
 
 int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
 
-int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
-
 #endif
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index 3699dbb..dc4e023 100644
--- a/packaging/RPM/ctdb.spec
+++ b/packaging/RPM/ctdb.spec
@@ -5,7 +5,7 @@ Vendor: Samba Team
 Packager: Samba Team <samba at samba.org>
 Name: ctdb
 Version: 1.0.82
-Release: 11
+Release: 12
 Epoch: 0
 License: GNU GPL version 3
 Group: System Environment/Daemons
@@ -133,10 +133,8 @@ fi
 %{_libdir}/pkgconfig/ctdb.pc
 
 %changelog
-* Mon Oct 12 2009 : Version 1.0.82-11
- - Backport the "freeze databases by priority" from HEAD to handle
-   that samba now can hold a log on a database while requesting data
-   from a different database.
+* Tue Oct 13 2009 : Version 1.0.82-12
+ - Revert the lock order patch and apply a simpler workaround from Volker instead.
 * Thu Oct 10 2009 : Version 1.0.82-10
  - Be very aggressive to ban nocdes that fails to freeze the databases
 * Fri Oct 2 2009 : Version 1.0.82-9
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index 1574039..f9bd424 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -98,15 +98,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 	}
 
 	case CTDB_CONTROL_STATISTICS: {
-		int i;
 		CHECK_CONTROL_DATA_SIZE(0);
 		ctdb->statistics.memory_used = talloc_total_size(NULL);
-		ctdb->statistics.frozen = 0;
-		for (i=1; i<= NUM_DB_PRIORITIES; i++) {
-			if (ctdb->freeze_mode[i] == CTDB_FREEZE_FROZEN) {
-				ctdb->statistics.frozen = 1;
-			}
-		}
+		ctdb->statistics.frozen = (ctdb->freeze_mode == CTDB_FREEZE_FROZEN);
 		ctdb->statistics.recovering = (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE);
 		outdata->dptr = (uint8_t *)&ctdb->statistics;
 		outdata->dsize = sizeof(ctdb->statistics);
@@ -255,7 +249,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 
 	case CTDB_CONTROL_THAW:
 		CHECK_CONTROL_DATA_SIZE(0);
-		return ctdb_control_thaw(ctdb, (uint32_t)c->srvid);
+		return ctdb_control_thaw(ctdb);
 
 	case CTDB_CONTROL_SET_RECMODE:
 		CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));		
@@ -451,22 +445,6 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 		CHECK_CONTROL_DATA_SIZE(sizeof(double));
 		ctdb_reclock_latency(ctdb, "recd reclock", &ctdb->statistics.reclock.recd, *((double *)indata.dptr));
 		return 0;
-
-	case CTDB_CONTROL_SET_DB_PRIORITY:
-		CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_db_priority));
-		return ctdb_control_set_db_priority(ctdb, indata);
-
-	case CTDB_CONTROL_GET_DB_PRIORITY: {
-		uint32_t db_id;
-		struct ctdb_db_context *ctdb_db;
-
-		CHECK_CONTROL_DATA_SIZE(sizeof(db_id));
-		db_id = *(uint32_t *)indata.dptr;
-		ctdb_db = find_ctdb_db(ctdb, db_id);
-		if (ctdb_db == NULL) return -1;
-		return ctdb_db->priority;
-	}
-
 	default:
 		DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
 		return -1;
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 5c4655d..1a94cfc 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -724,7 +724,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
 	}
 
 	/* start frozen, then let the first election sort things out */
-	if (ctdb_blocking_freeze(ctdb)) {
+	if (!ctdb_blocking_freeze(ctdb)) {
 		ctdb_fatal(ctdb, "Failed to get initial freeze\n");
 	}
 
diff --git a/server/ctdb_freeze.c b/server/ctdb_freeze.c
index 53a76f3..78493cb 100644
--- a/server/ctdb_freeze.c
+++ b/server/ctdb_freeze.c
@@ -30,14 +30,21 @@
 /*
   lock all databases
  */
-static int ctdb_lock_all_databases(struct ctdb_context *ctdb, uint32_t priority)
+static int ctdb_lock_all_databases(struct ctdb_context *ctdb)
 {
 	struct ctdb_db_context *ctdb_db;
 	for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
-		if (ctdb_db->priority != priority) {
+		if (strstr(ctdb_db->db_name, "notify") != NULL) {
+			continue;
+		}
+		if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
+			return -1;
+		}
+	}
+	for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
+		if (strstr(ctdb_db->db_name, "notify") == NULL) {
 			continue;
 		}
-		DEBUG(DEBUG_INFO,("locking database 0x%08x priority:%u %s\n", ctdb_db->db_id, ctdb_db->priority, ctdb_db->db_name));
 		if (tdb_lockall(ctdb_db->ltdb->tdb) != 0) {
 			return -1;
 		}
@@ -53,17 +60,17 @@ struct ctdb_freeze_waiter {
 	struct ctdb_freeze_waiter *next, *prev;
 	struct ctdb_context *ctdb;
 	struct ctdb_req_control *c;
-	uint32_t priority;
 	int32_t status;
 };
 
 /* a handle to a freeze lock child process */
 struct ctdb_freeze_handle {
 	struct ctdb_context *ctdb;
-	uint32_t priority;
 	pid_t child;
 	int fd;
 	struct ctdb_freeze_waiter *waiters;
+	bool transaction_started;
+	uint32_t transaction_id;
 };
 
 /*
@@ -74,14 +81,9 @@ static int ctdb_freeze_handle_destructor(struct ctdb_freeze_handle *h)
 	struct ctdb_context *ctdb = h->ctdb;
 	struct ctdb_db_context *ctdb_db;
 
-	DEBUG(DEBUG_ERR,("Release freeze handler for prio %u\n", h->priority));
-
 	/* cancel any pending transactions */
-	if (ctdb->freeze_transaction_started) {
+	if (ctdb->freeze_handle && ctdb->freeze_handle->transaction_started) {
 		for (ctdb_db=ctdb->db_list;ctdb_db;ctdb_db=ctdb_db->next) {
-			if (ctdb_db->priority != h->priority) {
-				continue;
-			}
 			tdb_add_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
 			if (tdb_transaction_cancel(ctdb_db->ltdb->tdb) != 0) {
 				DEBUG(DEBUG_ERR,(__location__ " Failed to cancel transaction for db '%s'\n",
@@ -89,11 +91,11 @@ static int ctdb_freeze_handle_destructor(struct ctdb_freeze_handle *h)
 			}
 			tdb_remove_flags(ctdb_db->ltdb->tdb, TDB_NOLOCK);
 		}
-		ctdb->freeze_transaction_started = false;
+		ctdb->freeze_handle->transaction_started = false;
 	}
 
-	ctdb->freeze_mode[h->priority]    = CTDB_FREEZE_NONE;
-	ctdb->freeze_handles[h->priority] = NULL;
+	ctdb->freeze_mode = CTDB_FREEZE_NONE;
+	ctdb->freeze_handle = NULL;
 
 	kill(h->child, SIGKILL);
 	return 0;
@@ -109,8 +111,11 @@ static void ctdb_freeze_lock_handler(struct event_context *ev, struct fd_event *
 	int32_t status;
 	struct ctdb_freeze_waiter *w;
 
-	if (h->ctdb->freeze_mode[h->priority] == CTDB_FREEZE_FROZEN) {
+	if (h->ctdb->freeze_mode == CTDB_FREEZE_FROZEN) {
 		DEBUG(DEBUG_INFO,("freeze child died - unfreezing\n"));
+		if (h->ctdb->freeze_handle == h) {
+			h->ctdb->freeze_handle = NULL;
+		}
 		talloc_free(h);
 		return;
 	}
@@ -127,12 +132,12 @@ static void ctdb_freeze_lock_handler(struct event_context *ev, struct fd_event *
 		return;
 	}
 
-	h->ctdb->freeze_mode[h->priority] = CTDB_FREEZE_FROZEN;
+	h->ctdb->freeze_mode = CTDB_FREEZE_FROZEN;
 
 	/* notify the waiters */
-	while ((w = h->ctdb->freeze_handles[h->priority]->waiters)) {
+	while ((w = h->ctdb->freeze_handle->waiters)) {
 		w->status = status;
-		DLIST_REMOVE(h->ctdb->freeze_handles[h->priority]->waiters, w);
+		DLIST_REMOVE(h->ctdb->freeze_handle->waiters, w);
 		talloc_free(w);
 	}
 }
@@ -141,7 +146,7 @@ static void ctdb_freeze_lock_handler(struct event_context *ev, struct fd_event *
   create a child which gets locks on all the open databases, then calls the callback telling the parent
   that it is done
  */
-static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, uint32_t priority)
+static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb)
 {
 	struct ctdb_freeze_handle *h;
 	int fd[2];
@@ -150,8 +155,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
 	h = talloc_zero(ctdb, struct ctdb_freeze_handle);
 	CTDB_NO_MEMORY_NULL(ctdb, h);
 
-	h->ctdb     = ctdb;
-	h->priority = priority;
+	h->ctdb = ctdb;
 
 	/* use socketpair() instead of pipe() so we have bi-directional fds */
 	if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != 0) {
@@ -172,7 +176,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
 		int count = 0;
 		/* in the child */
 		close(fd[0]);
-		ret = ctdb_lock_all_databases(ctdb, priority);
+		ret = ctdb_lock_all_databases(ctdb);


-- 
CTDB repository


More information about the samba-cvs mailing list