Add general statistics-gathering infrastructure.
[bluesky.git] / bluesky / bluesky.h
index 59a33c5..ff2bf23 100644 (file)
@@ -41,6 +41,16 @@ extern BlueSkyOptions bluesky_options;
  * limit */
 extern int bluesky_max_threads;
 
+/* A general-purpose counter for gathering run-time statistics. */
+struct bluesky_stats {
+    const char *name;
+    int64_t count;
+    int64_t sum;
+};
+struct bluesky_stats *bluesky_stats_new(const char *name);
+void bluesky_stats_add(struct bluesky_stats *stats, int64_t value);
+void bluesky_stats_dump_all();
+
 /* BlueSky status and error codes.  Various frontends should translate these to
  * the appropriate error code for whatever protocol they implement. */
 typedef enum {
@@ -129,6 +139,9 @@ typedef struct {
      * is held for list editing purposes.  Items at the head of the list are
      * most recently accessed/modified. */
     GList dirty_list, accessed_list;
+
+    /* Mutex for the flush daemon, to prevent concurrent execution. */
+    GMutex *flushd_lock;
 } BlueSkyFS;
 
 /* Inode number of the root directory. */
@@ -283,6 +296,7 @@ gint bluesky_dirent_compare(gconstpointer a, gconstpointer b,
                             gpointer unused);
 
 void bluesky_flushd_invoke(BlueSkyFS *fs);
+void bluesky_flushd_invoke_conditional(BlueSkyFS *fs);
 void bluesky_inode_do_sync(BlueSkyInode *inode);
 
 void bluesky_debug_dump(BlueSkyFS *fs);