1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-daemon: Add accessors for CTDB_DB_FLAGS_STICKY flag

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2017-03-02 15:47:46 +11:00 committed by Martin Schwenke
parent d0fa710ea1
commit 4e43a344cc
5 changed files with 20 additions and 6 deletions

View 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,

View 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
*/

View 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);
}

View 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));

View 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;
}
}