mirror of
https://review.haiku-os.org/haiku
synced 2025-02-01 03:06:08 +01:00
nfs4: fix incrementing owner sequence id in some cases
If in a compound request an error occurs before the operation that takes sequence id is executed (e.g. OPEN or LOCK) do not increment sequence id regardless of the error code.
This commit is contained in:
parent
fa1ca5e20c
commit
9ac4430cd6
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user