More fixes to BlueSky cache management.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 10 Aug 2010 21:19:49 +0000 (14:19 -0700)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Tue, 10 Aug 2010 21:19:49 +0000 (14:19 -0700)
bluesky/cache.c
bluesky/cloudlog.c
bluesky/file.c
bluesky/inode.c

index d64cdbc..d4d410e 100644 (file)
  *   - 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;
index 76776b4..4c671be 100644 (file)
@@ -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);
index 977618d..d3ba5f8 100644 (file)
@@ -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);
index f3b804d..39241ea 100644 (file)
@@ -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