[haiku-commits] BRANCH pdziepak-github.nfs4 - src/add-ons/kernel/file_systems/nfs4

  • From: pdziepak-github.nfs4 <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 4 Jan 2013 20:30:49 +0100 (CET)

added 2 changesets to branch 'refs/remotes/pdziepak-github/nfs4'
old head: d72bdcc88a354b1fc118d05b204649843a4a6cbf
new head: 4d120407378d6ec21783c076cdbb753e81a62eba
overview: https://github.com/pdziepak/Haiku/compare/d72bdcc...4d12040

----------------------------------------------------------------------------

332621d: nfs4: Use DoublyLinkedList instead of custom FileSystem list 
implementation

4d12040: nfs4: Remove CacheRevalidator
  
  There is no point in periodically revalidating all existing directory caches.
  Directory snapshot can be revalidated when readdir is invoked.

                                    [ Pawel Dziepak <pdziepak@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

13 files changed, 73 insertions(+), 313 deletions(-)
.../file_systems/nfs4/CacheRevalidator.cpp       | 122 -------------------
.../kernel/file_systems/nfs4/CacheRevalidator.h  |  83 -------------
src/add-ons/kernel/file_systems/nfs4/Cookie.h    |   1 +
.../kernel/file_systems/nfs4/DirectoryCache.cpp  |  70 ++++++-----
.../kernel/file_systems/nfs4/DirectoryCache.h    |  16 +--
.../kernel/file_systems/nfs4/FileSystem.cpp      |   2 -
.../kernel/file_systems/nfs4/FileSystem.h        |  16 +--
src/add-ons/kernel/file_systems/nfs4/Inode.cpp   |   7 +-
src/add-ons/kernel/file_systems/nfs4/Inode.h     |   1 +
.../kernel/file_systems/nfs4/InodeDir.cpp        |  29 ++---
src/add-ons/kernel/file_systems/nfs4/Jamfile     |   1 -
.../kernel/file_systems/nfs4/NFS4Server.cpp      |  36 ++----
.../kernel/file_systems/nfs4/NFS4Server.h        |   2 +-

############################################################################

Commit:      332621d196b32ed04abf0e317ca0870d278a6c1c
Author:      Pawel Dziepak <pdziepak@xxxxxxxxxxx>
Date:        Fri Jan  4 15:03:36 2013 UTC

nfs4: Use DoublyLinkedList instead of custom FileSystem list implementation

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp 
b/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp
index fd5e57b..1b6031c 100644
--- a/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp
+++ b/src/add-ons/kernel/file_systems/nfs4/FileSystem.cpp
@@ -24,8 +24,6 @@ extern RPC::ProgramData* CreateNFS4Server(RPC::Server* serv);
 
 FileSystem::FileSystem(const MountConfiguration& configuration)
        :
-       fNext(NULL),
-       fPrev(NULL),
        fOpenCount(0),
        fOpenOwnerSequence(0),
        fNamedAttrs(true),
diff --git a/src/add-ons/kernel/file_systems/nfs4/FileSystem.h 
b/src/add-ons/kernel/file_systems/nfs4/FileSystem.h
index 2937066..d1f0c8b 100644
--- a/src/add-ons/kernel/file_systems/nfs4/FileSystem.h
+++ b/src/add-ons/kernel/file_systems/nfs4/FileSystem.h
@@ -27,7 +27,7 @@ struct MountConfiguration {
        bool    fCacheMetadata;
 };
 
-class FileSystem {
+class FileSystem : public DoublyLinkedListLinkImpl<FileSystem> {
 public:
        static  status_t                        Mount(FileSystem** pfs, 
RPC::Server* serv,
                                                                        const 
char* path, dev_t id,
@@ -76,8 +76,6 @@ public:
 
        inline  const MountConfiguration&       GetConfiguration();
 
-                       FileSystem*                     fNext;
-                       FileSystem*                     fPrev;
 private:
                                                                
FileSystem(const MountConfiguration& config);
 
diff --git a/src/add-ons/kernel/file_systems/nfs4/NFS4Server.cpp 
b/src/add-ons/kernel/file_systems/nfs4/NFS4Server.cpp
index 1de3bcf..c9b0867 100644
--- a/src/add-ons/kernel/file_systems/nfs4/NFS4Server.cpp
+++ b/src/add-ons/kernel/file_systems/nfs4/NFS4Server.cpp
@@ -21,7 +21,6 @@ NFS4Server::NFS4Server(RPC::Server* serv)
        fLeaseTime(0),
        fClientIdLastUse(0),
        fUseCount(0),
-       fFileSystems(NULL),
        fServer(serv)
 {
        ASSERT(serv != NULL);
@@ -58,7 +57,7 @@ NFS4Server::ServerRebooted(uint64 clientId)
 
        // reclaim all opened files and held locks from all filesystems
        MutexLocker _(fFSLock);
-       FileSystem* fs = fFileSystems;
+       FileSystem* fs = fFileSystems.Head();
        while (fs != NULL) {
                DoublyLinkedList<OpenState>::Iterator iterator
                        = fs->OpenFilesLock().GetIterator();
@@ -70,7 +69,7 @@ NFS4Server::ServerRebooted(uint64 clientId)
                }
                fs->OpenFilesUnlock();
 
-               fs = fs->fNext;
+               fs = fFileSystems.GetNext(fs);
        }
 
        return fClientId;
@@ -83,11 +82,8 @@ NFS4Server::AddFileSystem(FileSystem* fs)
        ASSERT(fs != NULL);
 
        MutexLocker _(fFSLock);
-       fs->fPrev = NULL;
-       fs->fNext = fFileSystems;
-       if (fFileSystems != NULL)
-               fFileSystems->fPrev = fs;
-       fFileSystems = fs;
+       fFileSystems.Add(fs);
+
        fUseCount += fs->OpenFilesCount();
        if (fs->OpenFilesCount() > 0)
                _StartRenewing();
@@ -100,13 +96,7 @@ NFS4Server::RemoveFileSystem(FileSystem* fs)
        ASSERT(fs != NULL);
 
        MutexLocker _(fFSLock);
-       if (fs == fFileSystems)
-               fFileSystems = fs->fNext;
-
-       if (fs->fNext)
-               fs->fNext->fPrev = fs->fPrev;
-       if (fs->fPrev)
-               fs->fPrev->fNext = fs->fNext;
+       fFileSystems.Remove(fs);
        fUseCount -= fs->OpenFilesCount();
 }
 
@@ -152,10 +142,10 @@ NFS4Server::FileSystemMigrated()
 {
        // reclaim all opened files and held locks from all filesystems
        MutexLocker _(fFSLock);
-       FileSystem* fs = fFileSystems;
+       FileSystem* fs = fFileSystems.Head();
        while (fs != NULL) {
                fs->Migrate(fServer);
-               fs = fs->fNext;
+               fs = fFileSystems.GetNext(fs);
        }
 
        return B_OK;
@@ -336,13 +326,13 @@ NFS4Server::CallbackRecall(RequestInterpreter* request, 
ReplyBuilder* reply)
        MutexLocker locker(fFSLock);
 
        Delegation* delegation = NULL;
-       FileSystem* current = fFileSystems;
+       FileSystem* current = fFileSystems.Head();
        while (current != NULL) {
                delegation = current->GetDelegation(handle);
                if (delegation != NULL)
                        break;
 
-               current = current->fNext;
+               current = fFileSystems.GetNext(current);
        }
        locker.Unlock();
 
@@ -379,13 +369,13 @@ NFS4Server::CallbackGetAttr(RequestInterpreter* request, 
ReplyBuilder* reply)
        MutexLocker locker(fFSLock);
 
        Delegation* delegation = NULL;
-       FileSystem* current = fFileSystems;
+       FileSystem* current = fFileSystems.Head();
        while (current != NULL) {
                delegation = current->GetDelegation(handle);
                if (delegation != NULL)
                        break;
 
-               current = current->fNext;
+               current = fFileSystems.GetNext(current);
        }
        locker.Unlock();
 
@@ -411,7 +401,7 @@ status_t
 NFS4Server::RecallAll()
 {
        MutexLocker _(fFSLock);
-       FileSystem* fs = fFileSystems;
+       FileSystem* fs = fFileSystems.Head();
        while (fs != NULL) {
                DoublyLinkedList<Delegation>& list = fs->DelegationsLock();
                DoublyLinkedList<Delegation>::Iterator iterator = 
list.GetIterator();
@@ -427,7 +417,7 @@ NFS4Server::RecallAll()
                }       
                fs->DelegationsUnlock();
 
-               fs = fs->fNext;
+               fs = fFileSystems.GetNext(fs);
        }
 
        return B_OK;
diff --git a/src/add-ons/kernel/file_systems/nfs4/NFS4Server.h 
b/src/add-ons/kernel/file_systems/nfs4/NFS4Server.h
index 4fe2dcc..624b0fe 100644
--- a/src/add-ons/kernel/file_systems/nfs4/NFS4Server.h
+++ b/src/add-ons/kernel/file_systems/nfs4/NFS4Server.h
@@ -66,7 +66,7 @@ private:
                        mutex                   fClientIdLock;
 
                        uint32                  fUseCount;
-                       FileSystem*             fFileSystems;
+                       DoublyLinkedList<FileSystem>    fFileSystems;
                        mutex                   fFSLock;
 
                        RPC::Server*    fServer;

############################################################################

Commit:      4d120407378d6ec21783c076cdbb753e81a62eba
Author:      Pawel Dziepak <pdziepak@xxxxxxxxxxx>
Date:        Fri Jan  4 19:05:15 2013 UTC

nfs4: Remove CacheRevalidator

There is no point in periodically revalidating all existing directory caches.
Directory snapshot can be revalidated when readdir is invoked.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_systems/nfs4/CacheRevalidator.cpp 
b/src/add-ons/kernel/file_systems/nfs4/CacheRevalidator.cpp
deleted file mode 100644
index 5391c12..0000000
--- a/src/add-ons/kernel/file_systems/nfs4/CacheRevalidator.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2012 Haiku, Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Paweł Dziepak, pdziepak@xxxxxxxxxxx
- */
-
-
-#include "CacheRevalidator.h"
-
-#include <fs_cache.h>
-
-#include "NFS4Defs.h"
-
-
-CacheRevalidator::CacheRevalidator()
-       :
-       fThreadCancel(false),
-       fWaitCancel(create_sem(0, NULL))
-{
-       mutex_init(&fDirectoryCachesLock, NULL);
-
-       _StartRevalidator();
-}
-
-
-CacheRevalidator::~CacheRevalidator()
-{
-       fThreadCancel = true;
-       release_sem(fWaitCancel);
-       status_t result;
-       wait_for_thread(fThread, &result);
-
-       delete_sem(fThreadCancel);
-       mutex_destroy(&fDirectoryCachesLock);
-}
-
-
-status_t
-CacheRevalidator::_StartRevalidator()
-{
-       fThreadCancel = false;
-       fThread = 
spawn_kernel_thread(&CacheRevalidator::_DirectoryRevalidatorStart,
-               "NFSv4 Cache Revalidator", B_NORMAL_PRIORITY, this);
-       if (fThread < B_OK)
-               return fThread;
-
-       status_t result = resume_thread(fThread);
-       if (result != B_OK) {
-               kill_thread(fThread);
-               return result;
-       }
-
-       return B_OK;
-}
-
-
-status_t
-CacheRevalidator::_DirectoryRevalidatorStart(void* object)
-{
-       ASSERT(object != NULL);
-
-       CacheRevalidator* revalidator = 
reinterpret_cast<CacheRevalidator*>(object);
-       revalidator->_DirectoryCacheRevalidator();
-       return B_OK;
-}
-
-
-void
-CacheRevalidator::_DirectoryCacheRevalidator()
-{
-       while (!fThreadCancel) {
-               MutexLocker locker(fDirectoryCachesLock);
-               DirectoryCache* current = fDirectoryCaches.Head();
-
-               if (current == NULL) {
-                       locker.Unlock();
-
-                       status_t result = acquire_sem_etc(fWaitCancel, 1,
-                               B_RELATIVE_TIMEOUT,     
DirectoryCache::kExpirationTime);
-
-                       if (result != B_TIMED_OUT) {
-                               if (result == B_OK)
-                                       release_sem(fWaitCancel);
-                               return;
-                       }
-                       continue;
-               }
-
-               current->Lock();
-               if (!current->Valid()) {
-                       RemoveDirectory(current);
-                       current->Unlock();
-                       continue;
-               }
-
-               if (current->ExpireTime() > system_time()) {
-                       current->Unlock();
-                       locker.Unlock();
-
-                       status_t result = acquire_sem_etc(fWaitCancel, 1,
-                               B_ABSOLUTE_TIMEOUT, current->ExpireTime());
-                       if (result != B_TIMED_OUT) {
-                               if (result == B_OK)
-                                       release_sem(fWaitCancel);
-                               return;
-                       }
-
-                       continue;
-               }
-
-               fDirectoryCaches.RemoveHead();
-               current->fRevalidated = false;
-
-               if (current->Revalidate() == B_OK)
-                       AddDirectory(current);
-
-               current->Unlock();
-       }
-}
-
diff --git a/src/add-ons/kernel/file_systems/nfs4/CacheRevalidator.h 
b/src/add-ons/kernel/file_systems/nfs4/CacheRevalidator.h
deleted file mode 100644
index a4764dc..0000000
--- a/src/add-ons/kernel/file_systems/nfs4/CacheRevalidator.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2012 Haiku, Inc. All rights reserved.
- * Distributed under the terms of the MIT License.
- *
- * Authors:
- *             Paweł Dziepak, pdziepak@xxxxxxxxxxx
- */
-#ifndef CACHEREVALIDATOR_H
-#define CACHEREVALIDATOR_H
-
-
-#include <lock.h>
-#include <util/AutoLock.h>
-#include <util/DoublyLinkedList.h>
-
-#include "DirectoryCache.h"
-
-
-class CacheRevalidator {
-public:
-                                                       CacheRevalidator();
-                                                       ~CacheRevalidator();
-
-       inline  void                    Lock();
-       inline  void                    Unlock();
-
-
-       inline  void                    AddDirectory(DirectoryCache* cache);
-       inline  void                    RemoveDirectory(DirectoryCache* cache);
-
-private:
-                       void                    _DirectoryCacheRevalidator();
-       static  status_t                _DirectoryRevalidatorStart(void* 
object);
-                       status_t                _StartRevalidator();
-
-                       thread_id               fThread;
-                       bool                    fThreadCancel;
-                       sem_id                  fWaitCancel;
-
-                       DoublyLinkedList<DirectoryCache>        
fDirectoryCaches;
-                       mutex                   fDirectoryCachesLock;
-};
-
-
-inline void
-CacheRevalidator::Lock()
-{
-       mutex_lock(&fDirectoryCachesLock);
-}
-
-
-inline void
-CacheRevalidator::Unlock()
-{
-       mutex_unlock(&fDirectoryCachesLock);
-}
-
-
-inline void
-CacheRevalidator::AddDirectory(DirectoryCache* cache)
-{
-       ASSERT(cache != NULL);
-
-       if (!cache->fRevalidated) {
-               cache->fRevalidated = true;
-               fDirectoryCaches.InsertAfter(fDirectoryCaches.Tail(), cache);
-       }
-}
-
-
-inline void
-CacheRevalidator::RemoveDirectory(DirectoryCache* cache)
-{
-       ASSERT(cache != NULL);
-
-       if (cache->fRevalidated == true)
-               fDirectoryCaches.Remove(cache);
-       cache->fRevalidated = false;
-}
-
-
-#endif // CACHEREVALIDATOR_H
-
diff --git a/src/add-ons/kernel/file_systems/nfs4/Cookie.h 
b/src/add-ons/kernel/file_systems/nfs4/Cookie.h
index c8956ee..a3d36c9 100644
--- a/src/add-ons/kernel/file_systems/nfs4/Cookie.h
+++ b/src/add-ons/kernel/file_systems/nfs4/Cookie.h
@@ -11,6 +11,7 @@
 
 #include <SupportDefs.h>
 
+#include "DirectoryCache.h"
 #include "FileSystem.h"
 
 
diff --git a/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.cpp 
b/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.cpp
index 923ae53..c40707a 100644
--- a/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.cpp
+++ b/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.cpp
@@ -92,10 +92,6 @@ DirectoryCache::DirectoryCache(Inode* inode, bool attr)
 
 DirectoryCache::~DirectoryCache()
 {
-       fInode->GetFileSystem()->Revalidator().Lock();
-       fInode->GetFileSystem()->Revalidator().RemoveDirectory(this);
-       fInode->GetFileSystem()->Revalidator().Unlock();
-
        mutex_destroy(&fLock);
 }
 
@@ -119,7 +115,7 @@ DirectoryCache::Trash()
                delete current;
        }
 
-       SetSnapshot(NULL);
+       _SetSnapshot(NULL);
 
        fTrashed = true;
 }
@@ -207,7 +203,7 @@ DirectoryCache::RemoveEntry(const char* name)
 
 
 void
-DirectoryCache::SetSnapshot(DirectoryCacheSnapshot* snapshot)
+DirectoryCache::_SetSnapshot(DirectoryCacheSnapshot* snapshot)
 {
        if (fDirectoryCache != NULL)
                fDirectoryCache->ReleaseReference();
@@ -216,50 +212,62 @@ DirectoryCache::SetSnapshot(DirectoryCacheSnapshot* 
snapshot)
 
 
 status_t
-DirectoryCache::Revalidate()
+DirectoryCache::_LoadSnapshot(bool trash)
 {
-       uint64 change;
-       if (fInode->GetChangeInfo(&change, fAttrDir) != B_OK) {
-               Trash();
-               return B_ERROR;
-       }
-
-       if (change == fChange) {
-               fExpireTime = system_time() + kExpirationTime;
-               return B_OK;
-       }
-
        DirectoryCacheSnapshot* oldSnapshot = fDirectoryCache;
-       if (oldSnapshot == NULL) {
-               Trash();
-               return B_ERROR;
-       }
-
-       oldSnapshot->AcquireReference();
+       if (oldSnapshot != NULL)
+               oldSnapshot->AcquireReference();
 
-       Trash();
+       if (trash)
+               Trash();
 
        DirectoryCacheSnapshot* newSnapshot;
        status_t result = fInode->GetDirSnapshot(&newSnapshot, NULL, &fChange,
                fAttrDir);
        if (result != B_OK) {
-               oldSnapshot->ReleaseReference();
-               return B_ERROR;
+               if (oldSnapshot != NULL)
+                       oldSnapshot->ReleaseReference();
+               return result;
        }
        newSnapshot->AcquireReference();
 
-       SetSnapshot(newSnapshot);
+       _SetSnapshot(newSnapshot);
        fExpireTime = system_time() + kExpirationTime;
+
        fTrashed = false;
 
-       NotifyChanges(oldSnapshot, newSnapshot);
-       oldSnapshot->ReleaseReference();
-       newSnapshot->ReleaseReference();
+       if (oldSnapshot != NULL)
+               NotifyChanges(oldSnapshot, newSnapshot);
 
+       if (oldSnapshot != NULL)
+               oldSnapshot->ReleaseReference();
+
+       newSnapshot->ReleaseReference();
        return B_OK;
 }
 
 
+status_t
+DirectoryCache::Revalidate()
+{
+       if (fExpireTime < system_time())
+               return B_OK;
+
+       uint64 change;
+       if (fInode->GetChangeInfo(&change, fAttrDir) != B_OK) {
+               Trash();
+               return B_ERROR;
+       }
+
+       if (change == fChange) {
+               fExpireTime = system_time() + kExpirationTime;
+               return B_OK;
+       }
+
+       return _LoadSnapshot(true);
+}
+
+
 void
 DirectoryCache::NotifyChanges(DirectoryCacheSnapshot* oldSnapshot,
        DirectoryCacheSnapshot* newSnapshot)
diff --git a/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.h 
b/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.h
index 5cc6854..7abefb7 100644
--- a/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.h
+++ b/src/add-ons/kernel/file_systems/nfs4/DirectoryCache.h
@@ -38,7 +38,7 @@ struct DirectoryCacheSnapshot : public KernelReferenceable {
                                                        
~DirectoryCacheSnapshot();
 };
 
-class DirectoryCache : public DoublyLinkedListLinkImpl<DirectoryCache> {
+class DirectoryCache {
 public:
                                                        DirectoryCache(Inode* 
inode, bool attr = false);
                                                        ~DirectoryCache();
@@ -54,7 +54,6 @@ public:
                                                                bool created = 
false);
                        void                    RemoveEntry(const char* name);
 
-                       void                    
SetSnapshot(DirectoryCacheSnapshot* snapshot);
        inline  DirectoryCacheSnapshot* GetSnapshot();
 
        inline  SinglyLinkedList<NameCacheEntry>&       EntriesList();
@@ -66,7 +65,6 @@ public:
        inline  uint64                  ChangeInfo();
 
        inline  Inode*                  GetInode();
-       inline  time_t                  ExpireTime();
 
        static  const bigtime_t kExpirationTime         = 15000000;
 
@@ -76,6 +74,9 @@ protected:
                                                                
DirectoryCacheSnapshot* newSnapshot);
 
 private:
+                       void                    
_SetSnapshot(DirectoryCacheSnapshot* snapshot);
+                       status_t                _LoadSnapshot(bool trash);
+
                        SinglyLinkedList<NameCacheEntry>        fNameCache;
 
                        DirectoryCacheSnapshot* fDirectoryCache;
@@ -115,6 +116,8 @@ DirectoryCache::Valid()
 inline DirectoryCacheSnapshot*
 DirectoryCache::GetSnapshot()
 {
+       if (fDirectoryCache == NULL)
+               _LoadSnapshot(false);
        return fDirectoryCache;
 }
 
@@ -164,12 +167,5 @@ DirectoryCache::GetInode()
 }
 
 
-inline time_t
-DirectoryCache::ExpireTime()
-{
-       return fExpireTime;
-}
-
-
 #endif // DIRECTORYCACHE_H
                        
diff --git a/src/add-ons/kernel/file_systems/nfs4/FileSystem.h 
b/src/add-ons/kernel/file_systems/nfs4/FileSystem.h
index d1f0c8b..67e3996 100644
--- a/src/add-ons/kernel/file_systems/nfs4/FileSystem.h
+++ b/src/add-ons/kernel/file_systems/nfs4/FileSystem.h
@@ -9,7 +9,6 @@
 #define FILESYSTEM_H
 
 
-#include "CacheRevalidator.h"
 #include "Delegation.h"
 #include "InodeIdMap.h"
 #include "NFS4Defs.h"
@@ -51,8 +50,6 @@ public:
                        void                            
RemoveDelegation(Delegation* delegation);
                        Delegation*                     GetDelegation(const 
FileHandle& handle);
 
-       inline  CacheRevalidator&       Revalidator();
-
        inline  bool                            IsAttrSupported(Attribute attr) 
const;
        inline  uint32                          ExpireType() const;
 
@@ -79,8 +76,6 @@ public:
 private:
                                                                
FileSystem(const MountConfiguration& config);
 
-                       CacheRevalidator        fCacheRevalidator;
-
                        mutex                           fDelegationLock;
                        DoublyLinkedList<Delegation>    fDelegationList;
                        AVLTreeMap<FileHandle, Delegation*> fHandleToDelegation;
@@ -113,13 +108,6 @@ private:
 };
 
 
-inline CacheRevalidator&
-FileSystem::Revalidator()
-{
-       return fCacheRevalidator;
-}
-
-
 inline RootInode*
 FileSystem::Root()
 {
diff --git a/src/add-ons/kernel/file_systems/nfs4/Inode.cpp 
b/src/add-ons/kernel/file_systems/nfs4/Inode.cpp
index be79b53..795a2a2 100644
--- a/src/add-ons/kernel/file_systems/nfs4/Inode.cpp
+++ b/src/add-ons/kernel/file_systems/nfs4/Inode.cpp
@@ -204,20 +204,15 @@ Inode::LookUp(const char* name, ino_t* id)
        if (result != B_OK)
                return result;
 
-       fFileSystem->Revalidator().Lock();
        fCache->Lock();
        if (!fCache->Valid()) {
                fCache->Reset();
                fCache->SetChangeInfo(change);
-       } else {
-               fFileSystem->Revalidator().RemoveDirectory(fCache);
+       } else
                fCache->ValidateChangeInfo(change);
-       }
 
        fCache->AddEntry(name, *id);
-       fFileSystem->Revalidator().AddDirectory(fCache);
        fCache->Unlock();
-       fFileSystem->Revalidator().Unlock();
 
        return B_OK;
 }
