ctdb-daemon: Add accessors for CTDB_DB_FLAGS_STICKY flag
authorAmitay Isaacs <amitay@gmail.com>
Thu, 2 Mar 2017 04:47:46 +0000 (15:47 +1100)
committerMartin Schwenke <martins@samba.org>
Thu, 29 Jun 2017 08:34:27 +0000 (10:34 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/common/common.h
ctdb/common/ctdb_ltdb.c
ctdb/server/ctdb_call.c
ctdb/server/ctdb_ltdb_server.c
ctdb/server/ctdb_recover.c

index 0085fcfa989df175fa8af5600bae14dd977866f3..8aeec82b6fc1d0ed94eb447501a4eac9291e1a5d 100644 (file)
@@ -51,6 +51,9 @@ 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);
 
+bool ctdb_db_sticky(struct ctdb_db_context *ctdb_db);
+void ctdb_db_set_sticky(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,
index 818ac76d3876b433e630106adb2a9f42930c6511..aa1db9de6eaf2915662148cd63471ab993ca321a 100644 (file)
@@ -103,6 +103,16 @@ void ctdb_db_reset_readonly(struct ctdb_db_context *ctdb_db)
        ctdb_db->readonly = false;
 }
 
+bool ctdb_db_sticky(struct ctdb_db_context *ctdb_db)
+{
+       return ctdb_db->sticky;
+}
+
+void ctdb_db_set_sticky(struct ctdb_db_context *ctdb_db)
+{
+       ctdb_db->sticky = true;
+}
+
 /*
   return the lmaster given a key
 */
index 86498cf3a9623265aa582f37f9704480beb5218b..5b2e2f5a02eb009e1b4435b12bc1d70f47379857 100644 (file)
@@ -381,7 +381,7 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
           see if the record is flagged as "hot" and set up a pin-down
           context to stop migrations for a little while if so
        */
-       if (ctdb_db->sticky) {
+       if (ctdb_db_sticky(ctdb_db)) {
                ctdb_set_sticky_pindown(ctdb, ctdb_db, key);
        }
 
@@ -929,7 +929,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
        /* If this record is pinned down we should defer the
           request until the pindown times out
        */
-       if (ctdb_db->sticky) {
+       if (ctdb_db_sticky(ctdb_db)) {
                if (ctdb_defer_pinned_down_request(ctdb, ctdb_db, call->key, hdr) == 0) {
                        DEBUG(DEBUG_WARNING,
                              ("Defer request for pinned down record in %s\n", ctdb_db->db_name));
@@ -1105,7 +1105,8 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
           hopcount is big. If it is it means the record is hot and we
           should make it sticky.
        */
-       if (ctdb_db->sticky && c->hopcount >= ctdb->tunable.hopcount_make_sticky) {
+       if (ctdb_db_sticky(ctdb_db) &&
+           c->hopcount >= ctdb->tunable.hopcount_make_sticky) {
                ctdb_make_record_sticky(ctdb, ctdb_db, call->key);
        }
 
index 1282929366c3274e30d25cb9faf7611fab6d31c7..57611e29fbcc0957a8bf36d6facc2b47e3cfec49 100644 (file)
@@ -1570,7 +1570,7 @@ int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id)
 
 int ctdb_set_db_sticky(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db)
 {
-       if (ctdb_db->sticky) {
+       if (ctdb_db_sticky(ctdb_db)) {
                return 0;
        }
 
@@ -1582,7 +1582,7 @@ int ctdb_set_db_sticky(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_d
 
        ctdb_db->sticky_records = trbt_create(ctdb_db, 0);
 
-       ctdb_db->sticky = true;
+       ctdb_db_set_sticky(ctdb_db);
 
        DEBUG(DEBUG_NOTICE,("set db sticky %s\n", ctdb_db->db_name));
 
index 9097f7a3ffa8d4b994940609add9e736391ba6ed..0af6309c28eb7024d563a9b9110e8af4f4f1161e 100644 (file)
@@ -121,7 +121,7 @@ ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indat
                if (ctdb_db_readonly(ctdb_db)) {
                        dbid_map->dbs[i].flags |= CTDB_DB_FLAGS_READONLY;
                }
-               if (ctdb_db->sticky != 0) {
+               if (ctdb_db_sticky(ctdb_db)) {
                        dbid_map->dbs[i].flags |= CTDB_DB_FLAGS_STICKY;
                }
        }