int log_dir;
int log_seq;
char *filename; // Local filename, relateive to log directory
- gint refcount; // References to the mmaped data
+ gint mapcount; // References to the mmaped data
const char *addr; // May be null if data is not mapped in memory
size_t len;
BlueSkyFS *fs;
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);
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");
}
map->filename = logname;
map->log_seq = log_seq;
map->log = log;
- g_atomic_int_set(&map->refcount, 0);
+ g_atomic_int_set(&map->mapcount, 0);
g_hash_table_insert(log->mmap_cache, GINT_TO_POINTER(log_seq), map);
if (mmap == NULL)
return;
- if (g_atomic_int_dec_and_test(&mmap->refcount)) {
+ if (g_atomic_int_dec_and_test(&mmap->mapcount)) {
g_mutex_lock(mmap->lock);
- if (g_atomic_int_get(&mmap->refcount) > 0) {
+ if (g_atomic_int_get(&mmap->mapcount) > 0) {
g_print("Unmapped log segment %d...\n", mmap->log_seq);
munmap((void *)mmap->addr, mmap->len);
mmap->addr = NULL;
BlueSkyRCStr *string = g_new(BlueSkyRCStr, 1);
string->mmap = mmap;
- g_atomic_int_inc(&mmap->refcount);
+ g_atomic_int_inc(&mmap->mapcount);
string->data = (char *)mmap->addr + offset;
string->len = len;
g_atomic_int_set(&string->refcount, 1);