SCCS-vsn: sys/nfs/nfs_socket.c 7.21
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)nfs_socket.c 7.20 (Berkeley) %G%
+ * @(#)nfs_socket.c 7.21 (Berkeley) %G%
#include "socket.h"
#include "socketvar.h"
#include "syslog.h"
#include "socket.h"
#include "socketvar.h"
#include "syslog.h"
#include "../netinet/in.h"
#include "../netinet/tcp.h"
#include "../netinet/in.h"
#include "../netinet/tcp.h"
register struct nfsreq *rp;
int error;
register struct nfsreq *rp;
int error;
- if (rep->r_procp)
- tprintf(rep->r_procp->p_session,
- "Nfs server %s, trying reconnect\n",
- nmp->nm_mountp->mnt_stat.f_mntfromname);
- else
- tprintf(NULL, "Nfs server %s, trying a reconnect\n",
- nmp->nm_mountp->mnt_stat.f_mntfromname);
+ nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname,
+ "trying reconnect");
while (error = nfs_connect(nmp)) {
#ifdef lint
error = error;
while (error = nfs_connect(nmp)) {
#ifdef lint
error = error;
return (EINTR);
(void) tsleep((caddr_t)&lbolt, PSOCK, "nfscon", 0);
}
return (EINTR);
(void) tsleep((caddr_t)&lbolt, PSOCK, "nfscon", 0);
}
- if (rep->r_procp)
- tprintf(rep->r_procp->p_session,
- "Nfs server %s, reconnected\n",
- nmp->nm_mountp->mnt_stat.f_mntfromname);
- else
- tprintf(NULL, "Nfs server %s, reconnected\n",
- nmp->nm_mountp->mnt_stat.f_mntfromname);
+ nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname,
+ "reconnected");
/*
* Loop through outstanding request list and fix up all requests
/*
* Loop through outstanding request list and fix up all requests
caddr_t fcp, tcp;
u_long len;
struct mbuf **getnam;
caddr_t fcp, tcp;
u_long len;
struct mbuf **getnam;
- int error, siz, mlen, soflags, rcvflg = MSG_WAITALL;
+ int error, siz, mlen, soflags, rcvflg;
/*
* Set up arguments for soreceive()
/*
* Set up arguments for soreceive()
auio.uio_offset = 0;
auio.uio_resid = sizeof(u_long);
do {
auio.uio_offset = 0;
auio.uio_resid = sizeof(u_long);
do {
- error = soreceive(so, (struct mbuf **)0, &auio,
+ rcvflg = MSG_WAITALL;
+ error = soreceive(so, (struct mbuf **)0, &auio,
(struct mbuf **)0, (struct mbuf **)0, &rcvflg);
(struct mbuf **)0, (struct mbuf **)0, &rcvflg);
- if (error == EWOULDBLOCK && rep) {
+ if (error == EWOULDBLOCK && rep) {
if (rep->r_flags & R_SOFTTERM)
return (EINTR);
if (rep->r_flags & R_MUSTRESEND)
goto tryagain;
if (rep->r_flags & R_SOFTTERM)
return (EINTR);
if (rep->r_flags & R_MUSTRESEND)
goto tryagain;
} while (error == EWOULDBLOCK);
} while (error == EWOULDBLOCK);
- if (!error && auio.uio_resid > 0)
- error = EPIPE;
+ if (!error && auio.uio_resid > 0) {
+ if (rep)
+ log(LOG_INFO,
+ "short receive (%d/%d) from nfs server %s\n",
+ sizeof(u_long) - auio.uio_resid,
+ sizeof(u_long),
+ rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
+ error = EPIPE;
+ }
if (error)
goto errout;
len = ntohl(len) & ~0x80000000;
if (error)
goto errout;
len = ntohl(len) & ~0x80000000;
* and forcing a disconnect/reconnect is all I can do.
*/
if (len > NFS_MAXPACKET) {
* and forcing a disconnect/reconnect is all I can do.
*/
if (len > NFS_MAXPACKET) {
- error = EFBIG;
- goto errout;
+ if (rep)
+ log(LOG_ERR, "%s (%d) from nfs server %s\n",
+ "impossible packet length",
+ len,
+ rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
+ error = EFBIG;
+ goto errout;
}
auio.uio_resid = len;
do {
}
auio.uio_resid = len;
do {
error = soreceive(so, (struct mbuf **)0,
&auio, mp, (struct mbuf **)0, &rcvflg);
} while (error == EWOULDBLOCK || error == EINTR ||
error == ERESTART);
error = soreceive(so, (struct mbuf **)0,
&auio, mp, (struct mbuf **)0, &rcvflg);
} while (error == EWOULDBLOCK || error == EINTR ||
error == ERESTART);
- if (!error && auio.uio_resid > 0)
- error = EPIPE;
+ if (!error && auio.uio_resid > 0) {
+ if (rep)
+ log(LOG_INFO,
+ "short receive (%d/%d) from nfs server %s\n",
+ len - auio.uio_resid, len,
+ rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
+ error = EPIPE;
+ }
} else {
auio.uio_resid = len = 1000000; /* Anything Big */
do {
} else {
auio.uio_resid = len = 1000000; /* Anything Big */
do {
error = soreceive(so, (struct mbuf **)0,
&auio, mp, (struct mbuf **)0, &rcvflg);
if (error == EWOULDBLOCK && rep) {
error = soreceive(so, (struct mbuf **)0,
&auio, mp, (struct mbuf **)0, &rcvflg);
if (error == EWOULDBLOCK && rep) {
if (error && rep && error != EINTR && error != ERESTART) {
m_freem(*mp);
*mp = (struct mbuf *)0;
if (error && rep && error != EINTR && error != ERESTART) {
m_freem(*mp);
*mp = (struct mbuf *)0;
+ if (error != EPIPE && rep)
+ log(LOG_INFO,
+ "receive error %d from nfs server %s\n",
+ error,
+ rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
nfs_disconnect(rep->r_nmp);
error = nfs_reconnect(rep, rep->r_nmp);
if (!error)
nfs_disconnect(rep->r_nmp);
error = nfs_reconnect(rep, rep->r_nmp);
if (!error)
getnam = aname;
auio.uio_resid = len = 1000000;
do {
getnam = aname;
auio.uio_resid = len = 1000000;
do {
error = soreceive(so, getnam, &auio, mp,
(struct mbuf **)0, &rcvflg);
if (error == EWOULDBLOCK && rep &&
error = soreceive(so, getnam, &auio, mp,
(struct mbuf **)0, &rcvflg);
if (error == EWOULDBLOCK && rep &&
* If there was a successful reply and a tprintf msg.
* tprintf a response.
*/
* If there was a successful reply and a tprintf msg.
* tprintf a response.
*/
- if (!error && (rep->r_flags & R_TPRINTFMSG)) {
- if (rep->r_procp)
- tprintf(rep->r_procp->p_session,
- "Nfs server %s, is alive again\n",
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- else
- tprintf(NULL, "Nfs server %s, is alive again\n",
- rep->r_nmp->nm_mountp->mnt_stat.f_mntfromname);
- }
+ if (!error && (rep->r_flags & R_TPRINTFMSG))
+ nfs_msg(rep->r_procp, nmp->nm_mountp->mnt_stat.f_mntfromname,
+ "is alive again");
m_freem(rep->r_mreq);
mrep = rep->r_mrep;
FREE((caddr_t)rep, M_NFSREQ);
m_freem(rep->r_mreq);
mrep = rep->r_mrep;
FREE((caddr_t)rep, M_NFSREQ);
*/
if ((rep->r_flags & R_TPRINTFMSG) == 0 &&
rep->r_rexmit > NFS_FISHY) {
*/
if ((rep->r_flags & R_TPRINTFMSG) == 0 &&
rep->r_rexmit > NFS_FISHY) {
- if (rep->r_procp && rep->r_procp->p_session)
- tprintf(rep->r_procp->p_session,
- "Nfs server %s, not responding\n",
- nmp->nm_mountp->mnt_stat.f_mntfromname);
- else
- tprintf(NULL,
- "Nfs server %s, not responding\n",
- nmp->nm_mountp->mnt_stat.f_mntfromname);
+ nfs_msg(rep->r_procp,
+ nmp->nm_mountp->mnt_stat.f_mntfromname,
+ "not responding");
rep->r_flags |= R_TPRINTFMSG;
}
if (rep->r_rexmit >= rep->r_retry) { /* too many */
rep->r_flags |= R_TPRINTFMSG;
}
if (rep->r_rexmit >= rep->r_retry) { /* too many */
+nfs_msg(p, server, msg)
+ struct proc *p;
+ char *server, *msg;
+{
+ tpr_t tpr;
+
+ if (p)
+ tpr = tprintf_open(p);
+ else
+ tpr = NULL;
+ tprintf(tpr, "nfs server %s: %s\n", server, msg);
+ tprintf_close(tpr);
+}
+
/*
* Lock a socket against others.
* Necessary for STREAM sockets to ensure you get an entire rpc request/reply
/*
* Lock a socket against others.
* Necessary for STREAM sockets to ensure you get an entire rpc request/reply