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:
@@ -869,6 +869,9 @@ BlockAllocator::CheckNextNode(check_control *control)
|
|||||||
|
|
||||||
// get iterator for the next directory
|
// get iterator for the next directory
|
||||||
|
|
||||||
|
#ifdef UNSAFE_GET_VNODE
|
||||||
|
RecursiveLocker locker(fVolume->Lock());
|
||||||
|
#endif
|
||||||
Vnode vnode(fVolume, cookie->current);
|
Vnode vnode(fVolume, cookie->current);
|
||||||
Inode *inode;
|
Inode *inode;
|
||||||
if (vnode.Get(&inode) < B_OK) {
|
if (vnode.Get(&inode) < B_OK) {
|
||||||
|
|||||||
@@ -83,15 +83,16 @@ Index::SetTo(const char *name)
|
|||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
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;
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
if (fNode == NULL) {
|
if (fNode == NULL) {
|
||||||
FATAL(("fatal error at Index::InitCheck(), get_vnode() returned NULL pointer\n"));
|
FATAL(("fatal error at Index::InitCheck(), get_vnode() returned NULL pointer\n"));
|
||||||
put_vnode(fVolume->ID(), id);
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vnode.Keep();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 you haven't yet access to the attributes directory, get it
|
||||||
if (fAttributes == NULL) {
|
if (fAttributes == NULL) {
|
||||||
|
#ifdef UNSAFE_GET_VNODE
|
||||||
|
RecursiveLocker locker(volume->Lock());
|
||||||
|
#endif
|
||||||
if (get_vnode(volume->ID(), volume->ToVnode(fInode->Attributes()),
|
if (get_vnode(volume->ID(), volume->ToVnode(fInode->Attributes()),
|
||||||
(void **)&fAttributes) != 0
|
(void **)&fAttributes) != 0
|
||||||
|| fAttributes == NULL) {
|
|| fAttributes == NULL) {
|
||||||
|
|||||||
@@ -240,6 +240,9 @@ class Vnode {
|
|||||||
status_t Get(Inode **inode)
|
status_t Get(Inode **inode)
|
||||||
{
|
{
|
||||||
// should we check inode against NULL here? it should not be necessary
|
// 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);
|
return get_vnode(fVolume->ID(), fID, (void **)inode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ oldOPTIM = $(OPTIM) ;
|
|||||||
{
|
{
|
||||||
local defines =
|
local defines =
|
||||||
KEEP_WRONG_DIRENT_RECLEN
|
KEEP_WRONG_DIRENT_RECLEN
|
||||||
|
UNSAFE_GET_VNODE
|
||||||
#BFS_BIG_ENDIAN_ONLY
|
#BFS_BIG_ENDIAN_ONLY
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
@@ -1035,8 +1035,9 @@ Equation::GetNextMatching(Volume *volume, TreeIterator *iterator,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vnode vnode(volume, offset);
|
||||||
Inode *inode;
|
Inode *inode;
|
||||||
if ((status = get_vnode(volume->ID(), offset, (void **)&inode)) != B_OK) {
|
if ((status = vnode.Get(&inode)) != B_OK) {
|
||||||
REPORT_ERROR(status);
|
REPORT_ERROR(status);
|
||||||
FATAL(("could not get inode %Ld in index \"%s\"!\n", offset, fAttribute));
|
FATAL(("could not get inode %Ld in index \"%s\"!\n", offset, fAttribute));
|
||||||
// try with next
|
// try with next
|
||||||
@@ -1104,8 +1105,6 @@ Equation::GetNextMatching(Volume *volume, TreeIterator *iterator,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
put_vnode(volume->ID(), inode->ID());
|
|
||||||
|
|
||||||
if (status == MATCH_OK)
|
if (status == MATCH_OK)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user