[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Thu Oct 24 05:29:03 UTC 2019


The branch, master has been updated
       via  6de5706b4db ctdb-tests: Add vacuuming tests
       via  49262a6bc4d ctdb-tests: Add handling of process clean-up on a cluster node
       via  b9654085f5f ctdb-tests: Factor out function check_cattdb_num_records()
       via  5a6d319eea6 ctdb-tests: Add ctdb-db-test tool
       via  439ef65d290 ctdb-client: Factor out function client_db_tdb()
       via  41a41d5f3e2 ctdb-daemon: Implement DB_VACUUM control
       via  d462d64cdf0 ctdb-vacuum: Only schedule next vacuum event if vacuuuming is scheduled
       via  13cedaf0195 ctdb-daemon: Factor out code to create vacuuming child
       via  5539edfdbe6 ctdb-vacuum: Simplify recording of in-progress vacuuming child
       via  496204feb0e ctdb-protocol: Add marshalling for control DB_VACUUM
       via  a896486b62b ctdb-protocol: Add marshalling for struct ctdb_db_vacuum
       via  b314835341e ctdb-protocol: Add new control CTDB_CONTROL_DB_VACUUM
       via  d0cc9edc05b ctdb-vacuum: Avoid processing any more packets
       via  680df07630a ctdb-daemon: Avoid memory leak when packet is deferred
       via  c6427dddf54 ctdb-recoverd: No need for database detach handler
       via  fc81729dd2d ctdb-recoverd: Drop VACUUM_FETCH message handling
       via  498932c0e8e ctdb-vacuum: Replace VACUUM_FETCH message with control
       via  86521837b68 ctdb-vacuum: Add processing of fetch queue
       via  da617f90d90 ctdb-daemon: Add implementation of VACUUM_FETCH control
       via  36f9b4953a8 ctdb-tests: Add marshalling tests for new control
       via  b71d8cd80f8 ctdb-protocol: Add marshalling for new control VACUUM_FETCH
       via  0872c52ef04 ctdb-protocol: Add new control VACUUM_FETCH
       via  913bd331f65 ctdb-tests: Drop code releated to obsolete controls
       via  688567f0801 ctdb-protocol: Drop code related to obsolete controls
       via  9f41a9fc1ee ctdb: Avoid malloc/memcpy/free in ctdb_ltdb_fetch()
      from  6e8c3ae6e9b samba-tool: py3 compatiblity in 'user syncpasswords --daemon'

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


- Log -----------------------------------------------------------------
commit 6de5706b4dbe70c66872abc80dd9301dccb2ee7c
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 14 15:26:25 2019 +1000

    ctdb-tests: Add vacuuming tests
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Thu Oct 24 05:28:21 UTC 2019 on sn-devel-184

commit 49262a6bc4d5f8b81aa341294bfe04a22a6b32b6
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Sep 29 08:27:33 2019 +1000

    ctdb-tests: Add handling of process clean-up on a cluster node
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b9654085f5facfe8a3d64667d65793146563d7f5
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 12 21:02:47 2019 +1000

    ctdb-tests: Factor out function check_cattdb_num_records()
    
    This can be use in multiple vacuuming tests.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5a6d319eea6b281e9f4c35cf6c8889856234a9fd
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 1 15:33:52 2019 +1000

    ctdb-tests: Add ctdb-db-test tool
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 439ef65d290357e513103530183091a9a6fed197
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Sep 27 16:49:01 2019 +1000

    ctdb-client: Factor out function client_db_tdb()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 41a41d5f3e2b8e16e25221e14939dc5962997ac7
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 30 14:17:11 2019 +1000

    ctdb-daemon: Implement DB_VACUUM control
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d462d64cdf001fd5d1cbf2a109df62e087ad0c49
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Oct 15 16:36:44 2019 +1100

    ctdb-vacuum: Only schedule next vacuum event if vacuuuming is scheduled
    
    At the moment vacuuming is always scheduled.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 13cedaf0195c6bda3a3820aedb1ee65f36dfc23e
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 30 14:16:13 2019 +1000

    ctdb-daemon: Factor out code to create vacuuming child
    
    This changes the behaviour for some failures from exiting to simply
    attempting to schedule the next run.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5539edfdbe69d1d5f084d06753cce8ed6e524999
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Oct 4 12:06:21 2019 +1000

    ctdb-vacuum: Simplify recording of in-progress vacuuming child
    
    There can only be one, so simplify the logic.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 496204feb0e2b6eb2f3d9a74e45596a3e74ad9b1
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 30 10:52:05 2019 +1000

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

commit a896486b62bbcf9915727ba7bfc768fb5383f0c7
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 30 16:59:37 2019 +1000

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

commit b314835341e4028f0770fa7f9a37d2d21448ddfd
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 30 10:34:03 2019 +1000

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

commit d0cc9edc05b6218a8e20a0a8009cbb9918ff4d02
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Oct 1 15:05:10 2019 +1000

    ctdb-vacuum: Avoid processing any more packets
    
    All the vacuum operations if required have an event loop to ensure
    completion of pending operations.  Once all the steps are complete,
    there is no reason to process any more packets.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 680df07630a94b3e76edefe98ee0986e7e5e1f12
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jun 6 15:47:13 2018 +0200

    ctdb-daemon: Avoid memory leak when packet is deferred
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit c6427dddf5425b267d8c09e8df18653a48679646
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 16 17:17:38 2018 +1100

    ctdb-recoverd: No need for database detach handler
    
    The only reason for recoverd attaching to databases was to migrate
    records to the local node as part of vacuuming.  Recovery daemon does
    not take part in database vacuuming any more.
    
    The actual database recovery is handled via the recovery_helper and
    recovery daemon should not need to attach to the databases any more.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit fc81729dd2d8eddea1e60e22b183894d6541c7dc
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 16 17:13:35 2018 +1100

    ctdb-recoverd: Drop VACUUM_FETCH message handling
    
    This is now implemented in the ctdb daemon using VACUMM_FETCH control.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 498932c0e8e8614bd52f3270c4d63e2b5f9e26a4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 16 17:01:21 2018 +1100

    ctdb-vacuum: Replace VACUUM_FETCH message with control
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 86521837b684df3b7c5a0a1e3b7e606c8b91f63e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 16 17:00:40 2018 +1100

    ctdb-vacuum: Add processing of fetch queue
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit da617f90d90151f955ee354c57bdc4bc6f6498f2
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 16 15:30:13 2018 +1100

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

commit 36f9b4953a8def40681a6f02f6576795a1ba5fbe
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Feb 16 17:28:49 2018 +1100

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

commit b71d8cd80f84169bacf2dd1e753e468a305c50ce
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Feb 15 11:57:44 2018 +1100

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

commit 0872c52ef0497f96f53318cf7e4d31be0854adde
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Feb 15 11:57:24 2018 +1100

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

commit 913bd331f65e9fe3d7cb16e041cd37b01987841f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Feb 15 12:28:11 2018 +1100

    ctdb-tests: Drop code releated to obsolete controls
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 688567f080156892270cbfb2907cd712cb77cb7a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Feb 15 12:13:53 2018 +1100

    ctdb-protocol: Drop code related to obsolete controls
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 9f41a9fc1ee10a28d379c8fda49ccfd295d66770
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 8 13:02:41 2019 +0200

    ctdb: Avoid malloc/memcpy/free in ctdb_ltdb_fetch()
    
    Make use of tdb_parse_record()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/client/client_db.c                            |  37 +-
 ctdb/client/client_private.h                       |   4 +
 ctdb/common/ctdb_ltdb.c                            | 103 ++-
 ctdb/include/ctdb_private.h                        |  10 +-
 ctdb/protocol/protocol.h                           |   9 +
 ctdb/protocol/protocol_api.h                       |   8 +
 ctdb/protocol/protocol_client.c                    |  57 +-
 ctdb/protocol/protocol_control.c                   | 107 ++-
 ctdb/protocol/protocol_debug.c                     |   2 +
 ctdb/protocol/protocol_private.h                   |  10 +
 ctdb/protocol/protocol_types.c                     |  63 ++
 ctdb/server/ctdb_control.c                         |  12 +
 ctdb/server/ctdb_freeze.c                          |   9 +-
 ctdb/server/ctdb_ltdb_server.c                     |  14 +-
 ctdb/server/ctdb_recoverd.c                        | 184 -----
 ctdb/server/ctdb_server.c                          |   3 +-
 ctdb/server/ctdb_vacuum.c                          | 535 ++++++++++++--
 .../database/recovery.003.no_resurrect.sh          |  13 +-
 ctdb/tests/INTEGRATION/database/scripts/local.bash |  84 +++
 ctdb/tests/INTEGRATION/database/vacuum.001.fast.sh | 159 +++++
 ctdb/tests/INTEGRATION/database/vacuum.002.full.sh |  96 +++
 .../INTEGRATION/database/vacuum.003.recreate.sh    | 139 ++++
 .../INTEGRATION/database/vacuum.030.locked.sh      | 102 +++
 .../INTEGRATION/database/vacuum.031.locked.sh      | 114 +++
 .../INTEGRATION/database/vacuum.032.locked.sh      | 102 +++
 .../INTEGRATION/database/vacuum.033.locked.sh      | 117 +++
 .../INTEGRATION/database/vacuum.034.locked.sh      | 129 ++++
 ctdb/tests/UNIT/cunit/protocol_test_101.sh         |   2 +-
 ctdb/tests/scripts/integration.bash                |  28 +
 ctdb/tests/src/db_test_tool.c                      | 790 +++++++++++++++++++++
 ctdb/tests/src/protocol_common.c                   |  13 +
 ctdb/tests/src/protocol_common.h                   |   4 +
 ctdb/tests/src/protocol_common_ctdb.c              | 108 +--
 ctdb/tests/src/protocol_ctdb_test.c                |   2 +-
 ctdb/tests/src/protocol_types_test.c               |   2 +
 ctdb/wscript                                       |   6 +
 36 files changed, 2699 insertions(+), 478 deletions(-)
 create mode 100644 ctdb/tests/INTEGRATION/database/scripts/local.bash
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.001.fast.sh
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.002.full.sh
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.003.recreate.sh
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.030.locked.sh
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.031.locked.sh
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.032.locked.sh
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.033.locked.sh
 create mode 100755 ctdb/tests/INTEGRATION/database/vacuum.034.locked.sh
 create mode 100644 ctdb/tests/src/db_test_tool.c


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c
index a008f2ad63d..0b06d6e5e52 100644
--- a/ctdb/client/client_db.c
+++ b/ctdb/client/client_db.c
@@ -37,6 +37,11 @@
 #include "client/client_private.h"
 #include "client/client.h"
 
+struct tdb_context *client_db_tdb(struct ctdb_db_context *db)
+{
+	return db->ltdb->tdb;
+}
+
 static struct ctdb_db_context *client_db_handle(
 					struct ctdb_client_context *client,
 					const char *db_name)
@@ -835,11 +840,11 @@ int ctdb_db_traverse_local(struct ctdb_db_context *db, bool readonly,
 	state.error = 0;
 
 	if (readonly) {
-		ret = tdb_traverse_read(db->ltdb->tdb,
+		ret = tdb_traverse_read(client_db_tdb(db),
 					ctdb_db_traverse_local_handler,
 					&state);
 	} else {
-		ret = tdb_traverse(db->ltdb->tdb,
+		ret = tdb_traverse(client_db_tdb(db),
 				   ctdb_db_traverse_local_handler, &state);
 	}
 
@@ -1105,14 +1110,14 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *db, TDB_DATA key,
 	size_t np;
 	int ret;
 
-	rec = tdb_fetch(db->ltdb->tdb, key);
+	rec = tdb_fetch(client_db_tdb(db), key);
 	if (rec.dsize < sizeof(struct ctdb_ltdb_header)) {
 		/* No record present */
 		if (rec.dptr != NULL) {
 			free(rec.dptr);
 		}
 
-		if (tdb_error(db->ltdb->tdb) != TDB_ERR_NOEXIST) {
+		if (tdb_error(client_db_tdb(db)) != TDB_ERR_NOEXIST) {
 			return EIO;
 		}
 
@@ -1235,18 +1240,18 @@ static int ctdb_fetch_lock_check(struct tevent_req *req)
 	int ret, err = 0;
 	bool do_migrate = false;
 
-	ret = tdb_chainlock(h->db->ltdb->tdb, h->key);
+	ret = tdb_chainlock(client_db_tdb(h->db), h->key);
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR,
 		      ("fetch_lock: %s tdb_chainlock failed, %s\n",
-		       h->db->db_name, tdb_errorstr(h->db->ltdb->tdb)));
+		       h->db->db_name, tdb_errorstr(client_db_tdb(h->db))));
 		err = EIO;
 		goto failed;
 	}
 
-	data = tdb_fetch(h->db->ltdb->tdb, h->key);
+	data = tdb_fetch(client_db_tdb(h->db), h->key);
 	if (data.dptr == NULL) {
-		if (tdb_error(h->db->ltdb->tdb) == TDB_ERR_NOEXIST) {
+		if (tdb_error(client_db_tdb(h->db)) == TDB_ERR_NOEXIST) {
 			goto migrate;
 		} else {
 			err = EIO;
@@ -1297,11 +1302,11 @@ failed:
 	if (data.dptr != NULL) {
 		free(data.dptr);
 	}
-	ret = tdb_chainunlock(h->db->ltdb->tdb, h->key);
+	ret = tdb_chainunlock(client_db_tdb(h->db), h->key);
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR,
 		      ("fetch_lock: %s tdb_chainunlock failed, %s\n",
-		       h->db->db_name, tdb_errorstr(h->db->ltdb->tdb)));
+		       h->db->db_name, tdb_errorstr(client_db_tdb(h->db))));
 		return EIO;
 	}
 
@@ -1377,11 +1382,11 @@ static int ctdb_record_handle_destructor(struct ctdb_record_handle *h)
 {
 	int ret;
 
-	ret = tdb_chainunlock(h->db->ltdb->tdb, h->key);
+	ret = tdb_chainunlock(client_db_tdb(h->db), h->key);
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR,
 		      ("fetch_lock: %s tdb_chainunlock failed, %s\n",
-		       h->db->db_name, tdb_errorstr(h->db->ltdb->tdb)));
+		       h->db->db_name, tdb_errorstr(client_db_tdb(h->db))));
 	}
 	free(h->data.dptr);
 	return 0;
