bluesky_list_unlink(&inode->fs->accessed_list, inode->accessed_list);
inode->accessed_list = bluesky_list_prepend(&inode->fs->accessed_list, inode);
g_mutex_unlock(inode->fs->lock);
+
+ bluesky_cloudlog_unref(inode->committed_item);
+ inode->committed_item = NULL;
}
/* Unfortunately a glib hash table is only guaranteed to be able to store
fs->next_inum = BLUESKY_ROOT_INUM + 1;
fs->store = bluesky_store_new("file");
fs->flushd_lock = g_mutex_new();
+ fs->flushd_cond = g_cond_new();
fs->locations = g_hash_table_new(bluesky_cloudlog_hash,
bluesky_cloudlog_equal);
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);
BlueSkyFS *fs = bluesky_new_fs(name);
fs->store = store;
fs->log = bluesky_log_new("journal");
+ fs->log->fs = fs;
BlueSkyInode *root = bluesky_new_inode(BLUESKY_ROOT_INUM, fs,
BLUESKY_DIRECTORY);
if (b->type == BLUESKY_BLOCK_DIRTY) {
g_error("Deleting an inode with dirty file data!");
}
- bluesky_cloudlog_unref(b->cloudref);
- bluesky_string_unref(b->data);
+ bluesky_cloudlog_unref(b->ref);
+ bluesky_string_unref(b->dirty);
}
g_array_unref(inode->blocks);
break;
void bluesky_inode_start_sync(BlueSkyInode *inode)
{
GList *log_items = NULL;
- BlueSkyFS *fs = inode->fs;
if (inode->type == BLUESKY_REGULAR)
bluesky_file_flush(inode, &log_items);
- GString *buf = g_string_new("");
- bluesky_serialize_inode(buf, inode);
- BlueSkyRCStr *data = bluesky_string_new_from_gstring(buf);
-
- char key[64];
- sprintf(key, "inode-%016"PRIx64, inode->inum);
-
- BlueSkyCloudLog *cloudlog = bluesky_cloudlog_new(fs);
- cloudlog->type = LOGTYPE_INODE;
- cloudlog->inum = inode->inum;
- cloudlog->data = data;
- bluesky_string_ref(data);
-
- if (inode->type == BLUESKY_REGULAR) {
- for (int i = 0; i < inode->blocks->len; i++) {
- BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, i);
- if (b->type == BLUESKY_BLOCK_CACHED
- || b->type == BLUESKY_BLOCK_REF)
- {
- BlueSkyCloudID id = b->cloudref->id;
- g_array_append_val(cloudlog->pointers, id);
- }
- }
- }
+ BlueSkyCloudLog *cloudlog = bluesky_serialize_inode(inode);
- if (inode->committed_item != NULL)
- bluesky_cloudlog_unref(inode->committed_item);
+ bluesky_cloudlog_unref(inode->committed_item);
inode->committed_item = cloudlog;
bluesky_cloudlog_sync(cloudlog);
+ bluesky_cloudlog_ref(cloudlog);
log_items = g_list_prepend(log_items, cloudlog);
- bluesky_cloudlog_insert(cloudlog);
/* Wait for all log items to be committed to disk. */
bluesky_log_finish_all(log_items);
+
+ /* Mark the inode as clean */
+ inode->change_commit = inode->change_count;
+ inode->change_time = 0;
+ g_mutex_lock(inode->fs->lock);
+ bluesky_list_unlink(&inode->fs->unlogged_list, inode->unlogged_list);
+ inode->unlogged_list = NULL;
+ g_mutex_unlock(inode->fs->lock);
}
/* Write back an inode and all associated data and wait for completion. Inode