From 9e79133f4d76f11f86241a0e841c03e1487f3c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 27 Mar 2008 09:48:33 +0000 Subject: [PATCH] * Reverted r22315 as far as free_vnode() is concerned: removing the vnode from the hash before putting it caused all sorts of problems. * For example, BFS would trim its preallocations when the vnode is put; if someone would read that same vnode after it had been removed, but before BFS could trim it, it would read the old vnode which still seemed to own the blocks which would subsequently be freed. * This fixes bug #1914, and should also fix bug #1956. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24607 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/vfs.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 979b474e9d..85ede2f8ac 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -691,12 +691,6 @@ free_vnode(struct vnode *vnode, bool reenter) // count, so that it will neither become negative nor 0. vnode->ref_count = 2; - // The file system has removed the resources of the vnode now, so we can - // make it available again (and remove the busy vnode from the hash) - mutex_lock(&sVnodeMutex); - hash_remove(sVnodeTable, vnode); - mutex_unlock(&sVnodeMutex); - // TODO: Usually, when the vnode is unreferenced, no one can get hold of the // cache either (i.e. no one can get a cache reference while we're deleting // the vnode).. This is, however, not the case for the page daemon. It gets @@ -713,6 +707,12 @@ free_vnode(struct vnode *vnode, bool reenter) } } + // The file system has removed the resources of the vnode now, so we can + // make it available again (and remove the busy vnode from the hash) + mutex_lock(&sVnodeMutex); + hash_remove(sVnodeTable, vnode); + mutex_unlock(&sVnodeMutex); + // if we have a vm_cache attached, remove it if (vnode->cache) vm_cache_release_ref(vnode->cache);