@@ -1487,11 +1492,11 @@ int ctdb_store_record(struct ctdb_record_handle *h, TDB_DATA data)
 	rec[1].dsize = data.dsize;
 	rec[1].dptr = data.dptr;
 
-	ret = tdb_storev(h->db->ltdb->tdb, h->key, rec, 2, TDB_REPLACE);
+	ret = tdb_storev(client_db_tdb(h->db), h->key, rec, 2, TDB_REPLACE);
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR,
 		      ("store_record: %s tdb_storev failed, %s\n",
-		       h->db->db_name, tdb_errorstr(h->db->ltdb->tdb)));
+		       h->db->db_name, tdb_errorstr(client_db_tdb(h->db))));
 		return EIO;
 	}
 
@@ -1538,11 +1543,11 @@ struct tevent_req *ctdb_delete_record_send(TALLOC_CTX *mem_ctx,
 	rec.dsize = np;
 	rec.dptr = header;
 
-	ret = tdb_store(h->db->ltdb->tdb, h->key, rec, TDB_REPLACE);
+	ret = tdb_store(client_db_tdb(h->db), h->key, rec, TDB_REPLACE);
 	if (ret != 0) {
 		D_ERR("fetch_lock delete: %s tdb_store failed, %s\n",
 		      h->db->db_name,
-		      tdb_errorstr(h->db->ltdb->tdb));
+		      tdb_errorstr(client_db_tdb(h->db)));
 		tevent_req_error(req, EIO);
 		return tevent_req_post(req, ev);
 	}
