From 80b412586b3cf15eb5877be8d3e96eb757281b8a Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Wed, 31 Mar 2010 14:01:59 -0700 Subject: [PATCH] Try to clean up the locking for LRU lists. --- bluesky/cache.c | 18 ++++++++++++------ bluesky/inode.c | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bluesky/cache.c b/bluesky/cache.c index 5f16ab0..f11168c 100644 --- a/bluesky/cache.c +++ b/bluesky/cache.c @@ -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); diff --git a/bluesky/inode.c b/bluesky/inode.c index 903f003..ee63820 100644 --- a/bluesky/inode.c +++ b/bluesky/inode.c @@ -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); -- 2.20.1