block data migration based on lowest discarded expiration of content in the datastore...
authorChristian Grothoff <christian@grothoff.org>
Mon, 19 Dec 2011 15:52:21 +0000 (15:52 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 19 Dec 2011 15:52:21 +0000 (15:52 +0000)
src/fs/gnunet-service-fs_cp.c
src/fs/gnunet-service-fs_cp.h
src/fs/gnunet-service-fs_pr.c

index 968cdffcb089334eb07803fc4e4dd216de16089f..7b26e18a6cbb538b2d77b2e51a4a19ad7216d334 100644 (file)
@@ -1710,12 +1710,11 @@ create_migration_stop_message (void *cls, size_t size, void *buf)
  */
 void
 GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
-                           struct GNUNET_TIME_Relative block_time)
+                           struct GNUNET_TIME_Absolute block_time)
 {
-  if (GNUNET_TIME_absolute_get_remaining (cp->last_migration_block).rel_value >
-      block_time.rel_value)
+  if (cp->last_migration_block.abs_value > block_time.abs_value)
   {
-#if DEBUG_FS && 0
+#if DEBUG_FS
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Migration already blocked for another %llu ms\n",
                 (unsigned long long)
@@ -1726,9 +1725,9 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
   }
 #if DEBUG_FS && 0
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asking to stop migration for %llu ms\n",
-              (unsigned long long) block_time.rel_value);
+              (unsigned long long) GNUNET_TIME_absolute_get_remaining (block_time).rel_value);
 #endif
-  cp->last_migration_block = GNUNET_TIME_relative_to_absolute (block_time);
+  cp->last_migration_block = block_time;
   if (cp->migration_pth != NULL)
     GSF_peer_transmit_cancel_ (cp->migration_pth);
   cp->migration_pth =
index 11be4c6f12a7c0c70e8e1c6939101c59ebbe640a..1abec2ad029efaff86125391a6b5222a7db52ef3 100644 (file)
@@ -140,10 +140,6 @@ struct GSF_PeerPerformanceData
    */
   unsigned int pending_replies;
 
-  /**
-   * How many of the last blocks from migration were duplicates?
-   */
-  unsigned int migration_duplication;
 };
 
 
@@ -339,7 +335,7 @@ GSF_get_peer_performance_data_ (struct GSF_ConnectedPeer *cp);
  */
 void
 GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
-                           struct GNUNET_TIME_Relative block_time);
+                           struct GNUNET_TIME_Absolute block_time);
 
 
 /**
index 49f395ef644c48d72cda0e5e3c6d12f3add9874c..e8a56c13cd2ba390b5809cf4d6b61c7ca6777e65 100644 (file)
@@ -899,34 +899,12 @@ put_migration_continuation (void *cls, int success,
                            const char *msg)
 {
   struct PutMigrationContext *pmc = cls;
-  struct GNUNET_TIME_Relative block_time;
   struct GSF_ConnectedPeer *cp;
-  struct GSF_PeerPerformanceData *ppd;
 
   cp = GSF_peer_get_ (&pmc->origin);
-  if ((GNUNET_OK != success) && (GNUNET_NO == pmc->requested))
-  {
-    /* block migration for a bit... */
-    if (NULL != cp)
-    {
-      ppd = GSF_get_peer_performance_data_ (cp);
-      ppd->migration_duplication++;
-      block_time =
-          GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
-                                         5 * ppd->migration_duplication +
-                                         GNUNET_CRYPTO_random_u32
-                                         (GNUNET_CRYPTO_QUALITY_WEAK, 5));
-      GSF_block_peer_migration_ (cp, block_time);
-    }
-  }
-  else
-  {
-    if (NULL != cp)
-    {
-      ppd = GSF_get_peer_performance_data_ (cp);
-      ppd->migration_duplication = 0;   /* reset counter */
-    }
-  }
+  if ((GNUNET_OK != success) && (GNUNET_NO == pmc->requested) && (min_expiration.abs_value > 0)&&
+      (NULL != cp) )
+    GSF_block_peer_migration_ (cp, min_expiration);      
   GNUNET_free (pmc);
   /* on failure, increase the put load dramatically */
   if (NULL != datastore_put_load)
@@ -1564,7 +1542,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
                                        GNUNET_CRYPTO_random_u32
                                        (GNUNET_CRYPTO_QUALITY_WEAK,
                                         (unsigned int) (60000 * putl * putl)));
-    GSF_block_peer_migration_ (cp, block_time);
+    GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute (block_time));
   }
   return GNUNET_OK;
 }