Attached are two more patches to fix problems this patch introduced. All fixes are in the "bugfix-only" branch of git://bogomips.org/fusedav I also have a cgit viewer running on http://bogomips.org/fusedav.git
commit b330ce5df52d09879ed98e6889863b8f405b9938 Author: Eric Wong <normalper...@yhbt.net> Date: Thu Nov 8 00:18:53 2012 +0000 filecache: avoid ABBA locking problem in unref Since we have other code which locks files_mutex before locking fi->mutex; we must preserve this ordering in and not attempt to unlink wile fi->mutex is held. Since file_cache_get will skip files on ref==0, it is safe to leave the old file in the global file cache with ref==0 after fi->mutex is unlocked. commit 60853e3bfed6d9909c7a47cfad9b5955fd78374e Author: Eric Wong <normalper...@yhbt.net> Date: Thu Nov 8 00:15:59 2012 +0000 filecache: fix unlocking in file_cache_close_all We need to unlock the global files_mutex before calling file_cache_unref(). Since we did not grab fi->mutex in file_cache_close_all(), it is a mistake (a typo) to release it.
>From 60853e3bfed6d9909c7a47cfad9b5955fd78374e Mon Sep 17 00:00:00 2001 From: Eric Wong <normalper...@yhbt.net> Date: Thu, 8 Nov 2012 00:15:59 +0000 Subject: [PATCH 1/3] filecache: fix unlocking in file_cache_close_all We need to unlock the global files_mutex before calling file_cache_unref(). Since we did not grab fi->mutex in file_cache_close_all(), it is a mistake (a typo) to release it. --- src/filecache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/filecache.c b/src/filecache.c index eded0aa..7527b77 100644 --- a/src/filecache.c +++ b/src/filecache.c @@ -426,7 +426,7 @@ int file_cache_close_all(void) { while (files) { struct file_info *fi = files; - pthread_mutex_unlock(&fi->mutex); + pthread_mutex_unlock(&files_mutex); file_cache_unref(fi); pthread_mutex_lock(&files_mutex); } -- 1.8.0.3.gdd57fab.dirty
>From b330ce5df52d09879ed98e6889863b8f405b9938 Mon Sep 17 00:00:00 2001 From: Eric Wong <normalper...@yhbt.net> Date: Thu, 8 Nov 2012 00:18:53 +0000 Subject: [PATCH 2/3] filecache: avoid ABBA locking problem in unref Since we have other code which locks files_mutex before locking fi->mutex; we must preserve this ordering in and not attempt to unlink wile fi->mutex is held. Since file_cache_get will skip files on ref==0, it is safe to leave the old file in the global file cache with ref==0 after fi->mutex is unlocked. --- src/filecache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/filecache.c b/src/filecache.c index 7527b77..a257a42 100644 --- a/src/filecache.c +++ b/src/filecache.c @@ -125,14 +125,15 @@ void file_cache_unref(void *f) { if (fi->ref == 0) { if (fi->writable) file_cache_sync_unlocked(fi); - file_cache_unlink(fi); unlinked = 1; } pthread_mutex_unlock(&fi->mutex); - if (unlinked) + if (unlinked) { + file_cache_unlink(fi); file_cache_free_unlocked(fi); + } } static void file_cache_unlink(struct file_info *fi) { -- 1.8.0.3.gdd57fab.dirty