From fc317af25e51b2c96c416b3d1fc01e3f0b168595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 23 Jan 2007 17:09:21 +0000 Subject: [PATCH] Writing to attributes was deadlock prone; the BFS volume lock was acquired with the BFS Journal lock held. Since our get_vnode() is no longer unsafe (unlike Be's version of it), we can get rid of the UNSAFE_GET_VNODE stuff, which also solves this bug. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19916 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../file_systems/bfs/BlockAllocator.cpp | 8 +---- src/add-ons/kernel/file_systems/bfs/Inode.h | 5 +--- src/add-ons/kernel/file_systems/bfs/Jamfile | 3 +- .../file_systems/bfs/kernel_interface.cpp | 30 +------------------ 4 files changed, 4 insertions(+), 42 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index 34f9e15997..6009beb7bc 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -1,6 +1,6 @@ /* BlockAllocator - block bitmap handling and allocation policies * - * Copyright 2001-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -935,9 +935,6 @@ BlockAllocator::CheckNextNode(check_control *control) // get iterator for the next directory -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(fVolume->Lock()); -#endif Vnode vnode(fVolume, cookie->current); Inode *inode; if (vnode.Get(&inode) < B_OK) { @@ -1039,9 +1036,6 @@ BlockAllocator::CheckNextNode(check_control *control) // if we are allowed to fix errors, we should remove the file if (control->flags & BFS_REMOVE_WRONG_TYPES && control->flags & BFS_FIX_BITMAP_ERRORS) { -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(fVolume->Lock()); -#endif // it's safe to start a transaction, because Inode::Remove() // won't touch the block bitmap (which we hold the lock for) // if we set the INODE_DONT_FREE_SPACE flag - since we fix diff --git a/src/add-ons/kernel/file_systems/bfs/Inode.h b/src/add-ons/kernel/file_systems/bfs/Inode.h index 8f7d7f9d3f..29b42d17e1 100644 --- a/src/add-ons/kernel/file_systems/bfs/Inode.h +++ b/src/add-ons/kernel/file_systems/bfs/Inode.h @@ -1,6 +1,6 @@ /* Inode - inode access functions * - * Copyright 2001-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ #ifndef INODE_H @@ -250,9 +250,6 @@ class Vnode { status_t Get(Inode **_inode) { // should we check inode against NULL here? it should not be necessary -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(fVolume->Lock()); -#endif return get_vnode(fVolume->ID(), fID, (void **)_inode); } diff --git a/src/add-ons/kernel/file_systems/bfs/Jamfile b/src/add-ons/kernel/file_systems/bfs/Jamfile index 52e59f3aee..ba9d72d8de 100644 --- a/src/add-ons/kernel/file_systems/bfs/Jamfile +++ b/src/add-ons/kernel/file_systems/bfs/Jamfile @@ -3,7 +3,7 @@ SubDir HAIKU_TOP src add-ons kernel file_systems bfs ; # save original optimization level oldOPTIM = $(OPTIM) ; -# R5 support is currently disabled! +# R5 support has been removed! # # Have a look in src/tests/add-ons/kernel/file_systems/bfs/r5/ # for an R5 compatible version. @@ -13,7 +13,6 @@ oldOPTIM = $(OPTIM) ; # set some additional defines { local defines = - UNSAFE_GET_VNODE #BFS_BIG_ENDIAN_ONLY ; diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index c3a8612fae..7405ee8399 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -1,6 +1,6 @@ /* kernel_interface - file system interface to Haiku's vnode layer * - * Copyright 2001-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2001-2007, Axel Dörfler, axeld@pinc-software.de. * This file may be used under the terms of the MIT License. */ @@ -693,10 +693,6 @@ bfs_write_stat(void *_ns, void *_node, const struct stat *stat, uint32 mask) if (status < B_OK) RETURN_ERROR(status); -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif - WriteLocked locked(inode->Lock()); if (locked.IsLocked() < B_OK) RETURN_ERROR(B_ERROR); @@ -793,9 +789,6 @@ bfs_create(void *_ns, void *_directory, const char *name, int openMode, int mode cookie->last_size = 0; cookie->last_notification = system_time(); -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif Transaction transaction(volume, directory->BlockNumber()); status_t status = Inode::Create(transaction, directory, name, S_FILE | (mode & S_IUMSK), @@ -834,9 +827,6 @@ bfs_create_symlink(void *_ns, void *_directory, const char *name, const char *pa if (status < B_OK) RETURN_ERROR(status); -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif Transaction transaction(volume, directory->BlockNumber()); Inode *link; @@ -904,9 +894,6 @@ bfs_unlink(void *_ns, void *_directory, const char *name) if (status < B_OK) return status; -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif Transaction transaction(volume, directory->BlockNumber()); off_t id; @@ -1274,9 +1261,6 @@ bfs_free_cookie(void *_ns, void *_node, void *_cookie) && (needsTrimming || inode->OldLastModified() != inode->LastModified() || inode->OldSize() != inode->Size())) { -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif ReadLocked locked(inode->Lock()); // trim the preallocated blocks and update the size, @@ -1406,9 +1390,6 @@ bfs_create_dir(void *_ns, void *_directory, const char *name, int mode, vnode_id if (status < B_OK) RETURN_ERROR(status); -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif Transaction transaction(volume, directory->BlockNumber()); // Inode::Create() locks the inode if we pass the "id" parameter, but we @@ -1438,9 +1419,6 @@ bfs_remove_dir(void *_ns, void *_directory, const char *name) Volume *volume = (Volume *)_ns; Inode *directory = (Inode *)_directory; -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif Transaction transaction(volume, directory->BlockNumber()); off_t id; @@ -1882,9 +1860,6 @@ bfs_create_index(fs_volume _fs, const char *name, uint32 type, uint32 flags) if (geteuid() != 0) return B_NOT_ALLOWED; -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif Transaction transaction(volume, volume->Indices()); Index index(volume); @@ -1917,9 +1892,6 @@ bfs_remove_index(void *_ns, const char *name) if ((indices = volume->IndicesNode()) == NULL) return B_ENTRY_NOT_FOUND; -#ifdef UNSAFE_GET_VNODE - RecursiveLocker locker(volume->Lock()); -#endif Transaction transaction(volume, volume->Indices()); status_t status = indices->Remove(transaction, name);