nfs4: Do not remove RootInode too soon

This commit is contained in:
Pawel Dziepak
2013-01-03 15:37:36 +01:00
parent e8ef557a56
commit d72bdcc88a
2 changed files with 16 additions and 4 deletions
@@ -27,9 +27,10 @@ void
VnodeToInode::Replace(Inode* newInode)
{
WriteLocker _(fLock);
if (fInode != NULL)
if (fInode != NULL && !IsRoot()) {
fInode->GetFileSystem()->InoIdMap()->MarkRemoved(fID);
delete fInode;
}
fInode = newInode;
if (fInode != NULL) {
@@ -14,6 +14,7 @@
#include "Inode.h"
#include "InodeIdMap.h"
#include "RootInode.h"
class VnodeToInode {
public:
@@ -31,6 +32,8 @@ public:
inline void Clear();
inline ino_t ID() const;
inline bool IsRoot() const;
private:
ino_t fID;
rw_lock fLock;
@@ -70,7 +73,7 @@ inline
VnodeToInode::~VnodeToInode()
{
Remove();
if (fFileSystem != NULL)
if (fFileSystem != NULL && !IsRoot())
fFileSystem->InoIdMap()->RemoveEntry(fID);
rw_lock_destroy(&fLock);
}
@@ -101,11 +104,19 @@ inline void
VnodeToInode::Clear()
{
WriteLocker _(fLock);
if (!IsRoot())
delete fInode;
fInode = NULL;
}
inline bool
VnodeToInode::IsRoot() const
{
return fInode && fFileSystem && fInode->ID() == fFileSystem->Root()->ID();
}
inline Inode*
VnodeToInode::GetPointer() const
{