X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fdebug.c;h=b409c74b492be2110ff0682978683a10f773cb6a;hb=adc8816a09e5b6be2e58f4a7c28d2418a74cce9c;hp=023b99f20a5ad2718396a33ba1518a3c3ff8c128;hpb=f57fa12ec60108a9338ca5c5c072ec6e0ea1b745;p=bluesky.git diff --git a/bluesky/debug.c b/bluesky/debug.c index 023b99f..b409c74 100644 --- a/bluesky/debug.c +++ b/bluesky/debug.c @@ -39,8 +39,54 @@ 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); } + +/* Statistics counters: for operation counts, bytes transferred, etc. */ +static GStaticMutex stats_lock = G_STATIC_MUTEX_INIT; +static GList *stats_list = NULL; + +struct bluesky_stats *bluesky_stats_new(const char *name) +{ + struct bluesky_stats *stats = g_new0(struct bluesky_stats, 1); + stats->name = name; + g_static_mutex_lock(&stats_lock); + stats_list = g_list_append(stats_list, stats); + g_static_mutex_unlock(&stats_lock); + return stats; +} + +void bluesky_stats_add(struct bluesky_stats *stats, int64_t value) +{ + __sync_fetch_and_add(&stats->count, (int64_t)1); + __sync_fetch_and_add(&stats->sum, value); +} + +void bluesky_stats_dump_all() +{ + g_static_mutex_lock(&stats_lock); + for (GList *item = stats_list; item != NULL; item = item->next) { + struct bluesky_stats *stats = (struct bluesky_stats *)item->data; + g_print("%s: count=%"PRIi64" sum=%"PRIi64"\n", + stats->name, stats->count, stats->sum); + } + g_static_mutex_unlock(&stats_lock); +}