[SCM] CTDB repository - branch 2.5 updated - ctdb-2.5.3-98-g922ab4c

Amitay Isaacs amitay at samba.org
Thu Jul 24 19:19:48 MDT 2014


The branch, 2.5 has been updated
       via  922ab4c0991f80dd4c5f569ee69896b23b21a9e1 (commit)
       via  467b9f11503ae54f917e8952bedb4276bb2c8a92 (commit)
       via  e092ce95e3eff6cb41974f78c1664f0773ef0202 (commit)
       via  d392d82f858036aeb13c474102d58ff5b62433aa (commit)
       via  392252c5fd4e4a2b0526a3c74bfaf0401f920292 (commit)
       via  59bbfe6a7db05e2bde16278fed91ff88c88690ee (commit)
       via  28b748cc86e8b6d233c63ce6fe2e66180b9c081e (commit)
       via  adffa7df439cde38096e68faa92a24f1fa6e5637 (commit)
      from  0cd00c7b3347f4d1355723f01a07883f137140cf (commit)

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


- Log -----------------------------------------------------------------
commit 922ab4c0991f80dd4c5f569ee69896b23b21a9e1
Author: Michael Adam <obnox at samba.org>
Date:   Wed Jul 23 13:34:03 2014 +0200

    vacuum: stop vacuuming when the first delete_list traverse fails.
    
    This indirect caller of delete_marshall_traverse was missed
    in fa4a81c86b6073b2563b090aa657d8e8b63c1276
    which lets failure of the second travers fail the vacuum run.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 9d6f187b5811faed6e9b6c4bc61e42175c0c0ae2)

commit 467b9f11503ae54f917e8952bedb4276bb2c8a92
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue May 6 18:52:54 2014 +1000

    vacuum: Use existing function ctdb_marshall_finish
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Wed Jul 23 09:44:00 CEST 2014 on sn-devel-104
    
    (Imported from commit f87b7f664f813957ee55a6f35abb208eb0f3dcad)

commit e092ce95e3eff6cb41974f78c1664f0773ef0202
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue May 6 18:39:25 2014 +1000

    vacuum: Use ctdb_marshall_add to add a record to marshall buffer
    
    This avoids duplicate code and extra talloc in ctdb_marshall_record.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    (Imported from commit 6edc4f23e9094860ad5cc6b93ce66169dd99047a)

commit d392d82f858036aeb13c474102d58ff5b62433aa
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue May 6 18:26:41 2014 +1000

    util: Refactor record marshalling routines to avoid extra talloc
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    (Imported from commit 42ba7a0a400c970dd534e92d2effa3ed385f8d6d)

commit 392252c5fd4e4a2b0526a3c74bfaf0401f920292
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 22 11:23:03 2014 +0000

    util: Refactor ctdb_marshall_record
    
    Create new routines ctdb_marshall_record_size and ctdb_marshall_record_copy
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    (Imported from commit 64ea6e30ef601d91ea16f6a9c5b7a6b9395c0152)

commit 59bbfe6a7db05e2bde16278fed91ff88c88690ee
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 22 11:22:25 2014 +0000

    util: Fix nonempty line endings
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    (Imported from commit 5eac2302819b26b8eaf4f6c0a333e4af2b368679)

commit 28b748cc86e8b6d233c63ce6fe2e66180b9c081e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 10 18:38:13 2014 +1000

    vacuum: If talloc_realloc fails, terminate traverse
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    (Imported from commit fa4a81c86b6073b2563b090aa657d8e8b63c1276)

commit adffa7df439cde38096e68faa92a24f1fa6e5637
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 22 11:19:13 2014 +0000

    vacuum: Fix talloc hierarchy in delete_marshall_traverse
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    (Imported from commit 9a4a9ccda397e20b0a894541f4f1a6d24e09bf19)

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

Summary of changes:
 common/ctdb_util.c    |   90 +++++++++++++++++++++++++++++--------------------
 server/ctdb_recover.c |    7 +---
 server/ctdb_vacuum.c  |   49 ++++++++------------------
 3 files changed, 70 insertions(+), 76 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index f71f74a..c4ac583 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -179,44 +179,67 @@ void ctdb_reqid_remove(struct ctdb_context *ctdb, uint32_t reqid)
 }
 
 
+static uint32_t ctdb_marshall_record_size(TDB_DATA key,
+					  struct ctdb_ltdb_header *header,
+					  TDB_DATA data)
+{
+	return offsetof(struct ctdb_rec_data, data) + key.dsize +
+	       data.dsize + (header ? sizeof(*header) : 0);
+}
+
+static void ctdb_marshall_record_copy(struct ctdb_rec_data *rec,
+				      uint32_t reqid,
+				      TDB_DATA key,
+				      struct ctdb_ltdb_header *header,
+				      TDB_DATA data,
+				      uint32_t length)
+{
+	uint32_t offset;
+
+	rec->length = length;
+	rec->reqid = reqid;
+	rec->keylen = key.dsize;
+	memcpy(&rec->data[0], key.dptr, key.dsize);
+	offset = key.dsize;
+
+	if (header) {
+		rec->datalen = data.dsize + sizeof(*header);
+		memcpy(&rec->data[offset], header, sizeof(*header));
+		offset += sizeof(*header);
+	} else {
+		rec->datalen = data.dsize;
+	}
+	memcpy(&rec->data[offset], data.dptr, data.dsize);
+}
+
 /*
   form a ctdb_rec_data record from a key/data pair
   
   note that header may be NULL. If not NULL then it is included in the data portion
   of the record
  */
-struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,	
-					   TDB_DATA key, 
+struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,
+					   TDB_DATA key,
 					   struct ctdb_ltdb_header *header,
 					   TDB_DATA data)
 {
 	size_t length;
 	struct ctdb_rec_data *d;
 
-	length = offsetof(struct ctdb_rec_data, data) + key.dsize + 
-		data.dsize + (header?sizeof(*header):0);
+	length = ctdb_marshall_record_size(key, header, data);
+
 	d = (struct ctdb_rec_data *)talloc_size(mem_ctx, length);
 	if (d == NULL) {
 		return NULL;
 	}
-	d->length = length;
-	d->reqid = reqid;
-	d->keylen = key.dsize;
-	memcpy(&d->data[0], key.dptr, key.dsize);
-	if (header) {
-		d->datalen = data.dsize + sizeof(*header);
-		memcpy(&d->data[key.dsize], header, sizeof(*header));
-		memcpy(&d->data[key.dsize+sizeof(*header)], data.dptr, data.dsize);
-	} else {
-		d->datalen = data.dsize;
-		memcpy(&d->data[key.dsize], data.dptr, data.dsize);
-	}
+
+	ctdb_marshall_record_copy(d, reqid, key, header, data, length);
 	return d;
 }
 
 
 /* helper function for marshalling multiple records */
-struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx, 
+struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx,
 					       struct ctdb_marshall_buffer *m,
 					       uint64_t db_id,
 					       uint32_t reqid,
@@ -225,36 +248,29 @@ struct ctdb_marshall_buffer *ctdb_marshall_add(TALLOC_CTX *mem_ctx,
 					       TDB_DATA data)
 {
 	struct ctdb_rec_data *r;
-	size_t m_size, r_size;
 	struct ctdb_marshall_buffer *m2;
+	uint32_t length, offset;
 
-	r = ctdb_marshall_record(mem_ctx, reqid, key, header, data);
-	if (r == NULL) {
-		talloc_free(m);
-		return NULL;
-	}
+	length = ctdb_marshall_record_size(key, header, data);
 
 	if (m == NULL) {
-		m = talloc_zero_size(mem_ctx, offsetof(struct ctdb_marshall_buffer, data));
-		if (m == NULL) {
-			return NULL;
-		}
-		m->db_id = db_id;
+		offset = offsetof(struct ctdb_marshall_buffer, data);
+		m2 = talloc_zero_size(mem_ctx, offset + length);
+	} else {
+		offset = talloc_get_size(m);
+		m2 = talloc_realloc_size(mem_ctx, m, offset + length);
 	}
-
-	m_size = talloc_get_size(m);
-	r_size = talloc_get_size(r);
-
-	m2 = talloc_realloc_size(mem_ctx, m,  m_size + r_size);
 	if (m2 == NULL) {
-		talloc_free(m);
+		TALLOC_FREE(m);
 		return NULL;
 	}
 
-	memcpy(m_size + (uint8_t *)m2, r, r_size);
-
-	talloc_free(r);
+	if (m == NULL) {
+		m2->db_id = db_id;
+	}
 
+	r = (struct ctdb_rec_data *)((uint8_t *)m2 + offset);
+	ctdb_marshall_record_copy(r, reqid, key, header, data, length);
 	m2->count++;
 
 	return m2;
diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c
index aa6abbe..ecf3aba 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -1092,8 +1092,7 @@ int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA inda
 	}	    
 
 
-	outdata->dptr = (uint8_t *)records;
-	outdata->dsize = talloc_get_size(records);
+	*outdata = ctdb_marshall_finish(records);
 
 	return 0;
 }
@@ -1290,9 +1289,7 @@ int32_t ctdb_control_receive_records(struct ctdb_context *ctdb,
 		rec = (struct ctdb_rec_data *)(rec->length + (uint8_t *)rec);
 	}
 
-
-	outdata->dptr = (uint8_t *)records;
-	outdata->dsize = talloc_get_size(records);
+	*outdata = ctdb_marshall_finish(records);
 
 	return 0;
 }
diff --git a/server/ctdb_vacuum.c b/server/ctdb_vacuum.c
index ce3c600..c3054bf 100644
--- a/server/ctdb_vacuum.c
+++ b/server/ctdb_vacuum.c
@@ -181,35 +181,23 @@ static int add_record_to_vacuum_fetch_list(struct vacuum_data *vdata,
 					   TDB_DATA key)
 {
 	struct ctdb_context *ctdb = vdata->ctdb;
-	struct ctdb_rec_data *rec;
 	uint32_t lmaster;
-	size_t old_size;
 	struct ctdb_marshall_buffer *vfl;
 
 	lmaster = ctdb_lmaster(ctdb, &key);
 
 	vfl = vdata->vacuum_fetch_list[lmaster];
 
-	rec = ctdb_marshall_record(vfl, ctdb->pnn, key, NULL, tdb_null);
-	if (rec == NULL) {
+	vfl = ctdb_marshall_add(ctdb, vfl, vfl->db_id, ctdb->pnn,
+				key, NULL, tdb_null);
+	if (vfl == NULL) {
 		DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
 		vdata->traverse_error = true;
 		return -1;
 	}
 
-	old_size = talloc_get_size(vfl);
-	vfl = talloc_realloc_size(NULL, vfl, old_size + rec->length);
-	if (vfl == NULL) {
-		DEBUG(DEBUG_ERR,(__location__ " Failed to expand\n"));
-		vdata->traverse_error = true;
-		return -1;
-	}
 	vdata->vacuum_fetch_list[lmaster] = vfl;
 
-	vfl->count++;
-	memcpy(old_size+(uint8_t *)vfl, rec, rec->length);
-	talloc_free(rec);
-
 	return 0;
 }
 
@@ -294,23 +282,17 @@ static int delete_marshall_traverse(void *param, void *data)
 {
 	struct delete_record_data *dd = talloc_get_type(data, struct delete_record_data);
 	struct delete_records_list *recs = talloc_get_type(param, struct delete_records_list);
-	struct ctdb_rec_data *rec;
-	size_t old_size;
+	struct ctdb_marshall_buffer *m;
 
-	rec = ctdb_marshall_record(dd, recs->records->db_id, dd->key, &dd->hdr, tdb_null);
-	if (rec == NULL) {
+	m = ctdb_marshall_add(recs, recs->records, recs->records->db_id,
+			      recs->records->db_id,
+			      dd->key, &dd->hdr, tdb_null);
+	if (m == NULL) {
 		DEBUG(DEBUG_ERR, (__location__ " failed to marshall record\n"));
-		return 0;
+		return -1;
 	}
 
-	old_size = talloc_get_size(recs->records);
-	recs->records = talloc_realloc_size(NULL, recs->records, old_size + rec->length);
-	if (recs->records == NULL) {
-		DEBUG(DEBUG_ERR,(__location__ " Failed to expand\n"));
-		return 0;
-	}
-	recs->records->count++;
-	memcpy(old_size+(uint8_t *)(recs->records), rec, rec->length);
+	recs->records = m;
 	return 0;
 }
 
@@ -793,8 +775,7 @@ static void ctdb_process_vacuum_fetch_lists(struct ctdb_db_context *ctdb_db,
 				   vfl->count, ctdb->nodes[i]->pnn,
 				   ctdb_db->db_name));
 
-		data.dsize = talloc_get_size(vfl);
-		data.dptr  = (void *)vfl;
+		data = ctdb_marshall_finish(vfl);
 		if (ctdb_client_send_message(ctdb, ctdb->nodes[i]->pnn,
 					     CTDB_SRVID_VACUUM_FETCH,
 					     data) != 0)
@@ -917,10 +898,10 @@ static void ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR, (__location__ " Error traversing the "
 		      "delete list for first marshalling.\n"));
+		goto done;
 	}
 
-	indata.dsize = talloc_get_size(recs->records);
-	indata.dptr  = (void *)recs->records;
+	indata = ctdb_marshall_finish(recs->records);
 
 	for (i = 0; i < num_active_nodes; i++) {
 		struct ctdb_marshall_buffer *records;
@@ -1024,10 +1005,10 @@ static void ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR, (__location__ " Error traversing the "
 		      "delete list for second marshalling.\n"));
+		goto done;
 	}
 
-	indata.dsize = talloc_get_size(recs->records);
-	indata.dptr  = (void *)recs->records;
+	indata = ctdb_marshall_finish(recs->records);
 
 	for (i = 0; i < num_active_nodes; i++) {
 		struct ctdb_marshall_buffer *records;


-- 
CTDB repository


More information about the samba-cvs mailing list