Some cleanup. Fixed gcc 4 warning.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22202 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2007-09-08 16:17:59 +00:00
parent 08dd9e7f3c
commit 43ab7500cc
+68 -65
View File
@@ -9,11 +9,23 @@
/*! Virtual File System and File System Interface Layer */ /*! Virtual File System and File System Interface Layer */
#include <OS.h> #include <ctype.h>
#include <StorageDefs.h> #include <fcntl.h>
#include <limits.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fs_info.h> #include <fs_info.h>
#include <fs_interface.h> #include <fs_interface.h>
#include <fs_volume.h> #include <fs_volume.h>
#include <OS.h>
#include <StorageDefs.h>
#include <util/AutoLock.h>
#include <block_cache.h> #include <block_cache.h>
#include <fd.h> #include <fd.h>
@@ -33,17 +45,7 @@
#include <disk_device_manager/KDiskDeviceUtils.h> #include <disk_device_manager/KDiskDeviceUtils.h>
#include <disk_device_manager/KDiskSystem.h> #include <disk_device_manager/KDiskSystem.h>
#include <fs/node_monitor.h> #include <fs/node_monitor.h>
#include <util/kernel_cpp.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <fcntl.h>
#include <limits.h>
#include <stddef.h>
//#define TRACE_VFS //#define TRACE_VFS
#ifdef TRACE_VFS #ifdef TRACE_VFS
@@ -133,50 +135,50 @@ struct advisory_lock {
static mutex sFileSystemsMutex; static mutex sFileSystemsMutex;
/** \brief Guards sMountsTable. /*! \brief Guards sMountsTable.
*
* The holder is allowed to read/write access the sMountsTable. The holder is allowed to read/write access the sMountsTable.
* Manipulation of the fs_mount structures themselves Manipulation of the fs_mount structures themselves
* (and their destruction) requires different locks though. (and their destruction) requires different locks though.
*/ */
static mutex sMountMutex; static mutex sMountMutex;
/** \brief Guards mount/unmount operations. /*! \brief Guards mount/unmount operations.
*
* The fs_mount() and fs_unmount() hold the lock during their whole operation. The fs_mount() and fs_unmount() hold the lock during their whole operation.
* That is locking the lock ensures that no FS is mounted/unmounted. In That is locking the lock ensures that no FS is mounted/unmounted. In
* particular this means that particular this means that
* - sMountsTable will not be modified, - sMountsTable will not be modified,
* - the fields immutable after initialization of the fs_mount structures in - the fields immutable after initialization of the fs_mount structures in
* sMountsTable will not be modified, sMountsTable will not be modified,
* - vnode::covered_by of any vnode in sVnodeTable will not be modified. - vnode::covered_by of any vnode in sVnodeTable will not be modified.
*
* The thread trying to lock the lock must not hold sVnodeMutex or The thread trying to lock the lock must not hold sVnodeMutex or
* sMountMutex. sMountMutex.
*/ */
static recursive_lock sMountOpLock; static recursive_lock sMountOpLock;
/** \brief Guards the vnode::covered_by field of any vnode /*! \brief Guards the vnode::covered_by field of any vnode
*
* The holder is allowed to read access the vnode::covered_by field of any The holder is allowed to read access the vnode::covered_by field of any
* vnode. Additionally holding sMountOpLock allows for write access. vnode. Additionally holding sMountOpLock allows for write access.
*
* The thread trying to lock the must not hold sVnodeMutex. The thread trying to lock the must not hold sVnodeMutex.
*/ */
static mutex sVnodeCoveredByMutex; static mutex sVnodeCoveredByMutex;
/** \brief Guards sVnodeTable. /*! \brief Guards sVnodeTable.
*
* The holder is allowed to read/write access sVnodeTable and to The holder is allowed to read/write access sVnodeTable and to
* to any unbusy vnode in that table, save any unbusy vnode in that table, save to the immutable fields (device, id,
* to the immutable fields (device, id, private_node, mount) to which private_node, mount) to which
* only read-only access is allowed, and to the field covered_by, which is only read-only access is allowed, and to the field covered_by, which is
* guarded by sMountOpLock and sVnodeCoveredByMutex. guarded by sMountOpLock and sVnodeCoveredByMutex.
*
* The thread trying to lock the mutex must not hold sMountMutex. The thread trying to lock the mutex must not hold sMountMutex.
* You must not have this mutex held when calling create_sem(), as this You must not have this mutex held when calling create_sem(), as this
* might call vfs_free_unused_vnodes(). might call vfs_free_unused_vnodes().
*/ */
static mutex sVnodeMutex; static mutex sVnodeMutex;
#define VNODE_HASH_TABLE_SIZE 1024 #define VNODE_HASH_TABLE_SIZE 1024
@@ -2606,25 +2608,26 @@ remove_vnode(dev_t mountID, ino_t vnodeID)
struct vnode *vnode; struct vnode *vnode;
bool remove = false; bool remove = false;
mutex_lock(&sVnodeMutex); MutexLocker locker(sVnodeMutex);
vnode = lookup_vnode(mountID, vnodeID); vnode = lookup_vnode(mountID, vnodeID);
if (vnode != NULL) { if (vnode == NULL)
if (vnode->covered_by != NULL) { return B_ENTRY_NOT_FOUND;
// this vnode is in use
mutex_unlock(&sVnodeMutex);
return B_BUSY;
}
vnode->remove = true; if (vnode->covered_by != NULL) {
if (vnode->unpublished) { // this vnode is in use
// prepare the vnode for deletion mutex_unlock(&sVnodeMutex);
vnode->busy = true; return B_BUSY;
remove = true;
}
} }
mutex_unlock(&sVnodeMutex); vnode->remove = true;
if (vnode->unpublished) {
// prepare the vnode for deletion
vnode->busy = true;
remove = true;
}
locker.Unlock();
if (remove) { if (remove) {
// if the vnode hasn't been published yet, we delete it here // if the vnode hasn't been published yet, we delete it here
@@ -2632,7 +2635,7 @@ remove_vnode(dev_t mountID, ino_t vnodeID)
free_vnode(vnode, true); free_vnode(vnode, true);
} }
return vnode != NULL ? B_OK : B_ENTRY_NOT_FOUND; return B_OK;
} }