[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Thu Jun 29 12:44:02 UTC 2017


The branch, master has been updated
       via  c5a5989 ctdb-tests: Add transaction/recovery test for replicated database
       via  ebaaf22 ctdb-tests: Generalize transaction_loop test
       via  5f86d09 ctdb-tests: Support replicated db in tool tests
       via  a388fe1 ctdb-tests: Add database type option for tests
       via  d74eb95 ctdb-tools: Allow attach for replicated databases
       via  006c1b6 ctdb-client: Add db support for CTDB_DB_FLAGS_REPLICATED
       via  b1b6cee ctdb-client: Add sync api for DB_ATTACH_REPLICATED control
       via  b783b93 ctdb-protocol: Add marshalling for CTDB_CONTROL_DB_ATTACH_REPLICATED control
       via  b8a0420 ctdb-daemon: Add implementation for CTDB_CONTROL_DB_ATTACH_REPLICATED control
       via  99113c4 ctdb-protocol: Add new control CTDB_CONTROL_DB_ATTACH_REPLICATED
       via  4e60637 ctdb-daemon: Add accessors for CTDB_DB_FLAGS_REPLICATED flag
       via  cb7e5e7 ctdb-daemon: Calculate tdb flags for replicated databases
       via  d66c5c2 ctdb-protocol: Add CTDB_DB_FLAGS_REPLICATED for new type of database
       via  0ca3f5a ctdb-client: Store db_flags instead of a boolean persistent flag
       via  1e10f22 ctdb-recovery: Use db_flags instead of a boolean persistent flag
       via  a29411d ctdb-daemon: Pass db_flags instead of passing persistent flag
       via  7c462b0 ctdb-daemon: Store db_flags instead of individual boolean flags
       via  4e43a34 ctdb-daemon: Add accessors for CTDB_DB_FLAGS_STICKY flag
       via  d0fa710 ctdb-daemon: Add accessors for CTDB_DB_FLAGS_READONLY flag
       via  94af277 ctdb-daemon: Add accessors for CTDB_DB_FLAGS_PERSISTENT flag
       via  2975de6 ctdb-protocol: Add DB_OPEN_FLAGS control to debug
       via  87308ea ctdb-tests: Fix control reply data for DB_ATTACH_PERSISTENT control
      from  6249602 tests py_credentials: Fix encrypt_netr_crypt_password test

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c5a59893d017dc9926612bd9fbc09fc1cf8c9a66
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Mar 21 15:36:36 2017 +1100

    ctdb-tests: Add transaction/recovery test for replicated database
    
    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): Thu Jun 29 14:43:44 CEST 2017 on sn-devel-144

