summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-04-07 12:17:16 +0200
committerMichael Adam <obnox@samba.org>2011-12-23 17:39:00 +0100
commita481ca711f26fe4b9d0e7eff2901d0c5944d964b (patch)
tree536d344849644ef30a9fb2187355503b4f693bbc
parent3dab0c9b0ba7ce6f15c9a9c3fb45188edf8ce307 (diff)
downloadsamba-a481ca711f26fe4b9d0e7eff2901d0c5944d964b.tar.gz
samba-a481ca711f26fe4b9d0e7eff2901d0c5944d964b.tar.xz
samba-a481ca711f26fe4b9d0e7eff2901d0c5944d964b.zip
vacuum: add ctdb_local_remove_from_delete_queue()
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> (This used to be ctdb commit a5065b42a98c709173503e02d217f97792878625)
-rw-r--r--ctdb/include/ctdb_private.h4
-rw-r--r--ctdb/server/ctdb_vacuum.c53
2 files changed, 57 insertions, 0 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index 9e5e188c49..547ad388c9 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -1427,6 +1427,10 @@ int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
const struct ctdb_ltdb_header *hdr,
TDB_DATA key);
+void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
+ const struct ctdb_ltdb_header *hdr,
+ const TDB_DATA key);
+
struct ctdb_ltdb_header *ctdb_header_from_record_handle(struct ctdb_record_handle *h);
/* For unit testing ctdb_transaction.c. */
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index 5be8abe420..2b85e7174c 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -1301,6 +1301,42 @@ int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db)
return 0;
}
+static void remove_record_from_delete_queue(struct ctdb_db_context *ctdb_db,
+ const struct ctdb_ltdb_header *hdr,
+ const TDB_DATA key)
+{
+ struct delete_record_data *kd;
+ uint32_t hash;
+
+ hash = (uint32_t)ctdb_hash(&key);
+
+ DEBUG(DEBUG_DEBUG, (__location__
+ " remove_record_from_delete_queue: db[%s] "
+ "db_id[0x%08x] "
+ "key_hash[0x%08x] "
+ "lmaster[%u] "
+ "migrated_with_data[%s]\n",
+ ctdb_db->db_name, ctdb_db->db_id,
+ hash,
+ ctdb_lmaster(ctdb_db->ctdb, &key),
+ hdr->flags & CTDB_REC_FLAG_MIGRATED_WITH_DATA ? "yes" : "no"));
+
+ kd = (struct delete_record_data *)trbt_lookup32(ctdb_db->delete_queue, hash);
+ if (kd == NULL) {
+ return;
+ }
+ if (kd->key.dsize != key.dsize) {
+ return;
+ }
+ if (memcmp(kd->key.dptr, key.dptr, key.dsize) != 0) {
+ return;
+ }
+
+ talloc_free(kd);
+
+ return;
+}
+
/**
* Insert a record into the ctdb_db context's delete queue,
* handling hash collisions.
@@ -1435,3 +1471,20 @@ int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
return ret;
}
+
+void ctdb_local_remove_from_delete_queue(struct ctdb_db_context *ctdb_db,
+ const struct ctdb_ltdb_header *hdr,
+ const TDB_DATA key)
+{
+ if (ctdb_db->ctdb->ctdbd_pid != getpid()) {
+ /*
+ * Only remove the record from the delete queue if called
+ * in the main daemon.
+ */
+ return;
+ }
+
+ remove_record_from_delete_queue(ctdb_db, hdr, key);
+
+ return;
+}