diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-12-25 20:45:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-12-25 20:45:28 +0000 |
commit | 89ead6c361a291cc25045cb8c519394ddffb48fb (patch) | |
tree | 666c1ae5d42e0a5889e1f8df7fac55238648a757 /src | |
parent | bc88c28ea1dc99ef2ea452b69ed8622981937cd0 (diff) | |
download | gnunet-89ead6c361a291cc25045cb8c519394ddffb48fb.tar.gz gnunet-89ead6c361a291cc25045cb8c519394ddffb48fb.zip |
fixing migration stop delay calculation, largely by first calculating datastore load correctly and then by better distinguishing between datastore full, datastore timeout and success and finally by adding per-peer tracking of the current block interval to adjust to repeated undesireable behavior. See #2029.
Diffstat (limited to 'src')
-rw-r--r-- | src/fs/gnunet-service-fs_cp.h | 7 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs_pr.c | 76 |
2 files changed, 73 insertions, 10 deletions
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h index 1abec2ad0..e3c7cd227 100644 --- a/src/fs/gnunet-service-fs_cp.h +++ b/src/fs/gnunet-service-fs_cp.h | |||
@@ -93,6 +93,13 @@ struct GSF_PeerPerformanceData | |||
93 | struct GNUNET_TIME_Relative avg_reply_delay; | 93 | struct GNUNET_TIME_Relative avg_reply_delay; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * If we get content we already have from this peer, for how | ||
97 | * long do we block him? Adjusted based on the fraction of | ||
98 | * redundant data we receive, between 1s and 1h. | ||
99 | */ | ||
100 | struct GNUNET_TIME_Relative migration_delay; | ||
101 | |||
102 | /** | ||
96 | * Point in time until which this peer does not want us to migrate content | 103 | * Point in time until which this peer does not want us to migrate content |
97 | * to it. | 104 | * to it. |
98 | */ | 105 | */ |
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index dcaba1203..3c0ad4f2d 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c | |||
@@ -901,18 +901,66 @@ put_migration_continuation (void *cls, int success, | |||
901 | { | 901 | { |
902 | struct PutMigrationContext *pmc = cls; | 902 | struct PutMigrationContext *pmc = cls; |
903 | struct GSF_ConnectedPeer *cp; | 903 | struct GSF_ConnectedPeer *cp; |
904 | struct GNUNET_TIME_Relative mig_pause; | ||
905 | struct GSF_PeerPerformanceData *ppd; | ||
904 | 906 | ||
905 | cp = GSF_peer_get_ (&pmc->origin); | ||
906 | if ((GNUNET_OK != success) && (GNUNET_NO == pmc->requested) && (min_expiration.abs_value > 0)&& | ||
907 | (NULL != cp) ) | ||
908 | GSF_block_peer_migration_ (cp, min_expiration); | ||
909 | GNUNET_free (pmc); | ||
910 | /* on failure, increase the put load dramatically */ | ||
911 | if (NULL != datastore_put_load) | 907 | if (NULL != datastore_put_load) |
912 | GNUNET_LOAD_update (datastore_put_load, | 908 | { |
913 | GNUNET_TIME_UNIT_HOURS.rel_value); | 909 | if (GNUNET_SYSERR != success) |
910 | { | ||
911 | GNUNET_LOAD_update (datastore_put_load, | ||
912 | GNUNET_TIME_absolute_get_duration (pmc->start).rel_value); | ||
913 | } | ||
914 | else | ||
915 | { | ||
916 | /* on queue failure / timeout, increase the put load dramatically */ | ||
917 | GNUNET_LOAD_update (datastore_put_load, | ||
918 | GNUNET_TIME_UNIT_MINUTES.rel_value); | ||
919 | } | ||
920 | } | ||
921 | cp = GSF_peer_get_ (&pmc->origin); | ||
914 | if (GNUNET_OK == success) | 922 | if (GNUNET_OK == success) |
923 | { | ||
924 | if (NULL != cp) | ||
925 | { | ||
926 | ppd = GSF_get_peer_performance_data_ (cp); | ||
927 | ppd->migration_delay.rel_value /= 2; | ||
928 | } | ||
929 | GNUNET_free (pmc); | ||
915 | return; | 930 | return; |
931 | } | ||
932 | if ( (GNUNET_NO == success) && | ||
933 | (GNUNET_NO == pmc->requested) && | ||
934 | (NULL != cp) ) | ||
935 | { | ||
936 | ppd = GSF_get_peer_performance_data_ (cp); | ||
937 | if (min_expiration.abs_value > 0) | ||
938 | { | ||
939 | #if DEBUG_FS | ||
940 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
941 | "Asking to stop migration for %llu ms because datastore is full\n", | ||
942 | (unsigned long long) GNUNET_TIME_absolute_get_remaining (min_expiration).rel_value); | ||
943 | #endif | ||
944 | GSF_block_peer_migration_ (cp, min_expiration); | ||
945 | } | ||
946 | else | ||
947 | { | ||
948 | ppd->migration_delay = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_SECONDS, | ||
949 | ppd->migration_delay); | ||
950 | ppd->migration_delay = GNUNET_TIME_relative_min (GNUNET_TIME_UNIT_HOURS, | ||
951 | ppd->migration_delay); | ||
952 | mig_pause.rel_value = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, | ||
953 | ppd->migration_delay.rel_value); | ||
954 | ppd->migration_delay = GNUNET_TIME_relative_multiply (ppd->migration_delay, 2); | ||
955 | #if DEBUG_FS | ||
956 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
957 | "Replicated content already exists locally, asking to stop migration for %llu ms\n", | ||
958 | (unsigned long long) mig_pause.rel_value); | ||
959 | #endif | ||
960 | GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute (mig_pause)); | ||
961 | } | ||
962 | } | ||
963 | GNUNET_free (pmc); | ||
916 | GNUNET_STATISTICS_update (GSF_stats, | 964 | GNUNET_STATISTICS_update (GSF_stats, |
917 | gettext_noop ("# Datastore `PUT' failures"), 1, | 965 | gettext_noop ("# Datastore `PUT' failures"), 1, |
918 | GNUNET_NO); | 966 | GNUNET_NO); |
@@ -1006,7 +1054,7 @@ handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, | |||
1006 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 1054 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
1007 | &put_migration_continuation, pmc)) | 1055 | &put_migration_continuation, pmc)) |
1008 | { | 1056 | { |
1009 | put_migration_continuation (pmc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, NULL); | 1057 | put_migration_continuation (pmc, GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, NULL); |
1010 | } | 1058 | } |
1011 | } | 1059 | } |
1012 | } | 1060 | } |
@@ -1524,7 +1572,7 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, | |||
1524 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 1572 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
1525 | &put_migration_continuation, pmc)) | 1573 | &put_migration_continuation, pmc)) |
1526 | { | 1574 | { |
1527 | put_migration_continuation (pmc, GNUNET_NO, GNUNET_TIME_UNIT_ZERO_ABS, NULL); | 1575 | put_migration_continuation (pmc, GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, NULL); |
1528 | } | 1576 | } |
1529 | } | 1577 | } |
1530 | else | 1578 | else |
@@ -1549,6 +1597,14 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp, | |||
1549 | GNUNET_CRYPTO_random_u32 | 1597 | GNUNET_CRYPTO_random_u32 |
1550 | (GNUNET_CRYPTO_QUALITY_WEAK, | 1598 | (GNUNET_CRYPTO_QUALITY_WEAK, |
1551 | (unsigned int) (60000 * putl * putl))); | 1599 | (unsigned int) (60000 * putl * putl))); |
1600 | #if DEBUG_FS | ||
1601 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1602 | "Asking to stop migration for %llu ms because of load %f and events %d/%d\n", | ||
1603 | (unsigned long long) block_time.rel_value, | ||
1604 | putl, | ||
1605 | active_to_migration, | ||
1606 | (GNUNET_NO == prq.request_found)); | ||
1607 | #endif | ||
1552 | GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute (block_time)); | 1608 | GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute (block_time)); |
1553 | } | 1609 | } |
1554 | return GNUNET_OK; | 1610 | return GNUNET_OK; |