From 86ba133b8efa6fcc704a6cd08fda509b1c366eee Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 19 Dec 2011 15:52:21 +0000 Subject: [PATCH] block data migration based on lowest discarded expiration of content in the datastore to avoid wasting bandwidth on migrating content that is just instantly discarded again anyway --- src/fs/gnunet-service-fs_cp.c | 11 +++++------ src/fs/gnunet-service-fs_cp.h | 6 +----- src/fs/gnunet-service-fs_pr.c | 30 ++++-------------------------- 3 files changed, 10 insertions(+), 37 deletions(-) diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 968cdffcb..7b26e18a6 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c @@ -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 = diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 11be4c6f1..1abec2ad0 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h @@ -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); /** diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 49f395ef6..e8a56c13c 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -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; } -- 2.25.1