Try to clean up the locking for LRU lists.
authorMichael Vrable <mvrable@cs.ucsd.edu>
Wed, 31 Mar 2010 21:01:59 +0000 (14:01 -0700)
committerMichael Vrable <mvrable@cs.ucsd.edu>
Wed, 31 Mar 2010 21:01:59 +0000 (14:01 -0700)
bluesky/cache.c
bluesky/inode.c

index 5f16ab0..f11168c 100644 (file)
@@ -124,6 +124,11 @@ static void flushd_dirty_inode(BlueSkyInode *inode)
 {
     BlueSkyFS *fs = inode->fs;
 
+    g_mutex_lock(fs->lock);
+    bluesky_list_unlink(&fs->dirty_list, inode->dirty_list);
+    inode->dirty_list = NULL;
+    g_mutex_unlock(fs->lock);
+
     /* Inode is clean; nothing to do. */
     if (inode->change_count == inode->change_commit)
         return;
@@ -184,9 +189,6 @@ static void flushd_dirty(BlueSkyFS *fs)
 
         bluesky_inode_ref(inode);
 
-        bluesky_list_unlink(&fs->dirty_list, fs->dirty_list.prev);
-        inode->dirty_list = NULL;
-
         g_mutex_unlock(fs->lock);
 
         g_mutex_lock(inode->lock);
@@ -230,13 +232,17 @@ static void flushd_clean(BlueSkyFS *fs)
 
         bluesky_inode_ref(inode);
 
-        bluesky_list_unlink(&fs->accessed_list, fs->accessed_list.prev);
-        inode->accessed_list = bluesky_list_prepend(&fs->accessed_list, inode);
-
         g_mutex_unlock(fs->lock);
 
         g_mutex_lock(inode->lock);
+
+        g_mutex_lock(fs->lock);
+        bluesky_list_unlink(&fs->accessed_list, inode->accessed_list);
+        inode->accessed_list = bluesky_list_prepend(&fs->accessed_list, inode);
+        g_mutex_unlock(fs->lock);
+
         drop_caches(inode);
+
         g_mutex_unlock(inode->lock);
         bluesky_inode_unref(inode);
 
index 903f003..ee63820 100644 (file)
@@ -350,6 +350,7 @@ static void complete_inode_fetch(BlueSkyStoreAsync *async, BlueSkyInode *inode)
 
     inode->access_time = bluesky_get_current_time();
     g_mutex_lock(inode->fs->lock);
+    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);