The branch, 1.13 has been updated
       via  0c0e887912ca37682312091f4b89ff5167b254d9 (commit)
      from  05e75dea9eaa0decc2909e0c2cf1715c81374200 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=1.13


- Log -----------------------------------------------------------------
commit 0c0e887912ca37682312091f4b89ff5167b254d9
Author: Ronnie Sahlberg <ronniesahlb...@gmail.com>
Date:   Fri Mar 2 12:57:23 2012 +1100

    READONLY: when updating a remote node to revoke a delegation, make sure we 
dont create the record if it doesnt already exist

-----------------------------------------------------------------------

Summary of changes:
 server/ctdb_call.c          |    1 +
 server/ctdb_update_record.c |   17 +++++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/server/ctdb_call.c b/server/ctdb_call.c
index 9922233..50f4cb2 100644
--- a/server/ctdb_call.c
+++ b/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/server/ctdb_update_record.c b/server/ctdb_update_record.c
index 4413597..f8be8e8 100644
--- a/server/ctdb_update_record.c
+++ b/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.


-- 
CTDB repository

Reply via email to