summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-04-19 02:57:00 +0200
committerMichael Adam <obnox@samba.org>2014-06-17 09:33:10 +0200
commit413f99f86e26a8b12a807d0c2436c78805983566 (patch)
treea7046fb2b4b217c3ac1e91eb8131753587948a2e
parent368683d7af747e3d67c48a702ff315a2022c6f85 (diff)
downloadsamba-413f99f86e26a8b12a807d0c2436c78805983566.zip
samba-413f99f86e26a8b12a807d0c2436c78805983566.tar.gz
samba-413f99f86e26a8b12a807d0c2436c78805983566.tar.xz
ctdb:vacuum: remove now unused ctdb_repack_tdb().
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rw-r--r--ctdb/server/ctdb_vacuum.c129
1 files changed, 0 insertions, 129 deletions
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index ee7bb0b..2c78de7 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -1295,135 +1295,6 @@ static int ctdb_vacuum_db(struct ctdb_db_context *ctdb_db,
return 0;
}
-
-/*
- * traverse function for repacking
- */
-static int repack_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
- void *private_data)
-{
- struct vacuum_data *vdata = (struct vacuum_data *)private_data;
-
- if (vdata->vacuum) {
- uint32_t hash = ctdb_hash(&key);
- struct delete_record_data *kd;
- /*
- * check if we can ignore this record because it's in the delete_list
- */
- kd = (struct delete_record_data *)trbt_lookup32(vdata->delete_list, hash);
- /*
- * there might be hash collisions so we have to compare the keys here to be sure
- */
- if (kd && kd->key.dsize == key.dsize && memcmp(kd->key.dptr, key.dptr, key.dsize) == 0) {
- struct ctdb_ltdb_header *hdr = (struct ctdb_ltdb_header *)data.dptr;
- /*
- * we have to check if the record hasn't changed in the meantime in order to
- * savely remove it from the database
- */
- if (data.dsize == sizeof(struct ctdb_ltdb_header) &&
- hdr->dmaster == kd->ctdb->pnn &&
- ctdb_lmaster(kd->ctdb, &(kd->key)) == kd->ctdb->pnn &&
- kd->hdr.rsn == hdr->rsn) {
- vdata->count.repack.vacuumed++;
- return 0;
- }
- }
- }
- if (tdb_store(vdata->dest_db, key, data, TDB_INSERT) != 0) {
- vdata->traverse_error = true;
- return -1;
- }
- vdata->count.repack.copied++;
- return 0;
-}
-
-/*
- * repack a tdb
- */
-static int ctdb_repack_tdb(struct tdb_context *tdb, TALLOC_CTX *mem_ctx, struct vacuum_data *vdata)
-{
- struct tdb_context *tmp_db;
-
- if (tdb_transaction_start(tdb) != 0) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to start transaction\n"));
- return -1;
- }
-
- tmp_db = tdb_open("tmpdb", tdb_hash_size(tdb),
- TDB_INTERNAL|TDB_DISALLOW_NESTING,
- O_RDWR|O_CREAT, 0);
- if (tmp_db == NULL) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to create tmp_db\n"));
- tdb_transaction_cancel(tdb);
- return -1;
- }
-
- vdata->traverse_error = false;
- vdata->dest_db = tmp_db;
- vdata->vacuum = true;
- vdata->count.repack.vacuumed = 0;
- vdata->count.repack.copied = 0;
-
- /*
- * repack and vacuum on-the-fly by not writing the records that are
- * no longer needed
- */
- if (tdb_traverse_read(tdb, repack_traverse, vdata) == -1) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to traverse copying out\n"));
- tdb_transaction_cancel(tdb);
- tdb_close(tmp_db);
- return -1;
- }
-
- DEBUG(DEBUG_INFO,(__location__ " %u records vacuumed\n",
- vdata->count.repack.vacuumed));
-
- if (vdata->traverse_error) {
- DEBUG(DEBUG_ERR,(__location__ " Error during traversal\n"));
- tdb_transaction_cancel(tdb);
- tdb_close(tmp_db);
- return -1;
- }
-
- if (tdb_wipe_all(tdb) != 0) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to wipe database\n"));
- tdb_transaction_cancel(tdb);
- tdb_close(tmp_db);
- return -1;
- }
-
- vdata->traverse_error = false;
- vdata->dest_db = tdb;
- vdata->vacuum = false;
- vdata->count.repack.copied = 0;
-
- if (tdb_traverse_read(tmp_db, repack_traverse, vdata) == -1) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to traverse copying back\n"));
- tdb_transaction_cancel(tdb);
- tdb_close(tmp_db);
- return -1;
- }
-
- if (vdata->traverse_error) {
- DEBUG(DEBUG_ERR,(__location__ " Error during second traversal\n"));
- tdb_transaction_cancel(tdb);
- tdb_close(tmp_db);
- return -1;
- }
-
- tdb_close(tmp_db);
-
-
- if (tdb_transaction_commit(tdb) != 0) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to commit\n"));
- return -1;
- }
- DEBUG(DEBUG_INFO,(__location__ " %u records copied\n",
- vdata->count.repack.copied));
-
- return 0;
-}
-
/*
* repack and vaccum a db
* called from the child context