diff --git a/ctdb/common/common.h b/ctdb/common/common.h index 0085fcfa989..8aeec82b6fc 100644 --- a/ctdb/common/common.h +++ b/ctdb/common/common.h @@ -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, diff --git a/ctdb/common/ctdb_ltdb.c b/ctdb/common/ctdb_ltdb.c index 818ac76d387..aa1db9de6ea 100644 --- a/ctdb/common/ctdb_ltdb.c +++ b/ctdb/common/ctdb_ltdb.c @@ -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 */ diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c index 86498cf3a96..5b2e2f5a02e 100644 --- a/ctdb/server/ctdb_call.c +++ b/ctdb/server/ctdb_call.c @@ -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); } diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c index 1282929366c..57611e29fbc 100644 --- a/ctdb/server/ctdb_ltdb_server.c +++ b/ctdb/server/ctdb_ltdb_server.c @@ -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)); diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 9097f7a3ffa..0af6309c28e 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -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; } }