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 void
FileSystem::AddDelegation(Delegation* delegation) FileSystem::AddDelegation(Delegation* delegation)
{ {
MutexLocker _(fDelegationLock); MutexLocker _(fDelegationLock);
fDelegationList.InsertBefore(fDelegationList.Head(), delegation);
fHandleToDelegation.Remove(delegation->fInfo.fHandle); fHandleToDelegation.Remove(delegation->fInfo.fHandle);
fHandleToDelegation.Insert(delegation->fInfo.fHandle, delegation); fHandleToDelegation.Insert(delegation->fInfo.fHandle, delegation);
@@ -328,6 +345,7 @@ FileSystem::RemoveDelegation(Delegation* delegation)
{ {
MutexLocker _(fDelegationLock); MutexLocker _(fDelegationLock);
fDelegationList.Remove(delegation);
fHandleToDelegation.Remove(delegation->fInfo.fHandle); fHandleToDelegation.Remove(delegation->fInfo.fHandle);
NFSServer()->DecUsage(); NFSServer()->DecUsage();
@@ -36,6 +36,8 @@ public:
void AddOpenFile(OpenState* state); void AddOpenFile(OpenState* state);
void RemoveOpenFile(OpenState* state); void RemoveOpenFile(OpenState* state);
DoublyLinkedList<Delegation>& DelegationsLock();
void DelegationsUnlock();
void AddDelegation(Delegation* delegation); void AddDelegation(Delegation* delegation);
void RemoveDelegation(Delegation* delegation); void RemoveDelegation(Delegation* delegation);
Delegation* GetDelegation(const FileHandle& handle); Delegation* GetDelegation(const FileHandle& handle);
@@ -68,6 +70,7 @@ private:
CacheRevalidator fCacheRevalidator; CacheRevalidator fCacheRevalidator;
mutex fDelegationLock; mutex fDelegationLock;
DoublyLinkedList<Delegation> fDelegationList;
AVLTreeMap<FileHandle, Delegation*> fHandleToDelegation; AVLTreeMap<FileHandle, Delegation*> fHandleToDelegation;
OpenState* fOpenFiles; OpenState* fOpenFiles;
@@ -346,26 +346,26 @@ NFS4Server::CallbackRecall(RequestInterpreter* request, ReplyBuilder* reply)
status_t status_t
NFS4Server::RecallAll() NFS4Server::RecallAll()
{ {
#if 0 MutexLocker _(fFSLock);
MutexLocker locker(fFSLock); FileSystem* fs = fFileSystems;
while (fs != NULL) {
DoublyLinkedList<Delegation>& list = fs->DelegationsLock();
DoublyLinkedList<Delegation>::Iterator iterator = list.GetIterator();
Delegation* delegation = NULL; Delegation* current = iterator.Next();
FileSystem* current = fFileSystems; while (current != NULL) {
while (current != NULL) { DelegationRecallArgs* args = new(std::nothrow) DelegationRecallArgs;
delegation = current->GetDelegation(handle); args->fDelegation = current;
if (delegation != NULL) args->fTruncate = false;
break; 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; return B_OK;
} }