Possible null pointer dereference fix.
[bluesky.git] / bluesky / debug.c
index b030b7f..7cdd4fd 100644 (file)
@@ -22,9 +22,9 @@ static void inode_dump(gpointer key, gpointer value, gpointer user_data)
 
     g_print("Inode %"PRIu64":\n", inode->inum);
 
-    gboolean locked = FALSE;
+    gboolean locked = TRUE;
     if (g_mutex_trylock(inode->lock)) {
-        locked = TRUE;
+        locked = FALSE;
         g_mutex_unlock(inode->lock);
     }
     g_print("    Locked: %c   Refcount: %d\n",
@@ -39,8 +39,23 @@ static void inode_dump(gpointer key, gpointer value, gpointer user_data)
 void bluesky_debug_dump(BlueSkyFS *fs)
 {
     g_print("*** DEBUG DUMP FOR FILESYSTEM %s ***\n", fs->name);
+    g_print("Cached blocks: %d\tDirty blocks: %d\n",
+            g_atomic_int_get(&fs->cache_total),
+            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);
 
+    GList *item;
+    g_print("Dirty inode LRU list:");
+    for (item = fs->dirty_list.next; item != NULL; item = item->next) {
+        g_print(" %"PRIu64";", ((BlueSkyInode *)item->data)->inum);
+    }
+    g_print("\n");
+    g_print("Accessed inode LRU list:");
+    for (item = fs->accessed_list.next; item != NULL; item = item->next) {
+        g_print(" %"PRIu64";", ((BlueSkyInode *)item->data)->inum);
+    }
+    g_print("\n");
+
     g_hash_table_foreach(fs->inodes, inode_dump, fs);
 }