From 056c44fda3f3d84dc3eb9766e0ee04bdb6387ea5 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 21 Aug 2014 12:26:58 +1000 Subject: [PATCH] ctdb-freeze: Refactor code to check if databases are frozen Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- ctdb/include/ctdb_private.h | 2 ++ ctdb/server/ctdb_freeze.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index b8ca020682f..83b8bd2b84e 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -997,6 +997,8 @@ void ctdb_request_control_reply(struct ctdb_context *ctdb, struct ctdb_req_contr int32_t ctdb_control_freeze(struct ctdb_context *ctdb, struct ctdb_req_control *c, bool *async_reply); int32_t ctdb_control_thaw(struct ctdb_context *ctdb, uint32_t priority, bool check_recmode); +bool ctdb_db_prio_frozen(struct ctdb_context *ctdb, uint32_t priority); +bool ctdb_db_all_frozen(struct ctdb_context *ctdb); int ctdb_start_recoverd(struct ctdb_context *ctdb); void ctdb_stop_recoverd(struct ctdb_context *ctdb); diff --git a/ctdb/server/ctdb_freeze.c b/ctdb/server/ctdb_freeze.c index ec0a97027ff..9f9710fdbda 100644 --- a/ctdb/server/ctdb_freeze.c +++ b/ctdb/server/ctdb_freeze.c @@ -488,3 +488,32 @@ int32_t ctdb_control_wipe_database(struct ctdb_context *ctdb, TDB_DATA indata) return 0; } + +bool ctdb_db_prio_frozen(struct ctdb_context *ctdb, uint32_t priority) +{ + if (priority == 0) { + priority = 1; + } + if (priority > NUM_DB_PRIORITIES) { + DEBUG(DEBUG_ERR, ("Invalid DB priority specified\n")); + return false; + } + + if (ctdb->freeze_mode[priority] != CTDB_FREEZE_FROZEN) { + return false; + } + + return true; +} + +bool ctdb_db_all_frozen(struct ctdb_context *ctdb) +{ + int i; + + for (i=1; i<=NUM_DB_PRIORITIES; i++) { + if (ctdb->freeze_mode[i] != CTDB_FREEZE_FROZEN) { + return false; + } + } + return true; +} -- 2.34.1