From: Michael Vrable Date: Tue, 10 Aug 2010 21:19:49 +0000 (-0700) Subject: More fixes to BlueSky cache management. X-Git-Url: https://git.vrable.net/?a=commitdiff_plain;h=3380ff6d419c7d1370c95cf476520ed5398e5b6d;p=bluesky.git More fixes to BlueSky cache management. --- diff --git a/bluesky/cache.c b/bluesky/cache.c index d64cdbc..d4d410e 100644 --- a/bluesky/cache.c +++ b/bluesky/cache.c @@ -22,33 +22,6 @@ * - 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; diff --git a/bluesky/cloudlog.c b/bluesky/cloudlog.c index 76776b4..4c671be 100644 --- a/bluesky/cloudlog.c +++ b/bluesky/cloudlog.c @@ -182,7 +182,7 @@ void bluesky_cloudlog_fetch(BlueSkyCloudLog *log) 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); diff --git a/bluesky/file.c b/bluesky/file.c index 977618d..d3ba5f8 100644 --- a/bluesky/file.c +++ b/bluesky/file.c @@ -44,9 +44,8 @@ void bluesky_block_touch(BlueSkyInode *inode, uint64_t i) 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); @@ -98,9 +97,9 @@ void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size) /* 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); diff --git a/bluesky/inode.c b/bluesky/inode.c index f3b804d..39241ea 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -55,6 +55,9 @@ void bluesky_inode_update_ctime(BlueSkyInode *inode, gboolean update_mtime) 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