CVS commit: src/sys/nfs

2024-02-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Feb 13 21:40:02 UTC 2024

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
s/Enque/Enqueue/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/nfs/nfs_bio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_bio.c
diff -u src/sys/nfs/nfs_bio.c:1.201 src/sys/nfs/nfs_bio.c:1.202
--- src/sys/nfs/nfs_bio.c:1.201	Fri Jun 24 16:50:00 2022
+++ src/sys/nfs/nfs_bio.c	Tue Feb 13 21:40:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.202 2024/02/13 21:40:02 andvar Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.202 2024/02/13 21:40:02 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -799,7 +799,7 @@ again:
 		 * Ensure that the queue never grows too large.
 		 */
 		if (curlwp == uvm.pagedaemon_lwp) {
-	  		/* Enque for later, to avoid free-page deadlock */
+	  		/* Enqueue for later, to avoid free-page deadlock */
 		} else while (nmp->nm_bufqlen >= 2 * nmp->nm_bufqiods) {
 			if (catch_p) {
 error = cv_timedwait_sig(>nm_aiocv,



CVS commit: src/sys/nfs

2024-02-13 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue Feb 13 21:40:02 UTC 2024

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
s/Enque/Enqueue/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/sys/nfs/nfs_bio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-12-10 Thread Amitai Schleier
Module Name:src
Committed By:   schmonz
Date:   Sun Dec 10 18:16:08 UTC 2023

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
NFS client: fix interop with macOS 14 servers.

Symptom: a bunch of "Cannot open `.' (Invalid argument)".

thorpej@ analysis and fix: on the first request to read a given
directory, make sure READDIR and READDIRPLUS cookie verifiers are
being set to 0. This is in RFC1813 and macOS must have gotten
stricter about it.

Verified on 10.0_RC1/aarch64 to fix the reproducers in PR kern/57691 as
well as the original use case in which I met the bug: pkg_rr once again
runs to completion.


To generate a diff of this commit:
cvs rdiff -u -r1.324 -r1.325 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.324 src/sys/nfs/nfs_vnops.c:1.325
--- src/sys/nfs/nfs_vnops.c:1.324	Tue May 24 06:28:02 2022
+++ src/sys/nfs/nfs_vnops.c	Sun Dec 10 18:16:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.324 2022/05/24 06:28:02 andvar Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.325 2023/12/10 18:16:08 schmonz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.324 2022/05/24 06:28:02 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.325 2023/12/10 18:16:08 schmonz Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -2422,8 +2422,13 @@ nfs_readdirrpc(struct vnode *vp, struct 
 txdr_cookie3(uiop->uio_offset, tl);
 			}
 			tl += 2;
-			*tl++ = dnp->n_cookieverf.nfsuquad[0];
-			*tl++ = dnp->n_cookieverf.nfsuquad[1];
+			if (uiop->uio_offset == 0) {
+*tl++ = 0;
+*tl++ = 0;
+			} else {
+*tl++ = dnp->n_cookieverf.nfsuquad[0];
+*tl++ = dnp->n_cookieverf.nfsuquad[1];
+			}
 		} else
 #endif
 		{
@@ -2632,8 +2637,13 @@ nfs_readdirplusrpc(struct vnode *vp, str
 			txdr_cookie3(uiop->uio_offset, tl);
 		}
 		tl += 2;
-		*tl++ = dnp->n_cookieverf.nfsuquad[0];
-		*tl++ = dnp->n_cookieverf.nfsuquad[1];
+		if (uiop->uio_offset == 0) {
+			*tl++ = 0;
+			*tl++ = 0;
+		} else {
+			*tl++ = dnp->n_cookieverf.nfsuquad[0];
+			*tl++ = dnp->n_cookieverf.nfsuquad[1];
+		}
 		*tl++ = txdr_unsigned(nmp->nm_readdirsize);
 		*tl = txdr_unsigned(nmp->nm_rsize);
 		nfsm_request(dnp, NFSPROC_READDIRPLUS, curlwp, cred);



CVS commit: src/sys/nfs

2023-12-10 Thread Amitai Schleier
Module Name:src
Committed By:   schmonz
Date:   Sun Dec 10 18:16:08 UTC 2023

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
NFS client: fix interop with macOS 14 servers.

Symptom: a bunch of "Cannot open `.' (Invalid argument)".

thorpej@ analysis and fix: on the first request to read a given
directory, make sure READDIR and READDIRPLUS cookie verifiers are
being set to 0. This is in RFC1813 and macOS must have gotten
stricter about it.

Verified on 10.0_RC1/aarch64 to fix the reproducers in PR kern/57691 as
well as the original use case in which I met the bug: pkg_rr once again
runs to completion.


To generate a diff of this commit:
cvs rdiff -u -r1.324 -r1.325 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:33:58 UTC 2023

Modified Files:
src/sys/nfs: nfs_socket.c

Log Message:
nfs: Simplify assertion.  No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_socket.c
diff -u src/sys/nfs/nfs_socket.c:1.200 src/sys/nfs/nfs_socket.c:1.201
--- src/sys/nfs/nfs_socket.c:1.200	Mon Sep  3 16:29:36 2018
+++ src/sys/nfs/nfs_socket.c	Sun Apr  9 12:33:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.200 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.201 2023/04/09 12:33:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.200 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.201 2023/04/09 12:33:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -1229,8 +1229,8 @@ nfs_getreq(struct nfsrv_descript *nd, st
 
 	nd->nd_md = md;
 	nd->nd_dpos = dpos;
-	KASSERT((nd->nd_cr == NULL && (nfsd->nfsd_flag & NFSD_NEEDAUTH) != 0)
-	 || (nd->nd_cr != NULL && (nfsd->nfsd_flag & NFSD_NEEDAUTH) == 0));
+	KASSERT((nd->nd_cr == NULL) ==
+	((nfsd->nfsd_flag & NFSD_NEEDAUTH) != 0));
 	return (0);
 nfsmout:
 errout:



CVS commit: src/sys/nfs

2023-04-09 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr  9 12:33:58 UTC 2023

Modified Files:
src/sys/nfs: nfs_socket.c

Log Message:
nfs: Simplify assertion.  No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:53:02 UTC 2023

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfs: Avoid free of uninitialized on bad name size in create, mknod.

XXX These error branches are a nightmare and need to be more
systematically cleaned up.  Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/nfs/nfs_serv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.183 src/sys/nfs/nfs_serv.c:1.184
--- src/sys/nfs/nfs_serv.c:1.183	Wed Apr 27 17:38:52 2022
+++ src/sys/nfs/nfs_serv.c	Thu Mar 23 19:53:01 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.184 2023/03/23 19:53:01 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.184 2023/03/23 19:53:01 riastradh Exp $");
 
 #include 
 #include 
@@ -1648,10 +1648,10 @@ nfsmout:
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vput(nd.ni_vp);
-	}
-	if (nd.ni_pathbuf != NULL) {
-		pathbuf_destroy(nd.ni_pathbuf);
-		nd.ni_pathbuf = NULL;
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	return (error);
 }
@@ -1801,10 +1801,10 @@ nfsmout:
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vput(nd.ni_vp);
-	}
-	if (nd.ni_pathbuf != NULL) {
-		pathbuf_destroy(nd.ni_pathbuf);
-		nd.ni_pathbuf = NULL;
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	if (dirp)
 		vrele(dirp);



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:53:02 UTC 2023

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfs: Avoid free of uninitialized on bad name size in create, mknod.

XXX These error branches are a nightmare and need to be more
systematically cleaned up.  Even if they are correct now, they are
impossible to audit and extremely fragile in case anyone ever needs
to make other changes to them.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/sys/nfs/nfs_serv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:52 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned name lengths so we don't trip over negative ones.

- nfsm_strsiz is only used with uint32_t in callers, but let's not
  leave it as a rake to step on.

- nfsm_srvnamesiz is abused with signed s.  The internal conversion
  to unsigned serves to reject both negative and too-large values in
  such callers.

  XXX Should make all callers use unsigned, rather than flipping back
  and forth between signed and unsigned for name lengths.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfsm_subs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:52 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned name lengths so we don't trip over negative ones.

- nfsm_strsiz is only used with uint32_t in callers, but let's not
  leave it as a rake to step on.

- nfsm_srvnamesiz is abused with signed s.  The internal conversion
  to unsigned serves to reject both negative and too-large values in
  such callers.

  XXX Should make all callers use unsigned, rather than flipping back
  and forth between signed and unsigned for name lengths.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfsm_subs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfsm_subs.h
diff -u src/sys/nfs/nfsm_subs.h:1.56 src/sys/nfs/nfsm_subs.h:1.57
--- src/sys/nfs/nfsm_subs.h:1.56	Thu Mar 23 19:52:33 2023
+++ src/sys/nfs/nfsm_subs.h	Thu Mar 23 19:52:52 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.56 2023/03/23 19:52:33 riastradh Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.57 2023/03/23 19:52:52 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -366,7 +366,7 @@
 
 #define	nfsm_strsiz(s,m) \
 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
-		if (((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
+		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > (m)) { \
 			m_freem(mrep); \
 			error = EBADRPC; \
 			goto nfsmout; \
@@ -374,7 +374,8 @@
 
 #define	nfsm_srvnamesiz(s) \
 		{ nfsm_dissect(tl,uint32_t *,NFSX_UNSIGNED); \
-		if (((s) = fxdr_unsigned(uint32_t,*tl)) > NFS_MAXNAMLEN) \
+		if ((uint32_t)((s) = fxdr_unsigned(uint32_t,*tl)) > \
+		NFS_MAXNAMLEN) \
 			error = NFSERR_NAMETOL; \
 		if (error) \
 			nfsm_reply(0); \



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:43 UTC 2023

Modified Files:
src/sys/nfs: nfs_srvsubs.c

Log Message:
nfs: Avoid integer overflow in nfs_namei bounds check.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/nfs/nfs_srvsubs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_srvsubs.c
diff -u src/sys/nfs/nfs_srvsubs.c:1.16 src/sys/nfs/nfs_srvsubs.c:1.17
--- src/sys/nfs/nfs_srvsubs.c:1.16	Wed Apr 27 17:38:52 2022
+++ src/sys/nfs/nfs_srvsubs.c	Thu Mar 23 19:52:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsubs.c,v 1.16 2022/04/27 17:38:52 hannken Exp $	*/
+/*	$NetBSD: nfs_srvsubs.c,v 1.17 2023/03/23 19:52:42 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.16 2022/04/27 17:38:52 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_srvsubs.c,v 1.17 2023/03/23 19:52:42 riastradh Exp $");
 
 #include 
 #include 
@@ -129,7 +129,7 @@ nfs_namei(struct nameidata *ndp, nfsrvfh
 	*retdirp = NULL;
 	ndp->ni_pathbuf = NULL;
 
-	if ((len + 1) > NFS_MAXPATHLEN)
+	if (len > NFS_MAXPATHLEN - 1)
 		return (ENAMETOOLONG);
 	if (len == 0)
 		return (EACCES);



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:33 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned fhlen so we don't trip over negative values.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/nfs/nfsm_subs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfsm_subs.h
diff -u src/sys/nfs/nfsm_subs.h:1.55 src/sys/nfs/nfsm_subs.h:1.56
--- src/sys/nfs/nfsm_subs.h:1.55	Thu Aug 12 20:25:27 2021
+++ src/sys/nfs/nfsm_subs.h	Thu Mar 23 19:52:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.55 2021/08/12 20:25:27 andvar Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.56 2023/03/23 19:52:33 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -480,20 +480,24 @@
 		} }
 
 #define nfsm_srvmtofh(nsfh) \
-	{ int fhlen = NFSX_V3FH; \
+	{ uint32_t fhlen = NFSX_V3FH; \
 		if (nfsd->nd_flag & ND_NFSV3) { \
-			nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
-			fhlen = fxdr_unsigned(int, *tl); \
+			nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); \
+			fhlen = fxdr_unsigned(uint32_t, *tl); \
+			CTASSERT(NFSX_V3FHMAX <= FHANDLE_SIZE_MAX); \
 			if (fhlen > NFSX_V3FHMAX || \
 			(fhlen < FHANDLE_SIZE_MIN && fhlen > 0)) { \
 error = EBADRPC; \
 nfsm_reply(0); \
 			} \
 		} else { \
+			CTASSERT(NFSX_V2FH >= FHANDLE_SIZE_MIN); \
 			fhlen = NFSX_V2FH; \
 		} \
 		(nsfh)->nsfh_size = fhlen; \
 		if (fhlen != 0) { \
+			KASSERT(fhlen >= FHANDLE_SIZE_MIN); \
+			KASSERT(fhlen <= FHANDLE_SIZE_MAX); \
 			nfsm_dissect(tl, u_int32_t *, fhlen); \
 			memcpy(NFSRVFH_DATA(nsfh), tl, fhlen); \
 		} \



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:33 UTC 2023

Modified Files:
src/sys/nfs: nfsm_subs.h

Log Message:
nfs: Use unsigned fhlen so we don't trip over negative values.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/nfs/nfsm_subs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-03-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 23 19:52:43 UTC 2023

Modified Files:
src/sys/nfs: nfs_srvsubs.c

Log Message:
nfs: Avoid integer overflow in nfs_namei bounds check.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/nfs/nfs_srvsubs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 21 15:47:46 UTC 2023

Modified Files:
src/sys/nfs: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.9 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.244 -r1.245 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.6 src/sys/nfs/nfs_clntsubs.c:1.7
--- src/sys/nfs/nfs_clntsubs.c:1.6	Mon Feb 28 03:45:36 2022
+++ src/sys/nfs/nfs_clntsubs.c	Tue Mar 21 11:47:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.7 2023/03/21 15:47:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.7 2023/03/21 15:47:46 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -390,7 +390,7 @@ nfs_check_wccdata(struct nfsnode *np, co
 	if (docheck) {
 		struct vnode *vp = NFSTOV(np);
 		struct nfsmount *nmp;
-		long now = time_second;
+		time_t now = time_second;
 		const struct timespec *omtime = >n_vattr->va_mtime;
 		const struct timespec *octime = >n_vattr->va_ctime;
 		const char *reason = NULL; /* XXX: gcc */

Index: src/sys/nfs/nfs_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.8 src/sys/nfs/nfs_iod.c:1.9
--- src/sys/nfs/nfs_iod.c:1.8	Mon Sep  3 12:29:36 2018
+++ src/sys/nfs/nfs_iod.c	Tue Mar 21 11:47:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.9 2023/03/21 15:47:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.8 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_iod.c,v 1.9 2023/03/21 15:47:46 christos Exp $");
 
 #include 
 #include 
@@ -409,7 +409,8 @@ nfs_savenickauth(struct nfsmount *nmp, k
 	struct timeval ktvin, ktvout;
 	u_int32_t nick;
 	char *dpos = *dposp, *cp2;
-	int deltasec, error = 0;
+	time_t deltasec;
+	int error = 0;
 
 	memset(, 0, sizeof ktvout);	 /* XXX gcc */
 

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.244 src/sys/nfs/nfs_vfsops.c:1.245
--- src/sys/nfs/nfs_vfsops.c:1.244	Thu Mar 16 20:46:35 2023
+++ src/sys/nfs/nfs_vfsops.c	Tue Mar 21 11:47:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.245 2023/03/21 15:47:46 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.245 2023/03/21 15:47:46 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -323,7 +323,7 @@ nfs_mountroot(void)
 	struct mount *mp;
 	struct vnode *vp;
 	struct lwp *l;
-	long n;
+	time_t n;
 	int error;
 
 	l = curlwp; /* XXX */
@@ -378,7 +378,7 @@ nfs_mountroot(void)
 		panic("nfs_mountroot: getattr for root");
 	n = attr.va_atime.tv_sec;
 #ifdef	DEBUG
-	printf("root time: 0x%lx\n", n);
+	printf("root time: 0x%jx\n", (intmax_t)n);
 #endif
 	setrootfstime(n);
 



CVS commit: src/sys/nfs

2023-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Mar 21 15:47:46 UTC 2023

Modified Files:
src/sys/nfs: nfs_clntsubs.c nfs_iod.c nfs_vfsops.c

Log Message:
PR/57279: Izumi Tsutsui: Fix some {int,long} -> time_t. Still things will
break eventually because parts of the nfs protocol assume time_t will fit
in 32 bits.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/nfs/nfs_clntsubs.c
cvs rdiff -u -r1.8 -r1.9 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.244 -r1.245 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2023-03-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Mar 17 00:46:35 UTC 2023

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.243 src/sys/nfs/nfs_vfsops.c:1.244
--- src/sys/nfs/nfs_vfsops.c:1.243	Sun Jun 13 10:25:11 2021
+++ src/sys/nfs/nfs_vfsops.c	Fri Mar 17 00:46:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.244 2023/03/17 00:46:35 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -1135,6 +1135,7 @@ nfs_start(struct mount *mp, int flags)
 void
 nfs_vfs_init(void)
 {
+	unsigned scale;
 
 	/* Initialize NFS server / client shared data. */
 	nfs_init();
@@ -1145,7 +1146,8 @@ nfs_vfs_init(void)
 	/* Initialize the iod structures */
 	nfs_iodinit();
 
-	nfs_commitsize = uvmexp.npages << (PAGE_SHIFT - 4);
+	scale = PAGE_SHIFT - 4;
+	nfs_commitsize = uimin(uvmexp.npages, INT_MAX >> scale) << scale;
 }
 
 void



CVS commit: src/sys/nfs

2023-03-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Mar 17 00:46:35 UTC 2023

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Avoid overflow of nfs_commitsize on machines with > 32GB RAM.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2022-12-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Dec 24 15:37:50 UTC 2022

Modified Files:
src/sys/nfs: nfs_bootdhcp.c

Log Message:
s/reqest/request/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfs_bootdhcp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_bootdhcp.c
diff -u src/sys/nfs/nfs_bootdhcp.c:1.56 src/sys/nfs/nfs_bootdhcp.c:1.57
--- src/sys/nfs/nfs_bootdhcp.c:1.56	Fri Jun 10 13:27:16 2016
+++ src/sys/nfs/nfs_bootdhcp.c	Sat Dec 24 15:37:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootdhcp.c,v 1.56 2016/06/10 13:27:16 ozaki-r Exp $	*/
+/*	$NetBSD: nfs_bootdhcp.c,v 1.57 2022/12/24 15:37:50 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.56 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bootdhcp.c,v 1.57 2022/12/24 15:37:50 andvar Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs_boot.h"
@@ -600,7 +600,7 @@ bootpc_call(struct nfs_diskless *nd, str
 	m_reset_rcvif(m);
 
 	/*
-	 * Build the BOOTP reqest message.
+	 * Build the BOOTP request message.
 	 * Note: xid is host order! (opaque to server)
 	 */
 	memset((void *)bootp, 0, BOOTP_SIZE_MAX);



CVS commit: src/sys/nfs

2022-12-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Dec 24 15:37:50 UTC 2022

Modified Files:
src/sys/nfs: nfs_bootdhcp.c

Log Message:
s/reqest/request/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/nfs/nfs_bootdhcp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2022-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 09:40:09 UTC 2022

Modified Files:
src/sys/nfs: nfs_srvsocket.c

Log Message:
When partitioning a mbuf chain with m_split() the last mbuf of the returned
tail chain is not necessarily the same as the last mbuf of the initial chain.

Always set "slp->ns_rawend" to the last mbuf of the tail chain to prevent
mbuf leaks and corruption.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_srvsocket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_srvsocket.c
diff -u src/sys/nfs/nfs_srvsocket.c:1.4 src/sys/nfs/nfs_srvsocket.c:1.5
--- src/sys/nfs/nfs_srvsocket.c:1.4	Thu Sep  3 20:59:12 2009
+++ src/sys/nfs/nfs_srvsocket.c	Tue Dec 20 09:40:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $	*/
+/*	$NetBSD: nfs_srvsocket.c,v 1.5 2022/12/20 09:40:09 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_srvsocket.c,v 1.5 2022/12/20 09:40:09 hannken Exp $");
 
 #include 
 #include 
@@ -323,8 +323,9 @@ nfsrv_getstream(struct nfssvc_sock *slp,
 			}
 			m_claimm(recm, _mowner);
 			slp->ns_raw = m;
-			if (m->m_next == NULL)
-slp->ns_rawend = m;
+			while (m->m_next)
+m = m->m_next;
+			slp->ns_rawend = m;
 			slp->ns_cc -= slp->ns_reclen;
 			slp->ns_reclen = 0;
 		} else {



CVS commit: src/sys/nfs

2022-12-20 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Dec 20 09:40:09 UTC 2022

Modified Files:
src/sys/nfs: nfs_srvsocket.c

Log Message:
When partitioning a mbuf chain with m_split() the last mbuf of the returned
tail chain is not necessarily the same as the last mbuf of the initial chain.

Always set "slp->ns_rawend" to the last mbuf of the tail chain to prevent
mbuf leaks and corruption.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_srvsocket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2022-06-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun 24 16:50:00 UTC 2022

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
Remove an incorrect assertion.

Just issue a readahead near the end of the vnode and enqueue an async read.
Now let nfs_setattr() truncate the vnode, set its new size and
nfs_vinvalbuf() waits for the pages from the readahead to become unbusy.

The async read gets processed and returns with uio_resid > 0 because there
is a hole and no write after the hole has been pushed yet.  As the vnode
size already got truncated to the new size the KASSERT() incorrectly fires.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_bio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_bio.c
diff -u src/sys/nfs/nfs_bio.c:1.200 src/sys/nfs/nfs_bio.c:1.201
--- src/sys/nfs/nfs_bio.c:1.200	Wed Oct 20 03:08:18 2021
+++ src/sys/nfs/nfs_bio.c	Fri Jun 24 16:50:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.200 2021/10/20 03:08:18 thorpej Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.200 2021/10/20 03:08:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.201 2022/06/24 16:50:00 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -878,8 +878,6 @@ nfs_doio_read(struct buf *bp, struct uio
 			 * Just zero fill the rest of the valid area.
 			 */
 
-			KASSERT(vp->v_size >=
-			uiop->uio_offset + uiop->uio_resid);
 			diff = bp->b_bcount - uiop->uio_resid;
 			len = uiop->uio_resid;
 			memset((char *)bp->b_data + diff, 0, len);



CVS commit: src/sys/nfs

2022-06-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun 24 16:50:00 UTC 2022

Modified Files:
src/sys/nfs: nfs_bio.c

Log Message:
Remove an incorrect assertion.

Just issue a readahead near the end of the vnode and enqueue an async read.
Now let nfs_setattr() truncate the vnode, set its new size and
nfs_vinvalbuf() waits for the pages from the readahead to become unbusy.

The async read gets processed and returns with uio_resid > 0 because there
is a hole and no write after the hole has been pushed yet.  As the vnode
size already got truncated to the new size the KASSERT() incorrectly fires.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/sys/nfs/nfs_bio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2022-04-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 27 17:38:52 UTC 2022

Modified Files:
src/sys/nfs: nfs_serv.c nfs_srvsubs.c nfs_var.h

Log Message:
As VOP_GETATTR() needs a shared lock at least move the preopattr lookup
inside nfs_namei() where we may lock the start directory without violating
the lock order.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.15 -r1.16 src/sys/nfs/nfs_srvsubs.c
cvs rdiff -u -r1.95 -r1.96 src/sys/nfs/nfs_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.182 src/sys/nfs/nfs_serv.c:1.183
--- src/sys/nfs/nfs_serv.c:1.182	Thu Sep 16 20:17:47 2021
+++ src/sys/nfs/nfs_serv.c	Wed Apr 27 17:38:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $");
 
 #include 
 #include 
@@ -422,7 +422,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = LOOKUP;
 	nd.ni_cnd.cn_flags = LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
+		, NULL, NULL,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
 
 	if (!error && pubflag) {
 		if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL &&
@@ -1447,10 +1448,8 @@ nfsrv_create(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		nfsm_reply(NFSX_WCCDATA(v3));
 		nfsm_srvwcc_data(dirfor_ret, , diraft_ret, );
@@ -1689,9 +1688,8 @@ nfsrv_mknod(struct nfsrv_descript *nfsd,
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp)
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
+		, _ret, ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		nfsm_reply(NFSX_WCCDATA(1));
 		nfsm_srvwcc_data(dirfor_ret, , diraft_ret, );
@@ -1845,14 +1843,8 @@ nfsrv_remove(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = DELETE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (error == 0 && dirp && v3) {
-		if (nd.ni_dvp == nd.ni_vp)
-			vn_lock(dirp, LK_SHARED | LK_RETRY);
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-		if (nd.ni_dvp == nd.ni_vp)
-			VOP_UNLOCK(dirp);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (!error) {
 		vp = nd.ni_vp;
 		if (vp->v_type == VDIR) {
@@ -1944,14 +1936,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	fromnd.ni_cnd.cn_nameiop = DELETE;
 	fromnd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, ,
-		, , lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (error == 0 && fdirp && v3) {
-		if (fromnd.ni_dvp == fromnd.ni_vp)
-			vn_lock(fdirp, LK_SHARED | LK_RETRY);
-		fdirfor_ret = VOP_GETATTR(fdirp, , cred);
-		if (fromnd.ni_dvp == fromnd.ni_vp)
-			VOP_UNLOCK(fdirp);
-	}
+		, , (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		fromnd.ni_cnd.cn_nameiop = 0;
 		nfsm_reply(2 * NFSX_WCCDATA(v3));
@@ -2021,10 +2007,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	tond.ni_cnd.cn_nameiop = RENAME;
 	tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE;
 	error = nfs_namei(, , len2, slp, nam, ,
-		, , lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (tdirp && v3) {
-		tdirfor_ret = VOP_GETATTR(tdirp, , cred);
-	}
+		, , (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		VFS_RENAMELOCK_EXIT(localfs);
 		VOP_ABORTOP(fromnd.ni_dvp, _cnd);
@@ -2218,10 +2202,8 @@ nfsrv_link(struct nfsrv_descript *nfsd, 
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error)
 		goto out1;
 	xp = nd.ni_vp;
@@ -2310,10 +2292,8 @@ nfsrv_symlink(struct nfsrv_descript *nfs
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, 

CVS commit: src/sys/nfs

2022-04-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 27 17:38:52 UTC 2022

Modified Files:
src/sys/nfs: nfs_serv.c nfs_srvsubs.c nfs_var.h

Log Message:
As VOP_GETATTR() needs a shared lock at least move the preopattr lookup
inside nfs_namei() where we may lock the start directory without violating
the lock order.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.15 -r1.16 src/sys/nfs/nfs_srvsubs.c
cvs rdiff -u -r1.95 -r1.96 src/sys/nfs/nfs_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2022-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 30 10:52:59 UTC 2022

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
restructure so we abort/unlock properly on failure.


To generate a diff of this commit:
cvs rdiff -u -r1.322 -r1.323 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2022-03-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 30 10:52:59 UTC 2022

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
restructure so we abort/unlock properly on failure.


To generate a diff of this commit:
cvs rdiff -u -r1.322 -r1.323 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.322 src/sys/nfs/nfs_vnops.c:1.323
--- src/sys/nfs/nfs_vnops.c:1.322	Sun Mar 27 12:24:58 2022
+++ src/sys/nfs/nfs_vnops.c	Wed Mar 30 06:52:59 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.322 2022/03/27 16:24:58 christos Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.323 2022/03/30 10:52:59 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.322 2022/03/27 16:24:58 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.323 2022/03/30 10:52:59 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -2004,21 +2004,18 @@ nfs_link(void *v)
 	struct vnode *vp = ap->a_vp;
 	struct vnode *dvp = ap->a_dvp;
 	struct componentname *cnp = ap->a_cnp;
-	int error = 0;
+	int error = 0, abrt = 1;
 
 	error = vn_lock(vp, LK_EXCLUSIVE);
-	if (error != 0) {
-		VOP_ABORTOP(dvp, cnp);
-		return error;
-	}
+	if (error != 0)
+		goto out;
 
 	error = kauth_authorize_vnode(cnp->cn_cred, KAUTH_VNODE_ADD_LINK, vp,
 	dvp, 0);
-	if (error) {
-		VOP_ABORTOP(dvp, cnp);
-		return error;
-	}
+	if (error)
+		goto out1;
 
+	abrt = 0;
 	/*
 	 * Push all writes to the server, so that the attribute cache
 	 * doesn't get "out of sync" with the server.
@@ -2032,7 +2029,11 @@ nfs_link(void *v)
 	if (error == 0) {
 		cache_purge1(dvp, cnp->cn_nameptr, cnp->cn_namelen, 0);
 	}
+out1:
 	VOP_UNLOCK(vp);
+out:
+	if (abrt)
+		VOP_ABORTOP(dvp, cnp);
 	return (error);
 }
 



CVS commit: src/sys/nfs

2022-02-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb 28 08:45:36 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
Revert the hack from the last commit now that VOP_UNLOCK()
no longer may hold v_interlock or vmobjlock.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_clntsubs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.5 src/sys/nfs/nfs_clntsubs.c:1.6
--- src/sys/nfs/nfs_clntsubs.c:1.5	Fri Jan 14 19:19:34 2022
+++ src/sys/nfs/nfs_clntsubs.c	Mon Feb 28 08:45:36 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.6 2022/02/28 08:45:36 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -360,20 +360,9 @@ nfs_delayedtruncate(struct vnode *vp)
 		np->n_flag &= ~NTRUNCDELAYED;
 		genfs_node_wrlock(vp);
 		rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
-
-		/*
-		 * This is disgusting but we can be called from VOP_UNLOCK
-		 * where the interlock is sometimes held, and we want to
-		 * make sure that it is unlocked when we call VOP_PUTPAGES
-		 * and uvm_vnp_setsize.
-		 */
-		int got = mutex_tryenter(vp->v_interlock);
-		mutex_exit(vp->v_interlock);
 		(void)VOP_PUTPAGES(vp, 0,
 		0, PGO_SYNCIO | PGO_CLEANIT | PGO_FREE | PGO_ALLPAGES);
 		uvm_vnp_setsize(vp, np->n_size);
-		if (!got)
-			mutex_enter(vp->v_interlock);
 		genfs_node_unlock(vp);
 	}
 }



CVS commit: src/sys/nfs

2022-02-28 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Feb 28 08:45:36 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
Revert the hack from the last commit now that VOP_UNLOCK()
no longer may hold v_interlock or vmobjlock.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_clntsubs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2022-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 14 19:19:35 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
This is a temporary hack to avoid nfs crashes related to nfs_delaytruncate.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_clntsubs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_clntsubs.c
diff -u src/sys/nfs/nfs_clntsubs.c:1.4 src/sys/nfs/nfs_clntsubs.c:1.5
--- src/sys/nfs/nfs_clntsubs.c:1.4	Sun Feb 23 10:46:41 2020
+++ src/sys/nfs/nfs_clntsubs.c	Fri Jan 14 14:19:34 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsubs.c,v 1.4 2020/02/23 15:46:41 ad Exp $	*/
+/*	$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.4 2020/02/23 15:46:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsubs.c,v 1.5 2022/01/14 19:19:34 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -360,9 +360,20 @@ nfs_delayedtruncate(struct vnode *vp)
 		np->n_flag &= ~NTRUNCDELAYED;
 		genfs_node_wrlock(vp);
 		rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
+
+		/*
+		 * This is disgusting but we can be called from VOP_UNLOCK
+		 * where the interlock is sometimes held, and we want to
+		 * make sure that it is unlocked when we call VOP_PUTPAGES
+		 * and uvm_vnp_setsize.
+		 */
+		int got = mutex_tryenter(vp->v_interlock);
+		mutex_exit(vp->v_interlock);
 		(void)VOP_PUTPAGES(vp, 0,
 		0, PGO_SYNCIO | PGO_CLEANIT | PGO_FREE | PGO_ALLPAGES);
 		uvm_vnp_setsize(vp, np->n_size);
+		if (!got)
+			mutex_enter(vp->v_interlock);
 		genfs_node_unlock(vp);
 	}
 }



CVS commit: src/sys/nfs

2022-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 14 19:19:35 UTC 2022

Modified Files:
src/sys/nfs: nfs_clntsubs.c

Log Message:
This is a temporary hack to avoid nfs crashes related to nfs_delaytruncate.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_clntsubs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2021-06-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun 13 10:25:11 UTC 2021

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Don't pretend that files are limited to 1TB on NFSv3.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.242 src/sys/nfs/nfs_vfsops.c:1.243
--- src/sys/nfs/nfs_vfsops.c:1.242	Fri Apr  2 03:07:54 2021
+++ src/sys/nfs/nfs_vfsops.c	Sun Jun 13 10:25:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.242 2021/04/02 03:07:54 christos Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.242 2021/04/02 03:07:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.243 2021/06/13 10:25:11 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -296,8 +296,7 @@ nfs_fsinfo(struct nfsmount *nmp, struct 
 			if (nmp->nm_readdirsize == 0)
 nmp->nm_readdirsize = xmax;
 		}
-		/* XXX */
-		nmp->nm_maxfilesize = (u_int64_t)0x8000 * DEV_BSIZE - 1;
+		nmp->nm_maxfilesize = 0xull;
 		maxfsize = fxdr_hyper(>fs_maxfilesize);
 		if (maxfsize > 0 && maxfsize < nmp->nm_maxfilesize)
 			nmp->nm_maxfilesize = maxfsize;



CVS commit: src/sys/nfs

2021-06-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jun 13 10:25:11 UTC 2021

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Don't pretend that files are limited to 1TB on NFSv3.


To generate a diff of this commit:
cvs rdiff -u -r1.242 -r1.243 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2021-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  4 10:44:59 UTC 2021

Modified Files:
src/sys/nfs: nfs.h nfs_export.c nfs_syscalls.c nfs_var.h

Log Message:
Add flag/command NFSSVC_REPLACEEXPORTSLIST to nfssvc(2) system call.

Works like NFSSVC_SETEXPORTSLIST but supports "mel_nexports > 1"
and will atomically update the complete exports list for a file system.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/nfs/nfs.h
cvs rdiff -u -r1.62 -r1.63 src/sys/nfs/nfs_export.c
cvs rdiff -u -r1.162 -r1.163 src/sys/nfs/nfs_syscalls.c
cvs rdiff -u -r1.94 -r1.95 src/sys/nfs/nfs_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs.h
diff -u src/sys/nfs/nfs.h:1.78 src/sys/nfs/nfs.h:1.79
--- src/sys/nfs/nfs.h:1.78	Wed Aug 22 01:05:24 2018
+++ src/sys/nfs/nfs.h	Fri Jun  4 10:44:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.h,v 1.78 2018/08/22 01:05:24 msaitoh Exp $	*/
+/*	$NetBSD: nfs.h,v 1.79 2021/06/04 10:44:58 hannken Exp $	*/
 /*
  * Copyright (c) 1989, 1993, 1995
  *	The Regents of the University of California.  All rights reserved.
@@ -285,6 +285,7 @@ struct nfsstats {
 #define	NFSSVC_AUTHINFAIL 0x080
 #define	NFSSVC_MNTD	0x100
 #define	NFSSVC_SETEXPORTSLIST	0x200
+#define	NFSSVC_REPLACEEXPORTSLIST	0x400
 
 /*
  * fs.nfs sysctl(3) identifiers

Index: src/sys/nfs/nfs_export.c
diff -u src/sys/nfs/nfs_export.c:1.62 src/sys/nfs/nfs_export.c:1.63
--- src/sys/nfs/nfs_export.c:1.62	Fri Jan 17 20:08:09 2020
+++ src/sys/nfs/nfs_export.c	Fri Jun  4 10:44:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.63 2021/06/04 10:44:58 hannken Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008, 2019 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.62 2020/01/17 20:08:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.63 2021/06/04 10:44:58 hannken Exp $");
 
 #include 
 #include 
@@ -233,17 +233,14 @@ netexport_fini(void)
  * Returns zero on success or an appropriate error code otherwise.
  *
  * Helper function for the nfssvc(2) system call (NFSSVC_SETEXPORTSLIST
- * command).
+ * and NFSSVC_REPLACEEXPORTSLIST command).
  */
 int
 mountd_set_exports_list(const struct mountd_exports_list *mel, struct lwp *l,
-struct mount *nmp)
+struct mount *nmp, int cmd)
 {
 	int error;
-#ifdef notyet
-	/* XXX: See below to see the reason why this is disabled. */
 	size_t i;
-#endif
 	struct mount *mp;
 	struct netexport *ne;
 	struct pathbuf *pb;
@@ -302,31 +299,24 @@ mountd_set_exports_list(const struct mou
 	KASSERT(ne != NULL);
 	KASSERT(ne->ne_mount == mp);
 
-	/*
-	 * XXX: The part marked as 'notyet' works fine from the kernel's
-	 * point of view, in the sense that it is able to atomically update
-	 * the complete exports list for a file system.  However, supporting
-	 * this in mountd(8) requires a lot of work; so, for now, keep the
-	 * old behavior of updating a single entry per call.
-	 *
-	 * When mountd(8) is fixed, just remove the second branch of this
-	 * preprocessor conditional and enable the first one.
-	 */
-#ifdef notyet
-	netexport_clear(ne);
-	for (i = 0; error == 0 && i < mel->mel_nexports; i++)
-		error = export(ne, >mel_exports[i]);
-#else
-	if (mel->mel_nexports == 0)
+	if (cmd == NFSSVC_SETEXPORTSLIST) {
+		if (mel->mel_nexports == 0)
+			netexport_clear(ne);
+		else if (mel->mel_nexports == 1)
+			error = export(ne, >mel_exports[0]);
+		else {
+			printf("%s: Cannot set more than one "
+			"entry at once (unimplemented)\n", __func__);
+			error = EOPNOTSUPP;
+		}
+	} else if (cmd == NFSSVC_REPLACEEXPORTSLIST) {
 		netexport_clear(ne);
-	else if (mel->mel_nexports == 1)
-		error = export(ne, >mel_exports[0]);
-	else {
-		printf("%s: Cannot set more than one "
-		"entry at once (unimplemented)\n", __func__);
+		for (i = 0; error == 0 && i < mel->mel_nexports; i++)
+			error = export(ne, >mel_exports[i]);
+	} else {
+		printf("%s: Command %#x not implemented\n", __func__, cmd);
 		error = EOPNOTSUPP;
 	}
-#endif
 
 out:
 	netexport_wrunlock();
@@ -455,7 +445,7 @@ nfs_export_update_30(struct mount *mp, c
 		mel.mel_exports = (void *)>eargs;
 	}
 
-	return mountd_set_exports_list(, curlwp, mp);
+	return mountd_set_exports_list(, curlwp, mp, NFSSVC_SETEXPORTSLIST);
 }
 
 /*

Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.162 src/sys/nfs/nfs_syscalls.c:1.163
--- src/sys/nfs/nfs_syscalls.c:1.162	Sat Mar 14 18:08:39 2020
+++ src/sys/nfs/nfs_syscalls.c	Fri Jun  4 10:44:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.162 2020/03/14 18:08:39 ad Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.163 2021/06/04 10:44:58 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.162 2020/03/14 18:08:39 ad Exp $");

CVS commit: src/sys/nfs

2021-06-04 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jun  4 10:44:59 UTC 2021

Modified Files:
src/sys/nfs: nfs.h nfs_export.c nfs_syscalls.c nfs_var.h

Log Message:
Add flag/command NFSSVC_REPLACEEXPORTSLIST to nfssvc(2) system call.

Works like NFSSVC_SETEXPORTSLIST but supports "mel_nexports > 1"
and will atomically update the complete exports list for a file system.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/nfs/nfs.h
cvs rdiff -u -r1.62 -r1.63 src/sys/nfs/nfs_export.c
cvs rdiff -u -r1.162 -r1.163 src/sys/nfs/nfs_syscalls.c
cvs rdiff -u -r1.94 -r1.95 src/sys/nfs/nfs_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2021-05-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 27 08:58:29 UTC 2021

Modified Files:
src/sys/nfs: nfsnode.h

Log Message:
Remove nfs_putpages() prototype; it's not defined anywhere.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/nfs/nfsnode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfsnode.h
diff -u src/sys/nfs/nfsnode.h:1.73 src/sys/nfs/nfsnode.h:1.74
--- src/sys/nfs/nfsnode.h:1.73	Fri May 30 08:47:45 2014
+++ src/sys/nfs/nfsnode.h	Thu May 27 08:58:29 2021
@@ -1,4 +1,4 @@
-/*	 $NetBSD: nfsnode.h,v 1.73 2014/05/30 08:47:45 hannken Exp $	*/
+/*	 $NetBSD: nfsnode.h,v 1.74 2021/05/27 08:58:29 simonb Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -280,7 +280,6 @@ int	nfs_print(void *);
 int	nfs_pathconf(void *);
 int	nfs_advlock(void *);
 int	nfs_getpages(void *);
-int	nfs_putpages(void *);
 int	nfs_kqfilter(void *);
 
 extern int (**nfsv2_vnodeop_p)(void *);



CVS commit: src/sys/nfs

2021-05-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu May 27 08:58:29 UTC 2021

Modified Files:
src/sys/nfs: nfsnode.h

Log Message:
Remove nfs_putpages() prototype; it's not defined anywhere.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/nfs/nfsnode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2021-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr  2 03:07:54 UTC 2021

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


To generate a diff of this commit:
cvs rdiff -u -r1.241 -r1.242 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2021-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr  2 03:07:54 UTC 2021

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


To generate a diff of this commit:
cvs rdiff -u -r1.241 -r1.242 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.241 src/sys/nfs/nfs_vfsops.c:1.242
--- src/sys/nfs/nfs_vfsops.c:1.241	Mon Apr 13 15:23:20 2020
+++ src/sys/nfs/nfs_vfsops.c	Thu Apr  1 23:07:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.241 2020/04/13 19:23:20 ad Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.242 2021/04/02 03:07:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.241 2020/04/13 19:23:20 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.242 2021/04/02 03:07:54 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -223,7 +223,6 @@ nfs_statvfs(struct mount *mp, struct sta
 		sbp->f_ffree = tquad;
 		sbp->f_favail = tquad;
 		sbp->f_fresvd = 0;
-		sbp->f_namemax = NFS_MAXNAMLEN;
 	} else {
 		sbp->f_bsize = NFS_FABLKSIZE;
 		sbp->f_frsize = fxdr_unsigned(int32_t, sfp->sf_bsize);
@@ -235,7 +234,6 @@ nfs_statvfs(struct mount *mp, struct sta
 		sbp->f_ffree = 0;
 		sbp->f_favail = 0;
 		sbp->f_fresvd = 0;
-		sbp->f_namemax = NFS_MAXNAMLEN;
 	}
 	copy_statvfs_info(sbp, mp);
 	nfsm_reqdone;
@@ -706,19 +704,20 @@ mountnfs(struct nfs_args *argp, struct m
 		nmp = VFSTONFS(mp);
 		/* update paths, file handles, etc, here	XXX */
 		m_freem(nam);
-		return (0);
-	} else {
-		nmp = kmem_zalloc(sizeof(*nmp), KM_SLEEP);
-		mp->mnt_data = nmp;
-		TAILQ_INIT(>nm_uidlruhead);
-		TAILQ_INIT(>nm_bufq);
-		rw_init(>nm_writeverflock);
-		mutex_init(>nm_lock, MUTEX_DEFAULT, IPL_NONE);
-		cv_init(>nm_rcvcv, "nfsrcv");
-		cv_init(>nm_sndcv, "nfssnd");
-		cv_init(>nm_aiocv, "nfsaio");
-		cv_init(>nm_disconcv, "nfsdis");
+		return 0;
 	}
+	nmp = kmem_zalloc(sizeof(*nmp), KM_SLEEP);
+	TAILQ_INIT(>nm_uidlruhead);
+	TAILQ_INIT(>nm_bufq);
+	rw_init(>nm_writeverflock);
+	mutex_init(>nm_lock, MUTEX_DEFAULT, IPL_NONE);
+	cv_init(>nm_rcvcv, "nfsrcv");
+	cv_init(>nm_sndcv, "nfssnd");
+	cv_init(>nm_aiocv, "nfsaio");
+	cv_init(>nm_disconcv, "nfsdis");
+
+	mp->mnt_data = nmp;
+	mp->mnt_stat.f_namemax = NFS_MAXNAMLEN;
 	vfs_getnewfsid(mp);
 	nmp->nm_mountp = mp;
 



CVS commit: src/sys/nfs

2020-05-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri May  1 08:43:00 UTC 2020

Modified Files:
src/sys/nfs: nfs_node.c

Log Message:
Resolve delayed truncation from nfs_inactive() too.

Should prevent "locking against self" from nfs_unlock().


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/nfs/nfs_node.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_node.c
diff -u src/sys/nfs/nfs_node.c:1.125 src/sys/nfs/nfs_node.c:1.126
--- src/sys/nfs/nfs_node.c:1.125	Mon Feb 24 20:11:45 2020
+++ src/sys/nfs/nfs_node.c	Fri May  1 08:43:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_node.c,v 1.125 2020/02/24 20:11:45 ad Exp $	*/
+/*	$NetBSD: nfs_node.c,v 1.126 2020/05/01 08:43:00 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.125 2020/02/24 20:11:45 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.126 2020/05/01 08:43:00 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -186,6 +186,9 @@ nfs_inactive(void *v)
 	struct sillyrename *sp;
 	struct vnode *vp = ap->a_vp;
 
+	/* If we have a delayed truncation, do it now. */
+	nfs_delayedtruncate(vp);
+
 	np = VTONFS(vp);
 	if (vp->v_type != VDIR) {
 		sp = np->n_sillyrename;



CVS commit: src/sys/nfs

2020-05-01 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri May  1 08:43:00 UTC 2020

Modified Files:
src/sys/nfs: nfs_node.c

Log Message:
Resolve delayed truncation from nfs_inactive() too.

Should prevent "locking against self" from nfs_unlock().


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/nfs/nfs_node.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2020-04-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr  4 07:07:20 UTC 2020

Modified Files:
src/sys/nfs: nfs_serv.c nfs_subs.c nfsm_subs.h

Log Message:
NFSv2 is limited to use only 32bit in metadata. Prevent that larger
metadata values are simply truncated.

-> clamp filesystem block counts to signed 32bit.
-> clamp file sizes to signed 32bit (*)

Some NFSv2 clients also have problems to handle buffer sizes larger
than (signed) 16bit.
-> clamp buffer sizes to signed 16bit for better compatibility.

(*) This can lead to erroneous behaviour for files larger than 2GB
that NFSv2 cannot handle but it is still better than before.
An alternative would be to (partially) reject operations on files
larger than 2GB, but which causes other problems.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.238 -r1.239 src/sys/nfs/nfs_subs.c
cvs rdiff -u -r1.53 -r1.54 src/sys/nfs/nfsm_subs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.179 src/sys/nfs/nfs_serv.c:1.180
--- src/sys/nfs/nfs_serv.c:1.179	Fri Jan 17 20:08:09 2020
+++ src/sys/nfs/nfs_serv.c	Sat Apr  4 07:07:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.180 2020/04/04 07:07:20 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.180 2020/04/04 07:07:20 mlelstv Exp $");
 
 #include 
 #include 
@@ -3394,10 +3394,10 @@ nfsrv_statfs(struct nfsrv_descript *nfsd
 		sfp->sf_invarsec = 0;
 	} else {
 		sfp->sf_tsize = txdr_unsigned(NFS_MAXDGRAMDATA);
-		sfp->sf_bsize = txdr_unsigned(sf->f_frsize);
-		sfp->sf_blocks = txdr_unsigned(sf->f_blocks);
-		sfp->sf_bfree = txdr_unsigned(sf->f_bfree);
-		sfp->sf_bavail = txdr_unsigned(sf->f_bavail);
+		sfp->sf_bsize = txdr_unsigned(NFS_V2CLAMP16(sf->f_frsize));
+		sfp->sf_blocks = txdr_unsigned(NFS_V2CLAMP32(sf->f_blocks));
+		sfp->sf_bfree = txdr_unsigned(NFS_V2CLAMP32(sf->f_bfree));
+		sfp->sf_bavail = txdr_unsigned(NFS_V2CLAMP32(sf->f_bavail));
 	}
 nfsmout:
 	if (sf)

Index: src/sys/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.238 src/sys/nfs/nfs_subs.c:1.239
--- src/sys/nfs/nfs_subs.c:1.238	Sun Mar  8 22:12:42 2020
+++ src/sys/nfs/nfs_subs.c	Sat Apr  4 07:07:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.238 2020/03/08 22:12:42 mgorny Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.239 2020/04/04 07:07:20 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.238 2020/03/08 22:12:42 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.239 2020/04/04 07:07:20 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -1696,8 +1696,8 @@ nfsm_srvfattr(struct nfsrv_descript *nfs
 	} else {
 		fp->fa_type = vtonfsv2_type(vap->va_type);
 		fp->fa_mode = vtonfsv2_mode(vap->va_type, vap->va_mode);
-		fp->fa2_size = txdr_unsigned(vap->va_size);
-		fp->fa2_blocksize = txdr_unsigned(vap->va_blocksize);
+		fp->fa2_size = txdr_unsigned(NFS_V2CLAMP32(vap->va_size));
+		fp->fa2_blocksize = txdr_unsigned(NFS_V2CLAMP16(vap->va_blocksize));
 		if (vap->va_type == VFIFO)
 			fp->fa2_rdev = 0x;
 		else

Index: src/sys/nfs/nfsm_subs.h
diff -u src/sys/nfs/nfsm_subs.h:1.53 src/sys/nfs/nfsm_subs.h:1.54
--- src/sys/nfs/nfsm_subs.h:1.53	Sat Sep 14 22:29:08 2013
+++ src/sys/nfs/nfsm_subs.h	Sat Apr  4 07:07:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.53 2013/09/14 22:29:08 martin Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.54 2020/04/04 07:07:20 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,6 +55,14 @@
 (((m)->m_flags & M_PKTHDR) ? MHLEN : MLEN))
 
 /*
+ * NFSv2 can only handle signed 32bit quantities and some clients
+ * get confused by larger than 16bit block sizes. Limit values
+ * for better compatibility.
+ */
+#define NFS_V2CLAMP32(x) ((x) > INT32_MAX ? INT32_MAX : (int32_t)(x))
+#define NFS_V2CLAMP16(x) ((x) > INT16_MAX ? INT16_MAX : (int32_t)(x))
+
+/*
  * Now for the macros that do the simple stuff and call the functions
  * for the hard stuff.
  * These macros use several vars. declared in nfsm_reqhead and these



CVS commit: src/sys/nfs

2020-04-04 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Apr  4 07:07:20 UTC 2020

Modified Files:
src/sys/nfs: nfs_serv.c nfs_subs.c nfsm_subs.h

Log Message:
NFSv2 is limited to use only 32bit in metadata. Prevent that larger
metadata values are simply truncated.

-> clamp filesystem block counts to signed 32bit.
-> clamp file sizes to signed 32bit (*)

Some NFSv2 clients also have problems to handle buffer sizes larger
than (signed) 16bit.
-> clamp buffer sizes to signed 16bit for better compatibility.

(*) This can lead to erroneous behaviour for files larger than 2GB
that NFSv2 cannot handle but it is still better than before.
An alternative would be to (partially) reject operations on files
larger than 2GB, but which causes other problems.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.238 -r1.239 src/sys/nfs/nfs_subs.c
cvs rdiff -u -r1.53 -r1.54 src/sys/nfs/nfsm_subs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2020-03-08 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Sun Mar  8 22:12:43 UTC 2020

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Update NFS errno mapping and add assert for correctness

Add the mapping for errno values missing in nfsrv_v2errmap[].  While
at it, add a compile-time assert to make sure that the array does not
become out-of-date again.


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.237 src/sys/nfs/nfs_subs.c:1.238
--- src/sys/nfs/nfs_subs.c:1.237	Mon Feb 24 20:18:53 2020
+++ src/sys/nfs/nfs_subs.c	Sun Mar  8 22:12:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.237 2020/02/24 20:18:53 ad Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.238 2020/03/08 22:12:42 mgorny Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.237 2020/02/24 20:18:53 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.238 2020/03/08 22:12:42 mgorny Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -207,7 +207,7 @@ const int nfsv2_procid[NFS_NPROCS] = {
  * Use NFSERR_IO as the catch all for ones not specifically defined in
  * RFC 1094.
  */
-static const u_char nfsrv_v2errmap[ELAST] = {
+static const u_char nfsrv_v2errmap[] = {
   NFSERR_PERM,	NFSERR_NOENT,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
   NFSERR_NXIO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
   NFSERR_IO,	NFSERR_IO,	NFSERR_ACCES,	NFSERR_IO,	NFSERR_IO,
@@ -224,8 +224,12 @@ static const u_char nfsrv_v2errmap[ELAST
   NFSERR_NOTEMPTY, NFSERR_IO,	NFSERR_IO,	NFSERR_DQUOT,	NFSERR_STALE,
   NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
   NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
-  NFSERR_IO,	NFSERR_IO,
+  NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
+  NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
+  NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,	NFSERR_IO,
+  NFSERR_IO,	NFSERR_IO,	NFSERR_IO
 };
+__CTASSERT(__arraycount(nfsrv_v2errmap) == ELAST);
 
 /*
  * Maps errno values to nfs error numbers.



CVS commit: src/sys/nfs

2020-03-08 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Sun Mar  8 22:12:43 UTC 2020

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Update NFS errno mapping and add assert for correctness

Add the mapping for errno values missing in nfsrv_v2errmap[].  While
at it, add a compile-time assert to make sure that the array does not
become out-of-date again.


To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2020-02-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Feb 24 20:18:53 UTC 2020

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
v_interlock -> vmobjlock


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.236 src/sys/nfs/nfs_subs.c:1.237
--- src/sys/nfs/nfs_subs.c:1.236	Sun Dec 15 21:11:34 2019
+++ src/sys/nfs/nfs_subs.c	Mon Feb 24 20:18:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.236 2019/12/15 21:11:34 ad Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.237 2020/02/24 20:18:53 ad Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.236 2019/12/15 21:11:34 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.237 2020/02/24 20:18:53 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -1751,28 +1751,13 @@ nfs_clearcommit_selector(void *cl, struc
 {
 	struct nfs_clearcommit_ctx *c = cl;
 	struct nfsnode *np;
-	struct vm_page *pg;
-	struct uvm_page_array a;
-	voff_t off;
 
 	KASSERT(mutex_owned(vp->v_interlock));
 
+	/* XXXAD mountpoint check looks like nonsense to me */
 	np = VTONFS(vp);
 	if (vp->v_type != VREG || vp->v_mount != c->mp || np == NULL)
 		return false;
-	np->n_pushlo = np->n_pushhi = np->n_pushedlo =
-	np->n_pushedhi = 0;
-	np->n_commitflags &=
-	~(NFS_COMMIT_PUSH_VALID | NFS_COMMIT_PUSHED_VALID);
-	uvm_page_array_init();
-	off = 0;
-	while ((pg = uvm_page_array_fill_and_peek(, >v_uobj, off,
-	0, 0)) != NULL) {
-		pg->flags &= ~PG_NEEDCOMMIT;
-		uvm_page_array_advance();
-		off = pg->offset + PAGE_SIZE;
-	}
-	uvm_page_array_fini();
 	return false;
 }
 
@@ -1786,15 +1771,41 @@ nfs_clearcommit_selector(void *cl, struc
 void
 nfs_clearcommit(struct mount *mp)
 {
-	struct vnode *vp __diagused;
+	struct vnode *vp;
 	struct vnode_iterator *marker;
 	struct nfsmount *nmp = VFSTONFS(mp);
 	struct nfs_clearcommit_ctx ctx;
+	struct nfsnode *np;
+	struct vm_page *pg;
+	struct uvm_page_array a;
+	voff_t off;
 
 	rw_enter(>nm_writeverflock, RW_WRITER);
 	vfs_vnode_iterator_init(mp, );
 	ctx.mp = mp;
-	vp = vfs_vnode_iterator_next(marker, nfs_clearcommit_selector, );
+	for (;;) {
+		vp = vfs_vnode_iterator_next(marker, nfs_clearcommit_selector,
+		);
+		if (vp == NULL)
+			break;
+		rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
+		np = VTONFS(vp);
+		np->n_pushlo = np->n_pushhi = np->n_pushedlo =
+		np->n_pushedhi = 0;
+		np->n_commitflags &=
+		~(NFS_COMMIT_PUSH_VALID | NFS_COMMIT_PUSHED_VALID);
+		uvm_page_array_init();
+		off = 0;
+		while ((pg = uvm_page_array_fill_and_peek(, >v_uobj, off,
+		0, 0)) != NULL) {
+			pg->flags &= ~PG_NEEDCOMMIT;
+			uvm_page_array_advance();
+			off = pg->offset + PAGE_SIZE;
+		}
+		uvm_page_array_fini();
+		rw_exit(vp->v_uobj.vmobjlock);
+		vrele(vp);
+	}
 	KASSERT(vp == NULL);
 	vfs_vnode_iterator_destroy(marker);
 	mutex_enter(>nm_lock);



CVS commit: src/sys/nfs

2020-02-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Feb 24 20:18:53 UTC 2020

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
v_interlock -> vmobjlock


To generate a diff of this commit:
cvs rdiff -u -r1.236 -r1.237 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2020-02-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Feb 24 20:11:46 UTC 2020

Modified Files:
src/sys/nfs: nfs_node.c

Log Message:
v_interlock -> vmobjlock


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/nfs/nfs_node.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_node.c
diff -u src/sys/nfs/nfs_node.c:1.124 src/sys/nfs/nfs_node.c:1.125
--- src/sys/nfs/nfs_node.c:1.124	Fri Oct 18 04:09:02 2019
+++ src/sys/nfs/nfs_node.c	Mon Feb 24 20:11:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_node.c,v 1.124 2019/10/18 04:09:02 msaitoh Exp $	*/
+/*	$NetBSD: nfs_node.c,v 1.125 2020/02/24 20:11:45 ad Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.124 2019/10/18 04:09:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_node.c,v 1.125 2020/02/24 20:11:45 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -273,11 +273,11 @@ nfs_gop_write(struct vnode *vp, struct v
 {
 	int i;
 
-	mutex_enter(vp->v_interlock);
+	rw_enter(vp->v_uobj.vmobjlock, RW_WRITER);
 	for (i = 0; i < npages; i++) {
 		pmap_page_protect(pgs[i], VM_PROT_READ);
 	}
-	mutex_exit(vp->v_interlock);
+	rw_exit(vp->v_uobj.vmobjlock);
 
 	return genfs_gop_write(vp, pgs, npages, flags);
 }



CVS commit: src/sys/nfs

2020-02-24 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Mon Feb 24 20:11:46 UTC 2020

Modified Files:
src/sys/nfs: nfs_node.c

Log Message:
v_interlock -> vmobjlock


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/sys/nfs/nfs_node.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2019-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 10 23:19:34 UTC 2019

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
remove NCHNAMLEN optimization


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.311 src/sys/nfs/nfs_vnops.c:1.312
--- src/sys/nfs/nfs_vnops.c:1.311	Mon Sep  3 12:29:36 2018
+++ src/sys/nfs/nfs_vnops.c	Tue Sep 10 19:19:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.311 2018/09/03 16:29:36 riastradh Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.312 2019/09/10 23:19:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.311 2018/09/03 16:29:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.312 2019/09/10 23:19:34 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -2778,11 +2778,9 @@ nfs_readdirplusrpc(struct vnode *vp, str
 if (bigenough) {
 	dp->d_type =
 	   IFTODT(VTTOIF(np->n_vattr->va_type));
-	if (cnp->cn_namelen <= NCHNAMLEN) {
-	ndp->ni_vp = newvp;
-	nfs_cache_enter(ndp->ni_dvp,
-		ndp->ni_vp, cnp);
-	}
+	ndp->ni_vp = newvp;
+	nfs_cache_enter(ndp->ni_dvp,
+	ndp->ni_vp, cnp);
 }
 }
 error = 0;



CVS commit: src/sys/nfs

2019-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 10 23:19:34 UTC 2019

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
remove NCHNAMLEN optimization


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2019-06-29 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 29 17:42:36 UTC 2019

Modified Files:
src/sys/nfs: nfs_bootparam.c

Log Message:
Appease GCC and initialize arps_ip

Fixes build as GCC errors with maybe-uninitialized that is a false
positive.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/nfs/nfs_bootparam.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_bootparam.c
diff -u src/sys/nfs/nfs_bootparam.c:1.38 src/sys/nfs/nfs_bootparam.c:1.39
--- src/sys/nfs/nfs_bootparam.c:1.38	Thu Sep 12 18:00:18 2013
+++ src/sys/nfs/nfs_bootparam.c	Sat Jun 29 17:42:36 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootparam.c,v 1.38 2013/09/12 18:00:18 drochner Exp $	*/
+/*	$NetBSD: nfs_bootparam.c,v 1.39 2019/06/29 17:42:36 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_bootparam.c,v 1.38 2013/09/12 18:00:18 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_bootparam.c,v 1.39 2019/06/29 17:42:36 kamil Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs_boot.h"
@@ -127,6 +127,7 @@ nfs_bootparam(struct nfs_diskless *nd, s
 	}
 
 	error = EADDRNOTAVAIL;
+	memset(_ip, 0, sizeof(arps_ip)); /* GCC */
 #if NARP > 0
 	if (ifp->if_type == IFT_ETHER || ifp->if_type == IFT_FDDI) {
 		/*



CVS commit: src/sys/nfs

2019-06-29 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Jun 29 17:42:36 UTC 2019

Modified Files:
src/sys/nfs: nfs_bootparam.c

Log Message:
Appease GCC and initialize arps_ip

Fixes build as GCC errors with maybe-uninitialized that is a false
positive.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/nfs/nfs_bootparam.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2018-05-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue May  8 16:47:58 UTC 2018

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Use M_MOVE_PKTHDR.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2018-05-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Tue May  8 16:47:58 UTC 2018

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Use M_MOVE_PKTHDR.


To generate a diff of this commit:
cvs rdiff -u -r1.231 -r1.232 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.231 src/sys/nfs/nfs_subs.c:1.232
--- src/sys/nfs/nfs_subs.c:1.231	Thu Apr 26 20:10:44 2018
+++ src/sys/nfs/nfs_subs.c	Tue May  8 16:47:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.231 2018/04/26 20:10:44 maxv Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.232 2018/05/08 16:47:58 maxv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.231 2018/04/26 20:10:44 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.232 2018/05/08 16:47:58 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -942,10 +942,7 @@ nfsm_disct(struct mbuf **mdp, char **dpo
 			*mdp = m1 = m_get(M_WAIT, MT_DATA);
 			MCLAIM(m1, m2->m_owner);
 			if ((m2->m_flags & M_PKTHDR) != 0) {
-/* XXX MOVE */
-M_COPY_PKTHDR(m1, m2);
-m_tag_delete_chain(m2, NULL);
-m2->m_flags &= ~M_PKTHDR;
+M_MOVE_PKTHDR(m1, m2);
 			}
 			if (havebuf) {
 havebuf->m_next = m1;



CVS commit: src/sys/nfs

2018-05-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  3 07:28:44 UTC 2018

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfsrv_readlink: stop attaching a zero-length mbuf for zero length symlinks.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/nfs/nfs_serv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.173 src/sys/nfs/nfs_serv.c:1.174
--- src/sys/nfs/nfs_serv.c:1.173	Wed Apr 26 03:02:49 2017
+++ src/sys/nfs/nfs_serv.c	Thu May  3 07:28:43 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.173 2017/04/26 03:02:49 riastradh Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.174 2018/05/03 07:28:43 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.173 2017/04/26 03:02:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.174 2018/05/03 07:28:43 hannken Exp $");
 
 #include 
 #include 
@@ -600,7 +600,10 @@ out:
 	}
 	len -= uiop->uio_resid;
 	padlen = nfsm_padlen(len);
-	if (uiop->uio_resid || padlen)
+	if (len == 0) {
+		m_freem(mp3);
+		mp3 = NULL;
+	} else if (uiop->uio_resid || padlen)
 		nfs_zeropad(mp3, uiop->uio_resid, padlen);
 	nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED);
 	*tl = txdr_unsigned(len);



CVS commit: src/sys/nfs

2018-05-03 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Thu May  3 07:28:44 UTC 2018

Modified Files:
src/sys/nfs: nfs_serv.c

Log Message:
nfsrv_readlink: stop attaching a zero-length mbuf for zero length symlinks.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/nfs/nfs_serv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 20:10:44 UTC 2018

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Hum. This should be M_READONLY, not M_ROMAP.

M_ROMAP tells us whether the mbuf storage is mapped on a read-only page.
But an mbuf can still be read-only in the sense that the storage is
shared with other mbufs.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.230 src/sys/nfs/nfs_subs.c:1.231
--- src/sys/nfs/nfs_subs.c:1.230	Sun Jan 21 20:36:49 2018
+++ src/sys/nfs/nfs_subs.c	Thu Apr 26 20:10:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.230 2018/01/21 20:36:49 christos Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.231 2018/04/26 20:10:44 maxv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.230 2018/01/21 20:36:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.231 2018/04/26 20:10:44 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -1602,7 +1602,7 @@ nfs_zeropad(struct mbuf *mp, int len, in
 		char *cp;
 		int i;
 
-		if (M_ROMAP(m) || M_TRAILINGSPACE(m) < nul) {
+		if (M_READONLY(m) || M_TRAILINGSPACE(m) < nul) {
 			struct mbuf *n;
 
 			KDASSERT(MLEN >= nul);



CVS commit: src/sys/nfs

2018-04-26 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Thu Apr 26 20:10:44 UTC 2018

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Hum. This should be M_READONLY, not M_ROMAP.

M_ROMAP tells us whether the mbuf storage is mapped on a read-only page.
But an mbuf can still be read-only in the sense that the storage is
shared with other mbufs.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/nfs

2018-01-25 Thread Tom Spindler (moof)
> > Log Message:
> > Use a random opaque cookie, not kva pointer, for nfssvc(2).
> > 
> > (What were they smoking?!)

It looks like most of the code is from the 4.4-Lite merge from mycroft
circa 1994 (!!); I leave it up to the reader to determine what was
being smoked when at Berkeley.

> > I suspect most of this is actually dead code that wasn't properly
> > amputated along with the rest of the gangrene of NFSKERB a decade
> > ago, but I'm out of time to investigate further.  If someone else
> > wants to kill NFSSVC_AUTHIN/NFSSVC_AUTHINFAIL and the rest of the
> > tentacular kerberosity, be my guest.

Alas, I don't remember what moved me to kill the NFSKERB bits in
../usr.sbin/nfsd, but given that the current source still has e.g.

#ifdef NFSKERB
XXX
#else
(void)ktvin.tv_sec;
#endif

in nfs_socket.c, I think it's completely safe and worthwhile to
utterly nuke everything related to the nfs-with-kerb4 code.



Re: CVS commit: src/sys/nfs

2018-01-25 Thread Taylor R Campbell
> Date: Thu, 25 Jan 2018 19:08:16 +0100
> From: Maxime Villard 
> 
> I noticed this issue a long time ago too. While it's clear that this hack was
> utter garbage, it wasn't essentially critical since the path that leads to 
> this
> place is privileged, and basically there's everywhere the assumption that only
> the privileged NFS daemon will invoke these syscalls.

Yes.  But even root shouldn't be allowed to control arbitrary kva
pointers, unless we want to give up on the concept of securelevel>0
altogether.


Re: CVS commit: src/sys/nfs

2018-01-25 Thread Maxime Villard

Le 25/01/2018 à 18:14, Taylor R Campbell a écrit :

Module Name:src
Committed By:   riastradh
Date:   Thu Jan 25 17:14:36 UTC 2018

Modified Files:
src/sys/nfs: nfs.h nfs_syscalls.c

Log Message:
Use a random opaque cookie, not kva pointer, for nfssvc(2).

(What were they smoking?!)

I suspect most of this is actually dead code that wasn't properly
amputated along with the rest of the gangrene of NFSKERB a decade
ago, but I'm out of time to investigate further.  If someone else
wants to kill NFSSVC_AUTHIN/NFSSVC_AUTHINFAIL and the rest of the
tentacular kerberosity, be my guest.


I noticed this issue a long time ago too. While it's clear that this hack was
utter garbage, it wasn't essentially critical since the path that leads to this
place is privileged, and basically there's everywhere the assumption that only
the privileged NFS daemon will invoke these syscalls.


CVS commit: src/sys/nfs

2018-01-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jan 25 17:14:36 UTC 2018

Modified Files:
src/sys/nfs: nfs.h nfs_syscalls.c

Log Message:
Use a random opaque cookie, not kva pointer, for nfssvc(2).

(What were they smoking?!)

I suspect most of this is actually dead code that wasn't properly
amputated along with the rest of the gangrene of NFSKERB a decade
ago, but I'm out of time to investigate further.  If someone else
wants to kill NFSSVC_AUTHIN/NFSSVC_AUTHINFAIL and the rest of the
tentacular kerberosity, be my guest.

Noted by Silvio Cesare of InfoSect.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/nfs/nfs.h
cvs rdiff -u -r1.158 -r1.159 src/sys/nfs/nfs_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs.h
diff -u src/sys/nfs/nfs.h:1.76 src/sys/nfs/nfs.h:1.77
--- src/sys/nfs/nfs.h:1.76	Sun Jan 21 20:36:49 2018
+++ src/sys/nfs/nfs.h	Thu Jan 25 17:14:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.h,v 1.76 2018/01/21 20:36:49 christos Exp $	*/
+/*	$NetBSD: nfs.h,v 1.77 2018/01/25 17:14:36 riastradh Exp $	*/
 /*
  * Copyright (c) 1989, 1993, 1995
  *	The Regents of the University of California.  All rights reserved.
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #endif
 
 /*
@@ -486,7 +487,7 @@ extern int nfssvc_sockhead_flag;
  * One of these structures is allocated for each nfsd.
  */
 struct nfsd {
-	TAILQ_ENTRY(nfsd) nfsd_chain;	/* List of all nfsd's */
+	struct rb_node	nfsd_node;	/* Tree of all nfsd's */
 	SLIST_ENTRY(nfsd) nfsd_idle;	/* List of idle nfsd's */
 	kcondvar_t	nfsd_cv;
 	int		nfsd_flag;	/* NFSD_ flags */
@@ -497,6 +498,7 @@ struct nfsd {
 	u_char		nfsd_verfstr[RPCVERF_MAXSIZ];
 	struct proc	*nfsd_procp;	/* Proc ptr */
 	struct nfsrv_descript *nfsd_nd;	/* Associated nfsrv_descript */
+	uint32_t	nfsd_cookie;	/* Userland cookie, fits 32bit ptr */
 };
 
 /* Bits for "nfsd_flag" */
@@ -557,7 +559,6 @@ struct nfsrv_descript {
 
 extern kmutex_t nfsd_lock;
 extern kcondvar_t nfsd_initcv;
-extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head;
 extern SLIST_HEAD(nfsdidlehead, nfsd) nfsd_idle_head;
 extern int nfsd_head_flag;
 #define	NFSD_CHECKSLP	0x01

Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.158 src/sys/nfs/nfs_syscalls.c:1.159
--- src/sys/nfs/nfs_syscalls.c:1.158	Sun Feb 12 18:24:31 2017
+++ src/sys/nfs/nfs_syscalls.c	Thu Jan 25 17:14:36 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.158 2017/02/12 18:24:31 maxv Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.159 2018/01/25 17:14:36 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.158 2017/02/12 18:24:31 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.159 2018/01/25 17:14:36 riastradh Exp $");
 
 #include 
 #include 
@@ -61,6 +61,8 @@ __KERNEL_RCSID(0, "$NetBSD: nfs_syscalls
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -87,9 +89,11 @@ kmutex_t nfsd_lock;
 struct nfssvc_sockhead nfssvc_sockhead;
 kcondvar_t nfsd_initcv;
 struct nfssvc_sockhead nfssvc_sockpending;
-struct nfsdhead nfsd_head;
 struct nfsdidlehead nfsd_idle_head;
 
+static rb_tree_t nfsd_tree;
+static const rb_tree_ops_t nfsd_tree_ops;
+
 int nfssvc_sockhead_flag;
 int nfsd_head_flag;
 
@@ -102,12 +106,118 @@ static void nfsd_rt(int, struct nfsrv_de
 static int nfssvc_nfsd(struct nfssvc_copy_ops *, struct nfsd_srvargs *, void *,
 		struct lwp *);
 
+static int nfsd_compare_nodes(void *, const void *, const void *);
+static int nfsd_compare_key(void *, const void *, const void *);
+
+static struct nfsd *nfsd_bake_cookie(struct nfsd *);
+static void nfsd_toss_cookie(struct nfsd *);
+static struct nfsd *nfsd_get(struct nfsd *);
+
 static int nfssvc_addsock_in(struct nfsd_args *, const void *);
 static int nfssvc_setexports_in(struct mountd_exports_list *, const void *);
 static int nfssvc_nsd_in(struct nfsd_srvargs *, const void *);
 static int nfssvc_nsd_out(void *, const struct nfsd_srvargs *);
 static int nfssvc_exp_in(struct export_args *, const void *, size_t);
 
+static const rb_tree_ops_t nfsd_tree_ops = {
+	.rbto_compare_nodes = nfsd_compare_nodes,
+	.rbto_compare_key = nfsd_compare_key,
+	.rbto_node_offset = offsetof(struct nfsd, nfsd_node),
+};
+
+static int
+nfsd_compare_nodes(void *cookie, const void *va, const void *vb)
+{
+	const struct nfsd *na = va;
+	const struct nfsd *nb = vb;
+
+	if (na->nfsd_cookie < nb->nfsd_cookie)
+		return -1;
+	if (na->nfsd_cookie > nb->nfsd_cookie)
+		return +1;
+	return 0;
+}
+
+static int
+nfsd_compare_key(void *cookie, const void *vn, const void *vk)
+{
+	const struct nfsd *n = vn;
+	const uint32_t *k = vk;
+
+	if (n->nfsd_cookie < *k)
+		return -1;
+	if (n->nfsd_cookie > *k)
+		return +1;
+	return 0;
+}
+
+/*
+ * nfsd_bake_cookie(nfsd)
+ *
+ *	Bake a cookie for nfsd, hang it on the tree of nfsds, and
+ *	

CVS commit: src/sys/nfs

2018-01-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Jan 25 17:14:36 UTC 2018

Modified Files:
src/sys/nfs: nfs.h nfs_syscalls.c

Log Message:
Use a random opaque cookie, not kva pointer, for nfssvc(2).

(What were they smoking?!)

I suspect most of this is actually dead code that wasn't properly
amputated along with the rest of the gangrene of NFSKERB a decade
ago, but I'm out of time to investigate further.  If someone else
wants to kill NFSSVC_AUTHIN/NFSSVC_AUTHINFAIL and the rest of the
tentacular kerberosity, be my guest.

Noted by Silvio Cesare of InfoSect.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/nfs/nfs.h
cvs rdiff -u -r1.158 -r1.159 src/sys/nfs/nfs_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2018-01-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 21 20:36:50 UTC 2018

Modified Files:
src/sys/nfs: nfs.h nfs_clntsocket.c nfs_socket.c nfs_subs.c

Log Message:
PR/40491: From Tobias Ulmer in tech-kern@:
1. Protect the nfs request queue with its own mutex
2. make the nfs_receive queue check for signals so that intr mounts
   can be interrupted.
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/nfs/nfs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.198 -r1.199 src/sys/nfs/nfs_socket.c
cvs rdiff -u -r1.229 -r1.230 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2018-01-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 21 20:36:50 UTC 2018

Modified Files:
src/sys/nfs: nfs.h nfs_clntsocket.c nfs_socket.c nfs_subs.c

Log Message:
PR/40491: From Tobias Ulmer in tech-kern@:
1. Protect the nfs request queue with its own mutex
2. make the nfs_receive queue check for signals so that intr mounts
   can be interrupted.
XXX: pullup-8


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/nfs/nfs.h
cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.198 -r1.199 src/sys/nfs/nfs_socket.c
cvs rdiff -u -r1.229 -r1.230 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs.h
diff -u src/sys/nfs/nfs.h:1.75 src/sys/nfs/nfs.h:1.76
--- src/sys/nfs/nfs.h:1.75	Mon Apr 20 09:12:24 2015
+++ src/sys/nfs/nfs.h	Sun Jan 21 15:36:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.h,v 1.75 2015/04/20 13:12:24 riastradh Exp $	*/
+/*	$NetBSD: nfs.h,v 1.76 2018/01/21 20:36:49 christos Exp $	*/
 /*
  * Copyright (c) 1989, 1993, 1995
  *	The Regents of the University of California.  All rights reserved.
@@ -341,6 +341,7 @@ struct nfsreq {
  * Queue head for nfsreq's
  */
 extern TAILQ_HEAD(nfsreqhead, nfsreq) nfs_reqq;
+extern kmutex_t nfs_reqq_lock;
 
 /* Flag values for r_flags */
 #define R_TIMING	0x01		/* timing request (in mntp) */

Index: src/sys/nfs/nfs_clntsocket.c
diff -u src/sys/nfs/nfs_clntsocket.c:1.5 src/sys/nfs/nfs_clntsocket.c:1.6
--- src/sys/nfs/nfs_clntsocket.c:1.5	Fri Jun 17 10:28:29 2016
+++ src/sys/nfs/nfs_clntsocket.c	Sun Jan 21 15:36:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsocket.c,v 1.5 2016/06/17 14:28:29 christos Exp $	*/
+/*	$NetBSD: nfs_clntsocket.c,v 1.6 2018/01/21 20:36:49 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.5 2016/06/17 14:28:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.6 2018/01/21 20:36:49 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -294,9 +294,11 @@ errout:
 			rcvflg = 0;
 			error =  (*so->so_receive)(so, getnam, , mp,
 NULL, );
-			if (error == EWOULDBLOCK &&
-			(rep->r_flags & R_SOFTTERM))
-return (EINTR);
+			if (error == EWOULDBLOCK) {
+int intr = nfs_sigintr(rep->r_nmp, rep, l);
+if (intr)
+	error = intr;
+			}
 		} while (error == EWOULDBLOCK);
 		len -= auio.uio_resid;
 		if (!error && *mp == NULL)
@@ -403,6 +405,7 @@ nfsmout:
 		 * Iff no match, just drop the datagram
 		 */
 		s = splsoftnet();
+		mutex_enter(_reqq_lock);
 		TAILQ_FOREACH(rep, _reqq, r_chain) {
 			if (rep->r_mrep != NULL || rxid != rep->r_xid)
 continue;
@@ -468,6 +471,7 @@ nfsmout:
 			nmp->nm_timeouts = 0;
 			break;
 		}
+		mutex_exit(_reqq_lock);
 		splx(s);
 		nfs_rcvunlock(nmp);
 		/*
@@ -653,7 +657,9 @@ tryagain:
 	 * to put it LAST so timer finds oldest requests first.
 	 */
 	s = splsoftnet();
+	mutex_enter(_reqq_lock);
 	TAILQ_INSERT_TAIL(_reqq, rep, r_chain);
+	mutex_exit(_reqq_lock);
 	nfs_timer_start();
 
 	/*
@@ -695,7 +701,9 @@ tryagain:
 	 * RPC done, unlink the request.
 	 */
 	s = splsoftnet();
+	mutex_enter(_reqq_lock);
 	TAILQ_REMOVE(_reqq, rep, r_chain);
+	mutex_exit(_reqq_lock);
 
 	/*
 	 * Decrement the outstanding request count.

Index: src/sys/nfs/nfs_socket.c
diff -u src/sys/nfs/nfs_socket.c:1.198 src/sys/nfs/nfs_socket.c:1.199
--- src/sys/nfs/nfs_socket.c:1.198	Fri Jun 17 10:28:29 2016
+++ src/sys/nfs/nfs_socket.c	Sun Jan 21 15:36:49 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.198 2016/06/17 14:28:29 christos Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.199 2018/01/21 20:36:49 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.198 2016/06/17 14:28:29 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.199 2018/01/21 20:36:49 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -166,6 +166,7 @@ int nfsrtton = 0;  
 struct nfsrtt nfsrtt;
 static const int nfs_backoff[8] = { 2, 4, 8, 16, 32, 64, 128, 256, };
 struct nfsreqhead nfs_reqq;
+kmutex_t nfs_reqq_lock;
 static callout_t nfs_timer_ch;
 static struct evcnt nfs_timer_ev;
 static struct evcnt nfs_timer_start_ev;
@@ -385,6 +386,7 @@ nfs_reconnect(struct nfsreq *rep)
 	 * on old socket.
 	 */
 	s = splsoftnet();
+	mutex_enter(_reqq_lock);
 	TAILQ_FOREACH(rp, _reqq, r_chain) {
 		if (rp->r_nmp == nmp) {
 			if ((rp->r_flags & R_MUSTRESEND) == 0)
@@ -392,6 +394,7 @@ nfs_reconnect(struct nfsreq *rep)
 			rp->r_rexmit = 0;
 		}
 	}
+	mutex_exit(_reqq_lock);
 	splx(s);
 	return (0);
 }
@@ -759,7 +762,7 @@ nfs_timer(void *arg)
 
 	nfs_timer_ev.ev_count++;
 
-	mutex_enter(softnet_lock);	/* XXX PR 40491 */
+	mutex_enter(_reqq_lock);
 	TAILQ_FOREACH(rep, _reqq, r_chain) {
 		more = true;
 		nmp = rep->r_nmp;
@@ -813,7 +816,7 @@ nfs_timer(void 

CVS commit: src/sys/nfs

2017-02-12 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Feb 12 18:24:31 UTC 2017

Modified Files:
src/sys/nfs: nfs_syscalls.c

Log Message:
Memory leak, found by Mootja; not tested, but obvious enough.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/nfs/nfs_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.157 src/sys/nfs/nfs_syscalls.c:1.158
--- src/sys/nfs/nfs_syscalls.c:1.157	Fri Jun 10 13:27:16 2016
+++ src/sys/nfs/nfs_syscalls.c	Sun Feb 12 18:24:31 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.157 2016/06/10 13:27:16 ozaki-r Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.158 2017/02/12 18:24:31 maxv Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.157 2016/06/10 13:27:16 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_syscalls.c,v 1.158 2017/02/12 18:24:31 maxv Exp $");
 
 #include 
 #include 
@@ -325,6 +325,7 @@ do_nfssvc(struct nfssvc_copy_ops *ops, s
 	 M_COPYALL, M_WAIT);
 	break;
 default:
+	kmem_free(nuidp, sizeof(*nuidp));
 	return EAFNOSUPPORT;
 };
 }



CVS commit: src/sys/nfs

2017-02-12 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Feb 12 18:24:31 UTC 2017

Modified Files:
src/sys/nfs: nfs_syscalls.c

Log Message:
Memory leak, found by Mootja; not tested, but obvious enough.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 src/sys/nfs/nfs_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2016-11-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Nov 20 09:28:43 UTC 2016

Modified Files:
src/sys/nfs: nfs_export.c

Log Message:
Memory leak, found by Mootja.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/nfs/nfs_export.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2016-11-20 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Nov 20 09:28:43 UTC 2016

Modified Files:
src/sys/nfs: nfs_export.c

Log Message:
Memory leak, found by Mootja.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/nfs/nfs_export.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_export.c
diff -u src/sys/nfs/nfs_export.c:1.58 src/sys/nfs/nfs_export.c:1.59
--- src/sys/nfs/nfs_export.c:1.58	Sat Dec 14 16:19:28 2013
+++ src/sys/nfs/nfs_export.c	Sun Nov 20 09:28:43 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.58 2013/12/14 16:19:28 christos Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.59 2016/11/20 09:28:43 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.58 2013/12/14 16:19:28 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_export.c,v 1.59 2016/11/20 09:28:43 maxv Exp $");
 
 #include 
 #include 
@@ -541,8 +541,10 @@ hang_addrlist(struct mount *mp, struct n
 		goto out;
 	if (saddr->sa_len > argp->ex_addrlen)
 		saddr->sa_len = argp->ex_addrlen;
-	if (sacheck(saddr) == -1)
-		return EINVAL;
+	if (sacheck(saddr) == -1) {
+		error = EINVAL;
+		goto out;
+	}
 	if (argp->ex_masklen) {
 		smask = (struct sockaddr *)((char *)saddr + argp->ex_addrlen);
 		error = copyin(argp->ex_mask, smask, argp->ex_masklen);
@@ -550,10 +552,14 @@ hang_addrlist(struct mount *mp, struct n
 			goto out;
 		if (smask->sa_len > argp->ex_masklen)
 			smask->sa_len = argp->ex_masklen;
-		if (smask->sa_family != saddr->sa_family)
-			return EINVAL;
-		if (sacheck(smask) == -1)
-			return EINVAL;
+		if (smask->sa_family != saddr->sa_family) {
+			error = EINVAL;
+			goto out;
+		}
+		if (sacheck(smask) == -1) {
+			error = EINVAL;
+			goto out;
+		}
 	}
 	i = saddr->sa_family;
 	if ((rnh = nep->ne_rtable[i]) == 0) {



CVS commit: src/sys/nfs

2016-06-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 17 14:28:29 UTC 2016

Modified Files:
src/sys/nfs: nfs_clntsocket.c nfs_socket.c

Log Message:
Serialize all access to the NFS request queue via splsoftnet(). Fixes random
crashes.
XXX: Pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.197 -r1.198 src/sys/nfs/nfs_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_clntsocket.c
diff -u src/sys/nfs/nfs_clntsocket.c:1.4 src/sys/nfs/nfs_clntsocket.c:1.5
--- src/sys/nfs/nfs_clntsocket.c:1.4	Mon Jun 13 10:23:26 2016
+++ src/sys/nfs/nfs_clntsocket.c	Fri Jun 17 10:28:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsocket.c,v 1.4 2016/06/13 14:23:26 christos Exp $	*/
+/*	$NetBSD: nfs_clntsocket.c,v 1.5 2016/06/17 14:28:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.4 2016/06/13 14:23:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.5 2016/06/17 14:28:29 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -324,7 +324,7 @@ nfs_reply(struct nfsreq *myrep, struct l
 	struct mbuf *mrep, *nam, *md;
 	u_int32_t rxid, *tl;
 	char *dpos, *cp2;
-	int error;
+	int error, s;
 
 	/*
 	 * Loop around until we get our own reply
@@ -402,6 +402,7 @@ nfsmout:
 		 * Loop through the request list to match up the reply
 		 * Iff no match, just drop the datagram
 		 */
+		s = splsoftnet();
 		TAILQ_FOREACH(rep, _reqq, r_chain) {
 			if (rep->r_mrep != NULL || rxid != rep->r_xid)
 continue;
@@ -467,6 +468,7 @@ nfsmout:
 			nmp->nm_timeouts = 0;
 			break;
 		}
+		splx(s);
 		nfs_rcvunlock(nmp);
 		/*
 		 * If not matched to a request, drop it.

Index: src/sys/nfs/nfs_socket.c
diff -u src/sys/nfs/nfs_socket.c:1.197 src/sys/nfs/nfs_socket.c:1.198
--- src/sys/nfs/nfs_socket.c:1.197	Tue Jul 14 23:28:55 2015
+++ src/sys/nfs/nfs_socket.c	Fri Jun 17 10:28:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.197 2015/07/15 03:28:55 manu Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.198 2016/06/17 14:28:29 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.197 2015/07/15 03:28:55 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_socket.c,v 1.198 2016/06/17 14:28:29 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -349,7 +349,7 @@ nfs_reconnect(struct nfsreq *rep)
 {
 	struct nfsreq *rp;
 	struct nfsmount *nmp = rep->r_nmp;
-	int error;
+	int error, s;
 	time_t before_ts;
 
 	nfs_disconnect(nmp);
@@ -384,6 +384,7 @@ nfs_reconnect(struct nfsreq *rep)
 	 * Loop through outstanding request list and fix up all requests
 	 * on old socket.
 	 */
+	s = splsoftnet();
 	TAILQ_FOREACH(rp, _reqq, r_chain) {
 		if (rp->r_nmp == nmp) {
 			if ((rp->r_flags & R_MUSTRESEND) == 0)
@@ -391,6 +392,7 @@ nfs_reconnect(struct nfsreq *rep)
 			rp->r_rexmit = 0;
 		}
 	}
+	splx(s);
 	return (0);
 }
 



CVS commit: src/sys/nfs

2016-06-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 17 14:28:29 UTC 2016

Modified Files:
src/sys/nfs: nfs_clntsocket.c nfs_socket.c

Log Message:
Serialize all access to the NFS request queue via splsoftnet(). Fixes random
crashes.
XXX: Pullup-7


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.197 -r1.198 src/sys/nfs/nfs_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2016-06-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 13 14:23:26 UTC 2016

Modified Files:
src/sys/nfs: nfs_clntsocket.c

Log Message:
Simplify, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/nfs/nfs_clntsocket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_clntsocket.c
diff -u src/sys/nfs/nfs_clntsocket.c:1.3 src/sys/nfs/nfs_clntsocket.c:1.4
--- src/sys/nfs/nfs_clntsocket.c:1.3	Tue Jul 14 23:28:55 2015
+++ src/sys/nfs/nfs_clntsocket.c	Mon Jun 13 10:23:26 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsocket.c,v 1.3 2015/07/15 03:28:55 manu Exp $	*/
+/*	$NetBSD: nfs_clntsocket.c,v 1.4 2016/06/13 14:23:26 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.3 2015/07/15 03:28:55 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_clntsocket.c,v 1.4 2016/06/13 14:23:26 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -403,67 +403,69 @@ nfsmout:
 		 * Iff no match, just drop the datagram
 		 */
 		TAILQ_FOREACH(rep, _reqq, r_chain) {
-			if (rep->r_mrep == NULL && rxid == rep->r_xid) {
-/* Found it.. */
-rep->r_mrep = mrep;
-rep->r_md = md;
-rep->r_dpos = dpos;
-if (nfsrtton) {
-	struct rttl *rt;
-
-	rt = [nfsrtt.pos];
-	rt->proc = rep->r_procnum;
-	rt->rto = NFS_RTO(nmp, nfs_proct[rep->r_procnum]);
-	rt->sent = nmp->nm_sent;
-	rt->cwnd = nmp->nm_cwnd;
-	rt->srtt = nmp->nm_srtt[nfs_proct[rep->r_procnum] - 1];
-	rt->sdrtt = nmp->nm_sdrtt[nfs_proct[rep->r_procnum] - 1];
-	rt->fsid = nmp->nm_mountp->mnt_stat.f_fsidx;
-	getmicrotime(>tstamp);
-	if (rep->r_flags & R_TIMING)
-		rt->rtt = rep->r_rtt;
-	else
-		rt->rtt = 100;
-	nfsrtt.pos = (nfsrtt.pos + 1) % NFSRTTLOGSIZ;
-}
-/*
- * Update congestion window.
- * Do the additive increase of
- * one rpc/rtt.
- */
-if (nmp->nm_cwnd <= nmp->nm_sent) {
-	nmp->nm_cwnd +=
-	   (NFS_CWNDSCALE * NFS_CWNDSCALE +
-	   (nmp->nm_cwnd >> 1)) / nmp->nm_cwnd;
-	if (nmp->nm_cwnd > NFS_MAXCWND)
-		nmp->nm_cwnd = NFS_MAXCWND;
-}
-rep->r_flags &= ~R_SENT;
-nmp->nm_sent -= NFS_CWNDSCALE;
+			if (rep->r_mrep != NULL || rxid != rep->r_xid)
+continue;
+
+			/* Found it.. */
+			rep->r_mrep = mrep;
+			rep->r_md = md;
+			rep->r_dpos = dpos;
+			if (nfsrtton) {
+struct rttl *rt;
+int proct = nfs_proct[rep->r_procnum];
+
+rt = [nfsrtt.pos];
+rt->proc = rep->r_procnum;
+rt->rto = NFS_RTO(nmp, proct);
+rt->sent = nmp->nm_sent;
+rt->cwnd = nmp->nm_cwnd;
+rt->srtt = nmp->nm_srtt[proct - 1];
+rt->sdrtt = nmp->nm_sdrtt[proct - 1];
+rt->fsid = nmp->nm_mountp->mnt_stat.f_fsidx;
+getmicrotime(>tstamp);
+if (rep->r_flags & R_TIMING)
+	rt->rtt = rep->r_rtt;
+else
+	rt->rtt = 100;
+nfsrtt.pos = (nfsrtt.pos + 1) % NFSRTTLOGSIZ;
+			}
+			/*
+			 * Update congestion window.
+			 * Do the additive increase of
+			 * one rpc/rtt.
+			 */
+			if (nmp->nm_cwnd <= nmp->nm_sent) {
+nmp->nm_cwnd +=
+   (NFS_CWNDSCALE * NFS_CWNDSCALE +
+   (nmp->nm_cwnd >> 1)) / nmp->nm_cwnd;
+if (nmp->nm_cwnd > NFS_MAXCWND)
+	nmp->nm_cwnd = NFS_MAXCWND;
+			}
+			rep->r_flags &= ~R_SENT;
+			nmp->nm_sent -= NFS_CWNDSCALE;
+			/*
+			 * Update rtt using a gain of 0.125 on the mean
+			 * and a gain of 0.25 on the deviation.
+			 */
+			if (rep->r_flags & R_TIMING) {
 /*
- * Update rtt using a gain of 0.125 on the mean
- * and a gain of 0.25 on the deviation.
+ * Since the timer resolution of
+ * NFS_HZ is so course, it can often
+ * result in r_rtt == 0. Since
+ * r_rtt == N means that the actual
+ * rtt is between N+dt and N+2-dt ticks,
+ * add 1.
  */
-if (rep->r_flags & R_TIMING) {
-	/*
-	 * Since the timer resolution of
-	 * NFS_HZ is so course, it can often
-	 * result in r_rtt == 0. Since
-	 * r_rtt == N means that the actual
-	 * rtt is between N+dt and N+2-dt ticks,
-	 * add 1.
-	 */
-	t1 = rep->r_rtt + 1;
-	t1 -= (NFS_SRTT(rep) >> 3);
-	NFS_SRTT(rep) += t1;
-	if (t1 < 0)
-		t1 = -t1;
-	t1 -= (NFS_SDRTT(rep) >> 2);
-	NFS_SDRTT(rep) += t1;
-}
-nmp->nm_timeouts = 0;
-break;
+t1 = rep->r_rtt + 1;
+t1 -= (NFS_SRTT(rep) >> 3);
+NFS_SRTT(rep) += t1;
+if (t1 < 0)
+	t1 = -t1;
+t1 -= (NFS_SDRTT(rep) >> 2);
+NFS_SDRTT(rep) += t1;
 			}
+			nmp->nm_timeouts = 0;
+			break;
 		}
 		nfs_rcvunlock(nmp);
 		/*



CVS commit: src/sys/nfs

2016-06-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 13 14:23:26 UTC 2016

Modified Files:
src/sys/nfs: nfs_clntsocket.c

Log Message:
Simplify, no functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/nfs/nfs_clntsocket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2016-01-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jan 19 10:57:00 UTC 2016

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
Return an error if NFSPROC_LOOKUP returns the file handle of the current
directory.  Treating it as DOT lookup would put garbage into the name
cache and could panic on future lookups.

Seen with ZFS file system exported from OmniOS, an OpenSolaris derivative.

Fixes PR kern/50664 "cd .." over NFS/ZFS can panic kernel


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.308 src/sys/nfs/nfs_vnops.c:1.309
--- src/sys/nfs/nfs_vnops.c:1.308	Thu May 14 17:35:54 2015
+++ src/sys/nfs/nfs_vnops.c	Tue Jan 19 10:56:59 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.308 2015/05/14 17:35:54 chs Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.309 2016/01/19 10:56:59 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.308 2015/05/14 17:35:54 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vnops.c,v 1.309 2016/01/19 10:56:59 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_nfs.h"
@@ -954,18 +954,11 @@ dorpc:
 
 	if (NFS_CMPFH(np, fhp, fhsize)) {
 		/*
-		 * as we handle "." lookup locally, this should be
+		 * As we handle "." lookup locally, this is
 		 * a broken server.
 		 */
-		vref(dvp);
-		newvp = dvp;
-#ifndef NFS_V2_ONLY
-		if (v3) {
-			nfsm_postop_attr(newvp, attrflag, 0);
-			nfsm_postop_attr(dvp, attrflag, 0);
-		} else
-#endif
-			nfsm_loadattr(newvp, (struct vattr *)0, 0);
+		m_freem(mrep);
+		return EBADRPC;
 	} else if (flags & ISDOTDOT) {
 		/*
 		 * ".." lookup



CVS commit: src/sys/nfs

2016-01-19 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Jan 19 10:57:00 UTC 2016

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
Return an error if NFSPROC_LOOKUP returns the file handle of the current
directory.  Treating it as DOT lookup would put garbage into the name
cache and could panic on future lookups.

Seen with ZFS file system exported from OmniOS, an OpenSolaris derivative.

Fixes PR kern/50664 "cd .." over NFS/ZFS can panic kernel


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/nfs

2015-11-02 Thread Paul Goyette

On Mon, 2 Nov 2015, Greg Oster wrote:


On Mon, 2 Nov 2015 09:57:43 +
"Paul Goyette"  wrote:


Module Name:src
Committed By:   pgoyette
Date:   Mon Nov  2 09:57:43 UTC 2015

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Don't forget to call nfs_fini() when we're finished.  Without this,
we leave a dangling pool nfsrvdescpl around.


Is this a candidate for pullups? (sounds like a good fix to me! :) )


Considering that this actually fixes (at least) one of my three nasty
module-related issues (see thread on current-users), I think it is an
excellent candidate for pull-up.



+--+--+-+
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:   |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com|
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd.org  |
+--+--+-+


CVS commit: src/sys/nfs

2015-11-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Nov  2 09:57:43 UTC 2015

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Don't forget to call nfs_fini() when we're finished.  Without this,
we leave a dangling pool nfsrvdescpl around.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.230 src/sys/nfs/nfs_vfsops.c:1.231
--- src/sys/nfs/nfs_vfsops.c:1.230	Wed Jul 15 03:28:55 2015
+++ src/sys/nfs/nfs_vfsops.c	Mon Nov  2 09:57:43 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.230 2015/07/15 03:28:55 manu Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.231 2015/11/02 09:57:43 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.230 2015/07/15 03:28:55 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.231 2015/11/02 09:57:43 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -1169,4 +1169,5 @@ nfs_vfs_done(void)
 	nfs_node_done();
 	nfs_kqfini();
 	nfs_iodfini();
+	nfs_fini();
 }



CVS commit: src/sys/nfs

2015-11-02 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Mon Nov  2 09:57:43 UTC 2015

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Don't forget to call nfs_fini() when we're finished.  Without this,
we leave a dangling pool nfsrvdescpl around.


To generate a diff of this commit:
cvs rdiff -u -r1.230 -r1.231 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2015-07-14 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed Jul 15 03:28:55 UTC 2015

Modified Files:
src/sys/nfs: nfs_bio.c nfs_clntsocket.c nfs_iod.c nfs_socket.c
nfs_var.h nfs_vfsops.c nfsmount.h

Log Message:
Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
  force unmount is ongoing. This causes timeouts to be reduced and
  prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.6 -r1.7 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.196 -r1.197 src/sys/nfs/nfs_socket.c
cvs rdiff -u -r1.93 -r1.94 src/sys/nfs/nfs_var.h
cvs rdiff -u -r1.229 -r1.230 src/sys/nfs/nfs_vfsops.c
cvs rdiff -u -r1.52 -r1.53 src/sys/nfs/nfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2015-07-14 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed Jul 15 03:28:55 UTC 2015

Modified Files:
src/sys/nfs: nfs_bio.c nfs_clntsocket.c nfs_iod.c nfs_socket.c
nfs_var.h nfs_vfsops.c nfsmount.h

Log Message:
Fix soft NFS force unmount

For many reasons, forcibly unmounting a soft NFS mount could hang forever.
Here are the fixes:
- Introduce decents timeouts in operation that awaited NFS server reply.
- On timeout, fails operations on soft mounts with EIO.
- Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a
  force unmount is ongoing. This causes timeouts to be reduced and
  prevents the NFS client to attempt reconnecting to the NFS server.

Also fix a race condition where some asynchronous I/O could reference
destroyed mount structures. We fix this by awaiting asynchronous I/O
to drain before proceeding.

Reviewed by Chuck Silvers.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.2 -r1.3 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.6 -r1.7 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.196 -r1.197 src/sys/nfs/nfs_socket.c
cvs rdiff -u -r1.93 -r1.94 src/sys/nfs/nfs_var.h
cvs rdiff -u -r1.229 -r1.230 src/sys/nfs/nfs_vfsops.c
cvs rdiff -u -r1.52 -r1.53 src/sys/nfs/nfsmount.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_bio.c
diff -u src/sys/nfs/nfs_bio.c:1.190 src/sys/nfs/nfs_bio.c:1.191
--- src/sys/nfs/nfs_bio.c:1.190	Fri Sep  5 05:34:57 2014
+++ src/sys/nfs/nfs_bio.c	Wed Jul 15 03:28:55 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.190 2014/09/05 05:34:57 matt Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.191 2015/07/15 03:28:55 manu Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.190 2014/09/05 05:34:57 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.191 2015/07/15 03:28:55 manu Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -624,7 +624,10 @@ nfs_vinvalbuf(struct vnode *vp, int flag
 		slptimeo = 2 * hz;
 	} else {
 		catch_p = false;
-		slptimeo = 0;
+		if (nmp-nm_flag  NFSMNT_SOFT)
+			slptimeo = nmp-nm_retry * nmp-nm_timeo;
+		else
+			slptimeo = 0;
 	}
 	/*
 	 * First wait for any other process doing a flush to complete.
@@ -743,6 +746,13 @@ nfs_asyncio(struct buf *bp)
 		return (EIO);
 
 	nmp = VFSTONFS(bp-b_vp-v_mount);
+
+	if (nmp-nm_flag  NFSMNT_SOFT)
+		slptimeo = nmp-nm_retry * nmp-nm_timeo;
+
+	if (nmp-nm_iflag  NFSMNT_DISMNTFORCE)
+		slptimeo = hz;
+
 again:
 	if (nmp-nm_flag  NFSMNT_INT)
 		catch_p = true;
@@ -804,6 +814,13 @@ again:
 nmp-nm_lock, slptimeo);
 			}
 			if (error) {
+if (error == EWOULDBLOCK 
+nmp-nm_flag  NFSMNT_SOFT) {
+	mutex_exit(nmp-nm_lock);
+	bp-b_error = EIO;
+	return (EIO);
+}
+
 if (nfs_sigintr(nmp, NULL, curlwp)) {
 	mutex_exit(nmp-nm_lock);
 	return (EINTR);

Index: src/sys/nfs/nfs_clntsocket.c
diff -u src/sys/nfs/nfs_clntsocket.c:1.2 src/sys/nfs/nfs_clntsocket.c:1.3
--- src/sys/nfs/nfs_clntsocket.c:1.2	Fri Sep  5 05:34:57 2014
+++ src/sys/nfs/nfs_clntsocket.c	Wed Jul 15 03:28:55 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsocket.c,v 1.2 2014/09/05 05:34:57 matt Exp $	*/
+/*	$NetBSD: nfs_clntsocket.c,v 1.3 2015/07/15 03:28:55 manu Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_clntsocket.c,v 1.2 2014/09/05 05:34:57 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_clntsocket.c,v 1.3 2015/07/15 03:28:55 manu Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -967,6 +967,12 @@ nfs_sndlock(struct nfsmount *nmp, struct
 	bool catch_p = false;
 	int error = 0;
 
+	if (nmp-nm_flag  NFSMNT_SOFT)
+		timeo = nmp-nm_retry * nmp-nm_timeo;
+
+	if (nmp-nm_iflag  NFSMNT_DISMNTFORCE)
+		timeo = hz;
+
 	if (rep) {
 		l = rep-r_lwp;
 		if (rep-r_nmp-nm_flag  NFSMNT_INT)
@@ -980,9 +986,20 @@ nfs_sndlock(struct nfsmount *nmp, struct
 			goto quit;
 		}
 		if (catch_p) {
-			cv_timedwait_sig(nmp-nm_sndcv, nmp-nm_lock, timeo);
+			error = cv_timedwait_sig(nmp-nm_sndcv,
+		 nmp-nm_lock, timeo);
 		} else {
-			cv_timedwait(nmp-nm_sndcv, nmp-nm_lock, timeo);
+			error = cv_timedwait(nmp-nm_sndcv,
+	 nmp-nm_lock, timeo);
+		}
+
+		if (error) {
+			if ((error == EWOULDBLOCK) 
+			(nmp-nm_flag  NFSMNT_SOFT)) {
+error = EIO;
+goto quit;
+			}
+			error = 0;
 		}
 		if (catch_p) {
 			catch_p = false;

Index: src/sys/nfs/nfs_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.6 src/sys/nfs/nfs_iod.c:1.7
--- src/sys/nfs/nfs_iod.c:1.6	Fri Oct 25 16:01:56 2013
+++ src/sys/nfs/nfs_iod.c	Wed Jul 15 03:28:55 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.6 2013/10/25 16:01:56 martin Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.7 2015/07/15 03:28:55 manu Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.6 

CVS commit: src/sys/nfs

2015-05-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu May 14 17:35:54 UTC 2015

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
in nfs_writerpc(), avoid a signed/unsigned problem in computing the
number of bytes to back up in the uio when we need to resend a write RPC
(eg. after a server crash) on a 64-bit platform.  should fix PR 35448.


To generate a diff of this commit:
cvs rdiff -u -r1.307 -r1.308 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.307 src/sys/nfs/nfs_vnops.c:1.308
--- src/sys/nfs/nfs_vnops.c:1.307	Mon Apr 20 23:03:09 2015
+++ src/sys/nfs/nfs_vnops.c	Thu May 14 17:35:54 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.307 2015/04/20 23:03:09 riastradh Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.308 2015/05/14 17:35:54 chs Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.307 2015/04/20 23:03:09 riastradh Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.308 2015/05/14 17:35:54 chs Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1311,7 +1311,7 @@ retry:
 	byte_count = 0; /* count of bytes actually written */
 	while (tsiz  0) {
 		uint32_t datalen; /* data bytes need to be allocated in mbuf */
-		uint32_t backup;
+		size_t backup;
 		bool stalewriteverf = false;
 
 		nfsstats.rpccnt[NFSPROC_WRITE]++;



CVS commit: src/sys/nfs

2015-05-14 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Thu May 14 17:35:54 UTC 2015

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
in nfs_writerpc(), avoid a signed/unsigned problem in computing the
number of bytes to back up in the uio when we need to resend a write RPC
(eg. after a server crash) on a 64-bit platform.  should fix PR 35448.


To generate a diff of this commit:
cvs rdiff -u -r1.307 -r1.308 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2015-05-09 Thread Tyler R. Retzlaff
Module Name:src
Committed By:   rtr
Date:   Sat May  9 18:12:19 UTC 2015

Modified Files:
src/sys/nfs: krpc_subr.c nfs_bootdhcp.c

Log Message:
when calling nfs_boot_sendrecv pass NULL for pointers instead of 0


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/nfs/krpc_subr.c
cvs rdiff -u -r1.53 -r1.54 src/sys/nfs/nfs_bootdhcp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/krpc_subr.c
diff -u src/sys/nfs/krpc_subr.c:1.39 src/sys/nfs/krpc_subr.c:1.40
--- src/sys/nfs/krpc_subr.c:1.39	Fri Mar 27 07:18:11 2015
+++ src/sys/nfs/krpc_subr.c	Sat May  9 18:12:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: krpc_subr.c,v 1.39 2015/03/27 07:18:11 hikaru Exp $	*/
+/*	$NetBSD: krpc_subr.c,v 1.40 2015/05/09 18:12:19 rtr Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon Ross, Adam Glass
@@ -43,7 +43,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: krpc_subr.c,v 1.39 2015/03/27 07:18:11 hikaru Exp $);
+__KERNEL_RCSID(0, $NetBSD: krpc_subr.c,v 1.40 2015/05/09 18:12:19 rtr Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -314,7 +314,7 @@ krpc_call(struct sockaddr_in *sa, u_int 
 	mhead-m_pkthdr.len = len;
 	mhead-m_pkthdr.rcvif = NULL;
 
-	error = nfs_boot_sendrecv(so, nam, 0, mhead, krpccheck, m, from,
+	error = nfs_boot_sendrecv(so, nam, NULL, mhead, krpccheck, m, from,
 	xid, l);
 	if (error)
 		goto out;

Index: src/sys/nfs/nfs_bootdhcp.c
diff -u src/sys/nfs/nfs_bootdhcp.c:1.53 src/sys/nfs/nfs_bootdhcp.c:1.54
--- src/sys/nfs/nfs_bootdhcp.c:1.53	Fri Mar 27 07:18:11 2015
+++ src/sys/nfs/nfs_bootdhcp.c	Sat May  9 18:12:19 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootdhcp.c,v 1.53 2015/03/27 07:18:11 hikaru Exp $	*/
+/*	$NetBSD: nfs_bootdhcp.c,v 1.54 2015/05/09 18:12:19 rtr Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bootdhcp.c,v 1.53 2015/03/27 07:18:11 hikaru Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bootdhcp.c,v 1.54 2015/05/09 18:12:19 rtr Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs_boot.h
@@ -636,7 +636,7 @@ bootpc_call(struct nfs_diskless *nd, str
 #endif
 
 	error = nfs_boot_sendrecv(so, nam, bootpset, m,
-  bootpcheck, 0, 0, bpc, lwp);
+  bootpcheck, NULL, NULL, bpc, lwp);
 	if (error)
 		goto out;
 
@@ -663,7 +663,7 @@ bootpc_call(struct nfs_diskless *nd, str
 		bpc.expected_dhcpmsgtype = DHCPACK;
 
 		error = nfs_boot_sendrecv(so, nam, bootpset, m,
-	  bootpcheck, 0, 0, bpc, lwp);
+	  bootpcheck, NULL, NULL, bpc, lwp);
 		if (error)
 			goto out;
 	}



CVS commit: src/sys/nfs

2015-03-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Mar  6 19:03:30 UTC 2015

Modified Files:
src/sys/nfs: krpc_subr.c

Log Message:
Fix uninitialized variable.

Found by The Brainy Code Scanner in FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/nfs/krpc_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2015-03-06 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Mar  6 19:03:30 UTC 2015

Modified Files:
src/sys/nfs: krpc_subr.c

Log Message:
Fix uninitialized variable.

Found by The Brainy Code Scanner in FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/nfs/krpc_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/krpc_subr.c
diff -u src/sys/nfs/krpc_subr.c:1.37 src/sys/nfs/krpc_subr.c:1.38
--- src/sys/nfs/krpc_subr.c:1.37	Sun Mar 15 17:20:09 2009
+++ src/sys/nfs/krpc_subr.c	Fri Mar  6 19:03:30 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: krpc_subr.c,v 1.37 2009/03/15 17:20:09 cegger Exp $	*/
+/*	$NetBSD: krpc_subr.c,v 1.38 2015/03/06 19:03:30 maxv Exp $	*/
 
 /*
  * Copyright (c) 1995 Gordon Ross, Adam Glass
@@ -43,7 +43,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: krpc_subr.c,v 1.37 2009/03/15 17:20:09 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: krpc_subr.c,v 1.38 2015/03/06 19:03:30 maxv Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -241,7 +241,7 @@ krpc_call(struct sockaddr_in *sa, u_int 
 	 * Create socket and set its receive timeout.
 	 */
 	if ((error = socreate(AF_INET, so, SOCK_DGRAM, 0, l, NULL)))
-		goto out;
+		return error;
 
 	if ((error = nfs_boot_setrecvtimo(so)))
 		goto out;



CVS commit: src/sys/nfs

2014-09-05 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Sep  5 09:22:30 UTC 2014

Modified Files:
src/sys/nfs: nfs_syscalls.c

Log Message:
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/nfs/nfs_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.154 src/sys/nfs/nfs_syscalls.c:1.155
--- src/sys/nfs/nfs_syscalls.c:1.154	Wed Nov 27 22:10:47 2013
+++ src/sys/nfs/nfs_syscalls.c	Fri Sep  5 09:22:30 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.154 2013/11/27 22:10:47 christos Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.155 2014/09/05 09:22:30 matt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.154 2013/11/27 22:10:47 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.155 2014/09/05 09:22:30 matt Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -336,7 +336,7 @@ nfssvc_addsock(file_t *fp, struct mbuf *
 	int error;
 	int val;
 
-	so = (struct socket *)fp-f_data;
+	so = fp-f_socket;
 	tslp = (struct nfssvc_sock *)0;
 	/*
 	 * Add it to the list, as required.
@@ -800,7 +800,7 @@ nfsrv_slpderef(struct nfssvc_sock *slp)
 		if (fp != NULL) {
 			slp-ns_fp = NULL;
 			KASSERT(fp != NULL);
-			KASSERT(fp-f_data == slp-ns_so);
+			KASSERT(fp-f_socket == slp-ns_so);
 			KASSERT(fp-f_count  0);
 			closef(fp);
 			slp-ns_so = NULL;



CVS commit: src/sys/nfs

2014-09-05 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Sep  5 09:22:30 UTC 2014

Modified Files:
src/sys/nfs: nfs_syscalls.c

Log Message:
Try not to use f_data, use f_{vnode,socket,pipe,mqueue,kqueue,ksem} to get
a correctly typed pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 src/sys/nfs/nfs_syscalls.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2014-09-04 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Sep  5 05:34:41 UTC 2014

Modified Files:
src/sys/nfs: nfsrtt.h

Log Message:
Don't nest structure definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/nfs/nfsrtt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfsrtt.h
diff -u src/sys/nfs/nfsrtt.h:1.9 src/sys/nfs/nfsrtt.h:1.10
--- src/sys/nfs/nfsrtt.h:1.9	Thu Dec 28 00:39:03 2006
+++ src/sys/nfs/nfsrtt.h	Fri Sep  5 05:34:41 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsrtt.h,v 1.9 2006/12/28 00:39:03 yamt Exp $	*/
+/*	$NetBSD: nfsrtt.h,v 1.10 2014/09/05 05:34:41 matt Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -52,19 +52,21 @@
  * list goes from nfsrtt.rttl[pos] -- nfsrtt.rttl[pos - 1] in
  * chronological order of completion.
  */
+struct rttl {
+	u_int32_t	proc;			/* NFS procedure number */
+	int		rtt;			/* Measured round trip time */
+	int		rto;			/* Round Trip Timeout */
+	int		sent;			/* # rpcs in progress */
+	int		cwnd;			/* Send window */
+	int		srtt;			/* Ave Round Trip Time */
+	int		sdrtt;			/* Ave mean deviation of RTT */
+	fsid_t		fsid;			/* Fsid for mount point */
+	struct timeval	tstamp;			/* Timestamp of log entry */
+};
+
 struct nfsrtt {
 	int pos;			/* Position in array for next entry */
-	struct rttl {
-		u_int32_t	proc;		/* NFS procedure number */
-		int		rtt;		/* Measured round trip time */
-		int		rto;		/* Round Trip Timeout */
-		int		sent;		/* # rpcs in progress */
-		int		cwnd;		/* Send window */
-		int		srtt;		/* Ave Round Trip Time */
-		int		sdrtt;		/* Ave mean deviation of RTT */
-		fsid_t		fsid;		/* Fsid for mount point */
-		struct timeval	tstamp;	/* Timestamp of log entry */
-	} rttl[NFSRTTLOGSIZ];
+	struct rttl rttl[NFSRTTLOGSIZ];
 };
 
 /*



CVS commit: src/sys/nfs

2014-09-04 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Sep  5 05:34:57 UTC 2014

Modified Files:
src/sys/nfs: nfs_bio.c nfs_clntsocket.c nfs_socket.c

Log Message:
Don't use catch as a variable name.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.1 -r1.2 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.192 -r1.193 src/sys/nfs/nfs_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_bio.c
diff -u src/sys/nfs/nfs_bio.c:1.189 src/sys/nfs/nfs_bio.c:1.190
--- src/sys/nfs/nfs_bio.c:1.189	Mon Aug 12 17:46:38 2013
+++ src/sys/nfs/nfs_bio.c	Fri Sep  5 05:34:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.189 2013/08/12 17:46:38 hannken Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.190 2014/09/05 05:34:57 matt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.189 2013/08/12 17:46:38 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.190 2014/09/05 05:34:57 matt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -615,15 +615,15 @@ nfs_vinvalbuf(struct vnode *vp, int flag
 	struct nfsnode *np = VTONFS(vp);
 	struct nfsmount *nmp = VFSTONFS(vp-v_mount);
 	int error = 0, allerror = 0, slptimeo;
-	bool catch;
+	bool catch_p;
 
 	if ((nmp-nm_flag  NFSMNT_INT) == 0)
 		intrflg = 0;
 	if (intrflg) {
-		catch = true;
+		catch_p = true;
 		slptimeo = 2 * hz;
 	} else {
-		catch = false;
+		catch_p = false;
 		slptimeo = 0;
 	}
 	/*
@@ -645,7 +645,7 @@ nfs_vinvalbuf(struct vnode *vp, int flag
 	 */
 	np-n_flag |= NFLUSHINPROG;
 	mutex_exit(vp-v_interlock);
-	error = vinvalbuf(vp, flags, cred, l, catch, 0);
+	error = vinvalbuf(vp, flags, cred, l, catch_p, 0);
 	while (error) {
 		if (allerror == 0)
 			allerror = error;
@@ -737,7 +737,7 @@ nfs_asyncio(struct buf *bp)
 	struct nfs_iod *iod;
 	struct nfsmount *nmp;
 	int slptimeo = 0, error;
-	bool catch = false;
+	bool catch_p = false;
 
 	if (nfs_numasync == 0)
 		return (EIO);
@@ -745,7 +745,7 @@ nfs_asyncio(struct buf *bp)
 	nmp = VFSTONFS(bp-b_vp-v_mount);
 again:
 	if (nmp-nm_flag  NFSMNT_INT)
-		catch = true;
+		catch_p = true;
 
 	/*
 	 * Find a free iod to process this request.
@@ -796,7 +796,7 @@ again:
 		if (curlwp == uvm.pagedaemon_lwp) {
 	  		/* Enque for later, to avoid free-page deadlock */
 		} else while (nmp-nm_bufqlen = 2 * nmp-nm_bufqiods) {
-			if (catch) {
+			if (catch_p) {
 error = cv_timedwait_sig(nmp-nm_aiocv,
 nmp-nm_lock, slptimeo);
 			} else {
@@ -808,8 +808,8 @@ again:
 	mutex_exit(nmp-nm_lock);
 	return (EINTR);
 }
-if (catch) {
-	catch = false;
+if (catch_p) {
+	catch_p = false;
 	slptimeo = 2 * hz;
 }
 			}

Index: src/sys/nfs/nfs_clntsocket.c
diff -u src/sys/nfs/nfs_clntsocket.c:1.1 src/sys/nfs/nfs_clntsocket.c:1.2
--- src/sys/nfs/nfs_clntsocket.c:1.1	Tue Mar  2 23:19:09 2010
+++ src/sys/nfs/nfs_clntsocket.c	Fri Sep  5 05:34:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_clntsocket.c,v 1.1 2010/03/02 23:19:09 pooka Exp $	*/
+/*	$NetBSD: nfs_clntsocket.c,v 1.2 2014/09/05 05:34:57 matt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_clntsocket.c,v 1.1 2010/03/02 23:19:09 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_clntsocket.c,v 1.2 2014/09/05 05:34:57 matt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -964,13 +964,13 @@ nfs_sndlock(struct nfsmount *nmp, struct
 {
 	struct lwp *l;
 	int timeo = 0;
-	bool catch = false;
+	bool catch_p = false;
 	int error = 0;
 
 	if (rep) {
 		l = rep-r_lwp;
 		if (rep-r_nmp-nm_flag  NFSMNT_INT)
-			catch = true;
+			catch_p = true;
 	} else
 		l = NULL;
 	mutex_enter(nmp-nm_lock);
@@ -979,13 +979,13 @@ nfs_sndlock(struct nfsmount *nmp, struct
 			error = EINTR;
 			goto quit;
 		}
-		if (catch) {
+		if (catch_p) {
 			cv_timedwait_sig(nmp-nm_sndcv, nmp-nm_lock, timeo);
 		} else {
 			cv_timedwait(nmp-nm_sndcv, nmp-nm_lock, timeo);
 		}
-		if (catch) {
-			catch = false;
+		if (catch_p) {
+			catch_p = false;
 			timeo = 2 * hz;
 		}
 	}

Index: src/sys/nfs/nfs_socket.c
diff -u src/sys/nfs/nfs_socket.c:1.192 src/sys/nfs/nfs_socket.c:1.193
--- src/sys/nfs/nfs_socket.c:1.192	Tue Aug  5 07:55:32 2014
+++ src/sys/nfs/nfs_socket.c	Fri Sep  5 05:34:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.192 2014/08/05 07:55:32 rtr Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.193 2014/09/05 05:34:57 matt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.192 2014/08/05 07:55:32 rtr Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.193 2014/09/05 05:34:57 matt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -889,12 +889,12 @@ nfs_rcvlock(struct nfsmount *nmp, struct
 {
 	int *flagp = nmp-nm_iflag;
 	int slptimeo = 0;
-	bool 

CVS commit: src/sys/nfs

2014-09-04 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Sep  5 05:34:41 UTC 2014

Modified Files:
src/sys/nfs: nfsrtt.h

Log Message:
Don't nest structure definitions.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/nfs/nfsrtt.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2014-09-04 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Fri Sep  5 05:34:57 UTC 2014

Modified Files:
src/sys/nfs: nfs_bio.c nfs_clntsocket.c nfs_socket.c

Log Message:
Don't use catch as a variable name.


To generate a diff of this commit:
cvs rdiff -u -r1.189 -r1.190 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.1 -r1.2 src/sys/nfs/nfs_clntsocket.c
cvs rdiff -u -r1.192 -r1.193 src/sys/nfs/nfs_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2014-07-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sat Jul  5 09:33:41 UTC 2014

Modified Files:
src/sys/nfs: nfs_vnops.c

Log Message:
Use vcache_rekey_* for nfs_lookitup() in the *npp != NULL case.


To generate a diff of this commit:
cvs rdiff -u -r1.304 -r1.305 src/sys/nfs/nfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2014-05-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri May 30 08:47:45 UTC 2014

Modified Files:
src/sys/nfs: nfs_node.c nfs_var.h nfs_vfsops.c nfsmount.h nfsnode.h

Log Message:
Change NFS from rbtree to vcache.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/nfs/nfs_node.c
cvs rdiff -u -r1.91 -r1.92 src/sys/nfs/nfs_var.h
cvs rdiff -u -r1.228 -r1.229 src/sys/nfs/nfs_vfsops.c
cvs rdiff -u -r1.51 -r1.52 src/sys/nfs/nfsmount.h
cvs rdiff -u -r1.72 -r1.73 src/sys/nfs/nfsnode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_node.c
diff -u src/sys/nfs/nfs_node.c:1.117 src/sys/nfs/nfs_node.c:1.118
--- src/sys/nfs/nfs_node.c:1.117	Thu Feb 27 16:51:38 2014
+++ src/sys/nfs/nfs_node.c	Fri May 30 08:47:45 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_node.c,v 1.117 2014/02/27 16:51:38 hannken Exp $	*/
+/*	$NetBSD: nfs_node.c,v 1.118 2014/05/30 08:47:45 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_node.c,v 1.117 2014/02/27 16:51:38 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_node.c,v 1.118 2014/05/30 08:47:45 hannken Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -106,120 +106,36 @@ nfs_node_done(void)
 	workqueue_destroy(nfs_sillyworkq);
 }
 
-struct fh_match {
-	nfsfh_t *fhm_fhp;
-	size_t fhm_fhsize;
-	size_t fhm_fhoffset;
-};
-
-static int
-nfs_compare_nodes(void *ctx, const void *parent, const void *node)
-{
-	const struct nfsnode * const pnp = parent;
-	const struct nfsnode * const np = node;
-
-	if (pnp-n_fhsize != np-n_fhsize)
-		return np-n_fhsize - pnp-n_fhsize;
-
-	return memcmp(np-n_fhp, pnp-n_fhp, np-n_fhsize);
-}
-
-static int
-nfs_compare_node_fh(void *ctx, const void *b, const void *key)
-{
-	const struct nfsnode * const pnp = b;
-	const struct fh_match * const fhm = key;
-
-	if (pnp-n_fhsize != fhm-fhm_fhsize)
-		return fhm-fhm_fhsize - pnp-n_fhsize;
-
-	return memcmp(fhm-fhm_fhp, pnp-n_fhp, pnp-n_fhsize);
-}
-
-static const rb_tree_ops_t nfs_node_rbtree_ops = {
-	.rbto_compare_nodes = nfs_compare_nodes,
-	.rbto_compare_key = nfs_compare_node_fh,
-	.rbto_node_offset = offsetof(struct nfsnode, n_rbnode),
-	.rbto_context = NULL
-};
-
-void
-nfs_rbtinit(struct nfsmount *nmp)
-{
-
-	rb_tree_init(nmp-nm_rbtree, nfs_node_rbtree_ops);
-}
-
 /*
- * Look up a vnode/nfsnode by file handle.
- * Callers must check for mount points!!
- * In all cases, a pointer to a
- * nfsnode structure is returned.
+ * Initialize this vnode / nfs node pair.
+ * Caller assures no other thread will try to load this node.
  */
 int
-nfs_nget1(struct mount *mntp, nfsfh_t *fhp, int fhsize, struct nfsnode **npp,
-int lkflags)
+nfs_loadvnode(struct mount *mp, struct vnode *vp,
+const void *key, size_t key_len, const void **new_key)
 {
+	int fhsize = key_len;
+	const nfsfh_t *fhp = key;
 	struct nfsnode *np;
-	struct vnode *vp;
-	struct nfsmount *nmp = VFSTONFS(mntp);
-	int error;
-	struct fh_match fhm;
-
-	fhm.fhm_fhp = fhp;
-	fhm.fhm_fhsize = fhsize;
 
-loop:
-	rw_enter(nmp-nm_rbtlock, RW_READER);
-	np = rb_tree_find_node(nmp-nm_rbtree, fhm);
-	if (np != NULL) {
-		vp = NFSTOV(np);
-		mutex_enter(vp-v_interlock);
-		rw_exit(nmp-nm_rbtlock);
-		error = vget(vp, LK_EXCLUSIVE | lkflags);
-		if (error == EBUSY)
-			return error;
-		if (error)
-			goto loop;
-		*npp = np;
-		return(0);
-	}
-	rw_exit(nmp-nm_rbtlock);
-
-	error = getnewvnode(VT_NFS, mntp, nfsv2_vnodeop_p, NULL, vp);
-	if (error) {
-		*npp = 0;
-		return (error);
-	}
+	/* Aloocate and initialize the nfsnode. */
 	np = pool_get(nfs_node_pool, PR_WAITOK);
 	memset(np, 0, sizeof *np);
-	np-n_vnode = vp;
-
-	/*
-	 * Insert the nfsnode in the hash queue for its new file handle
-	 */
-
 	if (fhsize  NFS_SMALLFH) {
 		np-n_fhp = kmem_alloc(fhsize, KM_SLEEP);
 	} else
 		np-n_fhp = np-n_fh;
+	vp-v_tag = VT_NFS;
+	vp-v_type = VNON;
+	vp-v_op = nfsv2_vnodeop_p;
+	vp-v_data = np;
 	memcpy(np-n_fhp, fhp, fhsize);
 	np-n_fhsize = fhsize;
 	np-n_accstamp = -1;
 	np-n_vattr = pool_get(nfs_vattr_pool, PR_WAITOK);
+	np-n_vnode = vp;
 
-	rw_enter(nmp-nm_rbtlock, RW_WRITER);
-	if (NULL != rb_tree_find_node(nmp-nm_rbtree, fhm)) {
-		rw_exit(nmp-nm_rbtlock);
-		if (fhsize  NFS_SMALLFH) {
-			kmem_free(np-n_fhp, fhsize);
-		}
-		pool_put(nfs_vattr_pool, np-n_vattr);
-		pool_put(nfs_node_pool, np);
-		ungetnewvnode(vp);
-		goto loop;
-	}
-	vp-v_data = np;
+	/* Initialize genfs node. */
 	genfs_node_init(vp, nfs_genfsops);
 	/*
 	 * Initalize read/write creds to useful values. VOP_OPEN will
@@ -229,15 +145,35 @@ loop:
 	kauth_cred_hold(np-n_rcred);
 	np-n_wcred = curlwp-l_cred;
 	kauth_cred_hold(np-n_wcred);
-	error = VOP_LOCK(vp, LK_EXCLUSIVE);
-	KASSERT(error == 0);
 	NFS_INVALIDATE_ATTRCACHE(np);
 	uvm_vnp_setsize(vp, 0);
-	(void)rb_tree_insert_node(nmp-nm_rbtree, np);
-	rw_exit(nmp-nm_rbtlock);
+	*new_key = np-n_fhp;
+	return 0;
+}
 
-	*npp = np;
-	return 

CVS commit: src/sys/nfs

2014-05-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri May 30 08:47:45 UTC 2014

Modified Files:
src/sys/nfs: nfs_node.c nfs_var.h nfs_vfsops.c nfsmount.h nfsnode.h

Log Message:
Change NFS from rbtree to vcache.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sys/nfs/nfs_node.c
cvs rdiff -u -r1.91 -r1.92 src/sys/nfs/nfs_var.h
cvs rdiff -u -r1.228 -r1.229 src/sys/nfs/nfs_vfsops.c
cvs rdiff -u -r1.51 -r1.52 src/sys/nfs/nfsmount.h
cvs rdiff -u -r1.72 -r1.73 src/sys/nfs/nfsnode.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2014-04-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 24 18:43:02 UTC 2014

Modified Files:
src/sys/nfs: nfs.h

Log Message:
PR/48426: Dimitris Karagkasidis: Convert to sized, unsigned types.
Ideally we could use uint64_t, but for compatibility and performance
we don't (for now)


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/nfs/nfs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/nfs

2014-03-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 17 09:34:51 UTC 2014

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Change nfs_sync() to use vfs_vnode_iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.224 src/sys/nfs/nfs_vfsops.c:1.225
--- src/sys/nfs/nfs_vfsops.c:1.224	Tue Feb 25 18:30:12 2014
+++ src/sys/nfs/nfs_vfsops.c	Mon Mar 17 09:34:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.224 2014/02/25 18:30:12 pooka Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.225 2014/03/17 09:34:51 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.224 2014/02/25 18:30:12 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.225 2014/03/17 09:34:51 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_nfs.h
@@ -945,51 +945,33 @@ extern int syncprt;
 int
 nfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
 {
-	struct vnode *vp, *mvp;
+	struct vnode *vp;
+	struct vnode_iterator *marker;
 	int error, allerror = 0;
 
 	/*
 	 * Force stale buffer cache information to be flushed.
 	 */
-	mvp = vnalloc(mp);
-loop:
-	/*
-	 * NOTE: not using the TAILQ_FOREACH here since in this loop vgone()
-	 * and vclean() can be called indirectly
-	 */
-	mutex_enter(mntvnode_lock);
-	for (vp = TAILQ_FIRST(mp-mnt_vnodelist); vp; vp = vunmark(mvp)) {
-		vmark(mvp, vp);
-		if (vp-v_mount != mp || vismarker(vp))
-			continue;
-		mutex_enter(vp-v_interlock);
-		/* XXX MNT_LAZY cannot be right? */
-		if (waitfor == MNT_LAZY ||
-		(LIST_EMPTY(vp-v_dirtyblkhd) 
-		 UVM_OBJ_IS_CLEAN(vp-v_uobj))) {
-			mutex_exit(vp-v_interlock);
+	vfs_vnode_iterator_init(mp, marker);
+	while (vfs_vnode_iterator_next(marker, vp)) {
+		error = vn_lock(vp, LK_EXCLUSIVE);
+		if (error) {
+			vrele(vp);
 			continue;
 		}
-		mutex_exit(mntvnode_lock);
-		error = vget(vp, LK_EXCLUSIVE | LK_NOWAIT);
-		if (error != 0) {
-			if (error != ENOENT) {
-mutex_enter(mntvnode_lock);
-continue;
-			}
-			(void)vunmark(mvp);
-			goto loop;
+		if (LIST_EMPTY(vp-v_dirtyblkhd) 
+		UVM_OBJ_IS_CLEAN(vp-v_uobj)) {
+			vput(vp);
+			continue;
 		}
 		error = VOP_FSYNC(vp, cred,
 		waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0);
 		if (error)
 			allerror = error;
 		vput(vp);
-		mutex_enter(mntvnode_lock);
 	}
-	mutex_exit(mntvnode_lock);
-	vnfree(mvp);
-	return (allerror);
+	vfs_vnode_iterator_destroy(marker);
+	return allerror;
 }
 
 /*



CVS commit: src/sys/nfs

2014-03-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 17 09:35:24 UTC 2014

Modified Files:
src/sys/nfs: nfs_subs.c

Log Message:
Change nfs_clearcommit() to use vfs_vnode_iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/nfs/nfs_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/nfs/nfs_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.224 src/sys/nfs/nfs_subs.c:1.225
--- src/sys/nfs/nfs_subs.c:1.224	Wed Sep 18 23:27:38 2013
+++ src/sys/nfs/nfs_subs.c	Mon Mar 17 09:35:24 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.224 2013/09/18 23:27:38 pgoyette Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.225 2014/03/17 09:35:24 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.224 2013/09/18 23:27:38 pgoyette Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.225 2014/03/17 09:35:24 hannken Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1754,22 +1754,21 @@ void
 nfs_clearcommit(struct mount *mp)
 {
 	struct vnode *vp;
+	struct vnode_iterator *marker;
 	struct nfsnode *np;
 	struct vm_page *pg;
 	struct nfsmount *nmp = VFSTONFS(mp);
 
 	rw_enter(nmp-nm_writeverflock, RW_WRITER);
-	mutex_enter(mntvnode_lock);
-	TAILQ_FOREACH(vp, mp-mnt_vnodelist, v_mntvnodes) {
-		KASSERT(vp-v_mount == mp);
-		if (vp-v_type != VREG)
-			continue;
+	vfs_vnode_iterator_init(mp, marker);
+	while (vfs_vnode_iterator_next(marker, vp)) {
 		mutex_enter(vp-v_interlock);
-		if (vp-v_iflag  (VI_XLOCK | VI_CLEAN)) {
+		np = VTONFS(vp);
+		if (vp-v_type != VREG || vp-v_mount != mp || np == NULL) {
 			mutex_exit(vp-v_interlock);
+			vrele(vp);
 			continue;
 		}
-		np = VTONFS(vp);
 		np-n_pushlo = np-n_pushhi = np-n_pushedlo =
 		np-n_pushedhi = 0;
 		np-n_commitflags =
@@ -1778,8 +1777,9 @@ nfs_clearcommit(struct mount *mp)
 			pg-flags = ~PG_NEEDCOMMIT;
 		}
 		mutex_exit(vp-v_interlock);
+		vrele(vp);
 	}
-	mutex_exit(mntvnode_lock);
+	vfs_vnode_iterator_destroy(marker);
 	mutex_enter(nmp-nm_lock);
 	nmp-nm_iflag = ~NFSMNT_STALEWRITEVERF;
 	mutex_exit(nmp-nm_lock);



CVS commit: src/sys/nfs

2014-03-17 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Mar 17 09:34:51 UTC 2014

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Change nfs_sync() to use vfs_vnode_iterator.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/sys/nfs/nfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   3   >