--- sys/nfsclient/nfs_socket.c- Thu Apr 21 16:43:34 2005 +++ sys/nfsclient/nfs_socket.c Tue May 10 10:25:14 2005 @@ -33,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/nfsclient/nfs_socket.c,v 1.123 2005/04/18 13:42:13 rees Exp $"); +__FBSDID("$FreeBSD: src/sys/nfsclient/nfs_socket.c,v 1.125 2005/05/10 14:25:14 rees Exp $"); /* * Socket operations for use by nfs @@ -521,8 +521,6 @@ return (error); } -int nfs_mrep_before_tsleep = 0; - int nfs_reply(struct nfsreq *rep) { @@ -582,7 +580,8 @@ if (rep->r_nmp->nm_flag & NFSMNT_INT) slpflag = PCATCH; mtx_lock(&nfs_reply_mtx); - while ((rep->r_mrep == NULL) && (error == 0)) + while ((rep->r_mrep == NULL) && (error == 0) && + ((sotype == SOCK_DGRAM) || ((rep->r_flags & R_MUSTRESEND) == 0))) error = msleep((caddr_t)rep, &nfs_reply_mtx, slpflag | (PZERO - 1), "nfsreq", 0); mtx_unlock(&nfs_reply_mtx); @@ -739,8 +738,10 @@ */ mtx_lock(&nfs_reqq_mtx); TAILQ_FOREACH(rp, &nfs_reqq, r_chain) { - if (rp->r_nmp == nmp) + if (rp->r_nmp == nmp) { + rp->r_flags |= R_MUSTRESEND; wakeup_nfsreq(rp); + } } mtx_unlock(&nfs_reqq_mtx); } @@ -804,10 +805,7 @@ * connection. */ if (error || auio.uio_resid > 0) { - if (auio.uio_resid > 0) { - log(LOG_INFO, - "nfs/tcp clnt: Peer closed connection, tearing down TCP connection\n"); - } else { + if (error != ECONNRESET) { log(LOG_ERR, "nfs/tcp clnt: Error %d reading socket, tearing down TCP connection\n", error); @@ -850,10 +848,7 @@ (so, (struct sockaddr **)0, &auio, &mp, (struct mbuf **)0, &rcvflg); if (error || auio.uio_resid > 0) { - if (auio.uio_resid > 0) { - log(LOG_INFO, - "nfs/tcp clnt: Peer closed connection, tearing down TCP connection\n"); - } else { + if (error != ECONNRESET) { log(LOG_ERR, "nfs/tcp clnt: Error %d reading socket, tearing down TCP connection\n", error); @@ -1226,11 +1221,18 @@ if (nmp->nm_sotype != SOCK_DGRAM) { if (++rep->r_rexmit > NFS_MAXREXMIT) rep->r_rexmit = NFS_MAXREXMIT; + /* + * For NFS/TCP, setting R_MUSTRESEND and waking up + * the requester will cause the request to be + * retransmitted (in nfs_reply()), re-connecting + * if necessary. + */ + rep->r_flags |= R_MUSTRESEND; + wakeup_nfsreq(rep); continue; } if ((so = nmp->nm_so) == NULL) continue; - /* * If there is enough space and the window allows.. * Resend it