fixing block reconstruction start/shutdown code
[oweals/gnunet.git] / src / fs / fs.h
index 0eba5615c2aa96e5d4b1b0531e102437b73adf9c..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_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.
  */
 #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.
@@ -899,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.
@@ -1156,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.
    */
@@ -1591,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.
@@ -1649,6 +1682,12 @@ struct DownloadRequest
 };
 
 
+/**
+ * Closure for 'reconstruct_cont' and 'reconstruct_cb'.
+ */
+struct ReconstructContext;
+
+
 /**
  * Context for controlling a download.
  */
@@ -1692,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.
    */
@@ -1781,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
@@ -1839,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;
 };