summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-03-11 15:55:52 +0100
committerMichael Adam <obnox@samba.org>2011-03-14 13:35:52 +0100
commit74f65b6ca62d7c306b2c9654faf1fd2b4faaaf5d (patch)
tree40c130dfad7578339df9414b302aaab33faf9f21
parentdd1a98e76b637020bb6d3ed02283b8bac18a8e20 (diff)
downloadsamba-74f65b6ca62d7c306b2c9654faf1fd2b4faaaf5d.tar.gz
samba-74f65b6ca62d7c306b2c9654faf1fd2b4faaaf5d.tar.xz
samba-74f65b6ca62d7c306b2c9654faf1fd2b4faaaf5d.zip
vacuum: refactor insert_record_into_delete_queue out of ctdb_control_schedule_for_deletion
(This used to be ctdb commit be4b63ee18933524f780df5c313447e5ef0786d1)
-rw-r--r--ctdb/server/ctdb_vacuum.c65
1 files changed, 40 insertions, 25 deletions
diff --git a/ctdb/server/ctdb_vacuum.c b/ctdb/server/ctdb_vacuum.c
index e0dd0ddea2..e34627cf9f 100644
--- a/ctdb/server/ctdb_vacuum.c
+++ b/ctdb/server/ctdb_vacuum.c
@@ -1271,30 +1271,16 @@ int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db)
}
/**
- * Schedule a record for deletetion.
- * Called from the parent context.
+ * Insert a record into the ctdb_db context's delete queue,
+ * handling hash collisions.
*/
-int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
- TDB_DATA indata)
+static int insert_record_into_delete_queue(struct ctdb_db_context *ctdb_db,
+ const struct ctdb_ltdb_header *hdr,
+ TDB_DATA key)
{
- struct ctdb_control_schedule_for_deletion *dd;
- struct ctdb_db_context *ctdb_db;
- int ret;
- TDB_DATA key;
- uint32_t hash;
struct delete_record_data *kd;
-
- dd = (struct ctdb_control_schedule_for_deletion *)indata.dptr;
-
- ctdb_db = find_ctdb_db(ctdb, dd->db_id);
- if (ctdb_db == NULL) {
- DEBUG(DEBUG_ERR, (__location__ " Unknown db id 0x%08x\n",
- dd->db_id));
- return -1;
- }
-
- key.dsize = dd->keylen;
- key.dptr = dd->key;
+ uint32_t hash;
+ int ret;
hash = (uint32_t)ctdb_hash(&key);
@@ -1303,10 +1289,10 @@ int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
"key_hash[0x%08x] "
"lmaster[%u] "
"migrated_with_data[%s]\n",
- ctdb_db->db_name, dd->db_id,
+ ctdb_db->db_name, ctdb_db->db_id,
hash,
ctdb_lmaster(ctdb_db->ctdb, &key),
- dd->hdr.flags & CTDB_REC_FLAG_MIGRATED_WITH_DATA ? "yes" : "no"));
+ 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) {
@@ -1324,9 +1310,9 @@ int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
}
}
- ret = insert_delete_record_data_into_tree(ctdb, ctdb_db,
+ ret = insert_delete_record_data_into_tree(ctdb_db->ctdb, ctdb_db,
ctdb_db->delete_queue,
- &dd->hdr, key);
+ hdr, key);
if (ret != 0) {
return -1;
}
@@ -1334,6 +1320,35 @@ int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
return 0;
}
+/**
+ * Schedule a record for deletetion.
+ * Called from the parent context.
+ */
+int32_t ctdb_control_schedule_for_deletion(struct ctdb_context *ctdb,
+ TDB_DATA indata)
+{
+ struct ctdb_control_schedule_for_deletion *dd;
+ struct ctdb_db_context *ctdb_db;
+ int ret;
+ TDB_DATA key;
+
+ dd = (struct ctdb_control_schedule_for_deletion *)indata.dptr;
+
+ ctdb_db = find_ctdb_db(ctdb, dd->db_id);
+ if (ctdb_db == NULL) {
+ DEBUG(DEBUG_ERR, (__location__ " Unknown db id 0x%08x\n",
+ dd->db_id));
+ return -1;
+ }
+
+ key.dsize = dd->keylen;
+ key.dptr = dd->key;
+
+ ret = insert_record_into_delete_queue(ctdb_db, &dd->hdr, key);
+
+ return ret;
+}
+
int32_t ctdb_local_schedule_for_deletion(struct ctdb_db_context *ctdb_db,
const struct ctdb_ltdb_header *hdr,
TDB_DATA key)