summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2012-03-02 12:57:23 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2012-03-02 12:57:23 +1100
commit62daab3688737d44477b617675146b6bc327ebdd (patch)
tree7ebd9afab2442c3f413a3c8d4ce12493b56611cc
parent1b971985190a2e2ea2138d985aa4dc342a744a43 (diff)
downloadsamba-62daab3688737d44477b617675146b6bc327ebdd.tar.gz
samba-62daab3688737d44477b617675146b6bc327ebdd.tar.xz
samba-62daab3688737d44477b617675146b6bc327ebdd.zip
READONLY: when updating a remote node to revoke a delegation, make sure we dont create the record if it doesnt already exist
(This used to be ctdb commit fb00e1290fcea3386132a46c883994019a43799a)
-rw-r--r--ctdb/server/ctdb_call.c1
-rw-r--r--ctdb/server/ctdb_update_record.c17
2 files changed, 18 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 9922233690..50f4cb2e1f 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -1300,6 +1300,7 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb, struct ctdb_db_contex
int ret;
header->flags &= ~(CTDB_REC_RO_REVOKING_READONLY|CTDB_REC_RO_HAVE_DELEGATIONS|CTDB_REC_RO_HAVE_READONLY);
+ header->flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
header->rsn -= 1;
if ((rc = talloc_zero(ctdb_db, struct revokechild_handle)) == NULL) {
diff --git a/ctdb/server/ctdb_update_record.c b/ctdb/server/ctdb_update_record.c
index 4413597f21..f8be8e88c4 100644
--- a/ctdb/server/ctdb_update_record.c
+++ b/ctdb/server/ctdb_update_record.c
@@ -28,8 +28,11 @@ struct ctdb_persistent_write_state {
struct ctdb_db_context *ctdb_db;
struct ctdb_marshall_buffer *m;
struct ctdb_req_control *c;
+ uint32_t flags;
};
+/* dont create/update records that does not exist locally */
+#define UPDATE_FLAGS_REPLACE_ONLY 1
/*
called from a child process to write the data
@@ -62,6 +65,19 @@ static int ctdb_persistent_store(struct ctdb_persistent_write_state *state)
goto failed;
}
+ /* we must check if the record exists or not because
+ ctdb_ltdb_fetch will unconditionally create a record
+ */
+ if (state->flags & UPDATE_FLAGS_REPLACE_ONLY) {
+ TDB_DATA rec;
+ rec = tdb_fetch(state->ctdb_db->ltdb->tdb, key);
+ if (rec.dsize == 0) {
+ talloc_free(tmp_ctx);
+ continue;
+ }
+ free(rec.dptr);
+ }
+
/* fetch the old header and ensure the rsn is less than the new rsn */
ret = ctdb_ltdb_fetch(state->ctdb_db, key, &oldheader, tmp_ctx, &olddata);
if (ret != 0) {
@@ -309,6 +325,7 @@ int32_t ctdb_control_update_record(struct ctdb_context *ctdb,
state->ctdb_db = ctdb_db;
state->c = c;
state->m = m;
+ state->flags = UPDATE_FLAGS_REPLACE_ONLY;
/* create a child process to take out a transaction and
write the data.