diff --git a/src/add-ons/kernel/file_systems/nfs4/Inode.h 
b/src/add-ons/kernel/file_systems/nfs4/Inode.h
index e72aadb..da4802f 100644
--- a/src/add-ons/kernel/file_systems/nfs4/Inode.h
+++ b/src/add-ons/kernel/file_systems/nfs4/Inode.h
@@ -9,6 +9,7 @@
 #define INODE_H
 
 
+#include "DirectoryCache.h"
 #include "MetadataCache.h"
 #include "NFS4Inode.h"
 #include "OpenState.h"
diff --git a/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp 
b/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp
index 2b71dce..10d2943 100644
--- a/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp
+++ b/src/add-ons/kernel/file_systems/nfs4/InodeDir.cpp
@@ -317,30 +317,21 @@ Inode::ReadDir(void* _buffer, uint32 size, uint32* _count,
        status_t result;
        DirectoryCache* cache = cookie->fAttrDir ? fAttrCache : fCache;
        if (cookie->fSnapshot == NULL) {
-               fFileSystem->Revalidator().Lock();
                cache->Lock();
-               if (!cache->Valid())
-                       cache->Reset();
-               else
-                       fFileSystem->Revalidator().RemoveDirectory(cache);
+               result = cache->Revalidate();
+               if (result != B_OK) {
+                       cache->Unlock();
+                       return result;
+               }
 
                DirectoryCacheSnapshot* snapshot = cache->GetSnapshot();
-               if (snapshot == NULL) {
-                       uint64 change;
-                       result = GetDirSnapshot(&snapshot, cookie, &change,
-                               cookie->fAttrDir);
-                       if (result != B_OK) {
-                               cache->Unlock();
-                               fFileSystem->Revalidator().Unlock();
-                               return result;
-                       }
-                       cache->ValidateChangeInfo(change);
-                       cache->SetSnapshot(snapshot);
-               }
+               ASSERT(snapshot != NULL);
+
                cookie->fSnapshot = new DirectoryCacheSnapshot(*snapshot);
-               fFileSystem->Revalidator().AddDirectory(cache);
                cache->Unlock();
-               fFileSystem->Revalidator().Unlock();
+
+               if (cookie->fSnapshot == NULL)
+                       return B_NO_MEMORY;
        }
 
        char* buffer = reinterpret_cast<char*>(_buffer);
diff --git a/src/add-ons/kernel/file_systems/nfs4/Jamfile 
b/src/add-ons/kernel/file_systems/nfs4/Jamfile
index c77e634..3d678a9 100644
--- a/src/add-ons/kernel/file_systems/nfs4/Jamfile
+++ b/src/add-ons/kernel/file_systems/nfs4/Jamfile
@@ -4,7 +4,6 @@ UsePrivateKernelHeaders ;
 UsePrivateHeaders shared ;
 
 KernelAddon nfs4 :
-       CacheRevalidator.cpp
        Cookie.cpp
        Connection.cpp
        Delegation.cpp


Other related posts: