Debugging/refcount cleanups.
[bluesky.git] / bluesky / debug.c
index 43b29be..9d875bd 100644 (file)
@@ -51,10 +51,21 @@ static void cloudlog_dump(gpointer key, gpointer value, gpointer user_data)
             log->location.sequence, log->location.offset);
 }
 
+static void cache_dump(gpointer key, gpointer value, gpointer user_data)
+{
+    BlueSkyCacheFile *cache = (BlueSkyCacheFile *)value;
+
+    g_print("%s addr=%p mapcount=%d",
+            cache->filename, cache->addr, cache->mapcount);
+    if (cache->fetching)
+        g_print(" (fetching)");
+    g_print("\n");
+}
+
 /* Dump a summary of filesystem state as it is cached in memory. */
 void bluesky_debug_dump(BlueSkyFS *fs)
 {
-    g_print("*** DEBUG DUMP FOR FILESYSTEM %s ***\n", fs->name);
+    g_print("\n*** DEBUG DUMP FOR FILESYSTEM %s ***\n", fs->name);
     g_print("Dirty blocks: %d\n", g_atomic_int_get(&fs->cache_dirty));
     g_print("Cached inodes: %u\tNext inode: %"PRIu64"\n",
             g_hash_table_size(fs->inodes), fs->next_inum);
@@ -85,6 +96,9 @@ void bluesky_debug_dump(BlueSkyFS *fs)
 
     g_print("\nLog Objects:\n");
     g_hash_table_foreach(fs->locations, cloudlog_dump, fs);
+
+    g_print("\nJournal/Cache Files:\n");
+    g_hash_table_foreach(fs->log->mmap_cache, cache_dump, fs);
     g_print("\n");
 }