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

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)
This commit is contained in:
Ronnie Sahlberg 2012-03-02 12:57:23 +11:00
parent 1b97198519
commit 62daab3688
2 changed files with 18 additions and 0 deletions

View File

@ -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) {

View File

@ -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.