nfs4: Recall all delegations when callback path is down

This commit is contained in:
Pawel Dziepak
2012-08-06 22:52:35 +02:00
parent 412174162e
commit 0dff48c7ea
3 changed files with 37 additions and 16 deletions
@@ -311,11 +311,28 @@ FileSystem::RemoveOpenFile(OpenState* state)
}
DoublyLinkedList<Delegation>&
FileSystem::DelegationsLock()
{
mutex_lock(&fDelegationLock);
return fDelegationList;
}
void
FileSystem::DelegationsUnlock()
{
mutex_unlock(&fDelegationLock);
}
void
FileSystem::AddDelegation(Delegation* delegation)
{
MutexLocker _(fDelegationLock);
fDelegationList.InsertBefore(fDelegationList.Head(), delegation);
fHandleToDelegation.Remove(delegation->fInfo.fHandle);
fHandleToDelegation.Insert(delegation->fInfo.fHandle, delegation);
@@ -328,6 +345,7 @@ FileSystem::RemoveDelegation(Delegation* delegation)
{
MutexLocker _(fDelegationLock);
fDelegationList.Remove(delegation);
fHandleToDelegation.Remove(delegation->fInfo.fHandle);
NFSServer()->DecUsage();
@@ -36,6 +36,8 @@ public:
void AddOpenFile(OpenState* state);
void RemoveOpenFile(OpenState* state);
DoublyLinkedList<Delegation>& DelegationsLock();
void DelegationsUnlock();
void AddDelegation(Delegation* delegation);
void RemoveDelegation(Delegation* delegation);
Delegation* GetDelegation(const FileHandle& handle);
@@ -68,6 +70,7 @@ private:
CacheRevalidator fCacheRevalidator;
mutex fDelegationLock;
DoublyLinkedList<Delegation> fDelegationList;
AVLTreeMap<FileHandle, Delegation*> fHandleToDelegation;
OpenState* fOpenFiles;
@@ -346,26 +346,26 @@ NFS4Server::CallbackRecall(RequestInterpreter* request, ReplyBuilder* reply)
status_t
NFS4Server::RecallAll()
{
#if 0
MutexLocker locker(fFSLock);
MutexLocker _(fFSLock);
FileSystem* fs = fFileSystems;
while (fs != NULL) {
DoublyLinkedList<Delegation>& list = fs->DelegationsLock();
DoublyLinkedList<Delegation>::Iterator iterator = list.GetIterator();
Delegation* delegation = NULL;
FileSystem* current = fFileSystems;
while (current != NULL) {
delegation = current->GetDelegation(handle);
if (delegation != NULL)
break;
Delegation* current = iterator.Next();
while (current != NULL) {
DelegationRecallArgs* args = new(std::nothrow) DelegationRecallArgs;
args->fDelegation = current;
args->fTruncate = false;
gWorkQueue->EnqueueJob(DelegationRecall, args);
current = current->fNext;
current = iterator.Next();
}
fs->DelegationsUnlock();
fs = fs->fNext;
}
locker.Unlock();
DelegationRecallArgs args = new(std::nothrow) DelegationRecallArgs;
DelegationRecallArgs* args;
args->fDelegation = delegation;
args->fTruncate = truncate;
gWorkQueue->EnqueueJob(DelegationRecall, args);
#endif
return B_OK;
}