summaryrefslogtreecommitdiffstats
path: root/ctdb
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-02-15 13:03:51 +0100
committerAmitay Isaacs <amitay@gmail.com>2014-03-06 11:31:14 +1100
commit83fa09e78c6ca8e08cb2659f013a05b4b340f0aa (patch)
tree85df8ce4200b01d33ff83d623e0e084701112115 /ctdb
parent974aa73160d50b7cf63b4a5e6dd7a7b1408ece42 (diff)
downloadsamba-83fa09e78c6ca8e08cb2659f013a05b4b340f0aa.tar.gz
samba-83fa09e78c6ca8e08cb2659f013a05b4b340f0aa.tar.xz
samba-83fa09e78c6ca8e08cb2659f013a05b4b340f0aa.zip
ctdb-vacuum: use tdb_parse_record instead of tdb_fetch in delete_marshall_traverse_first()
Spare malloc and free. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/server/ctdb_vacuum.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index 9e193a8a0a3..7d2a6b4a870 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -324,8 +324,7 @@ static int delete_marshall_traverse_first(void *param, void *data)
struct delete_records_list *recs = talloc_get_type(param, struct delete_records_list);
struct ctdb_db_context *ctdb_db = dd->ctdb_db;
struct ctdb_context *ctdb = ctdb_db->ctdb;
- struct ctdb_ltdb_header *header;
- TDB_DATA tdb_data;
+ struct ctdb_ltdb_header header;
uint32_t lmaster;
uint32_t hash = ctdb_hash(&(dd->key));
int res;
@@ -346,26 +345,13 @@ static int delete_marshall_traverse_first(void *param, void *data)
* changed and that we are still its lmaster and dmaster.
*/
- tdb_data = tdb_fetch(ctdb_db->ltdb->tdb, dd->key);
- if (tdb_data.dsize < sizeof(struct ctdb_ltdb_header)) {
- DEBUG(DEBUG_INFO, (__location__ ": record with hash [0x%08x] "
- "on database db[%s] does not exist or is not"
- " a ctdb-record. skipping.\n",
- hash, ctdb_db->db_name));
- goto skip;
- }
-
- if (tdb_data.dsize > sizeof(struct ctdb_ltdb_header)) {
- DEBUG(DEBUG_INFO, (__location__ ": record with hash [0x%08x] "
- "on database db[%s] has been recycled. "
- "skipping.\n",
- hash, ctdb_db->db_name));
+ res = tdb_parse_record(ctdb_db->ltdb->tdb, dd->key,
+ vacuum_record_parser, &header);
+ if (res != 0) {
goto skip;
}
- header = (struct ctdb_ltdb_header *)tdb_data.dptr;
-
- if (header->flags & CTDB_REC_RO_FLAGS) {
+ if (header.flags & CTDB_REC_RO_FLAGS) {
DEBUG(DEBUG_INFO, (__location__ ": record with hash [0x%08x] "
"on database db[%s] has read-only flags. "
"skipping.\n",
@@ -373,7 +359,7 @@ static int delete_marshall_traverse_first(void *param, void *data)
goto skip;
}
- if (header->dmaster != ctdb->pnn) {
+ if (header.dmaster != ctdb->pnn) {
DEBUG(DEBUG_INFO, (__location__ ": record with hash [0x%08x] "
"on database db[%s] has been migrated away. "
"skipping.\n",
@@ -381,7 +367,7 @@ static int delete_marshall_traverse_first(void *param, void *data)
goto skip;
}
- if (header->rsn != dd->hdr.rsn) {
+ if (header.rsn != dd->hdr.rsn) {
DEBUG(DEBUG_INFO, (__location__ ": record with hash [0x%08x] "
"on database db[%s] seems to have been "
"migrated away and back again (with empty "
@@ -409,7 +395,7 @@ static int delete_marshall_traverse_first(void *param, void *data)
* on the record's dmaster.
*/
- res = ctdb_ltdb_store(ctdb_db, dd->key, header, tdb_null);
+ res = ctdb_ltdb_store(ctdb_db, dd->key, &header, tdb_null);
if (res != 0) {
DEBUG(DEBUG_ERR, (__location__ ": Failed to store record with "
"key hash [0x%08x] on database db[%s].\n",
@@ -429,10 +415,6 @@ skip:
dd = NULL;
done:
- if (tdb_data.dptr != NULL) {
- free(tdb_data.dptr);
- }
-
if (dd == NULL) {
return 0;
}