X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fdebug.c;h=6242ba687fcf5747829c9d9cbf6eceff5f0b921c;hb=4e24d47abcb5b0e97ab13afc8f97f8fdcab14843;hp=312a0e1c80bf1422b0c55bca1a3673f890a11db2;hpb=f597cd5067ed36508118d2ecd29338e7b81f47e4;p=bluesky.git diff --git a/bluesky/debug.c b/bluesky/debug.c index 312a0e1..6242ba6 100644 --- a/bluesky/debug.c +++ b/bluesky/debug.c @@ -31,8 +31,24 @@ static void inode_dump(gpointer key, gpointer value, gpointer user_data) locked ? 'T' : 'F', inode->refcount); g_print(" Type: %d Mode: %o\n", inode->type, inode->mode); - g_print(" change_count = %"PRIu64", change_commit = %"PRIu64"\n", - inode->change_count, inode->change_commit); + g_print(" change_count = %"PRIu64", change_commit = %"PRIu64", " + "change_cloud = %"PRIu64"\n", + inode->change_count, inode->change_commit, inode->change_cloud); +} + +static void cloudlog_dump(gpointer key, gpointer value, gpointer user_data) +{ + BlueSkyCloudLog *log = (BlueSkyCloudLog *)value; + + for (int i = 0; i < sizeof(BlueSkyCloudID); i++) { + g_print("%02x", (uint8_t)(log->id.bytes[i])); + } + g_print(": refs=%d ty=%d inode=%"PRIu64" locs=%x log@(%d,%d) cloud@(%d,%d,%d)\n", + log->refcount, + log->type, log->inum, + log->location_flags | (log->data != NULL ? 0x100 : 0), + log->log_seq, log->log_offset, log->location.directory, + log->location.sequence, log->location.offset); } /* Dump a summary of filesystem state as it is cached in memory. */ @@ -45,5 +61,57 @@ void bluesky_debug_dump(BlueSkyFS *fs) g_print("Cached inodes: %u\tNext inode: %"PRIu64"\n", g_hash_table_size(fs->inodes), fs->next_inum); + GList *item; + g_print("Unsynced inode list:"); + for (item = fs->unlogged_list.next; item != NULL; item = item->next) { + g_print(" %"PRIu64";", ((BlueSkyInode *)item->data)->inum); + } + g_print("\n"); + 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); + + g_print("\nLog Objects:\n"); + g_hash_table_foreach(fs->locations, cloudlog_dump, fs); + g_print("\n"); +} + +/* 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); }