Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-2-0]: src/sys/nfs Pullup patch (requested by yamy in ticket #1078)
details: https://anonhg.NetBSD.org/src/rev/ba3dffe652e2
branches: netbsd-2-0
changeset: 564668:ba3dffe652e2
user: jmc <jmc%NetBSD.org@localhost>
date: Tue Jan 11 06:39:46 2005 +0000
description:
Pullup patch (requested by yamy in ticket #1078)
Don't do kludge for a reply to a retransmitted request
unless we actually retransmitted the request.
diffstat:
sys/nfs/nfs.h | 3 +-
sys/nfs/nfs_socket.c | 23 +++++++++++++++++---
sys/nfs/nfs_var.h | 4 +-
sys/nfs/nfs_vnops.c | 57 +++++++++++++++++++++++++++++----------------------
sys/nfs/nfsm_subs.h | 8 ++++--
5 files changed, 60 insertions(+), 35 deletions(-)
diffs (truncated from 346 to 300 lines):
diff -r c107511d9693 -r ba3dffe652e2 sys/nfs/nfs.h
--- a/sys/nfs/nfs.h Tue Jan 11 06:35:56 2005 +0000
+++ b/sys/nfs/nfs.h Tue Jan 11 06:39:46 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs.h,v 1.44 2003/12/06 02:48:35 jonathan Exp $ */
+/* $NetBSD: nfs.h,v 1.44.2.1 2005/01/11 06:39:46 jmc Exp $ */
/*
* Copyright (c) 1989, 1993, 1995
* The Regents of the University of California. All rights reserved.
@@ -340,6 +340,7 @@
#define R_TPRINTFMSG 0x20 /* Did a tprintf msg. */
#define R_MUSTRESEND 0x40 /* Must resend request */
#define R_GETONEREP 0x80 /* Probe for one reply only */
+#define R_REXMITTED 0x100 /* retransmitted after reconnect */
/*
* A list of nfssvc_sock structures is maintained with all the sockets
diff -r c107511d9693 -r ba3dffe652e2 sys/nfs/nfs_socket.c
--- a/sys/nfs/nfs_socket.c Tue Jan 11 06:35:56 2005 +0000
+++ b/sys/nfs/nfs_socket.c Tue Jan 11 06:39:46 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_socket.c,v 1.102.2.3 2004/08/30 10:11:47 tron Exp $ */
+/* $NetBSD: nfs_socket.c,v 1.102.2.4 2005/01/11 06:39:49 jmc Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.102.2.3 2004/08/30 10:11:47 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.102.2.4 2005/01/11 06:39:49 jmc Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@@ -356,7 +356,8 @@
*/
TAILQ_FOREACH(rp, &nfs_reqq, r_chain) {
if (rp->r_nmp == nmp) {
- rp->r_flags |= R_MUSTRESEND;
+ if ((rp->r_flags & R_MUSTRESEND) == 0)
+ rp->r_flags |= R_MUSTRESEND | R_REXMITTED;
rp->r_rexmit = 0;
}
}
@@ -927,7 +928,7 @@
* nb: always frees up mreq mbuf list
*/
int
-nfs_request(np, mrest, procnum, procp, cred, mrp, mdp, dposp)
+nfs_request(np, mrest, procnum, procp, cred, mrp, mdp, dposp, rexmitp)
struct nfsnode *np;
struct mbuf *mrest;
int procnum;
@@ -936,6 +937,7 @@
struct mbuf **mrp;
struct mbuf **mdp;
caddr_t *dposp;
+ int *rexmitp;
{
struct mbuf *m, *mrep;
struct nfsreq *rep;
@@ -962,6 +964,9 @@
boolean_t retry_cred = TRUE;
boolean_t use_opencred = (np->n_flag & NUSEOPENCRED) != 0;
+ if (rexmitp != NULL)
+ *rexmitp = 0;
+
tryagain_cred:
KASSERT(cred != NULL);
MALLOC(rep, struct nfsreq *, sizeof(struct nfsreq), M_NFSREQ, M_WAITOK);
@@ -1136,6 +1141,16 @@
nmp->nm_sent -= NFS_CWNDSCALE;
}
+ if (rexmitp != NULL) {
+ int rexmit;
+
+ if (nmp->nm_sotype != SOCK_DGRAM)
+ rexmit = (rep->r_flags & R_REXMITTED) != 0;
+ else
+ rexmit = rep->r_rexmit;
+ *rexmitp = rexmit;
+ }
+
/*
* If there was a successful reply and a tprintf msg.
* tprintf a response.
diff -r c107511d9693 -r ba3dffe652e2 sys/nfs/nfs_var.h
--- a/sys/nfs/nfs_var.h Tue Jan 11 06:35:56 2005 +0000
+++ b/sys/nfs/nfs_var.h Tue Jan 11 06:39:46 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_var.h,v 1.42.2.2 2004/09/18 19:22:19 he Exp $ */
+/* $NetBSD: nfs_var.h,v 1.42.2.3 2005/01/11 06:39:55 jmc Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -220,7 +220,7 @@
int nfs_reply __P((struct nfsreq *));
int nfs_request __P((struct nfsnode *, struct mbuf *, int, struct proc *,
struct ucred *, struct mbuf **, struct mbuf **,
- caddr_t *));
+ caddr_t *, int *));
int nfs_rephead __P((int, struct nfsrv_descript *, struct nfssvc_sock *,
int, int, u_quad_t *, struct mbuf **, struct mbuf **, caddr_t *));
void nfs_timer __P((void *));
diff -r c107511d9693 -r ba3dffe652e2 sys/nfs/nfs_vnops.c
--- a/sys/nfs/nfs_vnops.c Tue Jan 11 06:35:56 2005 +0000
+++ b/sys/nfs/nfs_vnops.c Tue Jan 11 06:39:46 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nfs_vnops.c,v 1.186.2.7 2005/01/11 06:35:46 jmc Exp $ */
+/* $NetBSD: nfs_vnops.c,v 1.186.2.8 2005/01/11 06:40:01 jmc Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.186.2.7 2005/01/11 06:35:46 jmc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.186.2.8 2005/01/11 06:40:01 jmc Exp $");
#include "opt_nfs.h"
#include "opt_uvmhist.h"
@@ -1793,14 +1793,6 @@
if (error != EINTR)
error = nfs_removerpc(dvp, cnp->cn_nameptr,
cnp->cn_namelen, cnp->cn_cred, cnp->cn_proc);
- /*
- * Kludge City: If the first reply to the remove rpc is lost..
- * the reply to the retransmitted request will be ENOENT
- * since the file was in fact removed
- * Therefore, we cheat and return success.
- */
- if (error == ENOENT)
- error = 0;
} else if (!np->n_sillyrename)
error = nfs_sillyrename(dvp, vp, cnp);
PNBUF_PUT(cnp->cn_pnbuf);
@@ -1849,6 +1841,7 @@
int error = 0, wccflag = NFSV3_WCCRATTR;
struct mbuf *mreq, *mrep, *md, *mb;
const int v3 = NFS_ISV3(dvp);
+ int rexmit;
struct nfsnode *dnp = VTONFS(dvp);
nfsstats.rpccnt[NFSPROC_REMOVE]++;
@@ -1856,13 +1849,21 @@
NFSX_FH(v3) + NFSX_UNSIGNED + nfsm_rndup(namelen));
nfsm_fhtom(dnp, v3);
nfsm_strtom(name, namelen, NFS_MAXNAMLEN);
- nfsm_request(dnp, NFSPROC_REMOVE, proc, cred);
+ nfsm_request1(dnp, NFSPROC_REMOVE, proc, cred, &rexmit);
if (v3)
nfsm_wcc_data(dvp, wccflag, 0);
nfsm_reqdone;
VTONFS(dvp)->n_flag |= NMODIFIED;
if (!wccflag)
NFS_INVALIDATE_ATTRCACHE(VTONFS(dvp));
+ /*
+ * Kludge City: If the first reply to the remove rpc is lost..
+ * the reply to the retransmitted request will be ENOENT
+ * since the file was in fact removed
+ * Therefore, we cheat and return success.
+ */
+ if (rexmit && error == ENOENT)
+ error = 0;
return (error);
}
@@ -1932,11 +1933,6 @@
vput(tvp);
vrele(fdvp);
vrele(fvp);
- /*
- * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry.
- */
- if (error == ENOENT)
- error = 0;
return (error);
}
@@ -1974,6 +1970,7 @@
int error = 0, fwccflag = NFSV3_WCCRATTR, twccflag = NFSV3_WCCRATTR;
struct mbuf *mreq, *mrep, *md, *mb;
const int v3 = NFS_ISV3(fdvp);
+ int rexmit;
struct nfsnode *fdnp = VTONFS(fdvp);
nfsstats.rpccnt[NFSPROC_RENAME]++;
@@ -1984,7 +1981,7 @@
nfsm_strtom(fnameptr, fnamelen, NFS_MAXNAMLEN);
nfsm_fhtom(VTONFS(tdvp), v3);
nfsm_strtom(tnameptr, tnamelen, NFS_MAXNAMLEN);
- nfsm_request(fdnp, NFSPROC_RENAME, proc, cred);
+ nfsm_request1(fdnp, NFSPROC_RENAME, proc, cred, &rexmit);
if (v3) {
nfsm_wcc_data(fdvp, fwccflag, 0);
nfsm_wcc_data(tdvp, twccflag, 0);
@@ -1996,6 +1993,11 @@
NFS_INVALIDATE_ATTRCACHE(VTONFS(fdvp));
if (!twccflag)
NFS_INVALIDATE_ATTRCACHE(VTONFS(tdvp));
+ /*
+ * Kludge: Map ENOENT => 0 assuming that it is a reply to a retry.
+ */
+ if (rexmit && error == ENOENT)
+ error = 0;
return (error);
}
@@ -2022,6 +2024,7 @@
struct mbuf *mreq, *mrep, *md, *mb;
/* XXX Should be const and initialised? */
int v3;
+ int rexmit;
struct nfsnode *np;
if (dvp->v_mount != vp->v_mount) {
@@ -2053,7 +2056,7 @@
nfsm_fhtom(np, v3);
nfsm_fhtom(VTONFS(dvp), v3);
nfsm_strtom(cnp->cn_nameptr, cnp->cn_namelen, NFS_MAXNAMLEN);
- nfsm_request(np, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred);
+ nfsm_request1(np, NFSPROC_LINK, cnp->cn_proc, cnp->cn_cred, &rexmit);
if (v3) {
nfsm_postop_attr(vp, attrflag, 0);
nfsm_wcc_data(dvp, wccflag, 0);
@@ -2073,7 +2076,7 @@
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
- if (error == EEXIST)
+ if (rexmit && error == EEXIST)
error = 0;
return (error);
}
@@ -2104,6 +2107,7 @@
struct mbuf *mreq, *mrep, *md, *mb;
struct vnode *newvp = (struct vnode *)0;
const int v3 = NFS_ISV3(dvp);
+ int rexmit;
struct nfsnode *dnp = VTONFS(dvp);
*ap->a_vpp = NULL;
@@ -2125,7 +2129,8 @@
txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
}
- nfsm_request(dnp, NFSPROC_SYMLINK, cnp->cn_proc, cnp->cn_cred);
+ nfsm_request1(dnp, NFSPROC_SYMLINK, cnp->cn_proc, cnp->cn_cred,
+ &rexmit);
if (v3) {
if (!error)
nfsm_mtofh(dvp, newvp, v3, gotvp);
@@ -2135,7 +2140,7 @@
/*
* Kludge: Map EEXIST => 0 assuming that it is a reply to a retry.
*/
- if (error == EEXIST)
+ if (rexmit && error == EEXIST)
error = 0;
if (error == 0 && newvp == NULL) {
struct nfsnode *np = NULL;
@@ -2186,6 +2191,7 @@
caddr_t bpos, dpos, cp2;
int error = 0, wccflag = NFSV3_WCCRATTR;
int gotvp = 0;
+ int rexmit;
struct mbuf *mreq, *mrep, *md, *mb;
const int v3 = NFS_ISV3(dvp);
@@ -2206,7 +2212,7 @@
txdr_nfsv2time(&vap->va_atime, &sp->sa_atime);
txdr_nfsv2time(&vap->va_mtime, &sp->sa_mtime);
}
- nfsm_request(dnp, NFSPROC_MKDIR, cnp->cn_proc, cnp->cn_cred);
+ nfsm_request1(dnp, NFSPROC_MKDIR, cnp->cn_proc, cnp->cn_cred, &rexmit);
if (!error)
nfsm_mtofh(dvp, newvp, v3, gotvp);
if (v3)
@@ -2219,7 +2225,7 @@
* 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 ((rexmit && error == EEXIST) || (!error && !gotvp)) {
if (newvp) {
vput(newvp);
newvp = (struct vnode *)0;
@@ -2266,6 +2272,7 @@
int32_t t1, t2;
caddr_t bpos, dpos, cp2;
int error = 0, wccflag = NFSV3_WCCRATTR;
+ int rexmit;
struct mbuf *mreq, *mrep, *md, *mb;
const int v3 = NFS_ISV3(dvp);
struct nfsnode *dnp;
@@ -2282,7 +2289,7 @@
Home |
Main Index |
Thread Index |
Old Index