* - Writing batches of data to the cloud.
*/
-#if 0
-static void writeback_complete(gpointer a, gpointer i)
-{
- BlueSkyInode *inode = (BlueSkyInode *)i;
-
- if (bluesky_verbose) {
- g_log("bluesky/flushd", G_LOG_LEVEL_DEBUG,
- "Writeback for inode %"PRIu64" complete", inode->inum);
- }
-
- g_mutex_lock(inode->lock);
-
- inode->change_commit = inode->change_pending;
- inode->change_pending = 0;
- if (inode->change_count == inode->change_commit) {
- /* If inode is no longer dirty... */
- inode->change_time = 0;
- g_mutex_lock(inode->fs->lock);
- bluesky_list_unlink(&inode->fs->dirty_list, inode->dirty_list);
- inode->dirty_list = NULL;
- g_mutex_unlock(inode->fs->lock);
- }
-
- g_mutex_unlock(inode->lock);
-}
-#endif
-
static void flushd_dirty_inode(BlueSkyInode *inode)
{
BlueSkyFS *fs = inode->fs;
if (log->data != NULL)
return;
- g_assert(log->location_flags & CLOUDLOG_JOURNAL);
+ g_assert((log->location_flags | log->pending_write) & CLOUDLOG_JOURNAL);
log->data = bluesky_log_map_object(log->fs->log, log->log_seq,
log->log_offset, log->log_size);
break;
}
- /*if (block->type != BLUESKY_BLOCK_CACHED
- && block->type != BLUESKY_BLOCK_DIRTY)
- g_atomic_int_add(&inode->fs->cache_total, 1); //FIXME */
+ if (block->type != BLUESKY_BLOCK_REF && block->type != BLUESKY_BLOCK_DIRTY)
+ g_atomic_int_add(&inode->fs->cache_total, 1);
if (block->type != BLUESKY_BLOCK_DIRTY)
g_atomic_int_add(&inode->fs->cache_dirty, 1);
/* Delete blocks from a file. Must reclaim memory. */
for (guint i = inode->blocks->len; i < blocks; i++) {
BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, i);
- /* if (b->type == BLUESKY_BLOCK_CACHED
+ if (b->type == BLUESKY_BLOCK_REF
|| b->type == BLUESKY_BLOCK_DIRTY)
- g_atomic_int_add(&inode->fs->cache_total, -1); FIXME */
+ g_atomic_int_add(&inode->fs->cache_total, -1);
if (b->type == BLUESKY_BLOCK_DIRTY)
g_atomic_int_add(&inode->fs->cache_dirty, -1);
bluesky_string_unref(b->dirty);
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