diff --git a/ctdb/client/client_private.h b/ctdb/client/client_private.h
index bb1705534e6..0bb2ad590ea 100644
--- a/ctdb/client/client_private.h
+++ b/ctdb/client/client_private.h
@@ -77,6 +77,10 @@ struct ctdb_tunnel_context {
 void ctdb_client_reply_call(struct ctdb_client_context *client,
 			    uint8_t *buf, size_t buflen, uint32_t reqid);
 
+/* From client_db.c */
+
+struct tdb_context *client_db_tdb(struct ctdb_db_context *db);
+
 /* From client_message.c */
 
 void ctdb_client_req_message(struct ctdb_client_context *client,
diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c
index 73458754def..0b79ab44281 100644
--- a/ctdb/common/ctdb_ltdb.c
+++ b/ctdb/common/ctdb_ltdb.c
@@ -167,55 +167,96 @@ static void ltdb_initial_header(struct ctdb_db_context *ctdb_db,
 	header->flags = CTDB_REC_FLAG_AUTOMATIC;
 }
 
+struct ctdb_ltdb_fetch_state {
+	struct ctdb_ltdb_header *header;
+	TALLOC_CTX *mem_ctx;
+	TDB_DATA *data;
+	int ret;
+	bool found;
+};
+
+static int ctdb_ltdb_fetch_fn(TDB_DATA key, TDB_DATA data, void *private_data)
+{
+	struct ctdb_ltdb_fetch_state *state = private_data;
+	struct ctdb_ltdb_header *header = state->header;
+	TDB_DATA *dstdata = state->data;
+
+	if (data.dsize < sizeof(*header)) {
+		return 0;
+	}
+
+	state->found = true;
+	memcpy(header, data.dptr, sizeof(*header));
+
+	if (dstdata != NULL) {
+		dstdata->dsize = data.dsize - sizeof(struct ctdb_ltdb_header);
+		dstdata->dptr = talloc_memdup(
+			state->mem_ctx,
+			data.dptr + sizeof(struct ctdb_ltdb_header),
+			dstdata->dsize);
+		if (dstdata->dptr == NULL) {
+			state->ret = -1;
+		}
+	}
+
+	return 0;
+}
 
 /*
   fetch a record from the ltdb, separating out the header information
   and returning the body of the record. A valid (initial) header is
   returned if the record is not present
 */
-int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db, 
-		    TDB_DATA key, struct ctdb_ltdb_header *header, 
+int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db,
+		    TDB_DATA key, struct ctdb_ltdb_header *header,
 		    TALLOC_CTX *mem_ctx, TDB_DATA *data)
 {
-	TDB_DATA rec;
 	struct ctdb_context *ctdb = ctdb_db->ctdb;
+	struct ctdb_ltdb_fetch_state state = {
+		.header = header,
+		.mem_ctx = mem_ctx,
+		.data = data,
+		.found = false,
+	};
+	int ret;
 
-	rec = tdb_fetch(ctdb_db->ltdb->tdb, key);
-	if (rec.dsize < sizeof(*header)) {
-		/* return an initial header */
-		if (rec.dptr) free(rec.dptr);
-		if (ctdb->vnn_map == NULL) {
-			/* called from the client */
-			ZERO_STRUCTP(data);
-			header->dmaster = (uint32_t)-1;
+	ret = tdb_parse_record(
+		ctdb_db->ltdb->tdb, key, ctdb_ltdb_fetch_fn, &state);
+
+	if (ret == -1) {
+		enum TDB_ERROR err = tdb_error(ctdb_db->ltdb->tdb);
+		if (err != TDB_ERR_NOEXIST) {
 			return -1;
 		}
-		ltdb_initial_header(ctdb_db, key, header);
-		if (data) {
-			*data = tdb_null;
-		}
-		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"));
-			}
-		}
+	}
+
+	if (state.ret != 0) {
+		DBG_DEBUG("ctdb_ltdb_fetch_fn failed\n");
+		return state.ret;
+	}
+
+	if (state.found) {
 		return 0;
 	}
 
-	*header = *(struct ctdb_ltdb_header *)rec.dptr;
+	if (data != NULL) {
+		*data = tdb_null;
+	}
 
-	if (data) {
-		data->dsize = rec.dsize - sizeof(struct ctdb_ltdb_header);
-		data->dptr = talloc_memdup(mem_ctx, 
-					   sizeof(struct ctdb_ltdb_header)+rec.dptr,
-					   data->dsize);
+	if (ctdb->vnn_map == NULL) {
+		/* called from the client */
+		header->dmaster = (uint32_t)-1;
+		return -1;
 	}
 
-	free(rec.dptr);
-	if (data) {
-		CTDB_NO_MEMORY(ctdb, data->dptr);
+	ltdb_initial_header(ctdb_db, key, header);
+	if (ctdb_db_persistent(ctdb_db) ||
+	    header->dmaster == ctdb_db->ctdb->pnn) {
+
+		ret = ctdb_ltdb_store(ctdb_db, key, header, tdb_null);
+		if (ret != 0) {
+			DBG_NOTICE("failed to store initial header\n");
+		}
 	}
 
 	return 0;
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 1f168dae2b8..4f36c9a44a5 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -318,7 +318,7 @@ struct ctdb_context {
 
 	TALLOC_CTX *banning_ctx;
 
-	struct ctdb_vacuum_child_context *vacuumers;
+	struct ctdb_vacuum_child_context *vacuumer;
 
 	/* mapping from pid to ctdb_client * */
 	struct ctdb_client_pid_list *client_pids;
@@ -359,6 +359,7 @@ struct ctdb_db_context {
 	struct revokechild_handle *revokechild_active;
 	struct ctdb_persistent_state *persistent_state;
 	struct trbt_tree *delete_queue;
+	struct trbt_tree *fetch_queue;
 	struct trbt_tree *sticky_records; 
 	int (*ctdb_ltdb_store_fn)(struct ctdb_db_context *ctdb_db,
 				  TDB_DATA key,
@@ -985,6 +986,11 @@ int32_t ctdb_control_uptime(struct ctdb_context *ctdb, TDB_DATA *outdata);
 
 /* from ctdb_vacuum.c */
 
+int32_t ctdb_control_db_vacuum(struct ctdb_context *ctdb,
+			       struct ctdb_req_control_old *c,
+			       TDB_DATA indata,
+			       bool *async_reply);
+
 void ctdb_stop_vacuuming(struct ctdb_context *ctdb);
 int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
 
@@ -998,6 +1004,8 @@ void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
 					 const struct ctdb_ltdb_header *hdr,
 					 const TDB_DATA key);
 
+int32_t ctdb_control_vacuum_fetch(struct ctdb_context *ctdb, TDB_DATA indata);
+
 /* from eventscript.c */
 
 int ctdb_start_eventd(struct ctdb_context *ctdb);
diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h
index b868553f6e8..43175ae3a95 100644
--- a/ctdb/protocol/protocol.h
+++ b/ctdb/protocol/protocol.h
@@ -373,6 +373,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
 		    CTDB_CONTROL_CHECK_PID_SRVID         = 151,
 		    CTDB_CONTROL_TUNNEL_REGISTER         = 152,
 		    CTDB_CONTROL_TUNNEL_DEREGISTER       = 153,
+		    CTDB_CONTROL_VACUUM_FETCH            = 154,
+		    CTDB_CONTROL_DB_VACUUM               = 155,
 };
 
 #define MAX_COUNT_BUCKETS 16
@@ -851,6 +853,12 @@ struct ctdb_pid_srvid {
 	uint64_t srvid;
 };
 
+struct ctdb_db_vacuum {
+	uint32_t db_id;
+	bool full_vacuum_run;
+
+};
+
 struct ctdb_req_control_data {
 	uint32_t opcode;
 	union {
@@ -888,6 +896,7 @@ struct ctdb_req_control_data {
 		struct ctdb_traverse_start_ext *traverse_start_ext;
 		struct ctdb_traverse_all_ext *traverse_all_ext;
 		struct ctdb_pid_srvid *pid_srvid;
+		struct ctdb_db_vacuum *db_vacuum;
 	} data;
 };
 
diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h
index 6104c10e7b5..c2cd4a76289 100644
--- a/ctdb/protocol/protocol_api.h
+++ b/ctdb/protocol/protocol_api.h
@@ -603,6 +603,14 @@ void ctdb_req_control_tunnel_deregister(struct ctdb_req_control *request,
 					uint64_t tunnel_id);
 int ctdb_reply_control_tunnel_deregister(struct ctdb_reply_control *reply);
 
+void ctdb_req_control_vacuum_fetch(struct ctdb_req_control *request,
+				   struct ctdb_rec_buffer *recbuf);
+int ctdb_reply_control_vacuum_fetch(struct ctdb_reply_control *reply);
+
+void ctdb_req_control_db_vacuum(struct ctdb_req_control *request,
+				struct ctdb_db_vacuum *db_vacuum);
+int ctdb_reply_control_db_vacuum(struct ctdb_reply_control *reply);
+
 /* 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 a461ff36016..6c5180d6d6d 100644
--- a/ctdb/protocol/protocol_client.c
+++ b/ctdb/protocol/protocol_client.c
@@ -424,8 +424,6 @@ int ctdb_reply_control_db_attach(struct ctdb_reply_control *reply,
 	return reply->status;
 }
 
-/* CTDB_CONTROL_SET_CALL */
-
 /* CTDB_CONTROL_TRAVERSE_START */
 
 void ctdb_req_control_traverse_start(struct ctdb_req_control *request,
@@ -718,8 +716,6 @@ int ctdb_reply_control_shutdown(struct ctdb_reply_control *reply)
 	return ctdb_reply_control_generic(reply, CTDB_CONTROL_SHUTDOWN);
 }
 
-/* CTDB_CONTROL_GET_MONMODE */
-
 /* CTDB_CONTROL_TCP_CLIENT */
 
 void ctdb_req_control_tcp_client(struct ctdb_req_control *request,
@@ -1170,9 +1166,6 @@ int ctdb_reply_control_try_delete_records(struct ctdb_reply_control *reply,
 	return reply->status;
 }
 
-/* CTDB_CONTROL_ENABLE_MONITOR */
-/* CTDB_CONTROL_DISABLE_MONITOR */
-
 /* CTDB_CONTROL_ADD_PUBLIC_IP */
 
 void ctdb_req_control_add_public_ip(struct ctdb_req_control *request,
@@ -1855,8 +1848,6 @@ int ctdb_reply_control_set_db_readonly(struct ctdb_reply_control *reply)
 	return ctdb_reply_control_generic(reply, CTDB_CONTROL_SET_DB_READONLY);
 }
 
-/* CTDB_CONTROL_CHECK_SRVIDS */
-
 /* CTDB_CONTROL_TRAVERSE_START_EXT */
 
 void ctdb_req_control_traverse_start_ext(struct ctdb_req_control *request,
@@ -2346,3 +2337,51 @@ int ctdb_reply_control_tunnel_deregister(struct ctdb_reply_control *reply)
 
 	return reply->status;
 }
+
+/* CTDB_CONTROL_VACUUM_FETCH */
+
+void ctdb_req_control_vacuum_fetch(struct ctdb_req_control *request,
+				   struct ctdb_rec_buffer *recbuf)
+{
+	request->opcode = CTDB_CONTROL_VACUUM_FETCH;
+	request->pad = 0;
+	request->srvid = 0;
+	request->client_id = 0;
+	request->flags = 0;
+
+	request->rdata.opcode = CTDB_CONTROL_VACUUM_FETCH;
+	request->rdata.data.recbuf = recbuf;
+}
+
+int ctdb_reply_control_vacuum_fetch(struct ctdb_reply_control *reply)
+{
+	if (reply->rdata.opcode != CTDB_CONTROL_VACUUM_FETCH) {
+		return EPROTO;
+	}
+
+	return reply->status;
+}
+
+/* CTDB_CONTROL_DB_VACUUM */
+
+void ctdb_req_control_db_vacuum(struct ctdb_req_control *request,
+				struct ctdb_db_vacuum *db_vacuum)
+{
+	request->opcode = CTDB_CONTROL_DB_VACUUM;
+	request->pad = 0;
+	request->srvid = 0;
+	request->client_id = 0;
+	request->flags = 0;
+
+	request->rdata.opcode = CTDB_CONTROL_DB_VACUUM;
+	request->rdata.data.db_vacuum = db_vacuum;
+}
+
+int ctdb_reply_control_db_vacuum(struct ctdb_reply_control *reply)
+{
+	if (reply->rdata.opcode != CTDB_CONTROL_DB_VACUUM) {
+		return EPROTO;
+	}
+
+	return reply->status;
+}
diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c
index 0b88b5c8b5a..a25c9b1cfe0 100644
--- a/ctdb/protocol/protocol_control.c
+++ b/ctdb/protocol/protocol_control.c
@@ -90,9 +90,6 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 		len = ctdb_string_len(&cd->data.db_name);
 		break;
 
-	case CTDB_CONTROL_SET_CALL:
-		break;
-
 	case CTDB_CONTROL_TRAVERSE_START:
 		len = ctdb_traverse_start_len(cd->data.traverse_start);
 		break;
@@ -145,9 +142,6 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 	case CTDB_CONTROL_SHUTDOWN:
 		break;
 
-	case CTDB_CONTROL_GET_MONMODE:
-		break;
-
 	case CTDB_CONTROL_TCP_CLIENT:
 		len = ctdb_connection_len(cd->data.conn);
 		break;
@@ -221,12 +215,6 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 		len = ctdb_rec_buffer_len(cd->data.recbuf);
 		break;
 
-	case CTDB_CONTROL_ENABLE_MONITOR:
-		break;
-
-	case CTDB_CONTROL_DISABLE_MONITOR:
-		break;
-
 	case CTDB_CONTROL_ADD_PUBLIC_IP:
 		len = ctdb_addr_info_len(cd->data.addr_info);
 		break;
@@ -338,9 +326,6 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd)
 		len = ctdb_uint32_len(&cd->data.db_id);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list