BlueSkyFS *bluesky_init_fs(gchar *name, BlueSkyStore *store)
{
- BlueSkyRCStr *data = bluesky_store_get(store, "superblock");
- if (data != NULL) {
- BlueSkyFS *fs = bluesky_deserialize_superblock(data->data);
- if (fs != NULL) {
- fs->store = store;
- fs->log = bluesky_log_new("journal");
- fs->log->fs = fs;
- g_print("Loaded filesystem superblock\n");
- g_free(fs->name);
- fs->name = g_strdup(name);
- return fs;
- }
- bluesky_string_unref(data);
- }
-
g_print("Initializing fresh filesystem\n");
BlueSkyFS *fs = bluesky_new_fs(name);
fs->store = store;
bluesky_replay(fs);
bluesky_inode_do_sync(root);
- bluesky_superblock_flush(fs);
return fs;
}
inum = fs->next_inum;
fs->next_inum++;
- bluesky_superblock_flush(fs);
-
return inum;
}
bluesky_store_async_unref(async);
}
-
-/* Synchronize filesystem superblock to stable storage. */
-void bluesky_superblock_flush(BlueSkyFS *fs)
-{
-#if 0
- GString *buf = g_string_new("");
- bluesky_serialize_superblock(buf, fs);
- BlueSkyRCStr *data = bluesky_string_new_from_gstring(buf);
-
- BlueSkyStoreAsync *async = bluesky_store_async_new(fs->store);
- async->op = STORE_OP_PUT;
- async->key = g_strdup("superblock");
- async->data = data;
- bluesky_store_async_submit(async);
- bluesky_store_async_unref(async);
-
- //bluesky_store_sync(fs->store);
-#endif
-}
if (!bluesky_deserialize_inode(inode, log_item))
g_print("Error deserializing inode %"PRIu64"\n", inum);
fs->next_inum = MAX(fs->next_inum, inum + 1);
+ bluesky_list_unlink(&fs->accessed_list, inode->accessed_list);
+ inode->accessed_list = bluesky_list_prepend(&fs->accessed_list, inode);
+ bluesky_list_unlink(&fs->dirty_list, inode->dirty_list);
+ inode->dirty_list = bluesky_list_prepend(&fs->dirty_list, inode);
+ bluesky_list_unlink(&fs->unlogged_list, inode->unlogged_list);
+ inode->unlogged_list = NULL;
+ inode->change_cloud = inode->change_commit;
+ bluesky_cloudlog_ref(log_item);
+ bluesky_cloudlog_unref(inode->committed_item);
+ inode->committed_item = log_item;
g_mutex_unlock(inode->lock);
g_mutex_unlock(fs->lock);
}