ctdb_ltdb_store_server: add ability to send SCHEDULE_FOR_DELETION control to ctdb_ltd...
authorMichael Adam <obnox@samba.org>
Tue, 28 Dec 2010 12:19:22 +0000 (13:19 +0100)
committerMichael Adam <obnox@samba.org>
Wed, 9 Mar 2011 23:56:35 +0000 (00:56 +0100)
server/ctdb_ltdb_server.c

index 5b52cd36c998c9ffe7d35b45c77d380d1a3758fe..94c32bd298f91de63ff70c6882a4a732184c20c9 100644 (file)
@@ -55,7 +55,8 @@ static int ctdb_fetch_func(struct ctdb_call_info *call)
  *
  * This is the server-variant of the ctdb_ltdb_store function.
  * It contains logic to determine whether a record should be
- * stored or deleted.
+ * stored or deleted. It also sends SCHEDULE_FOR_DELETION
+ * controls to the local ctdb daemon if apporpriate.
  */
 static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
                                  TDB_DATA key,
@@ -67,6 +68,7 @@ static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
        int ret;
        bool seqnum_suppressed = false;
        bool keep = false;
+       bool schedule_for_deletion = false;
        uint32_t lmaster;
 
        if (ctdb->flags & CTDB_FLAG_TORTURE) {
@@ -127,6 +129,14 @@ static int ctdb_ltdb_store_server(struct ctdb_db_context *ctdb_db,
                keep = true;
        }
 
+       if (keep &&
+           (data.dsize == 0) &&
+           !ctdb_db->persistent &&
+           (ctdb_db->ctdb->pnn == header->dmaster))
+       {
+               schedule_for_deletion = true;
+       }
+
 store:
        /*
         * The VACUUM_MIGRATED flag is only set temporarily for
@@ -195,6 +205,8 @@ store:
                            ctdb_db->db_name,
                            keep?"store":"delete", ret,
                            tdb_errorstr(ctdb_db->ltdb->tdb)));
+
+               schedule_for_deletion = false;
        }
        if (seqnum_suppressed) {
                tdb_add_flags(ctdb_db->ltdb->tdb, TDB_SEQNUM);
@@ -202,6 +214,14 @@ store:
 
        talloc_free(rec.dptr);
 
+       if (schedule_for_deletion) {
+               int ret2;
+               ret2 = ctdb_local_schedule_for_deletion(ctdb_db, header, key);
+               if (ret != 0) {
+                       DEBUG(DEBUG_ERR, (__location__ " ctdb_local_schedule_for_deletion failed.\n"));
+               }
+       }
+
        return ret;
 }