summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2017-03-02 15:44:48 +1100
committerMartin Schwenke <martins@samba.org>2017-06-29 10:34:26 +0200
commitd0fa710ea10049c69ec8cb155444a35ecad4b538 (patch)
treef6793005ffa38fc3bd3d1c62e5038055276dcb09 /ctdb
parent94af277c489f0ad861c6923d91286f46f9e4d29b (diff)
downloadsamba-d0fa710ea10049c69ec8cb155444a35ecad4b538.tar.gz
ctdb-daemon: Add accessors for CTDB_DB_FLAGS_READONLY flag
Signed-off-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/common/common.h4
-rw-r--r--ctdb/common/ctdb_ltdb.c15
-rw-r--r--ctdb/server/ctdb_call.c2
-rw-r--r--ctdb/server/ctdb_daemon.c2
-rw-r--r--ctdb/server/ctdb_ltdb_server.c6
-rw-r--r--ctdb/server/ctdb_recover.c12
6 files changed, 29 insertions, 12 deletions
diff --git a/ctdb/common/common.h b/ctdb/common/common.h
index 5c823a14e6f..0085fcfa989 100644
--- a/ctdb/common/common.h
+++ b/ctdb/common/common.h
@@ -47,6 +47,10 @@ struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb,
bool ctdb_db_persistent(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);
+
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 37ffda8f070..818ac76d387 100644
--- a/ctdb/common/ctdb_ltdb.c
+++ b/ctdb/common/ctdb_ltdb.c
@@ -88,6 +88,21 @@ bool ctdb_db_volatile(struct ctdb_db_context *ctdb_db)
return !ctdb_db->persistent;
}
+bool ctdb_db_readonly(struct ctdb_db_context *ctdb_db)
+{
+ return ctdb_db->readonly;
+}
+
+void ctdb_db_set_readonly(struct ctdb_db_context *ctdb_db)
+{
+ ctdb_db->readonly = true;
+}
+
+void ctdb_db_reset_readonly(struct ctdb_db_context *ctdb_db)
+{
+ ctdb_db->readonly = false;
+}
+
/*
return the lmaster given a key
*/
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 320a13aceac..86498cf3a96 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -961,7 +961,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
}
/* Dont do READONLY if we don't have a tracking database */
- if ((c->flags & CTDB_WANT_READONLY) && !ctdb_db->readonly) {
+ if ((c->flags & CTDB_WANT_READONLY) && !ctdb_db_readonly(ctdb_db)) {
c->flags &= ~CTDB_WANT_READONLY;
}
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 91a86c32dc9..591729baea3 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -681,7 +681,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
}
/* Dont do READONLY if we don't have a tracking database */
- if ((c->flags & CTDB_WANT_READONLY) && !ctdb_db->readonly) {
+ if ((c->flags & CTDB_WANT_READONLY) && !ctdb_db_readonly(ctdb_db)) {
c->flags &= ~CTDB_WANT_READONLY;
}
diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c
index 5c994c90694..1282929366c 100644
--- a/ctdb/server/ctdb_ltdb_server.c
+++ b/ctdb/server/ctdb_ltdb_server.c
@@ -718,7 +718,7 @@ int ctdb_set_db_readonly(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb
{
char *ropath;
- if (ctdb_db->readonly) {
+ if (ctdb_db_readonly(ctdb_db)) {
return 0;
}
@@ -745,7 +745,7 @@ int ctdb_set_db_readonly(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb
DEBUG(DEBUG_NOTICE,("OPENED tracking database : '%s'\n", ropath));
- ctdb_db->readonly = true;
+ ctdb_db_set_readonly(ctdb_db);
DEBUG(DEBUG_NOTICE, ("Readonly property set on DB %s\n", ctdb_db->db_name));
@@ -1292,7 +1292,7 @@ int32_t ctdb_control_db_detach(struct ctdb_context *ctdb, TDB_DATA indata,
}
/* Free readonly tracking database */
- if (ctdb_db->readonly) {
+ if (ctdb_db_readonly(ctdb_db)) {
talloc_free(ctdb_db->rottdb);
}
diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index b9fdaa7ed74..9097f7a3ffa 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/server/ctdb_recover.c
@@ -118,7 +118,7 @@ ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indat
if (ctdb_db_persistent(ctdb_db)) {
dbid_map->dbs[i].flags |= CTDB_DB_FLAGS_PERSISTENT;
}
- if (ctdb_db->readonly != 0) {
+ if (ctdb_db_readonly(ctdb_db)) {
dbid_map->dbs[i].flags |= CTDB_DB_FLAGS_READONLY;
}
if (ctdb_db->sticky != 0) {
@@ -513,15 +513,14 @@ int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata)
DEBUG(DEBUG_DEBUG,("finished push of %u records for dbid 0x%x\n",
reply->count, reply->db_id));
- if (ctdb_db->readonly) {
+ if (ctdb_db_readonly(ctdb_db)) {
DEBUG(DEBUG_CRIT,("Clearing the tracking database for dbid 0x%x\n",
ctdb_db->db_id));
if (tdb_wipe_all(ctdb_db->rottdb) != 0) {
DEBUG(DEBUG_ERR,("Failed to wipe tracking database for 0x%x. Dropping read-only delegation support\n", ctdb_db->db_id));
- ctdb_db->readonly = false;
tdb_close(ctdb_db->rottdb);
ctdb_db->rottdb = NULL;
- ctdb_db->readonly = false;
+ ctdb_db_reset_readonly(ctdb_db);
}
while (ctdb_db->revokechild_active != NULL) {
talloc_free(ctdb_db->revokechild_active);
@@ -702,7 +701,7 @@ int32_t ctdb_control_db_push_confirm(struct ctdb_context *ctdb,
return -1;
}
- if (ctdb_db->readonly) {
+ if (ctdb_db_readonly(ctdb_db)) {
DEBUG(DEBUG_ERR,
("Clearing the tracking database for dbid 0x%x\n",
ctdb_db->db_id));
@@ -711,10 +710,9 @@ int32_t ctdb_control_db_push_confirm(struct ctdb_context *ctdb,
("Failed to wipe tracking database for 0x%x."
" Dropping read-only delegation support\n",
ctdb_db->db_id));
- ctdb_db->readonly = false;
tdb_close(ctdb_db->rottdb);
ctdb_db->rottdb = NULL;
- ctdb_db->readonly = false;
+ ctdb_db_reset_readonly(ctdb_db);
}
while (ctdb_db->revokechild_active != NULL) {