[SCM] Samba Shared Repository - branch master updated
Martin Schwenke
martins at samba.org
Tue Mar 24 01:23:02 UTC 2020
The branch, master has been updated
via 716f52f68b2 ctdb-recoverd: Avoid dereferencing NULL rec->nodemap
via 147afe77de3 ctdb-daemon: Don't allow attach from recovery if recovery is not active
via 052f1bdb9cf ctdb-daemon: Remove more unused old client database functions
via 3a66d181b6f ctdb-recovery: Remove old code for creating missing databases
via 76a8174279f ctdb-recovery: Create database on nodes where it is missing
via e6e63f8fb81 ctdb-recovery: Fetch database name from all nodes where it is attached
via 1bdfeb3fdc0 ctdb-recovery: Pass db structure for each database recovery
via c6f74e590f6 ctdb-recovery: GET_DBMAP from all nodes
via 4c0b9c36050 ctdb-recovery: Replace use of ctdb_dbid_map with local db_list
via 7e5a8a4884e ctdb-daemon: Respect CTDB_CTRL_FLAG_ATTACH_RECOVERY when attaching databases
via 98e3d0db2bc ctdb-recovery: Use CTDB_CTRL_FLAG_ATTACH_RECOVERY to attach during recovery
via 17ed0425904 ctdb-protocol: Add control flag CTDB_CTRL_FLAG_ATTACH_RECOVERY
via fc23cd1b9cd ctdb-daemon: Remove unused old client database functions
via c6c89495fbe ctdb-daemon: Fix database attach deferral logic
via 1c56d6413f8 ctdb-recovery: Refactor banning a node into separate computation
via c6a0ff1bed0 ctdb-recovery: Don't trust nodemap obtained from local node
via 6e2f8756f1b ctdb-recovery: Consolidate node state
via 072ff4d12b8 ctdb-recovery: Fetched vnnmap is never used, so don't fetch it
from 1114b02a72c s3: libsmbclient.h: add missing time.h include
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 716f52f68b248ae7cfd66479b3fc678c4a0d8b38
Author: Martin Schwenke <martin at meltin.net>
Date: Sun Mar 22 13:46:46 2020 +1100
ctdb-recoverd: Avoid dereferencing NULL rec->nodemap
Inside the nested event loop in ctdb_ctrl_getnodemap(), various
asynchronous handlers may dereference rec->nodemap, which will be
NULL.
One example is lost_reclock_handler(), which causes rec->nodemap to be
unconditionally dereferenced in list_of_nodes() via this call chain:
list_of_nodes()
list_of_active_nodes()
set_recovery_mode()
force_election()
lost_reclock_handler()
Instead of attempting to trace all of the cases, just avoid leaving
rec->nodemap set to NULL. Attempting to use an old value is generally
harmless, especially since it will be the same as the new value in
most cases.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14324
Reported-by: Volker Lendecke <vl at samba.org>
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Autobuild-User(master): Martin Schwenke <martins at samba.org>
Autobuild-Date(master): Tue Mar 24 01:22:45 UTC 2020 on sn-devel-184
commit 147afe77de372ddb9c180228d6fe1b04cca4610f
Author: Martin Schwenke <martin at meltin.net>
Date: Tue Feb 25 17:32:56 2020 +1100
ctdb-daemon: Don't allow attach from recovery if recovery is not active
Neither the recovery daemon nor the recovery helper should attach
databases outside of the recovery process.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 052f1bdb9cf78f53f584edd32f81ae8e01e8e86e
Author: Martin Schwenke <martin at meltin.net>
Date: Tue Feb 25 06:20:32 2020 +1100
ctdb-daemon: Remove more unused old client database functions
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 3a66d181b6f6199fca362fcb0aa06513645b589d
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Feb 24 19:51:19 2020 +1100
ctdb-recovery: Remove old code for creating missing databases
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 76a8174279f42486b36cc41d5831d4e6613f172e
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Feb 24 11:31:33 2020 +1100
ctdb-recovery: Create database on nodes where it is missing
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit e6e63f8fb8194634135bf34cda18f6cc8ff69a7c
Author: Martin Schwenke <martin at meltin.net>
Date: Mon Feb 24 10:26:34 2020 +1100
ctdb-recovery: Fetch database name from all nodes where it is attached
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 1bdfeb3fdc06947a607957ab3d114f97bad5d7d7
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Feb 21 16:51:10 2020 +1100
ctdb-recovery: Pass db structure for each database recovery
Instead of db_id and db_flags.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit c6f74e590f602e2ed38fe293468770a5e669aefa
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Feb 21 16:10:05 2020 +1100
ctdb-recovery: GET_DBMAP from all nodes
This builds a complete list of databases across the cluster so it can
be used to create databases on the nodes where they are missing.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 4c0b9c36050a0ed8a180d4ac1853224089528e8e
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Feb 21 12:24:39 2020 +1100
ctdb-recovery: Replace use of ctdb_dbid_map with local db_list
This will be used to build a merged list of databases from all nodes,
allowing the recovery helper to create missing databases.
It would be possible to also include the db_name field in this
structure but that would cause a lot of churn. This field is used
locally in the recovery of each database so can continue to live in
the relevant state structure(s).
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 7e5a8a4884ea87bb985fe0e2b65ff130fc2ba8aa
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Feb 26 11:50:09 2020 +1100
ctdb-daemon: Respect CTDB_CTRL_FLAG_ATTACH_RECOVERY when attaching databases
This is currently only set by the recovery daemon when it attaches
missing databases, so there is no obvious behaviour change. However,
attaching missing databases can now be moved to the recovery helper as
long as it sets this flag.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 98e3d0db2bc5f33217e26fab1dfb4bb91eae534f
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Feb 21 11:13:05 2020 +1100
ctdb-recovery: Use CTDB_CTRL_FLAG_ATTACH_RECOVERY to attach during recovery
ctdb_ctrl_createdb() is only called by the recovery daemon, so this is
a safe, temporary change. This is temporary because
ctdb_ctrl_createdb(), create_missing_remote_databases() and
create_missing_local_databases() will all go away soon.
Note that this doesn't cause a change in behaviour. The main daemon
will still only defer attaches from non-recoverd processes during
recovery.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 17ed0425904a98624284d351ab7617b3e02c0f7b
Author: Martin Schwenke <martin at meltin.net>
Date: Fri Feb 21 11:04:14 2020 +1100
ctdb-protocol: Add control flag CTDB_CTRL_FLAG_ATTACH_RECOVERY
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit fc23cd1b9cdd1d70067491614b16e616291e8ff2
Author: Martin Schwenke <martin at meltin.net>
Date: Wed Feb 26 17:03:49 2020 +1100
ctdb-daemon: Remove unused old client database functions
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit c6c89495fbe9b6f238d10a538eccc92b937a69de
Author: Martin Schwenke <martin at meltin.net>
Date: Thu Feb 20 13:48:13 2020 +1100
ctdb-daemon: Fix database attach deferral logic
Commit 3cc230b5eeca749ab68d19cfda969f72c269f1f6 says:
Dont allow clients to connect to databases untile we are well past
and through the initial recovery phase
It is unclear what this commit was attempting to do. The commit
message implies that more attaches should be deferred but the code
change adds a conjunction that causes less attaches to be deferred.
In particular, no attaches will be deferred after startup is complete.
This seems wrong.
To implement what seems to be stated in the commit message an "or"
needs to be used so that non-recovery daemon attaches are deferred
either when in recovery or before startup is complete. Making this
change highlights that attaches need to be allowed during the
"startup" event because this is when smbd is started.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
commit 1c56d6413f86cc15ebac232f39ef1e2a53ae4297
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Mar 2 16:16:26 2020 +1100
ctdb-recovery: Refactor banning a node into separate computation
If a node is marked for banning, confirm that it's not become inactive
during the recovery. If yes, then don't ban the node.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit c6a0ff1bed0265e44fd6135d16bfc41919fe5bf5
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Feb 18 16:17:00 2020 +1100
ctdb-recovery: Don't trust nodemap obtained from local node
It's possible to have a node stopped, but recovery master not yet
updated flags on the local ctdb daemon when recovery is started. So do
not trust the list of active nodes obtained from the local node. Query
the connected nodes to calculate the list of active nodes.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 6e2f8756f1bce4dfc7fdc435e082f400116e29ec
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Mar 2 15:07:21 2020 +1100
ctdb-recovery: Consolidate node state
This avoids passing multiple arguments to async computation.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
commit 072ff4d12b8f34766120ddae888d772e97bca491
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Mar 2 13:59:42 2020 +1100
ctdb-recovery: Fetched vnnmap is never used, so don't fetch it
New vnnmap is constructed using the information from all the connected
nodes. So there is no need to fetch the vnnmap from recovery master.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Martin Schwenke <martin at meltin.net>
-----------------------------------------------------------------------
Summary of changes:
ctdb/include/ctdb_client.h | 34 -
ctdb/include/ctdb_private.h | 2 +
ctdb/protocol/protocol.h | 1 +
ctdb/server/ctdb_client.c | 242 ------
ctdb/server/ctdb_ltdb_server.c | 13 +-
ctdb/server/ctdb_recoverd.c | 169 +----
ctdb/server/ctdb_recovery_helper.c | 1478 +++++++++++++++++++++++++++---------
7 files changed, 1124 insertions(+), 815 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h
index ef4950ab533..198a8a38dbb 100644
--- a/ctdb/include/ctdb_client.h
+++ b/ctdb/include/ctdb_client.h
@@ -165,10 +165,6 @@ int ctdb_ctrl_getrecmaster(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, uint32_t recmaster);
-int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, struct timeval timeout,
- uint32_t destnode, TALLOC_CTX *mem_ctx,
- struct ctdb_dbid_map_old **dbmap);
-
int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, TALLOC_CTX *mem_ctx,
struct ctdb_node_map_old **nodemap);
@@ -176,39 +172,9 @@ int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, struct timeval timeout,
int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, uint32_t *runstate);
-int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout,
- uint32_t destnode, uint32_t dbid,
- TALLOC_CTX *mem_ctx, const char **path);
-int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout,
- uint32_t destnode, uint32_t dbid,
- TALLOC_CTX *mem_ctx, const char **name);
-
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
- uint32_t destnode, TALLOC_CTX *mem_ctx,
- const char *name, uint8_t db_flags, uint32_t *db_id);
-
int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode,
int32_t *level);
-/*
- attach to a ctdb database
-*/
-int ctdb_ctrl_db_open_flags(struct ctdb_context *ctdb, uint32_t db_id,
- int *tdb_flags);
-
-struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
- struct timeval timeout,
- const char *name,
- uint8_t db_flags);
-
-/* a ctdb call function */
-typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
-
-/*
- setup a ctdb call function
-*/
-int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id);
-
int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode);
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 405bf3b4186..e532323bb34 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -36,6 +36,8 @@ struct ctdb_tcp_array {
/*
an installed ctdb remote call
*/
+typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
+
struct ctdb_registered_call {
struct ctdb_registered_call *next, *prev;
uint32_t id;
diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h
index 43175ae3a95..04a651018be 100644
--- a/ctdb/protocol/protocol.h
+++ b/ctdb/protocol/protocol.h
@@ -944,6 +944,7 @@ struct ctdb_req_control {
#define CTDB_CTRL_FLAG_OPCODE_SPECIFIC 0xFFFF0000
/* Ugly overloading of this field... */
#define CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE 0x00010000
+#define CTDB_CTRL_FLAG_ATTACH_RECOVERY 0x00020000
uint32_t flags;
struct ctdb_req_control_data rdata;
};
diff --git a/ctdb/server/ctdb_client.c b/ctdb/server/ctdb_client.c
index 0da847c401b..453e7b28477 100644
--- a/ctdb/server/ctdb_client.c
+++ b/ctdb/server/ctdb_client.c
@@ -1029,30 +1029,6 @@ int ctdb_ctrl_setrecmaster(struct ctdb_context *ctdb, struct timeval timeout, ui
}
-/*
- get a list of databases off a remote node
- */
-int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, struct ctdb_dbid_map_old **dbmap)
-{
- int ret;
- TDB_DATA outdata;
- int32_t res;
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_GET_DBMAP, 0, tdb_null,
- mem_ctx, &outdata, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getdbmap failed ret:%d res:%d\n", ret, res));
- return -1;
- }
-
- *dbmap = (struct ctdb_dbid_map_old *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
- talloc_free(outdata.dptr);
-
- return 0;
-}
-
/*
get a list of nodes (vnn and flags ) from a remote node
*/
@@ -1107,108 +1083,6 @@ int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb,
return 0;
}
-/*
- find the real path to a ltdb
- */
-int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx,
- const char **path)
-{
- int ret;
- int32_t res;
- TDB_DATA data;
-
- data.dptr = (uint8_t *)&dbid;
- data.dsize = sizeof(dbid);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_GETDBPATH, 0, data,
- mem_ctx, &data, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- return -1;
- }
-
- (*path) = talloc_strndup(mem_ctx, (const char *)data.dptr, data.dsize);
- if ((*path) == NULL) {
- return -1;
- }
-
- talloc_free(data.dptr);
-
- return 0;
-}
-
-/*
- find the name of a db
- */
-int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx,
- const char **name)
-{
- int ret;
- int32_t res;
- TDB_DATA data;
-
- data.dptr = (uint8_t *)&dbid;
- data.dsize = sizeof(dbid);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_GET_DBNAME, 0, data,
- mem_ctx, &data, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- return -1;
- }
-
- (*name) = talloc_strndup(mem_ctx, (const char *)data.dptr, data.dsize);
- if ((*name) == NULL) {
- return -1;
- }
-
- talloc_free(data.dptr);
-
- return 0;
-}
-
-/*
- create a database
- */
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
- uint32_t destnode, TALLOC_CTX *mem_ctx,
- const char *name, uint8_t db_flags, uint32_t *db_id)
-{
- int ret;
- int32_t res;
- TDB_DATA data;
- uint32_t opcode;
-
- data.dptr = discard_const(name);
- data.dsize = strlen(name)+1;
-
- if (db_flags & CTDB_DB_FLAGS_PERSISTENT) {
- opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
- } else if (db_flags & CTDB_DB_FLAGS_REPLICATED) {
- opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
- } else {
- opcode = CTDB_CONTROL_DB_ATTACH;
- }
-
- ret = ctdb_control(ctdb, destnode, 0, opcode, 0, data,
- mem_ctx, &data, &res, &timeout, NULL);
-
- if (ret != 0 || res != 0) {
- return -1;
- }
-
- if (data.dsize != sizeof(uint32_t)) {
- TALLOC_FREE(data.dptr);
- return -1;
- }
- if (db_id != NULL) {
- *db_id = *(uint32_t *)data.dptr;
- }
- talloc_free(data.dptr);
-
- return 0;
-}
-
/*
get debug level on a node
*/
@@ -1233,122 +1107,6 @@ int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32
return 0;
}
-/*
- * Get db open flags
- */
-int ctdb_ctrl_db_open_flags(struct ctdb_context *ctdb, uint32_t db_id,
- int *tdb_flags)
-{
- TDB_DATA indata, outdata;
- int ret;
- int32_t res;
-
- indata.dptr = (uint8_t *)&db_id;
- indata.dsize = sizeof(db_id);
-
- ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0,
- CTDB_CONTROL_DB_OPEN_FLAGS, 0, indata,
- ctdb, &outdata, &res, NULL, NULL);
- if (ret != 0 || res != 0) {
- D_ERR("ctdb control for db open flags failed\n");
- return -1;
- }
-
- if (outdata.dsize != sizeof(int32_t)) {
- D_ERR(__location__ " expected %zi bytes, received %zi bytes\n",
- sizeof(int32_t), outdata.dsize);
- talloc_free(outdata.dptr);
- return -1;
- }
-
- *tdb_flags = *(int32_t *)outdata.dptr;
- talloc_free(outdata.dptr);
- return 0;
-}
-
-/*
- attach to a specific database - client call
-*/
-struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb,
- struct timeval timeout,
- const char *name,
- uint8_t db_flags)
-{
- struct ctdb_db_context *ctdb_db;
- int ret;
- int tdb_flags;
-
- ctdb_db = ctdb_db_handle(ctdb, name);
- if (ctdb_db) {
- return ctdb_db;
- }
-
- ctdb_db = talloc_zero(ctdb, struct ctdb_db_context);
- CTDB_NO_MEMORY_NULL(ctdb, ctdb_db);
-
- ctdb_db->ctdb = ctdb;
- ctdb_db->db_name = talloc_strdup(ctdb_db, name);
- CTDB_NO_MEMORY_NULL(ctdb, ctdb_db->db_name);
-
- /* tell ctdb daemon to attach */
- ret = ctdb_ctrl_createdb(ctdb, timeout, CTDB_CURRENT_NODE,
- ctdb_db, name, db_flags, &ctdb_db->db_id);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,("Failed to attach to database '%s'\n", name));
- talloc_free(ctdb_db);
- return NULL;
- }
-
- ret = ctdb_ctrl_getdbpath(ctdb, timeout, CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,("Failed to get dbpath for database '%s'\n", name));
- talloc_free(ctdb_db);
- return NULL;
- }
-
- ret = ctdb_ctrl_db_open_flags(ctdb, ctdb_db->db_id, &tdb_flags);
- if (ret != 0) {
- D_ERR("Failed to get tdb_flags for database '%s'\n", name);
- talloc_free(ctdb_db);
- return NULL;
- }
-
- ctdb_db->ltdb = tdb_wrap_open(ctdb_db, ctdb_db->db_path, 0, tdb_flags,
- O_RDWR, 0);
- if (ctdb_db->ltdb == NULL) {
- ctdb_set_error(ctdb, "Failed to open tdb '%s'\n", ctdb_db->db_path);
- talloc_free(ctdb_db);
- return NULL;
- }
-
- ctdb_db->db_flags = db_flags;
-
- DLIST_ADD(ctdb->db_list, ctdb_db);
-
- /* add well known functions */
- ctdb_set_call(ctdb_db, ctdb_null_func, CTDB_NULL_FUNC);
- ctdb_set_call(ctdb_db, ctdb_fetch_func, CTDB_FETCH_FUNC);
- ctdb_set_call(ctdb_db, ctdb_fetch_with_header_func, CTDB_FETCH_WITH_HEADER_FUNC);
-
- return ctdb_db;
-}
-
-/*
- setup a call for a database
- */
-int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id)
-{
- struct ctdb_registered_call *call;
-
- /* register locally */
- call = talloc(ctdb_db, struct ctdb_registered_call);
- call->fn = fn;
- call->id = id;
-
- DLIST_ADD(ctdb_db->calls, call);
- return 0;
-}
-
/* Freeze all databases */
int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode)
diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c
index 970eb54b00b..ce3569fe7b1 100644
--- a/ctdb/server/ctdb_ltdb_server.c
+++ b/ctdb/server/ctdb_ltdb_server.c
@@ -1135,9 +1135,16 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb,
return -1;
}
- if (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE &&
- client->pid != ctdb->recoverd_pid &&
- ctdb->runstate < CTDB_RUNSTATE_RUNNING) {
+ if ((c->flags & CTDB_CTRL_FLAG_ATTACH_RECOVERY) &&
+ ctdb->recovery_mode != CTDB_RECOVERY_ACTIVE) {
+ DBG_ERR("Attach from recovery refused because "
+ "recovery is not active\n");
+ return -1;
+ }
+
+ if (!(c->flags & CTDB_CTRL_FLAG_ATTACH_RECOVERY) &&
+ (ctdb->recovery_mode == CTDB_RECOVERY_ACTIVE ||
+ ctdb->runstate < CTDB_RUNSTATE_STARTUP)) {
struct ctdb_deferred_attach_context *da_ctx = talloc(client, struct ctdb_deferred_attach_context);
if (da_ctx == NULL) {
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 6fddb44a014..ee083e92fb1 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -424,140 +424,6 @@ static int set_recovery_mode(struct ctdb_context *ctdb,
return 0;
}
-/*
- ensure all other nodes have attached to any databases that we have
- */
-static int create_missing_remote_databases(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
- uint32_t pnn, struct ctdb_dbid_map_old *dbmap, TALLOC_CTX *mem_ctx)
-{
- unsigned int i, j, db;
- int ret;
- struct ctdb_dbid_map_old *remote_dbmap;
-
- /* verify that all other nodes have all our databases */
- for (j=0; j<nodemap->num; j++) {
- /* we don't need to ourself ourselves */
- if (nodemap->nodes[j].pnn == pnn) {
- continue;
- }
- /* don't check nodes that are unavailable */
- if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
- continue;
- }
-
- ret = ctdb_ctrl_getdbmap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
- mem_ctx, &remote_dbmap);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get dbids from node %u\n", pnn));
- return -1;
- }
-
- /* step through all local databases */
- for (db=0; db<dbmap->num;db++) {
- const char *name;
-
-
- for (i=0;i<remote_dbmap->num;i++) {
- if (dbmap->dbs[db].db_id == remote_dbmap->dbs[i].db_id) {
- break;
- }
- }
- /* the remote node already have this database */
- if (i!=remote_dbmap->num) {
- continue;
- }
- /* ok so we need to create this database */
- ret = ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), pnn,
- dbmap->dbs[db].db_id, mem_ctx,
- &name);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get dbname from node %u\n", pnn));
- return -1;
- }
- ret = ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(),
- nodemap->nodes[j].pnn,
- mem_ctx, name,
- dbmap->dbs[db].flags, NULL);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name));
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-
-/*
- ensure we are attached to any databases that anyone else is attached to
- */
-static int create_missing_local_databases(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
- uint32_t pnn, struct ctdb_dbid_map_old **dbmap, TALLOC_CTX *mem_ctx)
-{
- unsigned int i, j, db;
- int ret;
- struct ctdb_dbid_map_old *remote_dbmap;
-
- /* verify that we have all database any other node has */
- for (j=0; j<nodemap->num; j++) {
- /* we don't need to ourself ourselves */
- if (nodemap->nodes[j].pnn == pnn) {
- continue;
- }
- /* don't check nodes that are unavailable */
- if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
- continue;
- }
-
- ret = ctdb_ctrl_getdbmap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
- mem_ctx, &remote_dbmap);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get dbids from node %u\n", pnn));
- return -1;
- }
-
- /* step through all databases on the remote node */
- for (db=0; db<remote_dbmap->num;db++) {
- const char *name;
-
- for (i=0;i<(*dbmap)->num;i++) {
- if (remote_dbmap->dbs[db].db_id == (*dbmap)->dbs[i].db_id) {
- break;
- }
- }
- /* we already have this db locally */
- if (i!=(*dbmap)->num) {
- continue;
- }
- /* ok so we need to create this database and
- rebuild dbmap
- */
- ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
- remote_dbmap->dbs[db].db_id, mem_ctx, &name);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to get dbname from node %u\n",
- nodemap->nodes[j].pnn));
- return -1;
- }
- ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn,
- mem_ctx, name,
- remote_dbmap->dbs[db].flags, NULL);
- if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name));
--
Samba Shared Repository
More information about the samba-cvs
mailing list