diff options
author | Amitay Isaacs <amitay@gmail.com> | 2017-09-07 17:18:18 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2017-09-13 15:41:13 +0200 |
commit | 8c22449d65d0aac09f245b05a987361fea0c4850 (patch) | |
tree | e6f89e576e50071f214a0cc95cae77d0b9f48598 /ctdb | |
parent | a472eb9eeaa966ccf4f326c938116df40b8363c3 (diff) | |
download | samba-8c22449d65d0aac09f245b05a987361fea0c4850.tar.gz |
ctdb-daemon: Add a function to check if db access is allowed
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13021
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
(cherry picked from commit 5d2f2677de65a0fd6683bb759d80ebced604fa6b)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/include/ctdb_private.h | 1 | ||||
-rw-r--r-- | ctdb/server/ctdb_freeze.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 067777a79f3..043149eedd9 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -629,6 +629,7 @@ int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata); bool ctdb_db_frozen(struct ctdb_db_context *ctdb_db); bool ctdb_db_all_frozen(struct ctdb_context *ctdb); +bool ctdb_db_allow_access(struct ctdb_db_context *ctdb_db); /* from server/ctdb_keepalive.c */ diff --git a/ctdb/server/ctdb_freeze.c b/ctdb/server/ctdb_freeze.c index d92f707b25d..c41fc7d53ee 100644 --- a/ctdb/server/ctdb_freeze.c +++ b/ctdb/server/ctdb_freeze.c @@ -874,3 +874,21 @@ bool ctdb_db_all_frozen(struct ctdb_context *ctdb) } return true; } + +bool ctdb_db_allow_access(struct ctdb_db_context *ctdb_db) +{ + if (ctdb_db->freeze_mode == CTDB_FREEZE_NONE) { + /* If database is not frozen, then allow access. */ + return true; + } else if (ctdb_db->freeze_transaction_started) { + /* If database is frozen, allow access only if the + * transaction is started. This is required during + * recovery. + * + * If a node is inactive, then transaction is not started. + */ + return true; + } + + return false; +} |