summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_persistent.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2012-02-21 07:12:50 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2012-02-21 07:12:50 +1100
commit574b47e23fd141e96357cc596fe215f7f5c5007b (patch)
tree040d6e270683ae2a5298986c53e8fb2cd23a2ed5 /ctdb/server/ctdb_persistent.c
parentbaa3d7ea39c9b8225fd041e30745db1e1e683534 (diff)
parent42e477b14e0c690be28115825ac61f890e84d1c4 (diff)
downloadsamba-574b47e23fd141e96357cc596fe215f7f5c5007b.tar.gz
samba-574b47e23fd141e96357cc596fe215f7f5c5007b.tar.xz
samba-574b47e23fd141e96357cc596fe215f7f5c5007b.zip
Merge branch 'master' of 10.1.1.27:/shared/ctdb/ctdb-master
(This used to be ctdb commit 9b85aa1aa14091dc1de470a587f7c054b9e40078)
Diffstat (limited to 'ctdb/server/ctdb_persistent.c')
-rw-r--r--ctdb/server/ctdb_persistent.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/ctdb/server/ctdb_persistent.c b/ctdb/server/ctdb_persistent.c
index 0f4f4da52d..dd8d4793fb 100644
--- a/ctdb/server/ctdb_persistent.c
+++ b/ctdb/server/ctdb_persistent.c
@@ -456,12 +456,12 @@ static int ctdb_persistent_store(struct ctdb_persistent_write_state *state)
}
for (i=0;i<m->count;i++) {
- struct ctdb_ltdb_header *oldheader;
- struct ctdb_ltdb_header *header;
+ struct ctdb_ltdb_header oldheader;
+ struct ctdb_ltdb_header header;
TDB_DATA key, data, olddata;
TALLOC_CTX *tmp_ctx = talloc_new(state);
- rec = ctdb_marshall_loop_next(m, rec, NULL, NULL, &key, &data);
+ rec = ctdb_marshall_loop_next(m, rec, NULL, &header, &key, &data);
if (rec == NULL) {
DEBUG(DEBUG_ERR,("Failed to get next record %d for db_id 0x%08x in ctdb_persistent_store\n",
@@ -469,42 +469,29 @@ static int ctdb_persistent_store(struct ctdb_persistent_write_state *state)
talloc_free(tmp_ctx);
goto failed;
}
- header = (struct ctdb_ltdb_header *)&data.dptr[0];
/* fetch the old header and ensure the rsn is less than the new rsn */
- olddata = tdb_fetch(state->ctdb_db->ltdb->tdb, key);
- if (olddata.dptr == NULL) {
+ ret = ctdb_ltdb_fetch(state->ctdb_db, key, &oldheader, tmp_ctx, &olddata);
+ if (ret != 0) {
DEBUG(DEBUG_ERR,("Failed to fetch old record for db_id 0x%08x in ctdb_persistent_store\n",
state->ctdb_db->db_id));
talloc_free(tmp_ctx);
goto failed;
}
- if (olddata.dsize < sizeof(struct ctdb_ltdb_header)) {
- DEBUG(DEBUG_ERR,("Not enough header for record for db_id 0x%08x in ctdb_persistent_store\n",
- state->ctdb_db->db_id));
- talloc_free(tmp_ctx);
- free(olddata.dptr);
- goto failed;
- }
- oldheader = (struct ctdb_ltdb_header *)&olddata.dptr[0];
- if (oldheader->rsn >= header->rsn &&
- (olddata.dsize != data.dsize ||
- memcmp(&olddata.dptr[sizeof(struct ctdb_ltdb_header)],
- &data.dptr[sizeof(struct ctdb_ltdb_header)],
- data.dsize - sizeof(struct ctdb_ltdb_header)) != 0)) {
+ if (oldheader.rsn >= header.rsn &&
+ (olddata.dsize != data.dsize ||
+ memcmp(olddata.dptr, data.dptr, data.dsize) != 0)) {
DEBUG(DEBUG_CRIT,("existing header for db_id 0x%08x has larger RSN %llu than new RSN %llu in ctdb_persistent_store\n",
state->ctdb_db->db_id,
- (unsigned long long)oldheader->rsn, (unsigned long long)header->rsn));
+ (unsigned long long)oldheader.rsn, (unsigned long long)header.rsn));
talloc_free(tmp_ctx);
- free(olddata.dptr);
goto failed;
}
talloc_free(tmp_ctx);
- free(olddata.dptr);
- ret = tdb_store(state->ctdb_db->ltdb->tdb, key, data, TDB_REPLACE);
+ ret = ctdb_ltdb_store(state->ctdb_db, key, &header, data);
if (ret != 0) {
DEBUG(DEBUG_CRIT,("Failed to store record for db_id 0x%08x in ctdb_persistent_store\n",
state->ctdb_db->db_id));