fixing block reconstruction start/shutdown code
[oweals/gnunet.git] / src / fs / fs.h
index 605e6c84ba670393865a78a22cb1cce0ae32391a..e655a3e57e76e3242440a6737c4a401d8a2324cb 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
      This file is part of GNUnet.
      (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors)
 
 #include "gnunet_constants.h"
 #include "gnunet_datastore_service.h"
+#include "gnunet_dht_service.h"
 #include "gnunet_fs_service.h"
 #include "gnunet_block_lib.h"
 #include "block_fs.h"
 
+
+/**
+ * Maximum number of outgoing messages we queue per peer.
+ *
+ * Performance measurements for 2 peer setup for 50 MB file
+ * (with MAX_DATASTORE_QUEUE = 1 and RETRY_PROBABILITY_INV = 1):
+ *
+ *   2: 1700 kb/s, 1372 kb/s
+ *   8: 2117 kb/s, 1284 kb/s, 1112 kb/s
+ *  16: 3500 kb/s, 3200 kb/s, 3388 kb/s
+ *  32: 3441 kb/s, 3163 kb/s, 3277 kb/s
+ * 128: 1700 kb/s; 2010 kb/s, 3383 kb/s, 1156 kb/s
+ *
+ * Conclusion: 16 seems to be a pretty good value (stable
+ * and high performance, no excessive memory use).
+ */
+#define MAX_QUEUE_PER_PEER 16
+
 /**
  * Maximum size of the datastore queue for P2P operations.
+ * Needs to be large enough to queue MAX_QUEUE_PER_PEER
+ * operations for roughly the number of active (connected)
+ * peers.
  */
-#define MAX_DATASTORE_QUEUE 16
+#define MAX_DATASTORE_QUEUE (16 * MAX_QUEUE_PER_PEER)
 
 /**
  * Maximum number of blocks we keep in memory for migration.
  * be more efficient but will be more disruptive
  * as far as the scheduler is concerned.
  */
-#define HASHING_BLOCKSIZE (1024 * 1024)
+#define HASHING_BLOCKSIZE (1024 * 128)
 
 /**
  * Number of bits we set per entry in the bloomfilter.
  * Do not change!
  */
-#define BLOOMFILTER_K 16
+#define BLOOMFILTER_K GNUNET_DHT_GET_BLOOMFILTER_K
 
 /**
  * Number of availability trials we perform per search result.
  */
 #define AVAILABILITY_TRIALS_MAX 8
 
-/**
- * By how much (in ms) do we decrement the TTL
- * at each hop?
- */
-#define TTL_DECREMENT 5000
-
 /**
  * Length of the P2P success tracker.  Note that
  * having a very long list can also hurt performance.
@@ -898,6 +913,18 @@ GNUNET_FS_download_make_status_ (struct GNUNET_FS_ProgressInfo *pi,
                                 struct GNUNET_FS_DownloadContext *dc);
 
 
+/**
+ * Task that creates the initial (top-level) download
+ * request for the file.
+ *
+ * @param cls the 'struct GNUNET_FS_DownloadContext'
+ * @param tc scheduler context
+ */
+void
+GNUNET_FS_download_start_task_ (void *cls,
+                               const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
 /**
  * Fill in all of the generic fields for 
  * an unindex event and call the callback.
@@ -1155,11 +1182,6 @@ GNUNET_FS_end_top (struct GNUNET_FS_Handle *h,
  */
 struct GNUNET_FS_Handle
 {
-  /**
-   * Scheduler.
-   */
-  struct GNUNET_SCHEDULER_Handle *sched;
-
   /**
    * Configuration to use.
    */
@@ -1590,8 +1612,20 @@ struct GNUNET_FS_SearchContext
    * when the search is being stopped (if not
    * GNUNET_SCHEDULER_NO_TASK).  Used for the task that adds some
    * artificial delay when trying to reconnect to the FS service.
-   */
+o   */
   GNUNET_SCHEDULER_TaskIdentifier task;
+
+  /**
+   * How many of the entries in the search request
+   * map have been passed to the service so far?
+   */
+  unsigned int search_request_map_offset;
+
+  /**
+   * How many of the keywords in the KSK
+   * map have been passed to the service so far?
+   */
+  unsigned int keyword_offset;
   
   /**
    * Anonymity level for the search.
@@ -1648,6 +1682,12 @@ struct DownloadRequest
 };
 
 
+/**
+ * Closure for 'reconstruct_cont' and 'reconstruct_cb'.
+ */
+struct ReconstructContext;
+
+
 /**
  * Context for controlling a download.
  */
@@ -1691,6 +1731,11 @@ struct GNUNET_FS_DownloadContext
    */
   struct GNUNET_FS_DownloadContext *child_tail;
 
+  /**
+   * State for block reconstruction.
+   */
+  struct ReconstructContext *rcc;
+
   /**
    * Previous download belonging to the same parent.
    */
@@ -1780,6 +1825,11 @@ struct GNUNET_FS_DownloadContext
    */
   GNUNET_SCHEDULER_TaskIdentifier task;
 
+  /**
+   * Task used to start the download.
+   */
+  GNUNET_SCHEDULER_TaskIdentifier start_task;
+
   /**
    * What was the size of the file on disk that we're downloading
    * before we started?  Used to detect if there is a point in
@@ -1838,6 +1888,12 @@ struct GNUNET_FS_DownloadContext
    * data from the meta data yet?
    */
   int tried_full_data;
+
+  /**
+   * Have we tried to reconstruct an IBLOCK from disk
+   * and failed (and should hence not try again?)
+   */
+  int reconstruct_failed;
 };
 
 
@@ -2222,6 +2278,32 @@ struct PutMessage
 };
 
 
+/**
+ * Message send by a peer that wants to be excluded
+ * from migration for a while.
+ */
+struct MigrationStopMessage
+{
+  /**
+   * Message type will be 
+   * GNUNET_MESSAGE_TYPE_FS_MIGRATION_STOP.
+   */
+  struct GNUNET_MessageHeader header;
+
+  /**
+   * Always zero.
+   */
+  uint32_t reserved GNUNET_PACKED;
+
+  /**
+   * How long should the block last?
+   */
+  struct GNUNET_TIME_RelativeNBO duration;
+
+};
+
+
+
 #endif
 
 /* end of fs.h */