if (bluesky_options.writethrough_cache)
bluesky_file_flush(inode, NULL);
+
+ g_mutex_lock(inode->fs->lock);
+ bluesky_list_unlink(&inode->fs->dirty_list, inode->dirty_list);
+ inode->dirty_list = bluesky_list_prepend(&inode->fs->dirty_list, inode);
+ 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);
}
/* Unfortunately a glib hash table is only guaranteed to be able to store
root->nlink = 1;
root->mode = 0755;
bluesky_insert_inode(fs, root);
+ bluesky_inode_update_ctime(root, TRUE);
bluesky_inode_flush(fs, root);
bluesky_superblock_flush(fs);
void bluesky_inode_unref(BlueSkyInode *inode)
{
if (g_atomic_int_dec_and_test(&inode->refcount)) {
- g_error("Reference count for inode %"PRIu64" dropped to zero!\n",
+ g_print("Reference count for inode %"PRIu64" dropped to zero.\n",
inode->inum);
+
+ /* Sanity check: Is the inode clean? */
+ if (inode->change_commit < inode->change_count
+ || inode->dirty_list != NULL) {
+ g_warning("Dropping inode which is not clean (commit %"PRIi64" < change %"PRIi64"; dirty_list = %p)\n", inode->change_commit, inode->change_count, inode->dirty_list);
+ }
+
+ g_mutex_lock(inode->fs->lock);
+ bluesky_list_unlink(&inode->fs->accessed_list, inode->accessed_list);
+ bluesky_list_unlink(&inode->fs->dirty_list, inode->dirty_list);
+ g_mutex_unlock(inode->fs->lock);
+
+ /* Free file type specific data. It should be an error for there to be
+ * dirty data to commit when the reference count has reaches zero. */
+ switch (inode->type) {
+ case 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_DIRTY) {
+ g_error("Deleting an inode with dirty file data!");
+ }
+ g_free(b->ref);
+ bluesky_string_unref(b->data);
+ }
+ g_array_unref(inode->blocks);
+ break;
+
+ case BLUESKY_DIRECTORY:
+ g_hash_table_destroy(inode->dirhash);
+ g_hash_table_destroy(inode->dirhash_folded);
+ g_sequence_free(inode->dirents);
+ break;
+
+ case BLUESKY_SYMLINK:
+ g_free(inode->symlink_contents);
+ break;
+
+ default:
+ break;
+ }
+
+ g_mutex_free(inode->lock);
+
+ g_free(inode);
}
}
bluesky_inode_unref(inode);
}
+ inode->access_time = bluesky_get_current_time();
+ g_mutex_lock(inode->fs->lock);
+ inode->accessed_list = bluesky_list_prepend(&inode->fs->accessed_list, inode);
+ g_mutex_unlock(inode->fs->lock);
+
g_mutex_unlock(inode->lock);
bluesky_inode_unref(inode);
}