+ if (bluesky_verbose) {
+ g_log("bluesky/inode", G_LOG_LEVEL_DEBUG,
+ "Reference count for inode %"PRIu64" dropped to zero.",
+ inode->inum);
+ }
+
+ /* Sanity check: Is the inode clean? */
+ if (inode->change_commit < inode->change_count
+ || inode->accessed_list != NULL
+ || inode->unlogged_list != NULL
+ || inode->dirty_list != NULL) {
+ g_warning("Dropping inode which is not clean (commit %"PRIi64" < change %"PRIi64"; accessed_list = %p; dirty_list = %p)\n", inode->change_commit, inode->change_count, inode->accessed_list, inode->dirty_list);
+ }
+
+ /* These shouldn't be needed, but in case the above warning fires and
+ * we delete the inode anyway, we ought to be sure the inode is not on
+ * any LRU 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);
+ bluesky_list_unlink(&inode->fs->unlogged_list, inode->unlogged_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!");
+ }
+ bluesky_cloudlog_unref(b->ref);
+ bluesky_string_unref(b->dirty);
+ }
+ 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);