[SCM] Samba Shared Repository - branch master updated
Amitay Isaacs
amitay at samba.org
Wed Jul 23 01:44:04 MDT 2014
The branch, master has been updated
via f87b7f6 ctdb-vacuum: Use existing function ctdb_marshall_finish
via 6edc4f2 ctdb-vacuum: Use ctdb_marshall_add to add a record to marshall buffer
via 42ba7a0 ctdb-util: Refactor record marshalling routines to avoid extra talloc
via 64ea6e30 ctdb-util: Refactor ctdb_marshall_record
via 5eac230 ctdb-util: Fix nonempty line endings
via fa4a81c ctdb-vacuum: If talloc_realloc fails, terminate traverse
via 9a4a9cc ctdb-vacuum: Fix talloc hierarchy in delete_marshall_traverse
from 2f86c7d smbd: Fix a typo
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit f87b7f664f813957ee55a6f35abb208eb0f3dcad
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue May 6 18:52:54 2014 +1000
ctdb-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
commit 6edc4f23e9094860ad5cc6b93ce66169dd99047a
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue May 6 18:39:25 2014 +1000
ctdb-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>
commit 42ba7a0a400c970dd534e92d2effa3ed385f8d6d
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue May 6 18:26:41 2014 +1000
ctdb-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>
commit 64ea6e30ef601d91ea16f6a9c5b7a6b9395c0152
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jul 22 11:23:03 2014 +0000
ctdb-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>
commit 5eac2302819b26b8eaf4f6c0a333e4af2b368679
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jul 22 11:22:25 2014 +0000
ctdb-util: Fix nonempty line endings
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit fa4a81c86b6073b2563b090aa657d8e8b63c1276
Author: Amitay Isaacs <amitay at gmail.com>
Date: Thu Jul 10 18:38:13 2014 +1000
ctdb-vacuum: If talloc_realloc fails, terminate traverse
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Reviewed-by: Volker Lendecke <vl at samba.org>
commit 9a4a9ccda397e20b0a894541f4f1a6d24e09bf19
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Jul 22 11:19:13 2014 +0000
ctdb-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>
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/ctdb_util.c | 90 ++++++++++++++++++++++++++------------------
ctdb/server/ctdb_recover.c | 7 +--
ctdb/server/ctdb_vacuum.c | 48 +++++++----------------
3 files changed, 69 insertions(+), 76 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index f71f74a..c4ac583 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/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/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c
index aa6abbe..ecf3aba 100644
--- a/ctdb/server/ctdb_recover.c
+++ b/ctdb/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/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index ce3c600..be3ee1e 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/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)
@@ -919,8 +900,7 @@ static void ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
"delete list for first marshalling.\n"));
}
- 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 +1004,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;
--
Samba Shared Repository
More information about the samba-cvs
mailing list