aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-10-06 12:55:38 +0000
committerChristian Grothoff <christian@grothoff.org>2010-10-06 12:55:38 +0000
commit2ffb6f329c85b24367199f910f6603950e1fba68 (patch)
tree537e401b59e3f7c435d5d8369ba3088e1679743b /src/fs
parentb8da6057b2c0c66931ccde9b4bba418fc5222724 (diff)
downloadgnunet-2ffb6f329c85b24367199f910f6603950e1fba68.tar.gz
gnunet-2ffb6f329c85b24367199f910f6603950e1fba68.zip
DHT PUT integration into FS
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_test_lib_data.conf6
-rw-r--r--src/fs/gnunet-service-fs.c191
-rw-r--r--src/fs/test_fs_data.conf6
-rw-r--r--src/fs/test_fs_download_data.conf6
-rw-r--r--src/fs/test_fs_file_information_data.conf6
-rw-r--r--src/fs/test_fs_list_indexed_data.conf6
-rw-r--r--src/fs/test_fs_namespace_data.conf6
-rw-r--r--src/fs/test_fs_publish_data.conf6
-rw-r--r--src/fs/test_fs_search_data.conf6
-rw-r--r--src/fs/test_fs_unindex_data.conf6
-rw-r--r--src/fs/test_fs_uri_data.conf6
-rw-r--r--src/fs/test_gnunet_fs_idx_data.conf6
-rw-r--r--src/fs/test_gnunet_fs_ns_data.conf6
-rw-r--r--src/fs/test_gnunet_fs_psd_data.conf6
-rw-r--r--src/fs/test_gnunet_fs_rec_data.conf6
-rw-r--r--src/fs/test_gnunet_service_fs_migration_data.conf6
16 files changed, 280 insertions, 1 deletions
diff --git a/src/fs/fs_test_lib_data.conf b/src/fs/fs_test_lib_data.conf
index 7c8b867ae..c9dafa748 100644
--- a/src/fs/fs_test_lib_data.conf
+++ b/src/fs/fs_test_lib_data.conf
@@ -58,3 +58,9 @@ ACTIVEMIGRATION = NO
58 58
59[testing] 59[testing]
60WEAKRANDOM = YES 60WEAKRANDOM = YES
61
62
63[dhtcache]
64QUOTA=65536
65
66DATABASE=sqlite
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 610c6e6dd..2e1c574c8 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -65,6 +65,11 @@
65#define TRUST_FLUSH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5) 65#define TRUST_FLUSH_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
66 66
67/** 67/**
68 * How often do we at most PUT content into the DHT?
69 */
70#define MAX_DHT_PUT_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
71
72/**
68 * Inverse of the probability that we will submit the same query 73 * Inverse of the probability that we will submit the same query
69 * to the same peer again. If the same peer already got the query 74 * to the same peer again. If the same peer already got the query
70 * repeatedly recently, the probability is multiplied by the inverse 75 * repeatedly recently, the probability is multiplied by the inverse
@@ -718,6 +723,16 @@ static struct MigrationReadyBlock *mig_tail;
718static struct GNUNET_DATASTORE_QueueEntry *mig_qe; 723static struct GNUNET_DATASTORE_QueueEntry *mig_qe;
719 724
720/** 725/**
726 * Request to datastore for DHT PUTs (or NULL).
727 */
728static struct GNUNET_DATASTORE_QueueEntry *dht_qe;
729
730/**
731 * Type we will request for the next DHT PUT round from the datastore.
732 */
733static enum GNUNET_BLOCK_Type dht_put_type = GNUNET_BLOCK_TYPE_FS_KBLOCK;
734
735/**
721 * Where do we store trust information? 736 * Where do we store trust information?
722 */ 737 */
723static char *trustDirectory; 738static char *trustDirectory;
@@ -728,6 +743,11 @@ static char *trustDirectory;
728static GNUNET_SCHEDULER_TaskIdentifier mig_task; 743static GNUNET_SCHEDULER_TaskIdentifier mig_task;
729 744
730/** 745/**
746 * ID of task that collects blocks for DHT PUTs.
747 */
748static GNUNET_SCHEDULER_TaskIdentifier dht_task;
749
750/**
731 * What is the maximum frequency at which we are allowed to 751 * What is the maximum frequency at which we are allowed to
732 * poll the datastore for migration content? 752 * poll the datastore for migration content?
733 */ 753 */
@@ -749,6 +769,12 @@ static unsigned int mig_size;
749static int active_migration; 769static int active_migration;
750 770
751/** 771/**
772 * How many entires with zero anonymity do we currently estimate
773 * to have in the database?
774 */
775static unsigned int zero_anonymity_count_estimate;
776
777/**
752 * Typical priorities we're seeing from other peers right now. Since 778 * Typical priorities we're seeing from other peers right now. Since
753 * most priorities will be zero, this value is the weighted average of 779 * most priorities will be zero, this value is the weighted average of
754 * non-zero priorities seen "recently". In order to ensure that new 780 * non-zero priorities seen "recently". In order to ensure that new
@@ -983,6 +1009,19 @@ gather_migration_blocks (void *cls,
983 const struct GNUNET_SCHEDULER_TaskContext *tc); 1009 const struct GNUNET_SCHEDULER_TaskContext *tc);
984 1010
985 1011
1012
1013
1014/**
1015 * Task that is run periodically to obtain blocks for DHT PUTs.
1016 *
1017 * @param cls type of blocks to gather
1018 * @param tc scheduler context (unused)
1019 */
1020static void
1021gather_dht_put_blocks (void *cls,
1022 const struct GNUNET_SCHEDULER_TaskContext *tc);
1023
1024
986/** 1025/**
987 * If the migration task is not currently running, consider 1026 * If the migration task is not currently running, consider
988 * (re)scheduling it with the appropriate delay. 1027 * (re)scheduling it with the appropriate delay.
@@ -1012,6 +1051,41 @@ consider_migration_gathering ()
1012 1051
1013 1052
1014/** 1053/**
1054 * If the DHT PUT gathering task is not currently running, consider
1055 * (re)scheduling it with the appropriate delay.
1056 */
1057static void
1058consider_dht_put_gathering (void *cls)
1059{
1060 struct GNUNET_TIME_Relative delay;
1061
1062 if (dsh == NULL)
1063 return;
1064 if (dht_qe != NULL)
1065 return;
1066 if (dht_task != GNUNET_SCHEDULER_NO_TASK)
1067 return;
1068 if (zero_anonymity_count_estimate > 0)
1069 {
1070 delay = GNUNET_TIME_relative_divide (GNUNET_DHT_DEFAULT_REPUBLISH_FREQUENCY,
1071 zero_anonymity_count_estimate);
1072 delay = GNUNET_TIME_relative_min (delay,
1073 MAX_DHT_PUT_FREQ);
1074 }
1075 else
1076 {
1077 /* if we have NO zero-anonymity content yet, wait 5 minutes for some to
1078 (hopefully) appear */
1079 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5);
1080 }
1081 dht_task = GNUNET_SCHEDULER_add_delayed (sched,
1082 delay,
1083 &gather_dht_put_blocks,
1084 cls);
1085}
1086
1087
1088/**
1015 * Process content offered for migration. 1089 * Process content offered for migration.
1016 * 1090 *
1017 * @param cls closure 1091 * @param cls closure
@@ -1083,6 +1157,86 @@ process_migration_content (void *cls,
1083 1157
1084 1158
1085/** 1159/**
1160 * Function called upon completion of the DHT PUT operation.
1161 */
1162static void
1163dht_put_continuation (void *cls,
1164 const struct GNUNET_SCHEDULER_TaskContext *tc)
1165{
1166 GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
1167}
1168
1169
1170/**
1171 * Store content in DHT.
1172 *
1173 * @param cls closure
1174 * @param key key for the content
1175 * @param size number of bytes in data
1176 * @param data content stored
1177 * @param type type of the content
1178 * @param priority priority of the content
1179 * @param anonymity anonymity-level for the content
1180 * @param expiration expiration time for the content
1181 * @param uid unique identifier for the datum;
1182 * maybe 0 if no unique identifier is available
1183 */
1184static void
1185process_dht_put_content (void *cls,
1186 const GNUNET_HashCode * key,
1187 size_t size,
1188 const void *data,
1189 enum GNUNET_BLOCK_Type type,
1190 uint32_t priority,
1191 uint32_t anonymity,
1192 struct GNUNET_TIME_Absolute
1193 expiration, uint64_t uid)
1194{
1195 static unsigned int counter;
1196 static GNUNET_HashCode last_vhash;
1197 static GNUNET_HashCode vhash;
1198
1199 if (key == NULL)
1200 {
1201 dht_qe = NULL;
1202 consider_dht_put_gathering (cls);
1203 return;
1204 }
1205 /* slightly funky code to estimate the total number of values with zero
1206 anonymity from the maximum observed length of a monotonically increasing
1207 sequence of hashes over the contents */
1208 GNUNET_CRYPTO_hash (data, size, &vhash);
1209 if (GNUNET_CRYPTO_hash_cmp (&vhash, &last_vhash) <= 0)
1210 {
1211 if (zero_anonymity_count_estimate > 0)
1212 zero_anonymity_count_estimate /= 2;
1213 counter = 0;
1214 }
1215 last_vhash = vhash;
1216 if (counter < 31)
1217 counter++;
1218 if (zero_anonymity_count_estimate < (1 << counter))
1219 zero_anonymity_count_estimate = (1 << counter);
1220#if DEBUG_FS
1221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1222 "Retrieved block `%s' of type %u for DHT PUT\n",
1223 GNUNET_h2s (key),
1224 type);
1225#endif
1226 GNUNET_DHT_put (dht_handle,
1227 key,
1228 GNUNET_DHT_RO_NONE,
1229 type,
1230 size,
1231 data,
1232 expiration,
1233 GNUNET_TIME_UNIT_FOREVER_REL,
1234 &dht_put_continuation,
1235 cls);
1236}
1237
1238
1239/**
1086 * Task that is run periodically to obtain blocks for content 1240 * Task that is run periodically to obtain blocks for content
1087 * migration 1241 * migration
1088 * 1242 *
@@ -1096,7 +1250,7 @@ gather_migration_blocks (void *cls,
1096 mig_task = GNUNET_SCHEDULER_NO_TASK; 1250 mig_task = GNUNET_SCHEDULER_NO_TASK;
1097 if (dsh != NULL) 1251 if (dsh != NULL)
1098 { 1252 {
1099 mig_qe = GNUNET_DATASTORE_get_random (dsh, 0, -1, 1253 mig_qe = GNUNET_DATASTORE_get_random (dsh, 0, UINT_MAX,
1100 GNUNET_TIME_UNIT_FOREVER_REL, 1254 GNUNET_TIME_UNIT_FOREVER_REL,
1101 &process_migration_content, NULL); 1255 &process_migration_content, NULL);
1102 GNUNET_assert (mig_qe != NULL); 1256 GNUNET_assert (mig_qe != NULL);
@@ -1105,6 +1259,30 @@ gather_migration_blocks (void *cls,
1105 1259
1106 1260
1107/** 1261/**
1262 * Task that is run periodically to obtain blocks for DHT PUTs.
1263 *
1264 * @param cls type of blocks to gather
1265 * @param tc scheduler context (unused)
1266 */
1267static void
1268gather_dht_put_blocks (void *cls,
1269 const struct GNUNET_SCHEDULER_TaskContext *tc)
1270{
1271 dht_task = GNUNET_SCHEDULER_NO_TASK;
1272 if (dsh != NULL)
1273 {
1274 if (dht_put_type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
1275 dht_put_type = GNUNET_BLOCK_TYPE_FS_KBLOCK;
1276 dht_qe = GNUNET_DATASTORE_get_zero_anonymity (dsh, 0, UINT_MAX,
1277 GNUNET_TIME_UNIT_FOREVER_REL,
1278 dht_put_type++,
1279 &process_dht_put_content, NULL);
1280 GNUNET_assert (dht_qe != NULL);
1281 }
1282}
1283
1284
1285/**
1108 * We're done with a particular message list entry. 1286 * We're done with a particular message list entry.
1109 * Free all associated resources. 1287 * Free all associated resources.
1110 * 1288 *
@@ -1621,11 +1799,21 @@ shutdown_task (void *cls,
1621 GNUNET_DATASTORE_cancel (mig_qe); 1799 GNUNET_DATASTORE_cancel (mig_qe);
1622 mig_qe = NULL; 1800 mig_qe = NULL;
1623 } 1801 }
1802 if (dht_qe != NULL)
1803 {
1804 GNUNET_DATASTORE_cancel (dht_qe);
1805 dht_qe = NULL;
1806 }
1624 if (GNUNET_SCHEDULER_NO_TASK != mig_task) 1807 if (GNUNET_SCHEDULER_NO_TASK != mig_task)
1625 { 1808 {
1626 GNUNET_SCHEDULER_cancel (sched, mig_task); 1809 GNUNET_SCHEDULER_cancel (sched, mig_task);
1627 mig_task = GNUNET_SCHEDULER_NO_TASK; 1810 mig_task = GNUNET_SCHEDULER_NO_TASK;
1628 } 1811 }
1812 if (GNUNET_SCHEDULER_NO_TASK != dht_task)
1813 {
1814 GNUNET_SCHEDULER_cancel (sched, dht_task);
1815 dht_task = GNUNET_SCHEDULER_NO_TASK;
1816 }
1629 while (client_list != NULL) 1817 while (client_list != NULL)
1630 handle_client_disconnect (NULL, 1818 handle_client_disconnect (NULL,
1631 client_list->client); 1819 client_list->client);
@@ -3917,6 +4105,7 @@ main_init (struct GNUNET_SCHEDULER_Handle *s,
3917 _("Content migration is enabled, will start to gather data\n")); 4105 _("Content migration is enabled, will start to gather data\n"));
3918 consider_migration_gathering (); 4106 consider_migration_gathering ();
3919 } 4107 }
4108 consider_dht_put_gathering (NULL);
3920 GNUNET_SERVER_disconnect_notify (server, 4109 GNUNET_SERVER_disconnect_notify (server,
3921 &handle_client_disconnect, 4110 &handle_client_disconnect,
3922 NULL); 4111 NULL);
diff --git a/src/fs/test_fs_data.conf b/src/fs/test_fs_data.conf
index 53fc6b500..0796be2df 100644
--- a/src/fs/test_fs_data.conf
+++ b/src/fs/test_fs_data.conf
@@ -42,3 +42,9 @@ ACTIVEMIGRATION = NO
42 42
43[testing] 43[testing]
44WEAKRANDOM = YES 44WEAKRANDOM = YES
45
46
47[dhtcache]
48QUOTA=65536
49
50DATABASE=sqlite
diff --git a/src/fs/test_fs_download_data.conf b/src/fs/test_fs_download_data.conf
index d647d448d..0bc6cc2b3 100644
--- a/src/fs/test_fs_download_data.conf
+++ b/src/fs/test_fs_download_data.conf
@@ -43,3 +43,9 @@ ACTIVEMIGRATION = NO
43 43
44[testing] 44[testing]
45WEAKRANDOM = YES 45WEAKRANDOM = YES
46
47
48[dhtcache]
49QUOTA=65536
50
51DATABASE=sqlite
diff --git a/src/fs/test_fs_file_information_data.conf b/src/fs/test_fs_file_information_data.conf
index 55cfddff4..e7ccf7b4d 100644
--- a/src/fs/test_fs_file_information_data.conf
+++ b/src/fs/test_fs_file_information_data.conf
@@ -40,3 +40,9 @@ HOSTNAME = localhost
40 40
41[testing] 41[testing]
42WEAKRANDOM = YES 42WEAKRANDOM = YES
43
44
45[dhtcache]
46QUOTA=65536
47
48DATABASE=sqlite
diff --git a/src/fs/test_fs_list_indexed_data.conf b/src/fs/test_fs_list_indexed_data.conf
index 06317822a..45013672e 100644
--- a/src/fs/test_fs_list_indexed_data.conf
+++ b/src/fs/test_fs_list_indexed_data.conf
@@ -41,3 +41,9 @@ ACTIVEMIGRATION = NO
41 41
42[testing] 42[testing]
43WEAKRANDOM = YES 43WEAKRANDOM = YES
44
45
46[dhtcache]
47QUOTA=65536
48
49DATABASE=sqlite
diff --git a/src/fs/test_fs_namespace_data.conf b/src/fs/test_fs_namespace_data.conf
index fd0b14261..d1ed94a8b 100644
--- a/src/fs/test_fs_namespace_data.conf
+++ b/src/fs/test_fs_namespace_data.conf
@@ -41,3 +41,9 @@ IDENTITY_DIR = $SERVICEHOME/pseudos/
41 41
42[testing] 42[testing]
43WEAKRANDOM = YES 43WEAKRANDOM = YES
44
45
46[dhtcache]
47QUOTA=65536
48
49DATABASE=sqlite
diff --git a/src/fs/test_fs_publish_data.conf b/src/fs/test_fs_publish_data.conf
index 124f925b1..9ac58150f 100644
--- a/src/fs/test_fs_publish_data.conf
+++ b/src/fs/test_fs_publish_data.conf
@@ -41,3 +41,9 @@ ACTIVEMIGRATION = NO
41 41
42[testing] 42[testing]
43WEAKRANDOM = YES 43WEAKRANDOM = YES
44
45
46[dhtcache]
47QUOTA=65536
48
49DATABASE=sqlite
diff --git a/src/fs/test_fs_search_data.conf b/src/fs/test_fs_search_data.conf
index d8b34d91d..33c649dac 100644
--- a/src/fs/test_fs_search_data.conf
+++ b/src/fs/test_fs_search_data.conf
@@ -40,3 +40,9 @@ HOSTNAME = localhost
40 40
41[testing] 41[testing]
42WEAKRANDOM = YES 42WEAKRANDOM = YES
43
44
45[dhtcache]
46QUOTA=65536
47
48DATABASE=sqlite
diff --git a/src/fs/test_fs_unindex_data.conf b/src/fs/test_fs_unindex_data.conf
index b54d16f85..e25a3407e 100644
--- a/src/fs/test_fs_unindex_data.conf
+++ b/src/fs/test_fs_unindex_data.conf
@@ -40,3 +40,9 @@ HOSTNAME = localhost
40 40
41[testing] 41[testing]
42WEAKRANDOM = YES 42WEAKRANDOM = YES
43
44
45[dhtcache]
46QUOTA=65536
47
48DATABASE=sqlite
diff --git a/src/fs/test_fs_uri_data.conf b/src/fs/test_fs_uri_data.conf
index 12cf53b93..29c5cb202 100644
--- a/src/fs/test_fs_uri_data.conf
+++ b/src/fs/test_fs_uri_data.conf
@@ -7,3 +7,9 @@ HOSTKEY = $SERVICEHOME/.hostkey
7 7
8[TESTING] 8[TESTING]
9WEAKRANDOM = YES 9WEAKRANDOM = YES
10
11
12[dhtcache]
13QUOTA=65536
14
15DATABASE=sqlite
diff --git a/src/fs/test_gnunet_fs_idx_data.conf b/src/fs/test_gnunet_fs_idx_data.conf
index 43fcfc963..b3d9bc250 100644
--- a/src/fs/test_gnunet_fs_idx_data.conf
+++ b/src/fs/test_gnunet_fs_idx_data.conf
@@ -42,3 +42,9 @@ HOSTNAME = localhost
42 42
43[testing] 43[testing]
44WEAKRANDOM = YES 44WEAKRANDOM = YES
45
46
47[dhtcache]
48QUOTA=65536
49
50DATABASE=sqlite
diff --git a/src/fs/test_gnunet_fs_ns_data.conf b/src/fs/test_gnunet_fs_ns_data.conf
index e45cea44a..65bac0a15 100644
--- a/src/fs/test_gnunet_fs_ns_data.conf
+++ b/src/fs/test_gnunet_fs_ns_data.conf
@@ -42,3 +42,9 @@ HOSTNAME = localhost
42 42
43[testing] 43[testing]
44WEAKRANDOM = YES 44WEAKRANDOM = YES
45
46
47[dhtcache]
48QUOTA=65536
49
50DATABASE=sqlite
diff --git a/src/fs/test_gnunet_fs_psd_data.conf b/src/fs/test_gnunet_fs_psd_data.conf
index 75a96a1ae..1620c910a 100644
--- a/src/fs/test_gnunet_fs_psd_data.conf
+++ b/src/fs/test_gnunet_fs_psd_data.conf
@@ -42,3 +42,9 @@ HOSTNAME = localhost
42 42
43[testing] 43[testing]
44WEAKRANDOM = YES 44WEAKRANDOM = YES
45
46
47[dhtcache]
48QUOTA=65536
49
50DATABASE=sqlite
diff --git a/src/fs/test_gnunet_fs_rec_data.conf b/src/fs/test_gnunet_fs_rec_data.conf
index ad4b8cbcb..1679df036 100644
--- a/src/fs/test_gnunet_fs_rec_data.conf
+++ b/src/fs/test_gnunet_fs_rec_data.conf
@@ -43,3 +43,9 @@ HOSTNAME = localhost
43 43
44[testing] 44[testing]
45WEAKRANDOM = YES 45WEAKRANDOM = YES
46
47
48[dhtcache]
49QUOTA=65536
50
51DATABASE=sqlite
diff --git a/src/fs/test_gnunet_service_fs_migration_data.conf b/src/fs/test_gnunet_service_fs_migration_data.conf
index 4c7f95ee9..db1f5e87c 100644
--- a/src/fs/test_gnunet_service_fs_migration_data.conf
+++ b/src/fs/test_gnunet_service_fs_migration_data.conf
@@ -57,3 +57,9 @@ ACTIVEMIGRATION = YES
57 57
58[testing] 58[testing]
59WEAKRANDOM = YES 59WEAKRANDOM = YES
60
61
62[dhtcache]
63QUOTA=65536
64
65DATABASE=sqlite