Switched from direct get_vnode() usage to the Vnode class.

Now acquires the volume lock always before get_vnode() is called as long
as UNSAFE_GET_VNODE is defined (which now is by default).
May cause some unwanted side-effects; it still has to be thorougly tested.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6424 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2004-01-30 00:47:56 +00:00
parent b39a7a0edd
commit 36660c5e99
6 changed files with 16 additions and 6 deletions

View File

@ -869,6 +869,9 @@ 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) {

View File

@ -83,15 +83,16 @@ Index::SetTo(const char *name)
if (status != B_OK)
return status;
if (get_vnode(fVolume->ID(), id, (void **)&fNode) != B_OK)
Vnode vnode(fVolume, id);
if (vnode.Get(&fNode) != B_OK)
return B_ENTRY_NOT_FOUND;
if (fNode == NULL) {
FATAL(("fatal error at Index::InitCheck(), get_vnode() returned NULL pointer\n"));
put_vnode(fVolume->ID(), id);
return B_ERROR;
}
vnode.Keep();
return B_OK;
}

View File

@ -2169,6 +2169,9 @@ AttributeIterator::GetNext(char *name, size_t *_length, uint32 *_type, vnode_id
// if you haven't yet access to the attributes directory, get it
if (fAttributes == NULL) {
#ifdef UNSAFE_GET_VNODE
RecursiveLocker locker(volume->Lock());
#endif
if (get_vnode(volume->ID(), volume->ToVnode(fInode->Attributes()),
(void **)&fAttributes) != 0
|| fAttributes == NULL) {

View File

@ -238,8 +238,11 @@ 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);
}

View File

@ -7,6 +7,7 @@ oldOPTIM = $(OPTIM) ;
{
local defines =
KEEP_WRONG_DIRENT_RECLEN
UNSAFE_GET_VNODE
#BFS_BIG_ENDIAN_ONLY
;

View File

@ -1035,8 +1035,9 @@ Equation::GetNextMatching(Volume *volume, TreeIterator *iterator,
continue;
}
Vnode vnode(volume, offset);
Inode *inode;
if ((status = get_vnode(volume->ID(), offset, (void **)&inode)) != B_OK) {
if ((status = vnode.Get(&inode)) != B_OK) {
REPORT_ERROR(status);
FATAL(("could not get inode %Ld in index \"%s\"!\n", offset, fAttribute));
// try with next
@ -1104,8 +1105,6 @@ Equation::GetNextMatching(Volume *volume, TreeIterator *iterator,
#endif
}
put_vnode(volume->ID(), inode->ID());
if (status == MATCH_OK)
return B_OK;
}