Re: NFS over IPv6

From: Alfred Perlstein <alfred_at_freebsd.org>
Date: Sun, 11 Jul 2004 22:57:58 -0700
* Jun Kuriyama <kuriyama_at_imgsrc.co.jp> [040711 22:10] wrote:
> At Sun, 11 Jul 2004 21:16:24 -0700,
> Alfred Perlstein wrote:
> > Can you try this patch also:
> 
> Okay, with your patch, my NFS access (over IPv6) seems good as usual.
> 
> Thanks!
> 
> # I felt sometimes slowdown of directory listing, but I'm not sure
> # this is caused by my -current client or by load of server side..

Maybe IPv6 is timing out too much.  Can you test another patch
that I'll send you now and then tell me the output from the
sysctl:

vfs.nfs.reconnects

please.


Index: kern/uipc_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.201
diff -u -r1.201 uipc_socket.c
--- kern/uipc_socket.c	11 Jul 2004 23:13:14 -0000	1.201
+++ kern/uipc_socket.c	12 Jul 2004 04:06:19 -0000
_at__at_ -1541,6 +1541,25 _at__at_
 	return 0;
 }
 
+/*
+ * Kernel version of setsockopt(2)/
+ * XXX: optlen is size_t, not socklen_t
+ */
+int
+kern_setsockopt(struct socket *so, int level, int optname, void *optval,
+    size_t optlen)
+{
+	struct sockopt sopt;
+
+	sopt.sopt_level = level;
+	sopt.sopt_name = optname;
+	sopt.sopt_dir = SOPT_SET;
+	sopt.sopt_val = optval;
+	sopt.sopt_valsize = optlen;
+	sopt.sopt_td = NULL;
+	return (sosetopt(so, &sopt));
+}
+
 int
 sosetopt(so, sopt)
 	struct socket *so;
Index: nfsclient/nfs_socket.c
===================================================================
RCS file: /home/ncvs/src/sys/nfsclient/nfs_socket.c,v
retrieving revision 1.111
diff -u -r1.111 nfs_socket.c
--- nfsclient/nfs_socket.c	6 Jul 2004 16:55:41 -0000	1.111
+++ nfsclient/nfs_socket.c	12 Jul 2004 05:56:14 -0000
_at__at_ -111,12 +111,15 _at__at_
 static int	nfs_realign_test;
 static int	nfs_realign_count;
 static int	nfs_bufpackets = 4;
+static int	nfs_reconnects;
 
 SYSCTL_DECL(_vfs_nfs);
 
 SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, &nfs_realign_test, 0, "");
 SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_count, CTLFLAG_RW, &nfs_realign_count, 0, "");
 SYSCTL_INT(_vfs_nfs, OID_AUTO, bufpackets, CTLFLAG_RW, &nfs_bufpackets, 0, "");
+SYSCTL_INT(_vfs_nfs, OID_AUTO, reconnects, CTLFLAG_RD, &nfs_reconnects, 0,
+    "number of times the nfs client has had to reconnect");
 
 
 /*
_at__at_ -157,7 +160,7 _at__at_
 {
 	struct socket *so;
 	int error, rcvreserve, sndreserve;
-	int pktscale;
+	int opt, pktscale;
 	struct sockaddr *saddr;
 	struct thread *td = &thread0; /* only used for socreate and sobind */
 
_at__at_ -172,6 +175,10 _at__at_
 	so = nmp->nm_so;
 	nmp->nm_soflags = so->so_proto->pr_flags;
 
+	opt = 1;
+	(void)kern_setsockopt(so, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+	(void)kern_setsockopt(so, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt));
+
 	/*
 	 * Some servers require that the client port be a reserved port number.
 	 */
_at__at_ -261,7 +268,7 _at__at_
 		}
 		SOCK_UNLOCK(so);
 	}
-	so->so_rcv.sb_timeo = 5 * hz;
+	so->so_rcv.sb_timeo = 12 * hz;
 	so->so_snd.sb_timeo = 5 * hz;
 
 	/*
_at__at_ -357,6 +364,7 _at__at_
 	struct nfsmount *nmp = rep->r_nmp;
 	int error;
 
+	nfs_reconnects++;
 	nfs_disconnect(nmp);
 	while ((error = nfs_connect(nmp, rep)) != 0) {
 		if (error == ERESTART)
Index: nfsserver/nfs_srvsock.c
===================================================================
RCS file: /home/ncvs/src/sys/nfsserver/nfs_srvsock.c,v
retrieving revision 1.90
diff -u -r1.90 nfs_srvsock.c
--- nfsserver/nfs_srvsock.c	24 May 2004 04:06:14 -0000	1.90
+++ nfsserver/nfs_srvsock.c	11 Jul 2004 18:05:30 -0000
_at__at_ -433,16 +433,18 _at__at_
 	/* XXXRW: Unlocked read. */
 	if ((slp->ns_flag & SLP_VALID) == 0)
 		return;
-#ifdef notdef
+
 	/*
-	 * Define this to test for nfsds handling this under heavy load.
+	 * We can't do this in the context of a socket callback
+	 * because we're called with locks held.
+	 * XXX: SMP
 	 */
 	if (waitflag == M_DONTWAIT) {
 		NFSD_LOCK();
 		slp->ns_flag |= SLP_NEEDQ;
 		goto dorecs;
 	}
-#endif
+
 
 	NFSD_LOCK();
 	auio.uio_td = NULL;
Index: sys/socketvar.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/socketvar.h,v
retrieving revision 1.131
diff -u -r1.131 socketvar.h
--- sys/socketvar.h	27 Jun 2004 03:23:09 -0000	1.131
+++ sys/socketvar.h	12 Jul 2004 04:05:34 -0000
_at__at_ -438,6 +438,8 _at__at_
 /*
  * From uipc_socket and friends
  */
+int	kern_setsockopt(struct socket *so, int level, int optname,
+    void *optval, size_t optlen);
 int	sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
 int	getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
 void	sbappend(struct sockbuf *sb, struct mbuf *m);
Received on Mon Jul 12 2004 - 03:57:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:01 UTC