Remove hacks from the NFSv2/3 client intended to handle a lack of a
server-side RPC retranmission cache for non-idempotent operations: these hacks substituted 0 (success) for the expected EEXIST in the event that a target name already existed for LINK, SYMLINK, and MKDIR operations, under the assumption that EEXIST represented a second application of the original RPC rather than a true failure. Background: certain NFS operations (in this case, LINK, SYMLINK, and MKDIR) are not idempotent, as they leave behind persisting state on the server that prevents them from being replayed without an error;if an UDP RPC reply is lost leading to a retransmission by theclient, the second reply will return EEXIST rather than success, asthe new object has already been created. The NFS client previouslysilently mapped the EEXIST return into success to paper over thisproblem. However, in all modern NFS server implementations, a reply cache is kept in order to retransmit the original reply to a retransmitted request, rather than performing the operation a second time, allowing this hack to be avoided. This allows link()-based filelocking over NFS to operate correctly, as an application requestingthe creation of a new link for a file to tell if it succeededatomically or not. Other NFS clients, including Solaris and Linux, generally follow this behavior for the same reasons. Most clients also now default to TCP, which also helps avoid the issue of retransmitted but non-idempotent requests in most cases. Reported by: Adam McDougall <mcdouga9 at egr dot msu dot edu>, Timo Sirainen <tss at iki dot fi> Reviewed by: mohans MFC after: 1 week
This commit is contained in:
parent
fff090c011
commit
742eb19799
@ -1769,11 +1769,6 @@ nfs_link(struct vop_link_args *ap)
|
||||
VTONFS(vp)->n_attrstamp = 0;
|
||||
if (!wccflag)
|
||||
VTONFS(tdvp)->n_attrstamp = 0;
|
||||
/*
|
||||
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
|
||||
*/
|
||||
if (error == EEXIST)
|
||||
error = 0;
|
||||
return (error);
|
||||
}
|
||||
|
||||
@ -1837,17 +1832,9 @@ nfs_symlink(struct vop_symlink_args *ap)
|
||||
nfsmout:
|
||||
|
||||
/*
|
||||
* If we get an EEXIST error, silently convert it to no-error
|
||||
* in case of an NFS retry.
|
||||
*/
|
||||
if (error == EEXIST)
|
||||
error = 0;
|
||||
|
||||
/*
|
||||
* If we do not have (or no longer have) an error, and we could
|
||||
* not extract the newvp from the response due to the request being
|
||||
* NFSv2 or the error being EEXIST. We have to do a lookup in order
|
||||
* to obtain a newvp to return.
|
||||
* If we do not have an error and we could not extract the newvp from
|
||||
* the response due to the request being NFSv2, we have to do a
|
||||
* lookup in order to obtain a newvp to return.
|
||||
*/
|
||||
if (error == 0 && newvp == NULL) {
|
||||
struct nfsnode *np = NULL;
|
||||
@ -1925,15 +1912,7 @@ nfs_mkdir(struct vop_mkdir_args *ap)
|
||||
mtx_unlock(&(VTONFS(dvp))->n_mtx);
|
||||
if (!wccflag)
|
||||
VTONFS(dvp)->n_attrstamp = 0;
|
||||
/*
|
||||
* Kludge: Map EEXIST => 0 assuming that you have a reply to a retry
|
||||
* if we can succeed in looking up the directory.
|
||||
*/
|
||||
if (error == EEXIST || (!error && !gotvp)) {
|
||||
if (newvp) {
|
||||
vput(newvp);
|
||||
newvp = NULL;
|
||||
}
|
||||
if (error == 0 && newvp == NULL) {
|
||||
error = nfs_lookitup(dvp, cnp->cn_nameptr, len, cnp->cn_cred,
|
||||
cnp->cn_thread, &np);
|
||||
if (!error) {
|
||||
|
Loading…
Reference in New Issue
Block a user