summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_vacuum.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-02-14 21:50:59 +0100
committerAmitay Isaacs <amitay@gmail.com>2014-03-06 11:31:13 +1100
commit23be632449524e74d73fcb6fd3875a6d5a428d89 (patch)
treee288f18651070fe569dd25d4c0a5cda2de9b6fd1 /ctdb/server/ctdb_vacuum.c
parentbe2f1a0c790d08571dd757fb7b2941d367175008 (diff)
downloadsamba-23be632449524e74d73fcb6fd3875a6d5a428d89.tar.gz
samba-23be632449524e74d73fcb6fd3875a6d5a428d89.tar.xz
samba-23be632449524e74d73fcb6fd3875a6d5a428d89.zip
ctdb-vacuum: use tdb_parse_record instead of tdb_fetch in delete_record_traverse()
Spare malloc and free. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/server/ctdb_vacuum.c')
-rw-r--r--ctdb/server/ctdb_vacuum.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index 554e2752563..c7eeeb0e7e7 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -587,8 +587,7 @@ static int delete_record_traverse(void *param, void *data)
struct ctdb_db_context *ctdb_db = dd->ctdb_db;
struct ctdb_context *ctdb = ctdb_db->ctdb;
int res;
- struct ctdb_ltdb_header *header;
- TDB_DATA tdb_data;
+ struct ctdb_ltdb_header header;
uint32_t lmaster;
uint32_t hash = ctdb_hash(&(dd->key));
@@ -609,26 +608,13 @@ static int delete_record_traverse(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",
@@ -636,7 +622,7 @@ static int delete_record_traverse(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",
@@ -644,7 +630,7 @@ static int delete_record_traverse(void *param, void *data)
goto skip;
}
- if (header->rsn != dd->hdr.rsn + 1) {
+ if (header.rsn != dd->hdr.rsn + 1) {
/*
* The record has been migrated off the node and back again.
* But not requeued for deletion. Skip it.
@@ -691,8 +677,6 @@ skip:
vdata->delete_skipped++;
done:
- free(tdb_data.dptr);
-
tdb_chainunlock(ctdb_db->ltdb->tdb, dd->key);
talloc_free(dd);