commit ebaaf226ca3f7437e5f36fda12031b23c7c57336
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 18:15:05 2017 +1100

    ctdb-tests: Generalize transaction_loop test
    
    Instead of hard-coding the database name, it's passed as an argument
    along with database type.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 5f86d0934ba1f9fb5d478e5e719c23dcdc2e0681
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Apr 4 17:02:38 2017 +1000

    ctdb-tests: Support replicated db in tool tests
    
    This updates and adds unit tests for database operations.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit a388fe15231da71b256844180f46d64d990a5ab6
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 18:14:44 2017 +1100

    ctdb-tests: Add database type option for tests
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit d74eb9577d0af17cf11fc6cbf5893bf076d8871b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 17:36:59 2017 +1100

    ctdb-tools: Allow attach for replicated databases
    
    ... and update the output from various database query commands.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 006c1b68115336049d10b56c12627422b22ed654
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 17:34:55 2017 +1100

    ctdb-client: Add db support for CTDB_DB_FLAGS_REPLICATED
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit b1b6ceecedaa85529f33a17dd64ba307ee5cbe2e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Jun 26 15:55:15 2017 +1000

    ctdb-client: Add sync api for DB_ATTACH_REPLICATED control
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit b783b930de52554457647258bd4d843db912a38b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 17:07:13 2017 +1100

    ctdb-protocol: Add marshalling for CTDB_CONTROL_DB_ATTACH_REPLICATED control
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit b8a0420d10021c5521335f81effaeb28f43fd307
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 16:38:58 2017 +1100

    ctdb-daemon: Add implementation for CTDB_CONTROL_DB_ATTACH_REPLICATED control
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 99113c4c88c8e3f54d14600a30064948359a97db
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Mar 1 09:51:32 2017 +1100

    ctdb-protocol: Add new control CTDB_CONTROL_DB_ATTACH_REPLICATED
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 4e60637b31d90509b8a1a6f5ca0b70e2dbe2eac0
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 16:36:55 2017 +1100

    ctdb-daemon: Add accessors for CTDB_DB_FLAGS_REPLICATED flag
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit cb7e5e76905a900c8ad4488ba49ade90c2abe93d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue May 2 00:59:46 2017 +1000

    ctdb-daemon: Calculate tdb flags for replicated databases
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit d66c5c20b9fcb45b7ebf9b31adc7d4c5f0262351
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Feb 16 18:44:38 2017 +1100

    ctdb-protocol: Add CTDB_DB_FLAGS_REPLICATED for new type of database
    
    persistent: replicated and permanent
    volatile: distributed and temporary
    replicated: replicated and temporary
    
    This type of database will be used by CTDB for storing it's state.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 0ca3f5aef6e73cefeac11a3af0753cb9f81b59ef
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 17:29:04 2017 +1100

    ctdb-client: Store db_flags instead of a boolean persistent flag
    
    ... and add accessors for CTDB_DB_FLAGS_PERSISTENT flag.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 1e10f224ff7c4301af088697f0eb889e3b856126
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 16:19:11 2017 +1100

    ctdb-recovery: Use db_flags instead of a boolean persistent flag
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit a29411d6c792a127b9f0c1c00882283d97facb45
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 16:07:32 2017 +1100

    ctdb-daemon: Pass db_flags instead of passing persistent flag
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 7c462b0df873a42a5f0a19887c0a3d7f12993ddd
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 15:53:17 2017 +1100

    ctdb-daemon: Store db_flags instead of individual boolean flags
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 4e43a344cc30679d8326ba1b2c6ddf459ac6d0bb
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 15:47:46 2017 +1100

    ctdb-daemon: Add accessors for CTDB_DB_FLAGS_STICKY flag
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit d0fa710ea10049c69ec8cb155444a35ecad4b538
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 15:44:48 2017 +1100

    ctdb-daemon: Add accessors for CTDB_DB_FLAGS_READONLY flag
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 94af277c489f0ad861c6923d91286f46f9e4d29b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 2 15:39:29 2017 +1100

    ctdb-daemon: Add accessors for CTDB_DB_FLAGS_PERSISTENT flag
    
    This allows to differentiate between the two database models.
    
    ctdb_db_persistent() - replicated and permanent
    ctdb_db_volatile() - distributed and temporary
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 2975de6ffbb412e241ed44d64dd549de76c1d03a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jun 28 16:41:49 2017 +1000

    ctdb-protocol: Add DB_OPEN_FLAGS control to debug
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 87308ead4edf7e8fbdfc079c114abb3d4be18517
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jun 28 16:39:13 2017 +1000

    ctdb-tests: Fix control reply data for DB_ATTACH_PERSISTENT control
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 ctdb/client/client_control_sync.c                  | 30 ++++++++
 ctdb/client/client_db.c                            | 49 ++++++++++---
 ctdb/client/client_private.h                       |  2 +-
 ctdb/client/client_sync.h                          |  6 ++
 ctdb/client/ctdb_client.c                          |  9 ++-
 ctdb/common/common.h                               | 11 +++
 ctdb/common/ctdb_ltdb.c                            | 70 +++++++++++++++++-
 ctdb/doc/ctdb.1.xml                                | 27 ++++---
 ctdb/include/ctdb_private.h                        |  6 +-
 ctdb/protocol/protocol.h                           |  2 +
 ctdb/protocol/protocol_api.h                       |  5 ++
 ctdb/protocol/protocol_client.c                    | 27 +++++++
 ctdb/protocol/protocol_control.c                   | 26 +++++++
 ctdb/protocol/protocol_debug.c                     |  2 +
 ctdb/server/ctdb_call.c                            | 11 +--
 ctdb/server/ctdb_control.c                         | 12 +++-
 ctdb/server/ctdb_daemon.c                          |  2 +-
 ctdb/server/ctdb_freeze.c                          |  2 +-
 ctdb/server/ctdb_ltdb_server.c                     | 82 ++++++++++++----------
 ctdb/server/ctdb_recover.c                         | 20 ++----
 ctdb/server/ctdb_recovery_helper.c                 | 23 +++---
 ctdb/server/ctdb_traverse.c                        |  6 +-
 ctdb/server/ctdb_update_record.c                   |  2 +-
 ctdb/server/ctdb_vacuum.c                          |  6 +-
 ctdb/tests/cunit/protocol_test_002.sh              |  2 +-
 ctdb/tests/simple/53_transaction_loop.sh           |  9 ++-
 ctdb/tests/simple/54_transaction_loop_recovery.sh  |  9 ++-
 ...ry.sh => 56_replicated_transaction_recovery.sh} | 12 ++--
 ctdb/tests/src/fake_ctdbd.c                        |  7 +-
 ctdb/tests/src/protocol_client_test.c              | 20 +++++-
 ctdb/tests/src/test_options.c                      |  9 +++
 ctdb/tests/src/test_options.h                      |  1 +
 ctdb/tests/src/transaction_loop.c                  | 31 ++++----
 ctdb/tests/tool/ctdb.getdbmap.001.sh               |  6 +-
 ctdb/tests/tool/ctdb.getdbseqnum.001.sh            | 10 +++
 ctdb/tests/tool/ctdb.getdbseqnum.002.sh            |  8 +++
 ctdb/tests/tool/ctdb.getdbstatus.001.sh            | 31 ++++++++
 ctdb/tests/tool/ctdb.getdbstatus.002.sh            | 31 ++++++++
 ctdb/tests/tool/ctdb.setdbreadonly.001.sh          | 10 ++-
 ctdb/tests/tool/ctdb.setdbreadonly.002.sh          |  6 +-
 ctdb/tests/tool/ctdb.setdbreadonly.003.sh          |  8 ++-
 ctdb/tests/tool/ctdb.setdbreadonly.004.sh          |  6 +-
 ...dbreadonly.003.sh => ctdb.setdbreadonly.005.sh} | 12 ++--
 ctdb/tests/tool/ctdb.setdbsticky.001.sh            | 10 ++-
 ctdb/tests/tool/ctdb.setdbsticky.002.sh            |  6 +-
 ctdb/tests/tool/ctdb.setdbsticky.003.sh            |  8 ++-
 ctdb/tests/tool/ctdb.setdbsticky.004.sh            |  6 +-
 ...etdbreadonly.003.sh => ctdb.setdbsticky.005.sh} | 12 ++--
 ctdb/tools/ctdb.c                                  | 66 ++++++++++-------
 49 files changed, 595 insertions(+), 179 deletions(-)
 copy ctdb/tests/simple/{54_transaction_loop_recovery.sh => 56_replicated_transaction_recovery.sh} (73%)
 copy ctdb/tests/tool/{ctdb.setdbreadonly.003.sh => ctdb.setdbreadonly.005.sh} (67%)
 copy ctdb/tests/tool/{ctdb.setdbreadonly.003.sh => ctdb.setdbsticky.005.sh} (67%)


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c
index db2d7be..43a941d 100644
--- a/ctdb/client/client_control_sync.c
+++ b/ctdb/client/client_control_sync.c
@@ -2728,3 +2728,33 @@ int ctdb_ctrl_db_open_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 
 	return 0;
 }
