diff options
author | Amitay Isaacs <amitay@gmail.com> | 2017-03-02 15:39:29 +1100 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2017-06-29 10:34:26 +0200 |
commit | 94af277c489f0ad861c6923d91286f46f9e4d29b (patch) | |
tree | abc3184d45c6f3a173091730b76b3361265ef854 /ctdb/common | |
parent | 2975de6ffbb412e241ed44d64dd549de76c1d03a (diff) | |
download | samba-94af277c489f0ad861c6923d91286f46f9e4d29b.tar.gz |
ctdb-daemon: Add accessors for CTDB_DB_FLAGS_PERSISTENT flag
This allows to differentiate between the two database models.
ctdb_db_persistent() - replicated and permanent
ctdb_db_volatile() - distributed and temporary
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/common')
-rw-r--r-- | ctdb/common/common.h | 3 | ||||
-rw-r--r-- | ctdb/common/ctdb_ltdb.c | 18 |
2 files changed, 18 insertions, 3 deletions
diff --git a/ctdb/common/common.h b/ctdb/common/common.h index 0423c5e2538..5c823a14e6f 100644 --- a/ctdb/common/common.h +++ b/ctdb/common/common.h @@ -44,6 +44,9 @@ int ctdb_db_tdb_flags(uint8_t db_flags, bool with_valgrind, bool with_mutex); struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *name); +bool ctdb_db_persistent(struct ctdb_db_context *ctdb_db); +bool ctdb_db_volatile(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 34ebe6acbbc..37ffda8f070 100644 --- a/ctdb/common/ctdb_ltdb.c +++ b/ctdb/common/ctdb_ltdb.c @@ -78,6 +78,15 @@ struct ctdb_db_context *ctdb_db_handle(struct ctdb_context *ctdb, const char *na return NULL; } +bool ctdb_db_persistent(struct ctdb_db_context *ctdb_db) +{ + return ctdb_db->persistent; +} + +bool ctdb_db_volatile(struct ctdb_db_context *ctdb_db) +{ + return !ctdb_db->persistent; +} /* return the lmaster given a key @@ -133,7 +142,8 @@ int ctdb_ltdb_fetch(struct ctdb_db_context *ctdb_db, if (data) { *data = tdb_null; } - if (ctdb_db->persistent || header->dmaster == ctdb_db->ctdb->pnn) { + if (ctdb_db_persistent(ctdb_db) || + header->dmaster == ctdb_db->ctdb->pnn) { if (ctdb_ltdb_store(ctdb_db, key, header, tdb_null) != 0) { DEBUG(DEBUG_NOTICE, (__location__ "failed to store initial header\n")); @@ -285,8 +295,10 @@ int ctdb_ltdb_unlock(struct ctdb_db_context *ctdb_db, TDB_DATA key) */ int ctdb_ltdb_delete(struct ctdb_db_context *ctdb_db, TDB_DATA key) { - if (ctdb_db->persistent != 0) { - DEBUG(DEBUG_ERR,("Trying to delete empty record in persistent database\n")); + if (! ctdb_db_volatile(ctdb_db)) { + DEBUG(DEBUG_WARNING, + ("Ignored deletion of empty record from " + "non-volatile database\n")); return 0; } if (tdb_delete(ctdb_db->ltdb->tdb, key) != 0) { |