diff --git a/src/add-ons/kernel/file_systems/nfs4/NFS4Inode.cpp b/src/add-ons/kernel/file_systems/nfs4/NFS4Inode.cpp index d723502e68..af9b47d07d 100644 --- a/src/add-ons/kernel/file_systems/nfs4/NFS4Inode.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/NFS4Inode.cpp @@ -497,15 +497,15 @@ NFS4Inode::CreateFile(const char* name, int mode, int perms, OpenState* state, ReplyInterpreter& reply = request.Reply(); - sequence += IncrementSequence(reply.NFS4Error()); + result = reply.PutFH(); + if (result == B_OK) + sequence += IncrementSequence(reply.NFS4Error()); if (HandleErrors(attempt, reply.NFS4Error(), serv, NULL, state, &sequence)) { continue; } - reply.PutFH(); - result = reply.Open(state->fStateID, &state->fStateSeq, &confirm, delegation, changeInfo); if (result != B_OK) { @@ -596,13 +596,6 @@ NFS4Inode::OpenFile(OpenState* state, int mode, OpenDelegationData* delegation) ReplyInterpreter& reply = request.Reply(); - sequence += IncrementSequence(reply.NFS4Error()); - - if (HandleErrors(attempt, reply.NFS4Error(), serv, NULL, state, - &sequence)) { - continue; - } - // Verify if the file we want to open is the file this Inode // represents. if (fFileSystem->IsAttrSupported(FATTR4_FILEID) @@ -615,16 +608,21 @@ NFS4Inode::OpenFile(OpenState* state, int mode, OpenDelegationData* delegation) } result = reply.Verify(); - if (result != B_OK) + if (result != B_OK && reply.NFS4Error() == NFS4ERR_NOT_SAME) { fFileSystem->OpenOwnerSequenceUnlock(sequence); - - if (result != B_OK && reply.NFS4Error() == NFS4ERR_NOT_SAME) return B_ENTRY_NOT_FOUND; - else if (result != B_OK) - return result; + } + } + + result = reply.PutFH(); + if (result == B_OK) + sequence += IncrementSequence(reply.NFS4Error()); + + if (HandleErrors(attempt, reply.NFS4Error(), serv, NULL, state, + &sequence)) { + continue; } - reply.PutFH(); result = reply.Open(state->fStateID, &state->fStateSeq, &confirm, delegation); if (result != B_OK) { @@ -686,14 +684,15 @@ NFS4Inode::OpenAttr(OpenState* state, const char* name, int mode, ReplyInterpreter& reply = request.Reply(); - sequence += IncrementSequence(reply.NFS4Error()); + result = reply.PutFH(); + if (result == B_OK) + sequence += IncrementSequence(reply.NFS4Error()); if (HandleErrors(attempt, reply.NFS4Error(), serv, NULL, state, &sequence)) { continue; } - reply.PutFH(); result = reply.Open(state->fStateID, &state->fStateSeq, &confirm, delegation); @@ -1135,9 +1134,10 @@ NFS4Inode::AcquireLock(OpenFileCookie* cookie, LockInfo* lockInfo, bool wait) ReplyInterpreter& reply = request.Reply(); - sequence += IncrementSequence(reply.NFS4Error()); + result = reply.PutFH(); + if (result == B_OK) + sequence += IncrementSequence(reply.NFS4Error()); - reply.PutFH(); result = reply.Lock(lockInfo); ownerLocker.Unlock(); diff --git a/src/add-ons/kernel/file_systems/nfs4/NFS4Object.cpp b/src/add-ons/kernel/file_systems/nfs4/NFS4Object.cpp index 5211a4d183..e98abe4182 100644 --- a/src/add-ons/kernel/file_systems/nfs4/NFS4Object.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/NFS4Object.cpp @@ -209,12 +209,13 @@ NFS4Object::ConfirmOpen(const FileHandle& fh, OpenState* state, ReplyInterpreter& reply = request.Reply(); - *sequence += IncrementSequence(reply.NFS4Error()); + result = reply.PutFH(); + if (result == B_OK) + *sequence += IncrementSequence(reply.NFS4Error()); if (HandleErrors(attempt, reply.NFS4Error(), serv, NULL, state)) continue; - reply.PutFH(); result = reply.OpenConfirm(&state->fStateSeq); if (result != B_OK) return result; diff --git a/src/add-ons/kernel/file_systems/nfs4/OpenState.cpp b/src/add-ons/kernel/file_systems/nfs4/OpenState.cpp index e5935def23..73df95155a 100644 --- a/src/add-ons/kernel/file_systems/nfs4/OpenState.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/OpenState.cpp @@ -186,7 +186,9 @@ OpenState::_ReclaimOpen(uint64 newClientID) ReplyInterpreter& reply = request.Reply(); - sequence += IncrementSequence(reply.NFS4Error()); + result = reply.PutFH(); + if (result == B_OK) + sequence += IncrementSequence(reply.NFS4Error()); if (reply.NFS4Error() != NFS4ERR_STALE_CLIENTID && HandleErrors(attempt, reply.NFS4Error(), server, NULL, NULL, @@ -194,8 +196,6 @@ OpenState::_ReclaimOpen(uint64 newClientID) continue; } - reply.PutFH(); - result = reply.Open(fStateID, &fStateSeq, &confirm, &delegation); if (result != B_OK) { fFileSystem->OpenOwnerSequenceUnlock(sequence); @@ -254,7 +254,9 @@ OpenState::_ReclaimLocks(uint64 newClientID) ReplyInterpreter& reply = request.Reply(); - sequence += IncrementSequence(reply.NFS4Error()); + result = reply.PutFH(); + if (result == B_OK) + sequence += IncrementSequence(reply.NFS4Error()); if (reply.NFS4Error() != NFS4ERR_STALE_CLIENTID && reply.NFS4Error() != NFS4ERR_STALE_STATEID @@ -263,7 +265,6 @@ OpenState::_ReclaimLocks(uint64 newClientID) continue; } - reply.PutFH(); reply.Lock(linfo); fFileSystem->OpenOwnerSequenceUnlock(sequence); @@ -305,7 +306,9 @@ OpenState::Close() ReplyInterpreter& reply = request.Reply(); - sequence += IncrementSequence(reply.NFS4Error()); + result = reply.PutFH(); + if (result == B_OK) + sequence += IncrementSequence(reply.NFS4Error()); // RFC 3530 8.10.1. Some servers does not do anything to help client // recognize retried CLOSE requests so we just assume that BAD_STATEID @@ -321,8 +324,6 @@ OpenState::Close() } fFileSystem->OpenOwnerSequenceUnlock(sequence); - reply.PutFH(); - return reply.Close(); } while (true); }