+
+int ctdb_ctrl_db_attach_replicated(TALLOC_CTX *mem_ctx,
+				   struct tevent_context *ev,
+				   struct ctdb_client_context *client,
+				   int destnode, struct timeval timeout,
+				   const char *db_name, uint32_t *db_id)
+{
+	struct ctdb_req_control request;
+	struct ctdb_reply_control *reply;
+	int ret;
+
+	ctdb_req_control_db_attach_replicated(&request, db_name);
+	ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout,
+				  &request, &reply);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,
+		      ("Control DB_ATTACH_REPLICATED failed to node %u,"
+		       " ret=%d\n", destnode, ret));
+		return ret;
+	}
+
+	ret = ctdb_reply_control_db_attach_replicated(reply, db_id);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,
+		      ("Control DB_ATTACH_REPLICATED failed, ret=%d\n", ret));
+		return ret;
+	}
+
+	return 0;
+}
diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c
index 8cf08ae..05645f5 100644
--- a/ctdb/client/client_db.c
+++ b/ctdb/client/client_db.c
@@ -52,6 +52,31 @@ static struct ctdb_db_context *client_db_handle(
 	return NULL;
 }
 
+static bool ctdb_db_persistent(struct ctdb_db_context *db)
+{
+	if (db->db_flags & CTDB_DB_FLAGS_PERSISTENT) {
+		return true;
+	}
+	return false;
+}
+
+static bool ctdb_db_replicated(struct ctdb_db_context *db)
+{
+	if (db->db_flags & CTDB_DB_FLAGS_REPLICATED) {
+		return true;
+	}
+	return false;
+}
+
+static bool ctdb_db_volatile(struct ctdb_db_context *db)
+{
+	if (db->db_flags & CTDB_DB_FLAGS_PERSISTENT ||
+	    db->db_flags & CTDB_DB_FLAGS_REPLICATED) {
+		return false;
+	}
+	return true;
+}
+
 struct ctdb_set_db_flags_state {
 	struct tevent_context *ev;
 	struct ctdb_client_context *client;
@@ -299,13 +324,14 @@ struct tevent_req *ctdb_attach_send(TALLOC_CTX *mem_ctx,
 		return tevent_req_post(req, ev);
 	}
 
-	if (db_flags & CTDB_DB_FLAGS_PERSISTENT) {
-		state->db->persistent = true;
-	}
+	state->db->db_flags = db_flags;
 
-	if (state->db->persistent) {
+	if (ctdb_db_persistent(state->db)) {
 		ctdb_req_control_db_attach_persistent(&request,
 						      state->db->db_name);
+	} else if (ctdb_db_replicated(state->db)) {
+		ctdb_req_control_db_attach_replicated(&request,
+						      state->db->db_name);
 	} else {
 		ctdb_req_control_db_attach(&request, state->db->db_name);
 	}
@@ -337,17 +363,22 @@ static void ctdb_attach_dbid_done(struct tevent_req *subreq)
 	if (! status) {
 		DEBUG(DEBUG_ERR, ("attach: %s %s failed, ret=%d\n",
 				  state->db->db_name,
-				  (state->db->persistent
+				  (ctdb_db_persistent(state->db)
 					? "DB_ATTACH_PERSISTENT"
-					: "DB_ATTACH"),
+					: (ctdb_db_replicated(state->db)
+						? "DB_ATTACH_REPLICATED"
+						: "DB_ATTACH")),
 				  ret));
 		tevent_req_error(req, ret);
 		return;
 	}
 
-	if (state->db->persistent) {
+	if (ctdb_db_persistent(state->db)) {
 		ret = ctdb_reply_control_db_attach_persistent(
 				reply, &state->db->db_id);
+	} else if (ctdb_db_replicated(state->db)) {
+		ret = ctdb_reply_control_db_attach_replicated(
+				reply, &state->db->db_id);
 	} else {
 		ret = ctdb_reply_control_db_attach(reply, &state->db->db_id);
 	}
@@ -1173,7 +1204,7 @@ struct tevent_req *ctdb_fetch_lock_send(TALLOC_CTX *mem_ctx,
 	state->pnn = ctdb_client_pnn(client);
 
 	/* Check that database is not persistent */
-	if (db->persistent) {
+	if (! ctdb_db_volatile(db)) {
 		DEBUG(DEBUG_ERR, ("fetch_lock: %s database not volatile\n",
 				  db->db_name));
 		tevent_req_error(req, EINVAL);
@@ -2082,7 +2113,7 @@ struct tevent_req *ctdb_transaction_start_send(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 
-	if (! db->persistent) {
+	if (ctdb_db_volatile(db)) {
 		tevent_req_error(req, EINVAL);
 		return tevent_req_post(req, ev);
 	}
diff --git a/ctdb/client/client_private.h b/ctdb/client/client_private.h
index 7ea9b12..5af019b 100644
--- a/ctdb/client/client_private.h
+++ b/ctdb/client/client_private.h
@@ -26,10 +26,10 @@
 struct ctdb_db_context {
 	struct ctdb_db_context *prev, *next;
 	uint32_t db_id;
+	uint8_t db_flags;
 	const char *db_name;
 	const char *db_path;
 	struct tdb_wrap *ltdb;
-	bool persistent;
 };
 
 struct ctdb_client_context {
diff --git a/ctdb/client/client_sync.h b/ctdb/client/client_sync.h
index 7bf58e6..a4b5c49 100644
--- a/ctdb/client/client_sync.h
+++ b/ctdb/client/client_sync.h
@@ -488,6 +488,12 @@ int ctdb_ctrl_db_open_flags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
 			    int destnode, struct timeval timeout,
 			    uint32_t db_id, int *tdb_flags);
 
+int ctdb_ctrl_db_attach_replicated(TALLOC_CTX *mem_ctx,
+				   struct tevent_context *ev,
+				   struct ctdb_client_context *client,
+				   int destnode, struct timeval timeout,
+				   const char *db_name, uint32_t *db_id);
+
 /* from client/client_message_sync.c */
 
 int ctdb_message_recd_update_ip(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index cc23b05..5ec3d00 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -933,8 +933,9 @@ again:
 */
 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data)
 {
-	if (h->ctdb_db->persistent) {
-		DEBUG(DEBUG_ERR, (__location__ " ctdb_record_store prohibited for persistent dbs\n"));
+	if (! ctdb_db_volatile(h->ctdb_db)) {
+		DEBUG(DEBUG_ERR,
+		      ("ctdb_record_store prohibited for non-volatile dbs\n"));
 		return -1;
 	}
 
@@ -2175,7 +2176,9 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
 		return NULL;
 	}
 
-	ctdb_db->persistent = persistent;
+	if (persistent) {
+		ctdb_db->db_flags = CTDB_DB_FLAGS_PERSISTENT;
+	}
 
 	DLIST_ADD(ctdb->db_list, ctdb_db);
 
diff --git a/ctdb/common/common.h b/ctdb/common/common.h
index 0423c5e..1b276ca 100644
--- a/ctdb/common/common.h
+++ b/ctdb/common/common.h
@@ -44,6 +44,17 @@ int ctdb_db_tdb_flags(uint8_t db_flags, bool with_valgrind, bool with_mutex);
 struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb,
 				       const char *name);
 
+bool ctdb_db_persistent(struct ctdb_db_context *ctdb_db);
+bool ctdb_db_replicated(struct ctdb_db_context *ctdb_db);
+bool ctdb_db_volatile(struct ctdb_db_context *ctdb_db);
+
+bool ctdb_db_readonly(struct ctdb_db_context *ctdb_db);
+void ctdb_db_set_readonly(struct ctdb_db_context *ctdb_db);
+void ctdb_db_reset_readonly(struct ctdb_db_context *ctdb_db);
+
+bool ctdb_db_sticky(struct ctdb_db_context *ctdb_db);
+void ctdb_db_set_sticky(struct ctdb_db_context *ctdb_db);
+
 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key);
 
 int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c
index 34ebe6a..f4f216e 100644
--- a/ctdb/common/ctdb_ltdb.c
+++ b/ctdb/common/ctdb_ltdb.c
@@ -43,6 +43,12 @@ int ctdb_db_tdb_flags(uint8_t db_flags, bool with_valgrind, bool with_mutex)
 
 	if (db_flags & CTDB_DB_FLAGS_PERSISTENT) {
 		tdb_flags = TDB_DEFAULT;
+
+	} else if (db_flags & CTDB_DB_FLAGS_REPLICATED) {
+		tdb_flags = TDB_NOSYNC |
+			    TDB_CLEAR_IF_FIRST |
+			    TDB_INCOMPATIBLE_HASH;
+
 	} else {
 		tdb_flags = TDB_NOSYNC |
 			    TDB_CLEAR_IF_FIRST |
@@ -78,6 +84,61 @@ struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *na
 	return NULL;
 }
 
+bool ctdb_db_persistent(struct ctdb_db_context *ctdb_db)
+{
+	if (ctdb_db->db_flags & CTDB_DB_FLAGS_PERSISTENT) {
+		return true;
+	}
+	return false;
+}
+
+bool ctdb_db_replicated(struct ctdb_db_context *ctdb_db)
+{
+	if (ctdb_db->db_flags & CTDB_DB_FLAGS_REPLICATED) {
+		return true;
+	}
+	return false;
+}
+
+bool ctdb_db_volatile(struct ctdb_db_context *ctdb_db)
+{
+	if ((ctdb_db->db_flags & CTDB_DB_FLAGS_PERSISTENT) ||
+	    (ctdb_db->db_flags & CTDB_DB_FLAGS_REPLICATED)) {
+		return false;
+	}
+	return true;
+}
+
+bool ctdb_db_readonly(struct ctdb_db_context *ctdb_db)
+{
+	if (ctdb_db->db_flags & CTDB_DB_FLAGS_READONLY) {
+		return true;
+	}
+	return false;
+}
+
+void ctdb_db_set_readonly(struct ctdb_db_context *ctdb_db)
+{
+	ctdb_db->db_flags |= CTDB_DB_FLAGS_READONLY;
+}
+
+void ctdb_db_reset_readonly(struct ctdb_db_context *ctdb_db)
+{
+	ctdb_db->db_flags &= ~CTDB_DB_FLAGS_READONLY;
+}
+
+bool ctdb_db_sticky(struct ctdb_db_context *ctdb_db)
+{
+	if (ctdb_db->db_flags & CTDB_DB_FLAGS_STICKY) {
+		return true;
+	}
+	return false;
+}
+
+void ctdb_db_set_sticky(struct ctdb_db_context *ctdb_db)
+{
+	ctdb_db->db_flags |= CTDB_DB_FLAGS_STICKY;
+}
 
 /*
   return the lmaster given a key
@@ -133,7 +194,8 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
 		if (data) {
 			*data = tdb_null;
 		}
-		if (ctdb_db->persistent || header->dmaster == ctdb_db->ctdb->pnn) {
+		if (ctdb_db_persistent(ctdb_db) ||
+		    header->dmaster == ctdb_db->ctdb->pnn) {
 			if (ctdb_ltdb_store(ctdb_db, key, header, tdb_null) != 0) {
 				DEBUG(DEBUG_NOTICE,
 				      (__location__ "failed to store initial header\n"));
@@ -285,8 +347,10 @@ int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key)
 */
 int ctdb_ltdb_delete(struct ctdb_db_context *ctdb_db, TDB_DATA key)
 {
-	if (ctdb_db->persistent != 0) {
-		DEBUG(DEBUG_ERR,("Trying to delete empty record in persistent database\n"));
+	if (! ctdb_db_volatile(ctdb_db)) {
+		DEBUG(DEBUG_WARNING,
+		      ("Ignored deletion of empty record from "
+		       "non-volatile database\n"));
 		return 0;
 	}
 	if (tdb_delete(ctdb_db->ltdb->tdb, key) != 0) {
diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml
index ceab2d3..1af1f50 100644
--- a/ctdb/doc/ctdb.1.xml
+++ b/ctdb/doc/ctdb.1.xml
@@ -1363,14 +1363,22 @@ DB Statistics: locking.tdb
     <refsect2>
       <title>getdbmap</title>
       <para>
-	This command lists all clustered TDB databases that the CTDB daemon has attached to. Some databases are flagged as PERSISTENT, this means that the database stores data persistently and the data will remain across reboots. One example of such a database is secrets.tdb where information about how the cluster was joined to the domain is stored.
+	This command lists all clustered TDB databases that the CTDB
+	daemon has attached to. Some databases are flagged as PERSISTENT,
+	this means that the database stores data persistently and the
+	data will remain across reboots. One example of such a database
+	is secrets.tdb where information about how the cluster was joined
+	to the domain is stored.  Some database are flagged as REPLICATED,
+	this means that the data in that database is replicated across all
+	the nodes.  But the data will not remain across reboots.  This
+	type of database is used by CTDB to store it's internal state.
       </para>
       <para>
-	If a PERSISTENT database is not in a healthy state the database is
-	flagged as UNHEALTHY. If there's at least one completely healthy node running in
-	the cluster, it's possible that the content is restored by a recovery
-	run automaticly. Otherwise an administrator needs to analyze the
-	problem.
+	If a PERSISTENT database is not in a healthy state the database
+	is flagged as UNHEALTHY. If there's at least one completely
+	healthy node running in the cluster, it's possible that the
+	content is restored by a recovery run automaticly. Otherwise an
+	administrator needs to analyze the problem.
       </para>
       <para>
 	See also "ctdb getdbstatus", "ctdb backupdb", "ctdb restoredb",
@@ -1378,7 +1386,10 @@ DB Statistics: locking.tdb
 	and (if samba or tdb-utils are installed) "tdbtool check".
       </para>
       <para>
-	Most databases are not persistent and only store the state information that the currently running samba daemons need. These databases are always wiped when ctdb/samba starts and when a node is rebooted.
+	Most databases are not persistent and only store the state
+	information that the currently running samba daemons need. These
+	databases are always wiped when ctdb/samba starts and when a
+	node is rebooted.
       </para>
 
       <refsect3>
@@ -1755,7 +1766,7 @@ HEALTH: NO-HEALTHY-NODES - ERROR - Backup of corrupted TDB in '/usr/local/var/li
     </refsect2>
 
     <refsect2>
-      <title>attach <parameter>DBNAME</parameter> [persistent]</title>
+      <title>attach <parameter>DBNAME</parameter> [persistent|replicated]</title>
       <para>
 	Create a new CTDB database called DBNAME and attach to it on
 	all nodes.
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 8cdb4d8..067777a 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -344,9 +344,7 @@ struct ctdb_db_context {
 	struct ctdb_db_context *next, *prev;
 	struct ctdb_context *ctdb;
 	uint32_t db_id;
-	bool persistent;
-	bool readonly; /* Do we support read-only delegations ? */
-	bool sticky; /* Do we support sticky records ? */
+	uint8_t db_flags;
 	const char *db_name;
 	const char *db_path;
 	struct tdb_wrap *ltdb;
@@ -725,7 +723,7 @@ int ctdb_process_deferred_attach(struct ctdb_context *ctdb);
 
 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
 			       TDB_DATA *outdata,
-			       bool persistent, uint32_t client_id,
+			       uint8_t db_flags, uint32_t client_id,
 			       struct ctdb_req_control_old *c,
 			       bool *async_reply);
 int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h
index 7e99738..ee409f7 100644
--- a/ctdb/protocol/protocol.h
+++ b/ctdb/protocol/protocol.h
@@ -368,6 +368,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
 		    CTDB_CONTROL_DB_PUSH_START           = 147,
 		    CTDB_CONTROL_DB_PUSH_CONFIRM         = 148,
 		    CTDB_CONTROL_DB_OPEN_FLAGS           = 149,
+		    CTDB_CONTROL_DB_ATTACH_REPLICATED    = 150,
 };
 
 #define CTDB_MONITORING_ENABLED		0
@@ -456,6 +457,7 @@ struct ctdb_dbid {
 #define CTDB_DB_FLAGS_PERSISTENT	0x01
 #define CTDB_DB_FLAGS_READONLY		0x02
 #define CTDB_DB_FLAGS_STICKY		0x04
+#define CTDB_DB_FLAGS_REPLICATED	0x08
 	uint8_t flags;
 };
 
diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h
index 5666069..a887544 100644
--- a/ctdb/protocol/protocol_api.h
+++ b/ctdb/protocol/protocol_api.h
@@ -601,6 +601,11 @@ void ctdb_req_control_db_open_flags(struct ctdb_req_control *request,
 int ctdb_reply_control_db_open_flags(struct ctdb_reply_control *reply,
 				     int *tdb_flags);
 
+void ctdb_req_control_db_attach_replicated(struct ctdb_req_control *request,
+					   const char *db_name);
+int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply,
+					    uint32_t *db_id);
+
 /* From protocol/protocol_debug.c */
 
 void ctdb_packet_print(uint8_t *buf, size_t buflen, FILE *fp);
diff --git a/ctdb/protocol/protocol_client.c b/ctdb/protocol/protocol_client.c
index 018e157..daa70cc 100644
--- a/ctdb/protocol/protocol_client.c
+++ b/ctdb/protocol/protocol_client.c
@@ -2359,3 +2359,30 @@ int ctdb_reply_control_db_open_flags(struct ctdb_reply_control *reply,
 	}
 	return reply->status;
 }
+
+/* CTDB_CONTROL_DB_ATTACH_REPLICATED */
+
+void ctdb_req_control_db_attach_replicated(struct ctdb_req_control *request,
+					   const char *db_name)
+{
+	request->opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
+	request->pad = 0;
+	request->srvid = 0;
+	request->client_id = 0;
+	request->flags = 0;
+
+	request->rdata.opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
+	request->rdata.data.db_name = db_name;
+}
+
+int ctdb_reply_control_db_attach_replicated(struct ctdb_reply_control *reply,
+					    uint32_t *db_id)
+{
+	if (reply->rdata.opcode != CTDB_CONTROL_DB_ATTACH_REPLICATED) {
+		return EPROTO;
+	}
+	if (reply->status == 0) {
+		*db_id = reply->rdata.data.db_id;
+	}
+	return reply->status;
+}
diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c
index f542813..3c5c7ce 100644
--- a/ctdb/protocol/protocol_control.c
+++ b/ctdb/protocol/protocol_control.c
@@ -430,6 +430,10 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 	case CTDB_CONTROL_DB_OPEN_FLAGS:
 		len = ctdb_uint32_len(cd->data.db_id);
 		break;
+
+	case CTDB_CONTROL_DB_ATTACH_REPLICATED:
+		len = ctdb_string_len(cd->data.db_name);
+		break;
 	}
 
 	return len;
@@ -697,6 +701,10 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd,
 	case CTDB_CONTROL_DB_OPEN_FLAGS:
 		ctdb_uint32_push(cd->data.db_id, buf);
 		break;
+
+	case CTDB_CONTROL_DB_ATTACH_REPLICATED:
+		ctdb_string_push(cd->data.db_name, buf);
+		break;
 	}
 }
 
@@ -1032,6 +1040,11 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen,
 		ret = ctdb_uint32_pull(buf, buflen, mem_ctx,
 				       &cd->data.db_id);
 		break;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list