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-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-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-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-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-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-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: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

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-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-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-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

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-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-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

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-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-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.

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-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-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-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

2013-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 14 16:19:28 UTC 2013

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

Log Message:
don't allow the nfs server module to unload if it has exported filesystems.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/nfs/nfs_export.c
cvs rdiff -u -r1.166 -r1.167 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.90 -r1.91 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_export.c
diff -u src/sys/nfs/nfs_export.c:1.57 src/sys/nfs/nfs_export.c:1.58
--- src/sys/nfs/nfs_export.c:1.57	Sat Nov 23 09:20:46 2013
+++ src/sys/nfs/nfs_export.c	Sat Dec 14 11:19:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.57 2013/11/23 14:20:46 christos Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.58 2013/12/14 16:19:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.57 2013/11/23 14:20:46 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.58 2013/12/14 16:19:28 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -877,3 +877,10 @@ netexport_wrunlock(void)
 
 	rw_exit(netexport_lock);
 }
+
+bool
+netexport_hasexports(void)
+{
+	
+	return nfs_pub.np_valid || !TAILQ_EMPTY(netexport_list);
+}

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.166 src/sys/nfs/nfs_serv.c:1.167
--- src/sys/nfs/nfs_serv.c:1.166	Sat Sep 14 18:29:08 2013
+++ src/sys/nfs/nfs_serv.c	Sat Dec 14 11:19:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -125,6 +125,8 @@ nfsserver_modcmd(modcmd_t cmd, void *arg
 		nfs_timer_srvinit(nfsrv_timer);
 		return 0;
 	case MODULE_CMD_FINI:
+		if (netexport_hasexports())
+			return EBUSY;
 		error = syscall_disestablish(NULL, nfsserver_syscalls);
 		if (error != 0) {
 			return error;

Index: src/sys/nfs/nfs_var.h
diff -u src/sys/nfs/nfs_var.h:1.90 src/sys/nfs/nfs_var.h:1.91
--- src/sys/nfs/nfs_var.h:1.90	Tue Mar  2 18:19:09 2010
+++ src/sys/nfs/nfs_var.h	Sat Dec 14 11:19:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_var.h,v 1.90 2010/03/02 23:19:09 pooka Exp $	*/
+/*	$NetBSD: nfs_var.h,v 1.91 2013/12/14 16:19:28 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -349,4 +349,5 @@ void netexport_rdlock(void);
 void netexport_rdunlock(void);
 void netexport_init(void);
 void netexport_fini(void);
+bool netexport_hasexports(void);
 #endif /* _KERNEL */



CVS commit: src/sys/nfs

2013-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 14 22:04:03 UTC 2013

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

Log Message:
only prevent autounload, not regular unload when we have exports


To generate a diff of this commit:
cvs rdiff -u -r1.167 -r1.168 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.167 src/sys/nfs/nfs_serv.c:1.168
--- src/sys/nfs/nfs_serv.c:1.167	Sat Dec 14 11:19:28 2013
+++ src/sys/nfs/nfs_serv.c	Sat Dec 14 17:04:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.168 2013/12/14 22:04:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.168 2013/12/14 22:04:03 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -125,8 +125,6 @@ nfsserver_modcmd(modcmd_t cmd, void *arg
 		nfs_timer_srvinit(nfsrv_timer);
 		return 0;
 	case MODULE_CMD_FINI:
-		if (netexport_hasexports())
-			return EBUSY;
 		error = syscall_disestablish(NULL, nfsserver_syscalls);
 		if (error != 0) {
 			return error;
@@ -146,6 +144,10 @@ nfsserver_modcmd(modcmd_t cmd, void *arg
 		nfsrv_finicache();
 		nfs_fini();
 		return 0;
+	case MODULE_CMD_AUTOUNLOAD:
+		if (netexport_hasexports())
+			return EBUSY;
+		/*FALLTHROUGH*/
 	default:
 		return ENOTTY;
 	}



CVS commit: src/sys/nfs

2013-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 27 22:10:47 UTC 2013

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

Log Message:
CID 271162: NULL deref check


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 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.153 src/sys/nfs/nfs_syscalls.c:1.154
--- src/sys/nfs/nfs_syscalls.c:1.153	Thu Dec 31 15:01:33 2009
+++ src/sys/nfs/nfs_syscalls.c	Wed Nov 27 17:10:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.153 2009/12/31 20:01:33 christos Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.154 2013/11/27 22:10:47 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.153 2009/12/31 20:01:33 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.154 2013/11/27 22:10:47 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -609,14 +609,19 @@ nfssvc_nfsd(struct nfsd_srvargs *nsd, vo
 }
 if (error) {
 	nfsstats.srv_errs++;
-	nfsrv_updatecache(nd, false, mreq);
-	if (nd-nd_nam2)
-		m_freem(nd-nd_nam2);
+	if (nd) {
+		nfsrv_updatecache(nd, false,
+		mreq);
+		if (nd-nd_nam2)
+			m_freem(nd-nd_nam2);
+	}
 	break;
 }
-nfsstats.srvrpccnt[nd-nd_procnum]++;
-nfsrv_updatecache(nd, true, mreq);
-nd-nd_mrep = (struct mbuf *)0;
+if (nd) {
+	nfsstats.srvrpccnt[nd-nd_procnum]++;
+	nfsrv_updatecache(nd, true, mreq);
+	nd-nd_mrep = NULL;
+}
 			case RC_REPLY:
 m = mreq;
 siz = 0;
@@ -640,13 +645,15 @@ nfssvc_nfsd(struct nfsd_srvargs *nsd, vo
 	*mtod(m, u_int32_t *) =
 	htonl(0x8000 | siz);
 }
-nd-nd_mreq = m;
-if (nfsrtton) {
-	nfsd_rt(slp-ns_so-so_type, nd,
-	cacherep);
+if (nd) {
+	nd-nd_mreq = m;
+	if (nfsrtton) {
+		nfsd_rt(slp-ns_so-so_type, nd,
+		cacherep);
+	}
+	error = nfsdsock_sendreply(slp, nd);
+	nd = NULL;
 }
-error = nfsdsock_sendreply(slp, nd);
-nd = NULL;
 if (error == EPIPE)
 	nfsrv_zapsock(slp);
 if (error == EINTR || error == ERESTART) {
@@ -656,10 +663,12 @@ nfssvc_nfsd(struct nfsd_srvargs *nsd, vo
 }
 break;
 			case RC_DROPIT:
-if (nfsrtton)
-	nfsd_rt(sotype, nd, cacherep);
-m_freem(nd-nd_mrep);
-m_freem(nd-nd_nam2);
+if (nd) {
+	if (nfsrtton)
+		nfsd_rt(sotype, nd, cacherep);
+	m_freem(nd-nd_mrep);
+	m_freem(nd-nd_nam2);
+}
 break;
 			}
 			if (nd) {



CVS commit: src/sys/nfs

2013-11-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 23 14:20:46 UTC 2013

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

Log Message:
convert from CIRCLEQ to TAILQ


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 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.56 src/sys/nfs/nfs_export.c:1.57
--- src/sys/nfs/nfs_export.c:1.56	Sun Sep 15 09:03:59 2013
+++ src/sys/nfs/nfs_export.c	Sat Nov 23 09:20:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.56 2013/09/15 13:03:59 martin Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.57 2013/11/23 14:20:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.56 2013/09/15 13:03:59 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.57 2013/11/23 14:20:46 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -118,13 +118,13 @@ struct netcred {
  * Network export information.
  */
 struct netexport {
-	CIRCLEQ_ENTRY(netexport) ne_list;
+	TAILQ_ENTRY(netexport) ne_list;
 	struct mount *ne_mount;
 	struct netcred ne_defexported;		  /* Default export */
 	struct radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */
 };
-CIRCLEQ_HEAD(, netexport) netexport_list =
-CIRCLEQ_HEAD_INITIALIZER(netexport_list);
+TAILQ_HEAD(, netexport) netexport_list =
+TAILQ_HEAD_INITIALIZER(netexport_list);
 
 /* Publicly exported file system. */
 struct nfs_public nfs_pub;
@@ -207,9 +207,9 @@ netexport_fini(void)
 	struct mount *mp;
 	int error;
 
-	while (!CIRCLEQ_EMPTY(netexport_list)) {
+	while (!TAILQ_EMPTY(netexport_list)) {
 		netexport_wrlock();
-		ne = CIRCLEQ_FIRST(netexport_list);
+		ne = TAILQ_FIRST(netexport_list);
 		mp = ne-ne_mount;
 		error = vfs_busy(mp, NULL);
 		netexport_wrunlock();
@@ -340,14 +340,14 @@ static void
 netexport_insert(struct netexport *ne)
 {
 
-	CIRCLEQ_INSERT_HEAD(netexport_list, ne, ne_list);
+	TAILQ_INSERT_HEAD(netexport_list, ne, ne_list);
 }
 
 static void
 netexport_remove(struct netexport *ne)
 {
 
-	CIRCLEQ_REMOVE(netexport_list, ne, ne_list);
+	TAILQ_REMOVE(netexport_list, ne, ne_list);
 }
 
 static struct netexport *
@@ -355,7 +355,7 @@ netexport_lookup(const struct mount *mp)
 {
 	struct netexport *ne;
 
-	CIRCLEQ_FOREACH(ne, netexport_list, ne_list) {
+	TAILQ_FOREACH(ne, netexport_list, ne_list) {
 		if (ne-ne_mount == mp) {
 			goto done;
 		}
@@ -370,7 +370,7 @@ netexport_lookup_byfsid(const fsid_t *fs
 {
 	struct netexport *ne;
 
-	CIRCLEQ_FOREACH(ne, netexport_list, ne_list) {
+	TAILQ_FOREACH(ne, netexport_list, ne_list) {
 		const struct mount *mp = ne-ne_mount;
 
 		if (mp-mnt_stat.f_fsidx.__fsid_val[0] == fsid-__fsid_val[0] 



CVS commit: src/sys/nfs

2013-11-15 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Nov 15 14:39:53 UTC 2013

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

Log Message:
add one more __unused attribute to shut gcc4.8 off.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 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.300 src/sys/nfs/nfs_vnops.c:1.301
--- src/sys/nfs/nfs_vnops.c:1.300	Sat Sep 14 22:29:08 2013
+++ src/sys/nfs/nfs_vnops.c	Fri Nov 15 14:39:53 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.300 2013/09/14 22:29:08 martin Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.301 2013/11/15 14:39:53 nisimura Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.300 2013/09/14 22:29:08 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.301 2013/11/15 14:39:53 nisimura Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1164,7 +1164,7 @@ nfs_readrpc(struct vnode *vp, struct uio
 	char *bpos, *dpos, *cp2;
 	struct mbuf *mreq, *mrep, *md, *mb;
 	struct nfsmount *nmp;
-	int error = 0, len, retlen, tsiz, eof, byte_count;
+	int error = 0, len, retlen, tsiz, eof __unused, byte_count;
 	const int v3 = NFS_ISV3(vp);
 	struct nfsnode *np = VTONFS(vp);
 #ifndef NFS_V2_ONLY



CVS commit: src/sys/nfs

2013-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 25 16:01:56 UTC 2013

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

Log Message:
Mark a diagnostic-only variable


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/nfs/nfs_iod.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_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.5 src/sys/nfs/nfs_iod.c:1.6
--- src/sys/nfs/nfs_iod.c:1.5	Sat Sep 14 21:17:00 2013
+++ src/sys/nfs/nfs_iod.c	Fri Oct 25 16:01:56 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.5 2013/09/14 21:17:00 martin Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.6 2013/10/25 16:01:56 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.5 2013/09/14 21:17:00 martin Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.6 2013/10/25 16:01:56 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -194,7 +194,7 @@ nfs_iodinit(void)
 void
 nfs_iodfini(void)
 {
-	int error;
+	int error __diagused;
 
 	error = nfs_set_niothreads(0);
 	KASSERT(error == 0);



CVS commit: src/sys/nfs

2013-10-25 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct 25 20:46:29 UTC 2013

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

Log Message:
Mark a potentially unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/nfs/nfs_boot.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_boot.c
diff -u src/sys/nfs/nfs_boot.c:1.80 src/sys/nfs/nfs_boot.c:1.81
--- src/sys/nfs/nfs_boot.c:1.80	Mon Oct  4 23:48:22 2010
+++ src/sys/nfs/nfs_boot.c	Fri Oct 25 20:46:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_boot.c,v 1.80 2010/10/04 23:48:22 cyber Exp $	*/
+/*	$NetBSD: nfs_boot.c,v 1.81 2013/10/25 20:46:29 martin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_boot.c,v 1.80 2010/10/04 23:48:22 cyber Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_boot.c,v 1.81 2013/10/25 20:46:29 martin Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -112,7 +112,7 @@ nfs_boot_init(struct nfs_diskless *nd, s
 {
 	struct ifnet *ifp;
 	int error = 0;
-	int flags;
+	int flags __unused;
 
 	/* Explicitly necessary or build fails
 	 * due to unused variable, otherwise.



CVS commit: src/sys/nfs

2013-09-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 18 16:33:14 UTC 2013

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

Log Message:
Use reference counting to keep track of construction and destruction of the
structures used by both the nfs server and client code. Tested by pgoyette@

1. mount remote fs via nfs (my /home directory), which autoloads nfs module
2. manually modload nfsserver
3. wait a bit
4. manually modunload nfsserver
5. wait a couple minutes
6. verify that client access still works (/bin/ls ~paul home dir)
7. manually modload nfsserver again
8. start an nfsd process
9. wait a bit
10. kill nfsd process
11. wait
12. manually modunload nfsserver again
13. verify continued client access

XXX: Note that nfs_vfs_init() calls nfs_init(), but nfs_vfs_done() does not
 call nfs_fini(). Also note that the destruction order is wrong in it,
 but probably does not matter. someone (!= me) should fix it :-) and
 run the above tests.


To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 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.222 src/sys/nfs/nfs_subs.c:1.223
--- src/sys/nfs/nfs_subs.c:1.222	Sat Nov 19 17:51:30 2011
+++ src/sys/nfs/nfs_subs.c	Wed Sep 18 12:33:14 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.222 2011/11/19 22:51:30 tls Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.223 2013/09/18 16:33:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.222 2011/11/19 22:51:30 tls Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.223 2013/09/18 16:33:14 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1502,27 +1502,40 @@ nfs_init0(void)
 	return 0;
 }
 
+static volatile uint32_t nfs_mutex;
+static uint32_t nfs_refcount;
+
+#define nfs_p()	while (atomic_cas_32(nfs_mutex, 0, 1) == 0) continue;
+#define nfs_v()	while (atomic_cas_32(nfs_mutex, 1, 0) == 1) continue;
+
 /*
  * This is disgusting, but it must support both modular and monolothic
- * configurations.  For monolithic builds NFSSERVER may not imply NFS.
+ * configurations, plus the code is shared between server and client.
+ * For monolithic builds NFSSERVER may not imply NFS. Unfortunately we
+ * can't use regular mutexes here that would require static initialization
+ * and we can get initialized from multiple places, so we improvise.
  *
  * Yuck.
  */
 void
 nfs_init(void)
 {
-	static ONCE_DECL(nfs_init_once);
-
-	RUN_ONCE(nfs_init_once, nfs_init0);
+	nfs_p();
+	if (nfs_refcount++ == 0)
+		nfs_init0();
+	nfs_v();
 }
 
 void
 nfs_fini(void)
 {
-
-	nfsdreq_fini();
-	nfs_timer_fini();
-	MOWNER_DETACH(nfs_mowner);
+	nfs_p();
+	if (--nfs_refcount == 0) {
+		MOWNER_DETACH(nfs_mowner);
+		nfs_timer_fini();
+		nfsdreq_fini();
+	}
+	nfs_v();
 }
 
 /*



CVS commit: src/sys/nfs

2013-09-18 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Sep 18 23:27:38 UTC 2013

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

Log Message:
knf (blank line even if there are no local declarations)


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 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.223 src/sys/nfs/nfs_subs.c:1.224
--- src/sys/nfs/nfs_subs.c:1.223	Wed Sep 18 16:33:14 2013
+++ src/sys/nfs/nfs_subs.c	Wed Sep 18 23:27:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.223 2013/09/18 16:33:14 christos Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.224 2013/09/18 23:27:38 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.223 2013/09/18 16:33:14 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.224 2013/09/18 23:27:38 pgoyette Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1520,6 +1520,7 @@ static uint32_t nfs_refcount;
 void
 nfs_init(void)
 {
+
 	nfs_p();
 	if (nfs_refcount++ == 0)
 		nfs_init0();
@@ -1529,6 +1530,7 @@ nfs_init(void)
 void
 nfs_fini(void)
 {
+
 	nfs_p();
 	if (--nfs_refcount == 0) {
 		MOWNER_DETACH(nfs_mowner);



CVS commit: src/sys/nfs

2013-09-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 14 21:11:46 UTC 2013

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

Log Message:
Guard a function local CTASSERT with pro/epilogue


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 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.54 src/sys/nfs/nfs_export.c:1.55
--- src/sys/nfs/nfs_export.c:1.54	Fri Aug 30 07:35:44 2013
+++ src/sys/nfs/nfs_export.c	Sat Sep 14 21:11:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.54 2013/08/30 07:35:44 dholland Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.55 2013/09/14 21:11:45 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.54 2013/08/30 07:35:44 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.55 2013/09/14 21:11:45 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -449,7 +449,9 @@ nfs_export_update_30(struct mount *mp, c
 		 * The following code assumes export_args has not
 		 * changed since export_args30, so check that.
 		 */
+		__CT_LOCAL_PROLOGUE
 		__CTASSERT(sizeof(args-eargs) == sizeof(*mel.mel_exports));
+		__CT_LOCAL_EPILOGUE
 
 		mel.mel_nexports = 1;
 		mel.mel_exports = (void *)args-eargs;



CVS commit: src/sys/nfs

2013-09-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 14 21:17:00 UTC 2013

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

Log Message:
Avoid unused variable warnings


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/nfs/nfs_iod.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_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.4 src/sys/nfs/nfs_iod.c:1.5
--- src/sys/nfs/nfs_iod.c:1.4	Thu Dec 31 19:38:16 2009
+++ src/sys/nfs/nfs_iod.c	Sat Sep 14 21:17:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.4 2009/12/31 19:38:16 christos Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.5 2013/09/14 21:17:00 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.4 2009/12/31 19:38:16 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.5 2013/09/14 21:17:00 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -319,7 +319,10 @@ int
 nfs_getnickauth(struct nfsmount *nmp, kauth_cred_t cred, char **auth_str,
 int *auth_len, char *verf_str, int verf_len)
 {
-	struct timeval ktvin, ktvout, tv;
+#ifdef NFSKERB
+	struct timeval ktvin;
+#endif
+	struct timeval ktvout, tv;
 	struct nfsuid *nuidp;
 	u_int32_t *nickp, *verfp;
 
@@ -360,6 +363,7 @@ nfs_getnickauth(struct nfsmount *nmp, ka
 		nuidp-nu_timestamp = tv;
 	else
 		nuidp-nu_timestamp.tv_usec++;
+#ifdef NFSKERB
 	ktvin.tv_sec = txdr_unsigned(nuidp-nu_timestamp.tv_sec);
 	ktvin.tv_usec = txdr_unsigned(nuidp-nu_timestamp.tv_usec);
 
@@ -367,7 +371,6 @@ nfs_getnickauth(struct nfsmount *nmp, ka
 	 * Now encrypt the timestamp verifier in ecb mode using the session
 	 * key.
 	 */
-#ifdef NFSKERB
 	XXX
 #endif
 
@@ -405,6 +408,8 @@ nfs_savenickauth(struct nfsmount *nmp, k
 		 */
 #ifdef NFSKERB
 		XXX
+#else
+		(void)ktvin.tv_sec;
 #endif
 		ktvout.tv_sec = fxdr_unsigned(long, ktvout.tv_sec);
 		ktvout.tv_usec = fxdr_unsigned(long, ktvout.tv_usec);



CVS commit: src/sys/nfs

2013-09-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 14 21:48:49 UTC 2013

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

Log Message:
Silence gcc 4.8.1 warnings


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/sys/nfs/nfsm_subs.h:1.52
--- src/sys/nfs/nfsm_subs.h:1.51	Fri Apr 10 18:58:50 2009
+++ src/sys/nfs/nfsm_subs.h	Sat Sep 14 21:48:49 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfsm_subs.h,v 1.51 2009/04/10 18:58:50 bouyer Exp $	*/
+/*	$NetBSD: nfsm_subs.h,v 1.52 2013/09/14 21:48:49 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -255,6 +255,14 @@
 #define NFSV3_WCCRATTR	0
 #define NFSV3_WCCCHK	1
 
+#if __GNUC_PREREQ__(4, 8)
+/*
+ * With all the macros in here, it is hard to track set-but-not-used cases
+ * and avoid them without cluttering the code.
+ */
+_Pragma(GCC diagnostic ignored \-Wunused-but-set-variable\)
+#endif
+
 #define	nfsm_wcc_data(v, f, flags, docheck) \
 		{ int ttattrf, ttretf = 0, renewctime = 0, renewnctime = 0; \
 		struct timespec ctime, mtime; \



CVS commit: src/sys/nfs

2013-09-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 14 22:27:01 UTC 2013

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

Log Message:
Remove unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 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.221 src/sys/nfs/nfs_vfsops.c:1.222
--- src/sys/nfs/nfs_vfsops.c:1.221	Tue Jan 22 09:39:14 2013
+++ src/sys/nfs/nfs_vfsops.c	Sat Sep 14 22:27:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.221 2013/01/22 09:39:14 dholland Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.222 2013/09/14 22:27:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.221 2013/01/22 09:39:14 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.222 2013/09/14 22:27:01 martin Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_nfs.h
@@ -596,14 +596,12 @@ nfs_mount(struct mount *mp, const char *
 	struct sockaddr *sa;
 	struct vnode *vp;
 	char *pth, *hst;
-	struct proc *p;
 	size_t len;
 	u_char *nfh;
 
 	if (*data_len  sizeof *args)
 		return EINVAL;
 
-	p = l-l_proc;
 	if (mp-mnt_flag  MNT_GETARGS) {
 
 		if (nmp == NULL)



CVS commit: src/sys/nfs

2013-09-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Sep 14 22:29:09 UTC 2013

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

Log Message:
Backout wildcard pragma to kill warnings and instead sprinkle a few dozen
__unused attributes.
Requested by joerg@


To generate a diff of this commit:
cvs rdiff -u -r1.165 -r1.166 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.189 -r1.190 src/sys/nfs/nfs_socket.c
cvs rdiff -u -r1.299 -r1.300 src/sys/nfs/nfs_vnops.c
cvs rdiff -u -r1.52 -r1.53 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.165 src/sys/nfs/nfs_serv.c:1.166
--- src/sys/nfs/nfs_serv.c:1.165	Wed Aug 29 14:00:22 2012
+++ src/sys/nfs/nfs_serv.c	Sat Sep 14 22:29:08 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -166,7 +166,7 @@ nfsrv3_access(struct nfsrv_descript *nfs
 	char *bpos;
 	int error = 0, rdonly, cache = 0, getret;
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vattr va;
 	u_long inmode, testmode, outmode;
 	u_quad_t frev;
@@ -231,7 +231,7 @@ nfsrv_getattr(struct nfsrv_descript *nfs
 	char *bpos;
 	int error = 0, rdonly, cache = 0;
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	u_quad_t frev;
 
 	nfsm_srvmtofh(nsfh);
@@ -273,7 +273,7 @@ nfsrv_setattr(struct nfsrv_descript *nfs
 	int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1;
 	int v3 = (nfsd-nd_flag  ND_NFSV3), gcheck = 0;
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	u_quad_t frev;
 	struct timespec guard;
 
@@ -402,7 +402,7 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 	uint32_t len;
 	int v3 = (nfsd-nd_flag  ND_NFSV3), pubflag;
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vattr va, dirattr;
 	u_quad_t frev;
 
@@ -529,7 +529,7 @@ nfsrv_readlink(struct nfsrv_descript *nf
 	uint32_t len;
 	int v3 = (nfsd-nd_flag  ND_NFSV3);
 	char *cp2;
-	struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq;
+	struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq __unused;
 	struct vnode *vp;
 	struct vattr attr;
 	nfsrvfh_t nsfh;
@@ -852,7 +852,7 @@ nfsrv_write(struct nfsrv_descript *nfsd,
 	int stable = NFSV3WRITE_FILESYNC;
 	int v3 = (nfsd-nd_flag  ND_NFSV3);
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vnode *vp;
 	nfsrvfh_t nsfh;
 	struct uio io, *uiop = io;
@@ -1420,7 +1420,7 @@ nfsrv_create(struct nfsrv_descript *nfsd
 	int rdev = 0, abort = 0;
 	int v3 = (nfsd-nd_flag  ND_NFSV3), how, exclusive_flag = 0;
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vnode *vp = NULL, *dirp = NULL;
 	nfsrvfh_t nsfh;
 	u_quad_t frev, tempsize;
@@ -1660,7 +1660,7 @@ nfsrv_mknod(struct nfsrv_descript *nfsd,
 	u_int32_t major, minor;
 	enum vtype vtyp;
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vnode *vp, *dirp = (struct vnode *)0;
 	nfsrvfh_t nsfh;
 	u_quad_t frev;
@@ -1810,7 +1810,7 @@ nfsrv_remove(struct nfsrv_descript *nfsd
 	int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1;
 	int v3 = (nfsd-nd_flag  ND_NFSV3);
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vnode *vp, *dirp;
 	struct vattr dirfor, diraft;
 	nfsrvfh_t nsfh;
@@ -1897,7 +1897,7 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	int tdirfor_ret = 1, tdiraft_ret = 1;
 	int v3 = (nfsd-nd_flag  ND_NFSV3);
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct nameidata fromnd, tond;
 	struct vnode *fvp, *tvp, *tdvp;
 	struct vnode *fdirp = NULL, *tdirp = NULL;
@@ -2169,7 +2169,7 @@ nfsrv_link(struct nfsrv_descript *nfsd, 
 	int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1;
 	int getret = 1, v3 = (nfsd-nd_flag  ND_NFSV3);
 	char *cp2;
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vnode *vp, *xp, *dirp = (struct vnode *)0;
 	struct vattr dirfor, diraft, at;
 	nfsrvfh_t nsfh, dnsfh;
@@ -2271,7 +2271,7 @@ nfsrv_symlink(struct nfsrv_descript *nfs
 	int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1, abort = 0;
 	uint32_t len, len2;
 	int v3 = (nfsd-nd_flag  ND_NFSV3);
-	struct mbuf *mb, *mreq;
+	struct mbuf *mb, *mreq __unused;
 	struct vnode *dirp = (struct vnode *)0;
 	nfsrvfh_t nsfh;
 	u_quad_t frev;
@@ -2415,7 +2415,7 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd,
 	int abort = 0;
 	int v3 = (nfsd-nd_flag  ND_NFSV3);
 	char *cp2;
-	struct 

CVS commit: src/sys/nfs

2013-09-12 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Thu Sep 12 18:00:18 UTC 2013

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

Log Message:
tyop in comment, from Eivind Evensen via OpenBSD


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 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.37 src/sys/nfs/nfs_bootparam.c:1.38
--- src/sys/nfs/nfs_bootparam.c:1.37	Sun Mar 21 00:10:40 2010
+++ src/sys/nfs/nfs_bootparam.c	Thu Sep 12 18:00:18 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootparam.c,v 1.37 2010/03/21 00:10:40 chs Exp $	*/
+/*	$NetBSD: nfs_bootparam.c,v 1.38 2013/09/12 18:00:18 drochner Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bootparam.c,v 1.37 2010/03/21 00:10:40 chs Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bootparam.c,v 1.38 2013/09/12 18:00:18 drochner Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs_boot.h
@@ -101,7 +101,7 @@ static int bp_getfile (struct sockaddr_i
  * Use the old broadcast address for the WHOAMI
  * call because we do not yet know our netmask.
  * The server address returned by the WHOAMI call
- * is used for all subsequent booptaram RPCs.
+ * is used for all subsequent bootparam RPCs.
  */
 int
 nfs_bootparam(struct nfs_diskless *nd, struct lwp *lwp, int *flags)



CVS commit: src/sys/nfs

2013-08-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Aug 30 07:25:43 UTC 2013

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

Log Message:
typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/sys/nfs/nfs_export.c:1.52
--- src/sys/nfs/nfs_export.c:1.51	Tue Sep 27 01:07:38 2011
+++ src/sys/nfs/nfs_export.c	Fri Aug 30 07:25:43 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.51 2011/09/27 01:07:38 christos Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.52 2013/08/30 07:25:43 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.51 2011/09/27 01:07:38 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.52 2013/08/30 07:25:43 dholland Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -172,7 +172,7 @@ struct vfs_hooks nfs_export_hooks = {
  *
  * Releases NFS exports list resources if the given mount point has some.
  * As allocation happens lazily, it may be that it doesn't has this
- * information, although it theorically should.
+ * information, although it theoretically should.
  */
 static void
 netexport_unmount(struct mount *mp)



CVS commit: src/sys/nfs

2013-08-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Aug 30 07:30:50 UTC 2013

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

Log Message:
more typos in comments


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/sys/nfs/nfs_export.c:1.53
--- src/sys/nfs/nfs_export.c:1.52	Fri Aug 30 07:25:43 2013
+++ src/sys/nfs/nfs_export.c	Fri Aug 30 07:30:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.52 2013/08/30 07:25:43 dholland Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.53 2013/08/30 07:30:50 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.52 2013/08/30 07:25:43 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.53 2013/08/30 07:30:50 dholland Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -171,7 +171,7 @@ struct vfs_hooks nfs_export_hooks = {
  * VFS unmount hook for NFS exports.
  *
  * Releases NFS exports list resources if the given mount point has some.
- * As allocation happens lazily, it may be that it doesn't has this
+ * As allocation happens lazily, it may be that it doesn't have this
  * information, although it theoretically should.
  */
 static void
@@ -255,7 +255,7 @@ mountd_set_exports_list(const struct mou
 	KAUTH_REQ_NETWORK_NFS_EXPORT, NULL, NULL, NULL) != 0)
 		return EPERM;
 
-	/* Lookup the file system path. */
+	/* Look up the file system path. */
 	error = pathbuf_copyin(mel-mel_path, pb);
 	if (error) {
 		return error;
@@ -392,7 +392,7 @@ done:
  * in the address specified by 'wh'.
  *
  * This function is used exclusively by the NFS server.  It is generally
- * invoked before VFS_FHTOVP to validate that client has access to the
+ * invoked before VFS_FHTOVP to validate that a client has access to the
  * file system.
  */
 
@@ -557,7 +557,7 @@ hang_addrlist(struct mount *mp, struct n
 	if ((rnh = nep-ne_rtable[i]) == 0) {
 		/*
 		 * Seems silly to initialize every AF when most are not
-		 * used, do so on demand here
+		 * used, do so on demand here.
 		 */
 		DOMAIN_FOREACH(dom) {
 			if (dom-dom_family == i  dom-dom_rtattach) {
@@ -734,7 +734,7 @@ setpublicfs(struct mount *mp, struct net
 	size_t fhsize;
 
 	/*
-	 * mp == NULL - invalidate the current info, the FS is
+	 * mp == NULL -- invalidate the current info; the FS is
 	 * no longer exported. May be called from either export
 	 * or unmount, so check if it hasn't already been done.
 	 */
@@ -809,7 +809,7 @@ setpublicfs(struct mount *mp, struct net
 }
 
 /*
- * Lookup an export entry in the exports list that matches the address
+ * Look up an export entry in the exports list that matches the address
  * stored in 'nam'.  If no entry is found, the default one is used instead
  * (if available).
  */
@@ -825,7 +825,7 @@ netcred_lookup(struct netexport *ne, str
 	}
 
 	/*
-	 * Lookup in the export list first.
+	 * Look in the export list first.
 	 */
 	np = NULL;
 	if (nam != NULL) {



CVS commit: src/sys/nfs

2013-08-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Fri Aug 30 07:35:44 UTC 2013

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

Log Message:
Use __CTASSERT instead of handrolled version.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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.53 src/sys/nfs/nfs_export.c:1.54
--- src/sys/nfs/nfs_export.c:1.53	Fri Aug 30 07:30:50 2013
+++ src/sys/nfs/nfs_export.c	Fri Aug 30 07:35:44 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.53 2013/08/30 07:30:50 dholland Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.54 2013/08/30 07:35:44 dholland Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.53 2013/08/30 07:30:50 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.54 2013/08/30 07:35:44 dholland Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -445,9 +445,11 @@ nfs_export_update_30(struct mount *mp, c
 		 * value that used to be in MNT_DELEXPORT. */
 		mel.mel_nexports = 0;
 	} else {
-		/* The following assumes export_args has not changed since
-		 * export_args30 - typedef checks sizes. */
-		typedef char x[sizeof args-eargs == sizeof *mel.mel_exports ? 1 : -1];
+		/*
+		 * The following code assumes export_args has not
+		 * changed since export_args30, so check that.
+		 */
+		__CTASSERT(sizeof(args-eargs) == sizeof(*mel.mel_exports));
 
 		mel.mel_nexports = 1;
 		mel.mel_exports = (void *)args-eargs;



CVS commit: src/sys/nfs

2013-08-12 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Aug 12 17:46:38 UTC 2013

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

Log Message:
Function nfs_vinvalbuf() ignores errors from vinvalbuf() and therefore
delayed write errors may get lost.
Change nfs_vinvalbuf() to keep errors from vinvalbuf() for fsync() or close().

Presented on tech-kern@

Fix for PR kern/47980 (NFS over-quota not detected if utimes() called
before fsync()/close())


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 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.188 src/sys/nfs/nfs_bio.c:1.189
--- src/sys/nfs/nfs_bio.c:1.188	Tue Sep 27 01:07:38 2011
+++ src/sys/nfs/nfs_bio.c	Mon Aug 12 17:46:38 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.188 2011/09/27 01:07:38 christos Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.189 2013/08/12 17:46:38 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.188 2011/09/27 01:07:38 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.189 2013/08/12 17:46:38 hannken Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -614,7 +614,7 @@ nfs_vinvalbuf(struct vnode *vp, int flag
 {
 	struct nfsnode *np = VTONFS(vp);
 	struct nfsmount *nmp = VFSTONFS(vp-v_mount);
-	int error = 0, slptimeo;
+	int error = 0, allerror = 0, slptimeo;
 	bool catch;
 
 	if ((nmp-nm_flag  NFSMNT_INT) == 0)
@@ -647,6 +647,8 @@ nfs_vinvalbuf(struct vnode *vp, int flag
 	mutex_exit(vp-v_interlock);
 	error = vinvalbuf(vp, flags, cred, l, catch, 0);
 	while (error) {
+		if (allerror == 0)
+			allerror = error;
 		if (intrflg  nfs_sigintr(nmp, NULL, l)) {
 			error = EINTR;
 			break;
@@ -654,6 +656,13 @@ nfs_vinvalbuf(struct vnode *vp, int flag
 		error = vinvalbuf(vp, flags, cred, l, 0, slptimeo);
 	}
 	mutex_enter(vp-v_interlock);
+	if (allerror != 0) {
+		/*
+		 * Keep error from vinvalbuf so fsync/close will know.
+		 */
+		np-n_error = allerror;
+		np-n_flag |= NWRITEERR;
+	}
 	if (error == 0)
 		np-n_flag = ~NMODIFIED;
 	np-n_flag = ~NFLUSHINPROG;



CVS commit: src/sys/nfs

2012-11-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Nov  7 02:31:49 UTC 2012

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

Log Message:
fix crash in nfs client lookups, dholland says 'my fault'


To generate a diff of this commit:
cvs rdiff -u -r1.297 -r1.298 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.297 src/sys/nfs/nfs_vnops.c:1.298
--- src/sys/nfs/nfs_vnops.c:1.297	Mon Nov  5 17:27:39 2012
+++ src/sys/nfs/nfs_vnops.c	Wed Nov  7 02:31:48 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.297 2012/11/05 17:27:39 dholland Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.298 2012/11/07 02:31:48 macallan Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.297 2012/11/05 17:27:39 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.298 2012/11/07 02:31:48 macallan Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -847,6 +847,7 @@ nfs_lookup(void *v)
 
 		if (*vpp == NULLVP) {
 			/* namecache gave us a negative result */
+			error = ENOENT;
 			goto noentry;
 		}
 



CVS commit: src/sys/nfs

2012-08-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 29 14:00:22 UTC 2012

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

Log Message:
When unloading the nfsserver module, call nfs_fini() so that the nfsrvdescpl
pool gets destroyed. Otherwise we are left with a stray pool that points to
unmapped memory behind (and bad things happen). Typically you get seemingly
random page faults (without printing uvm_fault) that happen in various pool
operations. Most frequent one is the pool_drain() from the page daemon.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 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.164 src/sys/nfs/nfs_serv.c:1.165
--- src/sys/nfs/nfs_serv.c:1.164	Mon Aug 27 07:35:13 2012
+++ src/sys/nfs/nfs_serv.c	Wed Aug 29 10:00:22 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.164 2012/08/27 11:35:13 chs Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.164 2012/08/27 11:35:13 chs Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -142,6 +142,7 @@ nfsserver_modcmd(modcmd_t cmd, void *arg
 
 		/* Server uses server cache, so kill cache last. */
 		nfsrv_finicache();
+		nfs_fini();
 		return 0;
 	default:
 		return ENOTTY;



CVS commit: src/sys/nfs

2012-08-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Aug 27 11:35:14 UTC 2012

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

Log Message:
fix error handling in nfsrv_rename(): when the first nfs_namei() fails,
don't try to free the resources allocated by a successful lookup.


To generate a diff of this commit:
cvs rdiff -u -r1.163 -r1.164 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.163 src/sys/nfs/nfs_serv.c:1.164
--- src/sys/nfs/nfs_serv.c:1.163	Wed Feb  1 02:27:24 2012
+++ src/sys/nfs/nfs_serv.c	Mon Aug 27 11:35:13 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.164 2012/08/27 11:35:13 chs Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.164 2012/08/27 11:35:13 chs Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1931,6 +1931,7 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 			VOP_UNLOCK(fdirp);
 	}
 	if (error) {
+		fromnd.ni_cnd.cn_nameiop = 0;
 		nfsm_reply(2 * NFSX_WCCDATA(v3));
 		nfsm_srvwcc_data(fdirfor_ret, fdirfor, fdiraft_ret, fdiraft);
 		nfsm_srvwcc_data(tdirfor_ret, tdirfor, tdiraft_ret, tdiraft);



CVS commit: src/sys/nfs

2012-04-27 Thread Matthias Drochner
Module Name:src
Committed By:   drochner
Date:   Fri Apr 27 18:12:01 UTC 2012

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

Log Message:
fix access permission check which got broken by some kauth rework
in March, affected mostly systems with NFS root fs


To generate a diff of this commit:
cvs rdiff -u -r1.293 -r1.294 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.293 src/sys/nfs/nfs_vnops.c:1.294
--- src/sys/nfs/nfs_vnops.c:1.293	Mon Nov 28 08:05:06 2011
+++ src/sys/nfs/nfs_vnops.c	Fri Apr 27 18:12:01 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.293 2011/11/28 08:05:06 tls Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.294 2012/04/27 18:12:01 drochner Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.293 2011/11/28 08:05:06 tls Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.294 2012/04/27 18:12:01 drochner Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -3373,8 +3373,9 @@ nfsspec_access(void *v)
 		}
 	}
 
-	return (genfs_can_access(va.va_type, va.va_mode,
-	va.va_uid, va.va_gid, ap-a_mode, ap-a_cred));
+	return kauth_authorize_vnode(ap-a_cred, kauth_access_action(ap-a_mode,
+	va.va_type, va.va_mode), vp, NULL, genfs_can_access(va.va_type,
+	va.va_mode, va.va_uid, va.va_gid, ap-a_mode, ap-a_cred));
 }
 
 /*



CVS commit: src/sys/nfs

2011-11-21 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Nov 21 09:08:00 UTC 2011

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

Log Message:
nfsrv_lookup(): Defer the postopattr lookup on dirp until the
child node is unlocked.

Ok: YAMAMOTO Takashi y...@netbsd.org


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 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.161 src/sys/nfs/nfs_serv.c:1.162
--- src/sys/nfs/nfs_serv.c:1.161	Sun Oct 30 12:00:27 2011
+++ src/sys/nfs/nfs_serv.c	Mon Nov 21 09:07:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -453,15 +453,6 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 		}
 	}
 
-	if (dirp) {
-		if (v3) {
-			vn_lock(dirp, LK_SHARED | LK_RETRY);
-			dirattr_ret = VOP_GETATTR(dirp, dirattr, cred);
-			VOP_UNLOCK(dirp);
-		}
-		vrele(dirp);
-	}
-
 	if (error) {
 		if (nd.ni_pathbuf != NULL) {
 			pathbuf_destroy(nd.ni_pathbuf);
@@ -469,6 +460,14 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 		if (ipb != NULL) {
 			pathbuf_destroy(ipb);
 		}
+		if (dirp) {
+			if (v3) {
+vn_lock(dirp, LK_SHARED | LK_RETRY);
+dirattr_ret = VOP_GETATTR(dirp, dirattr, cred);
+vput(dirp);
+			} else
+vrele(dirp);
+		}
 		nfsm_reply(NFSX_POSTOPATTR(v3));
 		nfsm_srvpostop_attr(dirattr_ret, dirattr);
 		return (0);
@@ -484,6 +483,14 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 	if (!error)
 		error = VOP_GETATTR(vp, va, cred);
 	vput(vp);
+	if (dirp) {
+		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
+			dirattr_ret = VOP_GETATTR(dirp, dirattr, cred);
+			vput(dirp);
+		} else
+			vrele(dirp);
+	}
 	nfsm_reply(NFSX_SRVFH(nsfh, v3) + NFSX_POSTOPORFATTR(v3) +
 	NFSX_POSTOPATTR(v3));
 	if (error) {



CVS commit: src/sys/nfs

2011-10-30 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Oct 30 12:00:28 UTC 2011

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

Log Message:
VOP_GETATTR() needs a shared lock at least.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 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.160 src/sys/nfs/nfs_serv.c:1.161
--- src/sys/nfs/nfs_serv.c:1.160	Mon Aug  8 16:04:07 2011
+++ src/sys/nfs/nfs_serv.c	Sun Oct 30 12:00:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -454,8 +454,11 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 	}
 
 	if (dirp) {
-		if (v3)
+		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 			dirattr_ret = VOP_GETATTR(dirp, dirattr, cred);
+			VOP_UNLOCK(dirp);
+		}
 		vrele(dirp);
 	}
 
@@ -1582,7 +1585,9 @@ nfsrv_create(struct nfsrv_descript *nfsd
 error = EEXIST;
 		}
 		if (dirp) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 			diraft_ret = VOP_GETATTR(dirp, diraft, cred);
+			VOP_UNLOCK(dirp);
 		}
 	}
 	if (dirp) {
@@ -1741,7 +1746,9 @@ out:
 		vput(vp);
 	}
 	if (dirp) {
+		vn_lock(dirp, LK_SHARED | LK_RETRY);
 		diraft_ret = VOP_GETATTR(dirp, diraft, cred);
+		VOP_UNLOCK(dirp);
 		vrele(dirp);
 		dirp = NULL;
 	}
@@ -1810,8 +1817,12 @@ nfsrv_remove(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(nd, nsfh, len, slp, nam, md, dpos,
 		dirp, lwp, (nfsd-nd_flag  ND_KERBAUTH), false);
-	if (dirp  v3) {
+	if (error == 0  dirp  v3) {
+		if (nd.ni_dvp == nd.ni_vp)
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 		dirfor_ret = VOP_GETATTR(dirp, dirfor, cred);
+		if (nd.ni_dvp == nd.ni_vp)
+			VOP_UNLOCK(dirp);
 	}
 	if (!error) {
 		vp = nd.ni_vp;
@@ -1845,7 +1856,9 @@ out:
 	}
 	if (dirp) {
 		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 			diraft_ret = VOP_GETATTR(dirp, diraft, cred);
+			VOP_UNLOCK(dirp);
 		}
 		vrele(dirp);
 	}
@@ -1902,8 +1915,12 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	fromnd.ni_cnd.cn_flags = LOCKPARENT | INRENAME;
 	error = nfs_namei(fromnd, fnsfh, len, slp, nam, md,
 		dpos, fdirp, lwp, (nfsd-nd_flag  ND_KERBAUTH), false);
-	if (fdirp  v3) {
+	if (error == 0  fdirp  v3) {
+		if (fromnd.ni_dvp == fromnd.ni_vp)
+			vn_lock(fdirp, LK_SHARED | LK_RETRY);
 		fdirfor_ret = VOP_GETATTR(fdirp, fdirfor, cred);
+		if (fromnd.ni_dvp == fromnd.ni_vp)
+			VOP_UNLOCK(fdirp);
 	}
 	if (error) {
 		nfsm_reply(2 * NFSX_WCCDATA(v3));
@@ -2070,14 +2087,18 @@ out:
 out1:
 	if (fdirp) {
 		if (v3) {
+			vn_lock(fdirp, LK_SHARED | LK_RETRY);
 			fdiraft_ret = VOP_GETATTR(fdirp, fdiraft, cred);
+			VOP_UNLOCK(fdirp);
 		}
 		vrele(fdirp);
 		fdirp = NULL;
 	}
 	if (tdirp) {
 		if (v3) {
+			vn_lock(tdirp, LK_SHARED | LK_RETRY);
 			tdiraft_ret = VOP_GETATTR(tdirp, tdiraft, cred);
+			VOP_UNLOCK(tdirp);
 		}
 		vrele(tdirp);
 		tdirp = NULL;
@@ -2192,11 +2213,16 @@ out:
 			vrele(nd.ni_vp);
 	}
 out1:
-	if (v3)
+	if (v3) {
+		vn_lock(vp, LK_SHARED | LK_RETRY);
 		getret = VOP_GETATTR(vp, at, cred);
+		VOP_UNLOCK(vp);
+	}
 	if (dirp) {
 		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 			diraft_ret = VOP_GETATTR(dirp, diraft, cred);
+			VOP_UNLOCK(dirp);
 		}
 		vrele(dirp);
 	}
@@ -2315,7 +2341,9 @@ out:
 		free(pathcp, M_TEMP);
 	if (dirp) {
 		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 			diraft_ret = VOP_GETATTR(dirp, diraft, cred);
+			VOP_UNLOCK(dirp);
 		}
 		vrele(dirp);
 		dirp = NULL;
@@ -2436,7 +2464,9 @@ nfsrv_mkdir(struct nfsrv_descript *nfsd,
 out:
 	if (dirp) {
 		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 			diraft_ret = VOP_GETATTR(dirp, diraft, cred);
+			VOP_UNLOCK(dirp);
 		}
 		vrele(dirp);
 		dirp = NULL;
@@ -2559,7 +2589,9 @@ out:
 	}
 	if (dirp) {
 		if (v3) {
+			vn_lock(dirp, LK_SHARED | LK_RETRY);
 			diraft_ret = VOP_GETATTR(dirp, diraft, cred);
+			VOP_UNLOCK(dirp);
 		}
 		vrele(dirp);
 	}



CVS commit: src/sys/nfs

2011-10-24 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Mon Oct 24 11:43:31 UTC 2011

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

Log Message:
VOP_GETATTR() needs a shared lock at least.

As nfs_kqpoll() ignores the return value from VOP_GETATTR() initialize
the attrributes to zero -- nfs_kqfilter() does the same.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/nfs/nfs_kq.c
cvs rdiff -u -r1.219 -r1.220 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_kq.c
diff -u src/sys/nfs/nfs_kq.c:1.24 src/sys/nfs/nfs_kq.c:1.25
--- src/sys/nfs/nfs_kq.c:1.24	Sun Jun 12 03:35:59 2011
+++ src/sys/nfs/nfs_kq.c	Mon Oct 24 11:43:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_kq.c,v 1.24 2011/06/12 03:35:59 rmind Exp $	*/
+/*	$NetBSD: nfs_kq.c,v 1.25 2011/10/24 11:43:30 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_kq.c,v 1.24 2011/06/12 03:35:59 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_kq.c,v 1.25 2011/10/24 11:43:30 hannken Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -138,7 +138,10 @@ nfs_kqpoll(void *arg)
 			/* save v_size, nfs_getattr() updates it */
 			osize = ke-vp-v_size;
 
+			memset(attr, 0, sizeof(attr));
+			vn_lock(ke-vp, LK_SHARED | LK_RETRY);
 			(void) VOP_GETATTR(ke-vp, attr, l-l_cred);
+			VOP_UNLOCK(ke-vp);
 
 			/* following is a bit fragile, but about best
 			 * we can get */
@@ -318,7 +321,9 @@ nfs_kqfilter(void *v)
 	 * held. This is likely cheap due to attrcache, so do it now.
 	 */
 	memset(attr, 0, sizeof(attr));
+	vn_lock(vp, LK_SHARED | LK_RETRY);
 	(void) VOP_GETATTR(vp, attr, l-l_cred);
+	VOP_UNLOCK(vp);
 
 	mutex_enter(nfskq_lock);
 

Index: src/sys/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.219 src/sys/nfs/nfs_vfsops.c:1.220
--- src/sys/nfs/nfs_vfsops.c:1.219	Fri Oct  7 09:35:06 2011
+++ src/sys/nfs/nfs_vfsops.c	Mon Oct 24 11:43:30 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.219 2011/10/07 09:35:06 hannken Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.220 2011/10/24 11:43:30 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.219 2011/10/07 09:35:06 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.220 2011/10/24 11:43:30 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_nfs.h
@@ -387,7 +387,9 @@ nfs_mountroot(void)
 	vfs_unbusy(mp, false, NULL);
 
 	/* Get root attributes (for the time). */
+	vn_lock(vp, LK_SHARED | LK_RETRY);
 	error = VOP_GETATTR(vp, attr, l-l_cred);
+	VOP_UNLOCK(vp);
 	if (error)
 		panic(nfs_mountroot: getattr for root);
 	n = attr.va_atime.tv_sec;



CVS commit: src/sys/nfs

2011-09-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 27 01:05:09 UTC 2011

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

Log Message:
use NFS_MAXPATHLEN instead of MAXPATHLEN


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/nfs/nfs_srvsubs.c
cvs rdiff -u -r1.291 -r1.292 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_srvsubs.c
diff -u src/sys/nfs/nfs_srvsubs.c:1.11 src/sys/nfs/nfs_srvsubs.c:1.12
--- src/sys/nfs/nfs_srvsubs.c:1.11	Mon Aug  8 12:04:07 2011
+++ src/sys/nfs/nfs_srvsubs.c	Mon Sep 26 21:05:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsubs.c,v 1.11 2011/08/08 16:04:07 dholland Exp $	*/
+/*	$NetBSD: nfs_srvsubs.c,v 1.12 2011/09/27 01:05:08 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_srvsubs.c,v 1.11 2011/08/08 16:04:07 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_srvsubs.c,v 1.12 2011/09/27 01:05:08 christos Exp $);
 
 #include sys/param.h
 #include sys/proc.h
@@ -129,7 +129,7 @@ nfs_namei(struct nameidata *ndp, nfsrvfh
 	*retdirp = NULL;
 	ndp-ni_pathbuf = NULL;
 
-	if ((len + 1)  MAXPATHLEN)
+	if ((len + 1)  NFS_MAXPATHLEN)
 		return (ENAMETOOLONG);
 	if (len == 0)
 		return (EACCES);

Index: src/sys/nfs/nfs_vnops.c
diff -u src/sys/nfs/nfs_vnops.c:1.291 src/sys/nfs/nfs_vnops.c:1.292
--- src/sys/nfs/nfs_vnops.c:1.291	Sat Jun 11 23:35:59 2011
+++ src/sys/nfs/nfs_vnops.c	Mon Sep 26 21:05:08 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.291 2011/06/12 03:35:59 rmind Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.292 2011/09/27 01:05:08 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.291 2011/06/12 03:35:59 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.292 2011/09/27 01:05:08 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1131,7 +1131,7 @@ nfs_readlinkrpc(struct vnode *vp, struct
 		if (v3) {
 			nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED);
 			len = fxdr_unsigned(uint32_t, *tl);
-			if (len  MAXPATHLEN) {
+			if (len  NFS_MAXPATHLEN) {
 /*
  * this pathname is too long for us.
  */



CVS commit: src/sys/nfs

2011-09-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 27 01:07:38 UTC 2011

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

Log Message:
use NFS_MAXNAMLEN for all names.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/sys/nfs/nfs_bio.c
cvs rdiff -u -r1.50 -r1.51 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_bio.c
diff -u src/sys/nfs/nfs_bio.c:1.187 src/sys/nfs/nfs_bio.c:1.188
--- src/sys/nfs/nfs_bio.c:1.187	Sat Jun 18 22:42:53 2011
+++ src/sys/nfs/nfs_bio.c	Mon Sep 26 21:07:38 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.187 2011/06/19 02:42:53 rmind Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.188 2011/09/27 01:07:38 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.187 2011/06/19 02:42:53 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.188 2011/09/27 01:07:38 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -177,7 +177,7 @@ nfs_bioread(struct vnode *vp, struct uio
 
 	case VLNK:
 		nfsstats.biocache_readlinks++;
-		bp = nfs_getcacheblk(vp, (daddr_t)0, NFS_MAXPATHLEN, l);
+		bp = nfs_getcacheblk(vp, (daddr_t)0, MAXPATHLEN, l);
 		if (!bp)
 			return (EINTR);
 		if ((bp-b_oflags  BO_DONE) == 0) {
@@ -188,7 +188,7 @@ nfs_bioread(struct vnode *vp, struct uio
 return (error);
 			}
 		}
-		n = MIN(uio-uio_resid, NFS_MAXPATHLEN - bp-b_resid);
+		n = MIN(uio-uio_resid, MAXPATHLEN - bp-b_resid);
 		got_buf = 1;
 		on = 0;
 		break;

Index: src/sys/nfs/nfs_export.c
diff -u src/sys/nfs/nfs_export.c:1.50 src/sys/nfs/nfs_export.c:1.51
--- src/sys/nfs/nfs_export.c:1.50	Thu Mar 31 15:40:53 2011
+++ src/sys/nfs/nfs_export.c	Mon Sep 26 21:07:38 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.50 2011/03/31 19:40:53 dyoung Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.51 2011/09/27 01:07:38 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.50 2011/03/31 19:40:53 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.51 2011/09/27 01:07:38 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -783,9 +783,9 @@ setpublicfs(struct mount *mp, struct net
 	 * If an indexfile was specified, pull it in.
 	 */
 	if (argp-ex_indexfile != NULL) {
-		nfs_pub.np_index = malloc(MAXNAMLEN + 1, M_TEMP, M_WAITOK);
+		nfs_pub.np_index = malloc(NFS_MAXNAMLEN + 1, M_TEMP, M_WAITOK);
 		error = copyinstr(argp-ex_indexfile, nfs_pub.np_index,
-		MAXNAMLEN, (size_t *)0);
+		NFS_MAXNAMLEN, (size_t *)0);
 		if (!error) {
 			/*
 			 * Check for illegal filenames.



CVS commit: src/sys/nfs

2011-08-08 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Aug  8 16:04:07 UTC 2011

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

Log Message:
nfs_namei() should not return a non-null path buffer except on success,
even though the callers are apparently prepared to cope.

Fixes last tidyup part of PR 44625.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.10 -r1.11 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_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.159 src/sys/nfs/nfs_serv.c:1.160
--- src/sys/nfs/nfs_serv.c:1.159	Mon Apr 18 00:38:33 2011
+++ src/sys/nfs/nfs_serv.c	Mon Aug  8 16:04:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1911,7 +1911,9 @@
 		nfsm_srvwcc_data(tdirfor_ret, tdirfor, tdiraft_ret, tdiraft);
 		if (fdirp)
 			vrele(fdirp);
-		pathbuf_destroy(fromnd.ni_pathbuf);
+		if (fromnd.ni_pathbuf != NULL) {
+			pathbuf_destroy(fromnd.ni_pathbuf);
+		}
 		return (0);
 	}
 	if (fromnd.ni_dvp != fromnd.ni_vp) {
@@ -2060,7 +2062,10 @@
 		if (error == -1)
 			error = 0;
 	}
-	pathbuf_destroy(tond.ni_pathbuf);
+	if (tond.ni_pathbuf != NULL) {
+		pathbuf_destroy(tond.ni_pathbuf);
+		tond.ni_pathbuf = NULL;
+	}
 	tond.ni_cnd.cn_nameiop = 0;
 out1:
 	if (fdirp) {
@@ -2078,6 +2083,7 @@
 		tdirp = NULL;
 	}
 	pathbuf_destroy(fromnd.ni_pathbuf);
+	fromnd.ni_pathbuf = NULL;
 	fromnd.ni_cnd.cn_nameiop = 0;
 	localfs = NULL;
 	nfsm_reply(2 * NFSX_WCCDATA(v3));
@@ -2095,14 +2101,20 @@
 		vrele(tdirp);
 #endif
 	if (tond.ni_cnd.cn_nameiop) {
-		pathbuf_destroy(tond.ni_pathbuf);
+		if (tond.ni_pathbuf != NULL) {
+			pathbuf_destroy(tond.ni_pathbuf);
+			tond.ni_pathbuf = NULL;
+		}
 	}
 	if (localfs) {
 		VFS_RENAMELOCK_EXIT(localfs);
 	}
 	if (fromnd.ni_cnd.cn_nameiop) {
 		VOP_ABORTOP(fromnd.ni_dvp, fromnd.ni_cnd);
-		pathbuf_destroy(fromnd.ni_pathbuf);
+		if (fromnd.ni_pathbuf != NULL) {
+			pathbuf_destroy(fromnd.ni_pathbuf);
+			fromnd.ni_pathbuf = NULL;
+		}
 		vrele(fromnd.ni_dvp);
 		vrele(fvp);
 	}
@@ -2189,7 +2201,10 @@
 		vrele(dirp);
 	}
 	vrele(vp);
-	pathbuf_destroy(nd.ni_pathbuf);
+	if (nd.ni_pathbuf != NULL) {
+		pathbuf_destroy(nd.ni_pathbuf);
+		nd.ni_pathbuf = NULL;
+	}
 	nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3));
 	if (v3) {
 		nfsm_srvpostop_attr(getret, at);
@@ -2305,7 +2320,10 @@
 		vrele(dirp);
 		dirp = NULL;
 	}
-	pathbuf_destroy(nd.ni_pathbuf);
+	if (nd.ni_pathbuf != NULL) {
+		pathbuf_destroy(nd.ni_pathbuf);
+		nd.ni_pathbuf = NULL;
+	}
 	abort = 0;
 	nfsm_reply(NFSX_SRVFH(nsfh, v3) + NFSX_POSTOPATTR(v3) +
 	NFSX_WCCDATA(v3));
@@ -2326,7 +2344,10 @@
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vrele(nd.ni_vp);
-		pathbuf_destroy(nd.ni_pathbuf);
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	if (dirp)
 		vrele(dirp);
@@ -2374,6 +2395,7 @@
 	if (error) {
 		if (nd.ni_pathbuf != NULL) {
 			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
 		}
 		nfsm_reply(NFSX_WCCDATA(v3));
 		nfsm_srvwcc_data(dirfor_ret, dirfor, diraft_ret, diraft);
@@ -2419,7 +2441,10 @@
 		vrele(dirp);
 		dirp = NULL;
 	}
-	pathbuf_destroy(nd.ni_pathbuf);
+	if (nd.ni_pathbuf != NULL) {
+		pathbuf_destroy(nd.ni_pathbuf);
+		nd.ni_pathbuf = NULL;
+	}
 	abort = 0;
 	nfsm_reply(NFSX_SRVFH(nsfh, v3) + NFSX_POSTOPATTR(v3) +
 	NFSX_WCCDATA(v3));
@@ -2444,7 +2469,10 @@
 			vput(nd.ni_dvp);
 		if (nd.ni_vp)
 			vrele(nd.ni_vp);
-		pathbuf_destroy(nd.ni_pathbuf);
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
+		}
 	}
 	if (dirp)
 		vrele(dirp);
@@ -2487,6 +2515,7 @@
 	if (error) {
 		if (nd.ni_pathbuf != NULL) {
 			pathbuf_destroy(nd.ni_pathbuf);
+			nd.ni_pathbuf = NULL;
 		}
 		nfsm_reply(NFSX_WCCDATA(v3));
 		nfsm_srvwcc_data(dirfor_ret, dirfor, diraft_ret, diraft);
@@ -2524,7 +2553,10 @@
 			vput(nd.ni_dvp);
 		vput(vp);
 	}
-	pathbuf_destroy(nd.ni_pathbuf);
+	if (nd.ni_pathbuf != NULL) {
+		pathbuf_destroy(nd.ni_pathbuf);
+		nd.ni_pathbuf = NULL;
+	}
 	if (dirp) {
 		if (v3) {
 			diraft_ret = VOP_GETATTR(dirp, diraft, cred);

Index: src/sys/nfs/nfs_srvsubs.c
diff -u src/sys/nfs/nfs_srvsubs.c:1.10 src/sys/nfs/nfs_srvsubs.c:1.11
--- src/sys/nfs/nfs_srvsubs.c:1.10	Mon Apr 11 01:33:05 2011
+++ src/sys/nfs/nfs_srvsubs.c	Mon Aug  8 16:04:07 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsubs.c,v 1.10 2011/04/11 01:33:05 dholland Exp $	*/
+/*	$NetBSD: nfs_srvsubs.c,v 1.11 2011/08/08 

CVS commit: src/sys/nfs

2011-04-17 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Apr 18 00:38:33 UTC 2011

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

Log Message:
Back in -r1.60 of nfs_serv.c (a long time ago) VOP_MKNOD was changed
so nfsd no longer needed to do a lookup() call immediately afterwards
to retrieve the newly created object.

Since that change there has been no way for ISSYMLINK to be set upon
return from VOP_MKNOD (or before the call to VOP_MKNOD either) so
remove the test for it and associated block of dead code.

(I do not understand how this code was reachable before then either.
The logic in question is only reached if no object by that name
existed, and there's no reasonable way that a successful call to
VOP_MKNOD should ever create a symlink. The code appears to come from
4.4lite; maybe they had locking bugs?)


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 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.158 src/sys/nfs/nfs_serv.c:1.159
--- src/sys/nfs/nfs_serv.c:1.158	Mon Apr 11 01:33:05 2011
+++ src/sys/nfs/nfs_serv.c	Mon Apr 18 00:38:33 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.158 2011/04/11 01:33:05 dholland Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.158 2011/04/11 01:33:05 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1527,18 +1527,6 @@
 			if (error) {
 nfsm_reply(0);
 			}
-			if (nd.ni_cnd.cn_flags  ISSYMLINK) {
-vput(nd.ni_vp);
-vrele(nd.ni_dvp);
-VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
-if (nd.ni_pathbuf != NULL) {
-	pathbuf_destroy(nd.ni_pathbuf);
-	nd.ni_pathbuf = NULL;
-}
-error = EINVAL;
-abort = 0;
-nfsm_reply(0);
-			}
 		} else {
 			VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
 			if (nd.ni_pathbuf != NULL) {
@@ -1743,11 +1731,6 @@
 		error = VOP_MKNOD(nd.ni_dvp, nd.ni_vp, nd.ni_cnd, va);
 		if (error)
 			goto out;
-		if (nd.ni_cnd.cn_flags  ISSYMLINK) {
-			vput(nd.ni_vp);
-			VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
-			error = EINVAL;
-		}
 	}
 out:
 	vp = nd.ni_vp;



CVS commit: src/sys/nfs

2011-03-23 Thread Thor Lancelot Simon
Module Name:src
Committed By:   tls
Date:   Wed Mar 23 17:42:11 UTC 2011

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

Log Message:
As suggested by matt@: change socket buffer reservations for NFS send/receive
to 3 times max RPC size rather than 2 times.  Avoids nasty TCP stalls observed
at Panix.  Will require increase to sbmax via sysctl for those running really
huge NFS rsize/wsize (64K).


To generate a diff of this commit:
cvs rdiff -u -r1.188 -r1.189 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.188 src/sys/nfs/nfs_socket.c:1.189
--- src/sys/nfs/nfs_socket.c:1.188	Fri Dec 17 22:22:00 2010
+++ src/sys/nfs/nfs_socket.c	Wed Mar 23 17:42:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.188 2010/12/17 22:22:00 yamt Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.189 2011/03/23 17:42:11 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.188 2010/12/17 22:22:00 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.189 2011/03/23 17:42:11 tls Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -292,13 +292,13 @@
 		so-so_snd.sb_timeo = 0;
 	}
 	if (nmp-nm_sotype == SOCK_DGRAM) {
-		sndreserve = (nmp-nm_wsize + NFS_MAXPKTHDR) * 2;
+		sndreserve = (nmp-nm_wsize + NFS_MAXPKTHDR) * 3;
 		rcvreserve = (max(nmp-nm_rsize, nmp-nm_readdirsize) +
 		NFS_MAXPKTHDR) * 2;
 	} else if (nmp-nm_sotype == SOCK_SEQPACKET) {
-		sndreserve = (nmp-nm_wsize + NFS_MAXPKTHDR) * 2;
+		sndreserve = (nmp-nm_wsize + NFS_MAXPKTHDR) * 3;
 		rcvreserve = (max(nmp-nm_rsize, nmp-nm_readdirsize) +
-		NFS_MAXPKTHDR) * 2;
+		NFS_MAXPKTHDR) * 3;
 	} else {
 		sounlock(so);
 		if (nmp-nm_sotype != SOCK_STREAM)
@@ -314,9 +314,9 @@
 			sizeof(val));
 		}
 		sndreserve = (nmp-nm_wsize + NFS_MAXPKTHDR +
-		sizeof (u_int32_t)) * 2;
+		sizeof (u_int32_t)) * 3;
 		rcvreserve = (nmp-nm_rsize + NFS_MAXPKTHDR +
-		sizeof (u_int32_t)) * 2;
+		sizeof (u_int32_t)) * 3;
 		solock(so);
 	}
 	error = soreserve(so, sndreserve, rcvreserve);



CVS commit: src/sys/nfs

2011-03-18 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sat Mar 19 01:34:25 UTC 2011

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

Log Message:
Fix memory leak introduced with the struct pathbuf changes. Hi, me.
Closes PR 44625.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.8 -r1.9 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_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.156 src/sys/nfs/nfs_serv.c:1.157
--- src/sys/nfs/nfs_serv.c:1.156	Sat Feb  5 13:35:11 2011
+++ src/sys/nfs/nfs_serv.c	Sat Mar 19 01:34:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.157 2011/03/19 01:34:24 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.157 2011/03/19 01:34:24 dholland Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -463,6 +463,12 @@
 	}
 
 	if (error) {
+		if (nd.ni_pathbuf != NULL) {
+			pathbuf_destroy(nd.ni_pathbuf);
+		}
+		if (ipb != NULL) {
+			pathbuf_destroy(ipb);
+		}
 		nfsm_reply(NFSX_POSTOPATTR(v3));
 		nfsm_srvpostop_attr(dirattr_ret, dirattr);
 		return (0);

Index: src/sys/nfs/nfs_srvsubs.c
diff -u src/sys/nfs/nfs_srvsubs.c:1.8 src/sys/nfs/nfs_srvsubs.c:1.9
--- src/sys/nfs/nfs_srvsubs.c:1.8	Tue Nov 30 10:30:03 2010
+++ src/sys/nfs/nfs_srvsubs.c	Sat Mar 19 01:34:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsubs.c,v 1.8 2010/11/30 10:30:03 dholland Exp $	*/
+/*	$NetBSD: nfs_srvsubs.c,v 1.9 2011/03/19 01:34:24 dholland Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_srvsubs.c,v 1.8 2010/11/30 10:30:03 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_srvsubs.c,v 1.9 2011/03/19 01:34:24 dholland Exp $);
 
 #include sys/param.h
 #include sys/proc.h
@@ -276,6 +276,7 @@
 out:
 	if (ndp-ni_pathbuf != NULL) {
 		pathbuf_destroy(ndp-ni_pathbuf);
+		ndp-ni_pathbuf = NULL;
 	} else {
 		PNBUF_PUT(path);
 	}



CVS commit: src/sys/nfs

2011-02-05 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat Feb  5 13:35:11 UTC 2011

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

Log Message:
typo in a comment


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 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.155 src/sys/nfs/nfs_serv.c:1.156
--- src/sys/nfs/nfs_serv.c:1.155	Sun Jan  2 05:12:34 2011
+++ src/sys/nfs/nfs_serv.c	Sat Feb  5 13:35:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.155 2011/01/02 05:12:34 dholland Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.155 2011/01/02 05:12:34 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -3486,7 +3486,7 @@
  * what the heck.
  *
  * The exception to rule 2 is EPERM. If a file is IMMUTABLE, VOP_ACCESS()
- * will return EPERM instead of EACCESS. EPERM is always an error.
+ * will return EPERM instead of EACCES. EPERM is always an error.
  */
 int
 nfsrv_access(struct vnode *vp, int flags, kauth_cred_t cred, int rdonly, struct lwp *lwp, int override)



CVS commit: src/sys/nfs

2010-12-17 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Fri Dec 17 22:22:00 UTC 2010

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

Log Message:
nfs_rcvunlock: don't wake up all waiters.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 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.187 src/sys/nfs/nfs_socket.c:1.188
--- src/sys/nfs/nfs_socket.c:1.187	Tue Mar  2 23:19:09 2010
+++ src/sys/nfs/nfs_socket.c	Fri Dec 17 22:22:00 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.187 2010/03/02 23:19:09 pooka Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.188 2010/12/17 22:22:00 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.187 2010/03/02 23:19:09 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.188 2010/12/17 22:22:00 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -906,10 +906,12 @@
 		 * receive lock.
 		 */
 		if (rep-r_mrep != NULL) {
+			cv_signal(nmp-nm_rcvcv);
 			error = EALREADY;
 			break;
 		}
 		if (nfs_sigintr(rep-r_nmp, rep, rep-r_lwp)) {
+			cv_signal(nmp-nm_rcvcv);
 			error = EINTR;
 			break;
 		}
@@ -944,7 +946,7 @@
 	if ((nmp-nm_iflag  NFSMNT_RCVLOCK) == 0)
 		panic(nfs rcvunlock);
 	nmp-nm_iflag = ~NFSMNT_RCVLOCK;
-	cv_broadcast(nmp-nm_rcvcv);
+	cv_signal(nmp-nm_rcvcv);
 	mutex_exit(nmp-nm_lock);
 }
 



CVS commit: src/sys/nfs

2010-12-14 Thread Christoph Egger
Module Name:src
Committed By:   cegger
Date:   Tue Dec 14 16:25:19 UTC 2010

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

Log Message:
back out rev. 1.285. The problem I try to hunt down
in PR 42455 is not in the network stack as shown by PR 44206.


To generate a diff of this commit:
cvs rdiff -u -r1.287 -r1.288 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.287 src/sys/nfs/nfs_vnops.c:1.288
--- src/sys/nfs/nfs_vnops.c:1.287	Tue Nov 30 10:43:05 2010
+++ src/sys/nfs/nfs_vnops.c	Tue Dec 14 16:25:18 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.287 2010/11/30 10:43:05 dholland Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.288 2010/12/14 16:25:18 cegger Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.287 2010/11/30 10:43:05 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.288 2010/12/14 16:25:18 cegger Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1369,14 +1369,6 @@
 		if (v3) {
 			wccflag = NFSV3_WCCCHK;
 			nfsm_wcc_data(vp, wccflag, NAC_NOTRUNC, !error);
-
-			/* Diagnostic check: The KASSERT hits when PR 42455
-			 * is reproduced.
-			 */
-			if (ctx.nwc_mbufcount = 2) {
-KASSERT(mb-m_next != NULL);
-			}
-
 			if (!error) {
 nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED
 	+ NFSX_V3WRITEVERF);



CVS commit: src/sys/nfs

2010-12-14 Thread Christoph Egger
Module Name:src
Committed By:   cegger
Date:   Tue Dec 14 16:58:59 UTC 2010

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

Log Message:
Initialize mutex and cv after sanity checks


To generate a diff of this commit:
cvs rdiff -u -r1.288 -r1.289 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.288 src/sys/nfs/nfs_vnops.c:1.289
--- src/sys/nfs/nfs_vnops.c:1.288	Tue Dec 14 16:25:18 2010
+++ src/sys/nfs/nfs_vnops.c	Tue Dec 14 16:58:58 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.288 2010/12/14 16:25:18 cegger Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.289 2010/12/14 16:58:58 cegger Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.288 2010/12/14 16:25:18 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.289 2010/12/14 16:58:58 cegger Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1278,10 +1278,6 @@
 	int rlen, commit;
 #endif
 
-	mutex_init(ctx.nwc_lock, MUTEX_DRIVER, IPL_VM);
-	cv_init(ctx.nwc_cv, nfsmblk);
-	ctx.nwc_mbufcount = 1;
-
 	if (vp-v_mount-mnt_flag  MNT_RDONLY) {
 		panic(writerpc readonly vp %p, vp);
 	}
@@ -1292,7 +1288,12 @@
 #endif
 	tsiz = uiop-uio_resid;
 	if (uiop-uio_offset + tsiz  nmp-nm_maxfilesize)
-		return (EFBIG);
+		return EFBIG;
+
+	mutex_init(ctx.nwc_lock, MUTEX_DRIVER, IPL_VM);
+	cv_init(ctx.nwc_cv, nfsmblk);
+	ctx.nwc_mbufcount = 1;
+
 retry:
 	origresid = uiop-uio_resid;
 	KASSERT(origresid == uiop-uio_iov-iov_len);



CVS commit: src/sys/nfs

2010-11-06 Thread Masao Uebayashi
Module Name:src
Committed By:   uebayasi
Date:   Sat Nov  6 11:00:29 UTC 2010

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

Log Message:
Include uvm/uvm.h to use UVM internal type (struct vm_page).


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 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.219 src/sys/nfs/nfs_subs.c:1.220
--- src/sys/nfs/nfs_subs.c:1.219	Tue Mar  2 23:19:09 2010
+++ src/sys/nfs/nfs_subs.c	Sat Nov  6 11:00:29 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.219 2010/03/02 23:19:09 pooka Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.220 2010/11/06 11:00:29 uebayasi Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.219 2010/03/02 23:19:09 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.220 2010/11/06 11:00:29 uebayasi Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -99,7 +99,7 @@
 #include sys/kauth.h
 #include sys/atomic.h
 
-#include uvm/uvm_extern.h
+#include uvm/uvm.h
 
 #include nfs/rpcv2.h
 #include nfs/nfsproto.h



CVS commit: src/sys/nfs

2010-10-26 Thread Christoph Egger
Module Name:src
Committed By:   cegger
Date:   Tue Oct 26 11:44:53 UTC 2010

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

Log Message:
Add diagnostic check which hits when PR 42455 is reproduced.
Idea from hans@


To generate a diff of this commit:
cvs rdiff -u -r1.284 -r1.285 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.284 src/sys/nfs/nfs_vnops.c:1.285
--- src/sys/nfs/nfs_vnops.c:1.284	Thu Jun 24 13:03:17 2010
+++ src/sys/nfs/nfs_vnops.c	Tue Oct 26 11:44:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.284 2010/06/24 13:03:17 hannken Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.285 2010/10/26 11:44:53 cegger Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.284 2010/06/24 13:03:17 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.285 2010/10/26 11:44:53 cegger Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1378,6 +1378,14 @@
 		if (v3) {
 			wccflag = NFSV3_WCCCHK;
 			nfsm_wcc_data(vp, wccflag, NAC_NOTRUNC, !error);
+
+			/* Diagnostic check: The KASSERT hits when PR 42455
+			 * is reproduced.
+			 */
+			if (ctx.nwc_mbufcount = 2) {
+KASSERT(mb-m_next != NULL);
+			}
+
 			if (!error) {
 nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED
 	+ NFSX_V3WRITEVERF);



CVS commit: src/sys/nfs

2010-10-04 Thread Erik Berls
Module Name:src
Committed By:   cyber
Date:   Mon Oct  4 23:48:23 UTC 2010

Modified Files:
src/sys/nfs: nfs_boot.c nfs_bootdhcp.c nfsdiskless.h

Log Message:
Add support to honor MTU settings from DHCP during netboot.

Defines IP_MIN_MTU as 576.

Glanced over quickly by martin@ and jo...@.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/nfs/nfs_boot.c
cvs rdiff -u -r1.51 -r1.52 src/sys/nfs/nfs_bootdhcp.c
cvs rdiff -u -r1.29 -r1.30 src/sys/nfs/nfsdiskless.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_boot.c
diff -u src/sys/nfs/nfs_boot.c:1.79 src/sys/nfs/nfs_boot.c:1.80
--- src/sys/nfs/nfs_boot.c:1.79	Wed Mar  4 06:56:25 2009
+++ src/sys/nfs/nfs_boot.c	Mon Oct  4 23:48:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_boot.c,v 1.79 2009/03/04 06:56:25 nisimura Exp $	*/
+/*	$NetBSD: nfs_boot.c,v 1.80 2010/10/04 23:48:22 cyber Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_boot.c,v 1.79 2009/03/04 06:56:25 nisimura Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_boot.c,v 1.80 2010/10/04 23:48:22 cyber Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -91,6 +91,8 @@
 int nfs_boot_bootstatic = 1; /* BOOTSTATIC enabled (default) */
 #endif
 
+#define IP_MIN_MTU 576
+
 /* mountd RPC */
 static int md_mount(struct sockaddr_in *mdsin, char *path,
 	struct nfs_args *argp, struct lwp *l);
@@ -155,6 +157,12 @@
 		return (error);
 
 	/*
+	 * Set MTU if passed
+	 */
+	if (nd-nd_mtu = IP_MIN_MTU )
+		nfs_boot_setmtu(nd-nd_ifp, nd-nd_mtu, lwp);
+	
+	/*
 	 * If the gateway address is set, add a default route.
 	 * (The mountd RPCs may go across a gateway.)
 	 */
@@ -236,6 +244,48 @@
 	return (error);
 }
 
+void
+nfs_boot_setmtu(struct ifnet *ifp, int mtu, struct lwp *lwp)
+{
+	struct socket *so;
+	struct ifreq ireq;
+	int error;
+
+	memset(ireq, 0, sizeof(ireq));
+	memcpy(ireq.ifr_name, ifp-if_xname, IFNAMSIZ);
+
+	/*
+	 * Get a socket to use for various things in here.
+	 * After this, use goto out to cleanup and return.
+	 */
+	error = socreate(AF_INET, so, SOCK_DGRAM, 0, lwp, NULL);
+	if (error) {
+		printf(setmtu: socreate, error=%d\n, error);
+		return;
+	}
+
+	/*
+	 * Get structure, set the new MTU, push structure.
+	 */
+	error = ifioctl(so, SIOCGIFMTU, (void *)ireq, lwp);
+	if (error) {
+		printf(setmtu: GIFMTU, error=%d\n, error);
+		goto out;
+	}
+
+	ireq.ifr_mtu = mtu;
+
+	error = ifioctl(so, SIOCSIFMTU, ireq, lwp);
+	if (error) {
+		printf(setmtu: SIFMTU, error=%d\n, error);
+		goto out;
+	}
+
+out:
+	soclose(so);
+	return;
+}
+
 int
 nfs_boot_setaddress(struct ifnet *ifp, struct lwp *lwp,
 		uint32_t addr, uint32_t netmask, uint32_t braddr)

Index: src/sys/nfs/nfs_bootdhcp.c
diff -u src/sys/nfs/nfs_bootdhcp.c:1.51 src/sys/nfs/nfs_bootdhcp.c:1.52
--- src/sys/nfs/nfs_bootdhcp.c:1.51	Fri Jul 10 12:16:31 2009
+++ src/sys/nfs/nfs_bootdhcp.c	Mon Oct  4 23:48:22 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootdhcp.c,v 1.51 2009/07/10 12:16:31 roy Exp $	*/
+/*	$NetBSD: nfs_bootdhcp.c,v 1.52 2010/10/04 23:48:22 cyber 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.51 2009/07/10 12:16:31 roy Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bootdhcp.c,v 1.52 2010/10/04 23:48:22 cyber Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs_boot.h
@@ -176,6 +176,8 @@
 #define TAG_DOMAIN_NAME		((unsigned char)  15)
 #define TAG_SWAP_SERVER		((unsigned char)  16)
 #define TAG_ROOT_PATH		((unsigned char)  17)
+/* RFC 2132 */
+#define TAG_INTERFACE_MTU	((unsigned char)  26)
 /* End of stuff from bootp.h */
 
 #ifdef NFS_BOOT_DHCP
@@ -203,6 +205,8 @@
 #define DHCPRELEASE 7
 #endif
 
+#define IP_MIN_MTU 576
+
 #ifdef NFS_BOOT_DHCP
 #define BOOTP_SIZE_MAX	(sizeof(struct bootp)+312-64)
 #else
@@ -453,13 +457,14 @@
 	int vcilen;
 	
 	*area++ = TAG_PARAM_REQ;
-	*area++ = 6;
+	*area++ = 7;
 	*area++ = TAG_SUBNET_MASK;
 	*area++ = TAG_GATEWAY;
 	*area++ = TAG_HOST_NAME;
 	*area++ = TAG_DOMAIN_NAME;
 	*area++ = TAG_ROOT_PATH;
 	*area++ = TAG_SWAP_SERVER;
+	*area++ = TAG_INTERFACE_MTU;
 
 	/* Insert a NetBSD Vendor Class Identifier option. */
 	snprintf(vci, sizeof(vci), %s:%s:kernel:%s, ostype, MACHINE,
@@ -699,6 +704,7 @@
 	char *myname;	/* my hostname */
 	char *mydomain;	/* my domainname */
 	char *rootpath;
+	uint16_t myinterfacemtu;
 	int mynamelen;
 	int mydomainlen;
 	int rootpathlen;
@@ -716,6 +722,8 @@
 	rootserver = bootp-bp_siaddr;
 	/* assume that server name field is not overloaded by default */
 	overloaded = 0;
+	/* MTU can't be less than IP_MIN_MTU, set to 0 to indicate unset */
+	myinterfacemtu = 0;
 
 	p = bootp-bp_vend[4];
 	limit = ((u_char*)bootp) + replylen;
@@ -776,6 +784,15 @@
 			rootpath = p;
 			rootpathlen = len;
 			break;
+		case TAG_INTERFACE_MTU:
+			if (len != 2) 

CVS commit: src/sys/nfs

2010-08-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Aug 12 09:41:11 UTC 2010

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

Log Message:
Do not return a garbage vnode in vpp if fhtovp fails.

Fixes PR kern/43745 for nfs.


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 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.216 src/sys/nfs/nfs_vfsops.c:1.217
--- src/sys/nfs/nfs_vfsops.c:1.216	Wed Jul 21 17:52:13 2010
+++ src/sys/nfs/nfs_vfsops.c	Thu Aug 12 09:41:10 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.216 2010/07/21 17:52:13 hannken Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.217 2010/08/12 09:41:10 pooka Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.216 2010/07/21 17:52:13 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.217 2010/08/12 09:41:10 pooka Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_nfs.h
@@ -1104,6 +1104,7 @@
 	error = VOP_GETATTR(*vpp, va, kauth_cred_get());
 	if (error != 0) {
 		vput(*vpp);
+		*vpp = NULLVP;
 	}
 	return error;
 }



CVS commit: src/sys/nfs

2010-07-09 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Jul  9 08:25:57 UTC 2010

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

Log Message:
nfs_unmount(): No need to take a second reference for the root node.

nfs_root():Replace vget() with vref()/vn_lock(), this node already
   has a reference.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 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.214 src/sys/nfs/nfs_vfsops.c:1.215
--- src/sys/nfs/nfs_vfsops.c:1.214	Thu Jun 24 13:03:17 2010
+++ src/sys/nfs/nfs_vfsops.c	Fri Jul  9 08:25:57 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.214 2010/06/24 13:03:17 hannken Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.215 2010/07/09 08:25:57 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.214 2010/06/24 13:03:17 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vfsops.c,v 1.215 2010/07/09 08:25:57 hannken Exp $);
 
 #if defined(_KERNEL_OPT)
 #include opt_nfs.h
@@ -864,22 +864,21 @@
 	 */
 	/*
 	 * We need to decrement the ref. count on the nfsnode representing
-	 * the remote root.  See comment in mountnfs().  The VFS unmount()
-	 * has done vput on this vnode, otherwise we would get deadlock!
+	 * the remote root.  See comment in mountnfs().
 	 */
 	vp = nmp-nm_vnode;
-	error = vget(vp, LK_EXCLUSIVE | LK_RETRY);
+	error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
 	if (error != 0)
 		return error;
 
-	if ((mntflags  MNT_FORCE) == 0  vp-v_usecount  2) {
-		vput(vp);
+	if ((mntflags  MNT_FORCE) == 0  vp-v_usecount  1) {
+		VOP_UNLOCK(vp);
 		return (EBUSY);
 	}
 
 	error = vflush(mp, vp, flags);
 	if (error) {
-		vput(vp);
+		VOP_UNLOCK(vp);
 		return (error);
 	}
 
@@ -898,10 +897,10 @@
 	iostat_free(nmp-nm_stats);
 
 	/*
-	 * There are two reference counts to get rid of here
+	 * There is one reference count to get rid of here
 	 * (see comment in mountnfs()).
 	 */
-	vput(vp);
+	VOP_UNLOCK(vp);
 	vgone(vp);
 	nfs_disconnect(nmp);
 	m_freem(nmp-nm_nam);
@@ -929,9 +928,12 @@
 
 	nmp = VFSTONFS(mp);
 	vp = nmp-nm_vnode;
-	error = vget(vp, LK_EXCLUSIVE | LK_RETRY);
-	if (error != 0)
+	vref(vp);
+	error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+	if (error != 0) {
+		vrele(vp);
 		return error;
+	}
 	*vpp = vp;
 	return (0);
 }



CVS commit: src/sys/nfs

2010-06-12 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Jun 12 21:10:55 UTC 2010

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

Log Message:
Fix memory leak during some NFS writes.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 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.184 src/sys/nfs/nfs_bio.c:1.185
--- src/sys/nfs/nfs_bio.c:1.184	Fri Apr 23 15:38:47 2010
+++ src/sys/nfs/nfs_bio.c	Sat Jun 12 21:10:55 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bio.c,v 1.184 2010/04/23 15:38:47 pooka Exp $	*/
+/*	$NetBSD: nfs_bio.c,v 1.185 2010/06/12 21:10:55 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.184 2010/04/23 15:38:47 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.185 2010/06/12 21:10:55 jakllsch Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -1049,7 +1049,7 @@
 pgs[i]-flags = ~(PG_NEEDCOMMIT | PG_RDONLY);
 			}
 			mutex_exit(uobj-vmobjlock);
-			return 0;
+			goto out;
 		} else if (error == NFSERR_STALEWRITEVERF) {
 			nfs_clearcommit(vp-v_mount);
 			goto again;



CVS commit: src/sys/nfs

2010-03-20 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Mar 21 00:10:40 UTC 2010

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

Log Message:
in nfs_bootparam(), set the corresponding flag for each field that we fill in.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/sys/nfs/nfs_bootparam.c:1.37
--- src/sys/nfs/nfs_bootparam.c:1.36	Tue Mar  2 23:19:09 2010
+++ src/sys/nfs/nfs_bootparam.c	Sun Mar 21 00:10:40 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootparam.c,v 1.36 2010/03/02 23:19:09 pooka Exp $	*/
+/*	$NetBSD: nfs_bootparam.c,v 1.37 2010/03/21 00:10:40 chs Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1997 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_bootparam.c,v 1.36 2010/03/02 23:19:09 pooka Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bootparam.c,v 1.37 2010/03/21 00:10:40 chs Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs_boot.h
@@ -178,6 +178,7 @@
 		printf(nfs_boot: bootparam whoami, error=%d\n, error);
 		goto delout;
 	}
+	*flags |= NFS_BOOT_HAS_SERVADDR | NFS_BOOT_HAS_SERVER;
 	printf(nfs_boot: server_addr=%s\n, inet_ntoa(sin-sin_addr));
 	printf(nfs_boot: hostname=%s\n, hostname);
 
@@ -190,6 +191,7 @@
 		printf(nfs_boot: bootparam get root: %d\n, error);
 		goto delout;
 	}
+	*flags |= NFS_BOOT_HAS_ROOTPATH;
 
 #ifndef NFS_BOOTPARAM_NOGATEWAY
 	gw_ndm = kmem_alloc(sizeof(*gw_ndm), KM_SLEEP);
@@ -208,6 +210,7 @@
 	printf(nfs_boot: gateway=%s\n, inet_ntoa(sin-sin_addr));
 	/* Just save it.  Caller adds the route. */
 	nd-nd_gwip = sin-sin_addr;
+	*flags |= NFS_BOOT_HAS_GWIP;
 
 	/* Look for a mask string after the colon. */
 	p = strchr(gw_ndm-ndm_host, ':');
@@ -221,6 +224,7 @@
 
 	/* Have a netmask too!  Save it; update the I/F. */
 	nd-nd_mask.s_addr = mask;
+	*flags |= NFS_BOOT_HAS_MASK;
 	printf(nfs_boot: my_mask=%s\n, inet_ntoa(nd-nd_mask));
 	(void)  nfs_boot_deladdress(ifp, lwp, my_ip.s_addr);
 	error = nfs_boot_setaddress(ifp, lwp, my_ip.s_addr,
@@ -248,6 +252,7 @@
 	if (gw_ip.s_addr) {
 		/* Our caller will add the route. */
 		nd-nd_gwip = gw_ip;
+		*flags |= NFS_BOOT_HAS_GWIP;
 	}
 #endif
 



CVS commit: src/sys/nfs

2010-02-13 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sat Feb 13 11:17:31 UTC 2010

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

Log Message:
nfs_msg: #if 0 out tprintf for now and comment why.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 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.185 src/sys/nfs/nfs_socket.c:1.186
--- src/sys/nfs/nfs_socket.c:1.185	Tue Jan 19 13:39:04 2010
+++ src/sys/nfs/nfs_socket.c	Sat Feb 13 11:17:30 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.185 2010/01/19 13:39:04 yamt Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.186 2010/02/13 11:17:30 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.185 2010/01/19 13:39:04 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.186 2010/02/13 11:17:30 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include fs_nfs.h
@@ -2157,9 +2157,11 @@
 {
 	tpr_t tpr;
 
+#if 0 /* XXX nfs_timer can't block on proc_lock */
 	if (l)
 		tpr = tprintf_open(l-l_proc);
 	else
+#endif
 		tpr = NULL;
 	tprintf(tpr, nfs server %s: %s\n, server, msg);
 	tprintf_close(tpr);



CVS commit: src/sys/nfs

2010-01-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Jan 19 13:29:40 UTC 2010

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

Log Message:
remove unused r_timer member.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/nfs/nfs.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.70 src/sys/nfs/nfs.h:1.71
--- src/sys/nfs/nfs.h:1.70	Wed Oct 22 11:36:06 2008
+++ src/sys/nfs/nfs.h	Tue Jan 19 13:29:40 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.h,v 1.70 2008/10/22 11:36:06 matt Exp $	*/
+/*	$NetBSD: nfs.h,v 1.71 2010/01/19 13:29:40 yamt Exp $	*/
 /*
  * Copyright (c) 1989, 1993, 1995
  *	The Regents of the University of California.  All rights reserved.
@@ -329,7 +329,6 @@
 	int		r_flags;	/* flags on request, see below */
 	int		r_retry;	/* max retransmission count */
 	int		r_rexmit;	/* current retrans count */
-	int		r_timer;	/* tick counter on reply */
 	u_int32_t	r_procnum;	/* NFS procedure number */
 	int		r_rtt;		/* RTT for rpc */
 	struct lwp	*r_lwp;		/* LWP that did I/O system call */



CVS commit: src/sys/nfs

2010-01-19 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Tue Jan 19 13:39:04 UTC 2010

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

Log Message:
nfs_request: fix races which break congestion window and make nfs client stuck.


To generate a diff of this commit:
cvs rdiff -u -r1.184 -r1.185 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.184 src/sys/nfs/nfs_socket.c:1.185
--- src/sys/nfs/nfs_socket.c:1.184	Thu Dec 31 19:31:31 2009
+++ src/sys/nfs/nfs_socket.c	Tue Jan 19 13:39:04 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.184 2009/12/31 19:31:31 christos Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.185 2010/01/19 13:39:04 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.184 2009/12/31 19:31:31 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.185 2010/01/19 13:39:04 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include fs_nfs.h
@@ -1133,10 +1133,14 @@
 			if (nmp-nm_soflags  PR_CONNREQUIRED)
 nfs_sndunlock(nmp);
 		}
+		s = splsoftnet();
 		if (!error  (rep-r_flags  R_MUSTRESEND) == 0) {
-			nmp-nm_sent += NFS_CWNDSCALE;
-			rep-r_flags |= R_SENT;
+			if ((rep-r_flags  R_SENT) == 0) {
+nmp-nm_sent += NFS_CWNDSCALE;
+rep-r_flags |= R_SENT;
+			}
 		}
+		splx(s);
 	} else {
 		splx(s);
 		rep-r_rtt = -1;
@@ -1153,7 +1157,6 @@
 	 */
 	s = splsoftnet();
 	TAILQ_REMOVE(nfs_reqq, rep, r_chain);
-	splx(s);
 
 	/*
 	 * Decrement the outstanding request count.
@@ -1162,6 +1165,7 @@
 		rep-r_flags = ~R_SENT;	/* paranoia */
 		nmp-nm_sent -= NFS_CWNDSCALE;
 	}
+	splx(s);
 
 	if (rexmitp != NULL) {
 		int rexmit;



CVS commit: src/sys/nfs

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 19:30:45 UTC 2009

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

Log Message:
nuidhash_max is needed by sys_nfssvc


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

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/files.nfs
diff -u src/sys/nfs/files.nfs:1.9 src/sys/nfs/files.nfs:1.10
--- src/sys/nfs/files.nfs:1.9	Wed Nov 19 13:36:09 2008
+++ src/sys/nfs/files.nfs	Thu Dec 31 14:30:45 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: files.nfs,v 1.9 2008/11/19 18:36:09 ad Exp $
+#	$NetBSD: files.nfs,v 1.10 2009/12/31 19:30:45 christos Exp $
 
 deffs	fs_nfs.h		NFS
 
@@ -23,7 +23,7 @@
 file	nfs/nfs_bootparam.c	nfs  nfs_boot_bootparam
 file	nfs/nfs_bootstatic.c	nfs  nfs_boot_bootstatic
 file	nfs/nfs_export.c	nfsserver
-file	nfs/nfs_iod.c		nfs
+file	nfs/nfs_iod.c		nfsserver | nfs
 file	nfs/nfs_kq.c		nfs
 file	nfs/nfs_node.c		nfs
 file	nfs/nfs_serv.c		nfsserver



CVS commit: src/sys/nfs

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 19:31:31 UTC 2009

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

Log Message:
appease gcc.


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 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.183 src/sys/nfs/nfs_socket.c:1.184
--- src/sys/nfs/nfs_socket.c:1.183	Sun Dec  6 13:00:15 2009
+++ src/sys/nfs/nfs_socket.c	Thu Dec 31 14:31:31 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.183 2009/12/06 18:00:15 dyoung Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.184 2009/12/31 19:31:31 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.183 2009/12/06 18:00:15 dyoung Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.184 2009/12/31 19:31:31 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include fs_nfs.h
@@ -120,8 +120,8 @@
  * the nfs timer and reply error debugs every 10 seconds.
  */
 static const struct timeval nfs_err_interval = { 10, 0 };
-static struct timeval nfs_reply_last_err_time;
-static struct timeval nfs_timer_last_err_time;
+static struct timeval nfs_reply_last_err_time __attribute__((__used__));
+static struct timeval nfs_timer_last_err_time __attribute__((__used__));
 #endif
 
 /*



CVS commit: src/sys/nfs

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 19:38:16 UTC 2009

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

Log Message:
handle the nuidhash_max lossage differently


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/nfs/files.nfs
cvs rdiff -u -r1.3 -r1.4 src/sys/nfs/nfs_iod.c
cvs rdiff -u -r1.151 -r1.152 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/files.nfs
diff -u src/sys/nfs/files.nfs:1.10 src/sys/nfs/files.nfs:1.11
--- src/sys/nfs/files.nfs:1.10	Thu Dec 31 14:30:45 2009
+++ src/sys/nfs/files.nfs	Thu Dec 31 14:38:16 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: files.nfs,v 1.10 2009/12/31 19:30:45 christos Exp $
+#	$NetBSD: files.nfs,v 1.11 2009/12/31 19:38:16 christos Exp $
 
 deffs	fs_nfs.h		NFS
 
@@ -23,7 +23,7 @@
 file	nfs/nfs_bootparam.c	nfs  nfs_boot_bootparam
 file	nfs/nfs_bootstatic.c	nfs  nfs_boot_bootstatic
 file	nfs/nfs_export.c	nfsserver
-file	nfs/nfs_iod.c		nfsserver | nfs
+file	nfs/nfs_iod.c		nfs
 file	nfs/nfs_kq.c		nfs
 file	nfs/nfs_node.c		nfs
 file	nfs/nfs_serv.c		nfsserver

Index: src/sys/nfs/nfs_iod.c
diff -u src/sys/nfs/nfs_iod.c:1.3 src/sys/nfs/nfs_iod.c:1.4
--- src/sys/nfs/nfs_iod.c:1.3	Sat Mar 14 17:04:25 2009
+++ src/sys/nfs/nfs_iod.c	Thu Dec 31 14:38:16 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_iod.c,v 1.3 2009/03/14 21:04:25 dsl Exp $	*/
+/*	$NetBSD: nfs_iod.c,v 1.4 2009/12/31 19:38:16 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.3 2009/03/14 21:04:25 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.4 2009/12/31 19:38:16 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -75,7 +75,7 @@
 #include nfs/nfsrtt.h
 #include nfs/nfs_var.h
 
-int nuidhash_max = NFS_MAXUIDHASH;
+extern int nuidhash_max;
 
 /*
  * locking order:

Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.151 src/sys/nfs/nfs_syscalls.c:1.152
--- src/sys/nfs/nfs_syscalls.c:1.151	Wed Oct 21 17:12:06 2009
+++ src/sys/nfs/nfs_syscalls.c	Thu Dec 31 14:38:16 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.151 2009/10/21 21:12:06 rmind Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.152 2009/12/31 19:38:16 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.151 2009/10/21 21:12:06 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.152 2009/12/31 19:38:16 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -79,7 +79,7 @@
 		struct nfssvc_sock *,
 		struct lwp *, struct mbuf **);
 extern int nfsrvw_procrastinate;
-extern int nuidhash_max;
+int nuidhash_max = NFS_MAXUIDHASH;
 
 static int nfs_numnfsd = 0;
 static struct nfsdrt nfsdrt;



CVS commit: src/sys/nfs

2009-12-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 31 20:01:33 UTC 2009

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

Log Message:
put nuidhash_max in a file that is shared between server and client code.


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/nfs/nfs_subs.c
cvs rdiff -u -r1.152 -r1.153 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_subs.c
diff -u src/sys/nfs/nfs_subs.c:1.217 src/sys/nfs/nfs_subs.c:1.218
--- src/sys/nfs/nfs_subs.c:1.217	Thu May 14 11:42:22 2009
+++ src/sys/nfs/nfs_subs.c	Thu Dec 31 15:01:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.217 2009/05/14 15:42:22 yamt Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.218 2009/12/31 20:01:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.217 2009/05/14 15:42:22 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.218 2009/12/31 20:01:33 christos Exp $);
 
 #ifdef _KERNEL_OPT
 #include fs_nfs.h
@@ -118,6 +118,7 @@
 
 static u_int32_t nfs_xid;
 
+int nuidhash_max = NFS_MAXUIDHASH;
 /*
  * Data items converted to xdr at startup, since they are constant
  * This is kinda hokey, but may save a little time doing byte swaps

Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.152 src/sys/nfs/nfs_syscalls.c:1.153
--- src/sys/nfs/nfs_syscalls.c:1.152	Thu Dec 31 14:38:16 2009
+++ src/sys/nfs/nfs_syscalls.c	Thu Dec 31 15:01:33 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.152 2009/12/31 19:38:16 christos Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.153 2009/12/31 20:01:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.152 2009/12/31 19:38:16 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.153 2009/12/31 20:01:33 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -79,7 +79,7 @@
 		struct nfssvc_sock *,
 		struct lwp *, struct mbuf **);
 extern int nfsrvw_procrastinate;
-int nuidhash_max = NFS_MAXUIDHASH;
+extern int nuidhash_max;
 
 static int nfs_numnfsd = 0;
 static struct nfsdrt nfsdrt;



CVS commit: src/sys/nfs

2009-12-06 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Sun Dec  6 18:00:15 UTC 2009

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

Log Message:
For readability's sake, write NULL instead of (type *)0.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 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.182 src/sys/nfs/nfs_socket.c:1.183
--- src/sys/nfs/nfs_socket.c:1.182	Thu Nov  5 08:11:24 2009
+++ src/sys/nfs/nfs_socket.c	Sun Dec  6 18:00:15 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.182 2009/11/05 08:11:24 bouyer Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.183 2009/12/06 18:00:15 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.182 2009/11/05 08:11:24 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.183 2009/12/06 18:00:15 dyoung Exp $);
 
 #ifdef _KERNEL_OPT
 #include fs_nfs.h
@@ -206,7 +206,7 @@
 	struct mbuf *m;
 	int val;
 
-	nmp-nm_so = (struct socket *)0;
+	nmp-nm_so = NULL;
 	saddr = mtod(nmp-nm_nam, struct sockaddr *);
 	error = socreate(saddr-sa_family, nmp-nm_so,
 		nmp-nm_sotype, nmp-nm_soproto, l, NULL);
@@ -410,7 +410,7 @@
 
 	if (nmp-nm_so) {
 		so = nmp-nm_so;
-		nmp-nm_so = (struct socket *)0;
+		nmp-nm_so = NULL;
 		solock(so);
 		soshutdown(so, SHUT_RDWR);
 		sounlock(so);
@@ -489,7 +489,7 @@
 	} else
 		soflags = so-so_proto-pr_flags;
 	if ((soflags  PR_CONNREQUIRED) || (so-so_state  SS_ISCONNECTED))
-		sendnam = (struct mbuf *)0;
+		sendnam = NULL;
 	else
 		sendnam = nam;
 	if (so-so_type == SOCK_SEQPACKET)
@@ -573,8 +573,8 @@
 	/*
 	 * Set up arguments for soreceive()
 	 */
-	*mp = (struct mbuf *)0;
-	*aname = (struct mbuf *)0;
+	*mp = NULL;
+	*aname = NULL;
 	sotype = rep-r_nmp-nm_sotype;
 
 	/*
@@ -639,8 +639,8 @@
 			UIO_SETUP_SYSSPACE(auio);
 			do {
 			   rcvflg = MSG_WAITALL;
-			   error = (*so-so_receive)(so, (struct mbuf **)0, auio,
-(struct mbuf **)0, (struct mbuf **)0, rcvflg);
+			   error = (*so-so_receive)(so, NULL, auio,
+NULL, NULL, rcvflg);
 			   if (error == EWOULDBLOCK  rep) {
 if (rep-r_flags  R_SOFTTERM)
 	return (EINTR);
@@ -688,8 +688,8 @@
 			auio.uio_resid = len;
 			do {
 			rcvflg = MSG_WAITALL;
-			error =  (*so-so_receive)(so, (struct mbuf **)0,
-auio, mp, (struct mbuf **)0, rcvflg);
+			error =  (*so-so_receive)(so, NULL,
+auio, mp, NULL, rcvflg);
 			} while (error == EWOULDBLOCK || error == EINTR ||
  error == ERESTART);
 			if (!error  auio.uio_resid  0) {
@@ -713,7 +713,7 @@
 			/* not need to setup uio_vmspace */
 			do {
 			rcvflg = 0;
-			error =  (*so-so_receive)(so, (struct mbuf **)0,
+			error =  (*so-so_receive)(so, NULL,
 auio, mp, control, rcvflg);
 			if (control)
 m_freem(control);
@@ -732,7 +732,7 @@
 errout:
 		if (error  error != EINTR  error != ERESTART) {
 			m_freem(*mp);
-			*mp = (struct mbuf *)0;
+			*mp = NULL;
 			if (error != EPIPE)
 log(LOG_INFO,
 receive error %d from nfs server %s\n,
@@ -750,7 +750,7 @@
 		if ((so = rep-r_nmp-nm_so) == NULL)
 			return (EACCES);
 		if (so-so_state  SS_ISCONNECTED)
-			getnam = (struct mbuf **)0;
+			getnam = NULL;
 		else
 			getnam = aname;
 		auio.uio_resid = len = 100;
@@ -758,7 +758,7 @@
 		do {
 			rcvflg = 0;
 			error =  (*so-so_receive)(so, getnam, auio, mp,
-(struct mbuf **)0, rcvflg);
+NULL, rcvflg);
 			if (error == EWOULDBLOCK 
 			(rep-r_flags  R_SOFTTERM))
 return (EINTR);
@@ -769,7 +769,7 @@
 	}
 	if (error) {
 		m_freem(*mp);
-		*mp = (struct mbuf *)0;
+		*mp = NULL;
 	}
 	return (error);
 }
@@ -1004,7 +1004,7 @@
 	 * Get the RPC header with authorization.
 	 */
 kerbauth:
-	verf_str = auth_str = (char *)0;
+	verf_str = auth_str = NULL;
 	if (nmp-nm_flag  NFSMNT_KERB) {
 		verf_str = nickv;
 		verf_len = sizeof (nickv);
@@ -1196,7 +1196,7 @@
 		else if ((nmp-nm_flag  NFSMNT_KERB)  *tl++ == rpc_autherr) {
 			if (!failed_auth) {
 failed_auth++;
-mheadend-m_next = (struct mbuf *)0;
+mheadend-m_next = NULL;
 m_freem(mrep);
 m_freem(rep-r_mreq);
 goto kerbauth;
@@ -1691,10 +1691,10 @@
 		   (m = m_copym(rep-r_mreq, 0, M_COPYALL, M_DONTWAIT))){
 		if (so-so_state  SS_ISCONNECTED)
 			error = (*so-so_proto-pr_usrreq)(so, PRU_SEND, m,
-			(struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);
+			NULL, NULL, NULL);
 			else
 			error = (*so-so_proto-pr_usrreq)(so, PRU_SEND, m,
-			nmp-nm_nam, (struct mbuf *)0, (struct lwp *)0);
+			nmp-nm_nam, NULL, NULL);
 			if (error) {
 if (NFSIGNORE_SOERROR(nmp-nm_soflags, error)) {
 #ifdef DEBUG



CVS commit: src/sys/nfs

2009-10-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Fri Oct 16 23:36:06 UTC 2009

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

Log Message:
If send fails with EMSGSIZE for whatever reason, it's unlikely to
succeed no matter how hard we retry.  So just fail the request.


To generate a diff of this commit:
cvs rdiff -u -r1.180 -r1.181 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.180 src/sys/nfs/nfs_socket.c:1.181
--- src/sys/nfs/nfs_socket.c:1.180	Sat Mar 14 21:04:25 2009
+++ src/sys/nfs/nfs_socket.c	Fri Oct 16 23:36:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_socket.c,v 1.180 2009/03/14 21:04:25 dsl Exp $	*/
+/*	$NetBSD: nfs_socket.c,v 1.181 2009/10/16 23:36:05 pooka Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.180 2009/03/14 21:04:25 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_socket.c,v 1.181 2009/10/16 23:36:05 pooka Exp $);
 
 #ifdef _KERNEL_OPT
 #include fs_nfs.h
@@ -523,7 +523,7 @@
  */
 if (rep-r_flags  R_SOFTTERM)
 	error = EINTR;
-else
+else if (error != EMSGSIZE)
 	rep-r_flags |= R_MUSTRESEND;
 			}
 		} else {
@@ -540,7 +540,8 @@
 		 * Handle any recoverable (soft) socket errors here. (? ? ?)
 		 */
 		if (error != EINTR  error != ERESTART 
-			error != EWOULDBLOCK  error != EPIPE)
+		error != EWOULDBLOCK  error != EPIPE 
+		error != EMSGSIZE)
 			error = 0;
 	}
 	return (error);



CVS commit: src/sys/nfs

2009-09-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Sep 14 14:37:52 UTC 2009

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

Log Message:
Remove stale comment about super user.  no functional change


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 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.149 src/sys/nfs/nfs_syscalls.c:1.150
--- src/sys/nfs/nfs_syscalls.c:1.149	Tue Jul  7 14:09:05 2009
+++ src/sys/nfs/nfs_syscalls.c	Mon Sep 14 14:37:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.149 2009/07/07 14:09:05 christos Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.150 2009/09/14 14:37:52 pooka Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.149 2009/07/07 14:09:05 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.150 2009/09/14 14:37:52 pooka Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -128,9 +128,6 @@
 	struct nfssvc_sock *slp;
 	struct nfsuid *nuidp;
 
-	/*
-	 * Must be super user
-	 */
 	error = kauth_authorize_network(l-l_cred, KAUTH_NETWORK_NFS,
 	KAUTH_REQ_NETWORK_NFS_SVC, NULL, NULL, NULL);
 	if (error)



CVS commit: src/sys/nfs

2009-09-03 Thread Thor Lancelot Simon
Module Name:src
Committed By:   tls
Date:   Thu Sep  3 20:59:13 UTC 2009

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

Log Message:
Missed this file in previous commit, accidentally checked in fix to local
repository copy!  Sorry about that, folks.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/sys/nfs/nfs_srvsocket.c:1.4
--- src/sys/nfs/nfs_srvsocket.c:1.3	Sat Mar 14 15:36:24 2009
+++ src/sys/nfs/nfs_srvsocket.c	Thu Sep  3 20:59:12 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_srvsocket.c,v 1.3 2009/03/14 15:36:24 dsl Exp $	*/
+/*	$NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1995
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_srvsocket.c,v 1.3 2009/03/14 15:36:24 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_srvsocket.c,v 1.4 2009/09/03 20:59:12 tls Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -110,7 +110,7 @@
  * The void *arg is a pointer to the struct nfssvc_sock.
  */
 void
-nfsrv_soupcall(struct socket *so, void *arg, int waitflag)
+nfsrv_soupcall(struct socket *so, void *arg, int events, int waitflag)
 {
 	struct nfssvc_sock *slp = (struct nfssvc_sock *)arg;
 



CVS commit: src/sys/nfs

2009-09-03 Thread Thor Lancelot Simon
Module Name:src
Committed By:   tls
Date:   Thu Sep  3 21:06:21 UTC 2009

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

Log Message:
...and one more missed in the earlier commit (sigh).  Kernels should build
again now.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 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_var.h
diff -u src/sys/nfs/nfs_var.h:1.88 src/sys/nfs/nfs_var.h:1.89
--- src/sys/nfs/nfs_var.h:1.88	Tue Jul  7 14:09:05 2009
+++ src/sys/nfs/nfs_var.h	Thu Sep  3 21:06:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_var.h,v 1.88 2009/07/07 14:09:05 christos Exp $	*/
+/*	$NetBSD: nfs_var.h,v 1.89 2009/09/03 21:06:21 tls Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -183,7 +183,7 @@
 int nfs_sigintr(struct nfsmount *, struct nfsreq *, struct lwp *);
 int nfs_getreq(struct nfsrv_descript *, struct nfsd *, int);
 int nfs_msg(struct lwp *, const char *, const char *);
-void nfsrv_soupcall(struct socket *, void *, int);
+void nfsrv_soupcall(struct socket *, void *, int, int);
 void nfsrv_rcv(struct nfssvc_sock *);
 int nfsrv_getstream(struct nfssvc_sock *, int);
 int nfsrv_dorec(struct nfssvc_sock *, struct nfsd *, struct nfsrv_descript **,



CVS commit: src/sys/nfs

2009-07-14 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Tue Jul 14 20:59:54 UTC 2009

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

Log Message:
Use pid_t, not short, for a pid.
Part of PR 41255 from Kurt Lidl.


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 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.279 src/sys/nfs/nfs_vnops.c:1.280
--- src/sys/nfs/nfs_vnops.c:1.279	Tue Jun 23 19:36:40 2009
+++ src/sys/nfs/nfs_vnops.c	Tue Jul 14 20:59:54 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.279 2009/06/23 19:36:40 elad Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.280 2009/07/14 20:59:54 apb Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.279 2009/06/23 19:36:40 elad Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.280 2009/07/14 20:59:54 apb Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -2909,7 +2909,7 @@
 	struct sillyrename *sp;
 	struct nfsnode *np;
 	int error;
-	short pid;
+	pid_t pid;
 
 	cache_purge(dvp);
 	np = VTONFS(vp);



CVS commit: src/sys/nfs

2009-07-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jul  7 14:09:05 UTC 2009

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

Log Message:
The compatibility call to re-export from sys_mount() calls
mountd_set_exports_list, with the mnt_updating mutex held. Account for that
to avoid a locking against myself panic.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/nfs/nfs_export.c
cvs rdiff -u -r1.148 -r1.149 src/sys/nfs/nfs_syscalls.c
cvs rdiff -u -r1.87 -r1.88 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_export.c
diff -u src/sys/nfs/nfs_export.c:1.47 src/sys/nfs/nfs_export.c:1.48
--- src/sys/nfs/nfs_export.c:1.47	Sat May 23 14:19:19 2009
+++ src/sys/nfs/nfs_export.c	Tue Jul  7 10:09:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.47 2009/05/23 18:19:19 ad Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.48 2009/07/07 14:09:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.47 2009/05/23 18:19:19 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.48 2009/07/07 14:09:05 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -236,7 +236,8 @@
  * command).
  */
 int
-mountd_set_exports_list(const struct mountd_exports_list *mel, struct lwp *l)
+mountd_set_exports_list(const struct mountd_exports_list *mel, struct lwp *l,
+struct mount *nmp)
 {
 	int error;
 #ifdef notyet
@@ -260,6 +261,7 @@
 		return error;
 	vp = nd.ni_vp;
 	mp = vp-v_mount;
+	KASSERT(nmp == NULL || nmp == mp);
 
 	/*
 	 * Make sure the file system can do vptofh.  If the file system
@@ -278,7 +280,8 @@
 	vput(vp);
 	if (error != 0)
 		return error;
-	mutex_enter(mp-mnt_updating);	/* mnt_flag */
+	if (nmp == NULL)
+		mutex_enter(mp-mnt_updating);	/* mnt_flag */
 	netexport_wrlock();
 	ne = netexport_lookup(mp);
 	if (ne == NULL) {
@@ -311,15 +314,16 @@
 	else if (mel-mel_nexports == 1)
 		error = export(ne, mel-mel_exports[0]);
 	else {
-		printf(mountd_set_exports_list: Cannot set more than one 
-		entry at once (unimplemented)\n);
+		printf(%s: Cannot set more than one 
+		entry at once (unimplemented)\n, __func__);
 		error = EOPNOTSUPP;
 	}
 #endif
 
 out:
 	netexport_wrunlock();
-	mutex_exit(mp-mnt_updating);	/* mnt_flag */
+	if (nmp == NULL)
+		mutex_exit(mp-mnt_updating);	/* mnt_flag */
 	vfs_unbusy(mp, false, NULL);
 	return error;
 }
@@ -441,7 +445,7 @@
 		mel.mel_exports = (void *)args-eargs;
 	}
 
-	return mountd_set_exports_list(mel, curlwp);
+	return mountd_set_exports_list(mel, curlwp, mp);
 }
 
 /*

Index: src/sys/nfs/nfs_syscalls.c
diff -u src/sys/nfs/nfs_syscalls.c:1.148 src/sys/nfs/nfs_syscalls.c:1.149
--- src/sys/nfs/nfs_syscalls.c:1.148	Sat May 23 10:44:56 2009
+++ src/sys/nfs/nfs_syscalls.c	Tue Jul  7 10:09:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.148 2009/05/23 14:44:56 ad Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.149 2009/07/07 14:09:05 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.148 2009/05/23 14:44:56 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.149 2009/07/07 14:09:05 christos Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -192,7 +192,7 @@
 		}
 		mel.mel_exports = args;
 
-		error = mountd_set_exports_list(mel, l);
+		error = mountd_set_exports_list(mel, l, NULL);
 
 		free(args, M_TEMP);
 	} else {

Index: src/sys/nfs/nfs_var.h
diff -u src/sys/nfs/nfs_var.h:1.87 src/sys/nfs/nfs_var.h:1.88
--- src/sys/nfs/nfs_var.h:1.87	Sat May 23 11:31:21 2009
+++ src/sys/nfs/nfs_var.h	Tue Jul  7 10:09:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_var.h,v 1.87 2009/05/23 15:31:21 ad Exp $	*/
+/*	$NetBSD: nfs_var.h,v 1.88 2009/07/07 14:09:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -300,7 +300,8 @@
 
 /* nfs_export.c */
 extern struct nfs_public nfs_pub;
-int mountd_set_exports_list(const struct mountd_exports_list *, struct lwp *);
+int mountd_set_exports_list(const struct mountd_exports_list *, struct lwp *,
+struct mount *);
 int netexport_check(const fsid_t *, struct mbuf *, struct mount **, int *,
 kauth_cred_t *);
 void netexport_rdlock(void);



CVS commit: src/sys/nfs

2009-05-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat May 23 14:44:56 UTC 2009

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

Log Message:
Remove pointless error check.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 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.147 src/sys/nfs/nfs_syscalls.c:1.148
--- src/sys/nfs/nfs_syscalls.c:1.147	Fri Apr 10 19:04:14 2009
+++ src/sys/nfs/nfs_syscalls.c	Sat May 23 14:44:56 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_syscalls.c,v 1.147 2009/04/10 19:04:14 bouyer Exp $	*/
+/*	$NetBSD: nfs_syscalls.c,v 1.148 2009/05/23 14:44:56 ad Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.147 2009/04/10 19:04:14 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_syscalls.c,v 1.148 2009/05/23 14:44:56 ad Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -159,8 +159,6 @@
 			fd_putfile(nfsdarg.sock);
 			return (ENOTSOCK);
 		}
-		if (error)
-			return (error);
 		/*
 		 * Get the client address for connected sockets.
 		 */



CVS commit: src/sys/nfs

2009-05-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat May 23 14:45:18 UTC 2009

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

Log Message:
Fix a crash when unloading nfsserver module.


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 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.144 src/sys/nfs/nfs_serv.c:1.145
--- src/sys/nfs/nfs_serv.c:1.144	Fri Apr 10 18:58:50 2009
+++ src/sys/nfs/nfs_serv.c	Sat May 23 14:45:18 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.145 2009/05/23 14:45:18 ad Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.145 2009/05/23 14:45:18 ad Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -120,8 +120,8 @@
 		}
 		nfs_init();	/* XXX for monolithic kernel */
 		rw_init(netexport_lock);
-		nfsrv_init(0);		/* Init server data structures */
 		nfsrv_initcache();	/* Init the server request cache */
+		nfsrv_init(0);		/* Init server data structures */
 		vfs_hooks_attach(nfs_export_hooks);
 		nfs_timer_srvinit(nfsrv_timer);
 		return 0;
@@ -132,8 +132,8 @@
 		}
 		nfs_timer_srvfini();
 		vfs_hooks_detach(nfs_export_hooks);
-		nfsrv_finicache();
 		nfsrv_fini();
+		nfsrv_finicache();
 		rw_destroy(netexport_lock);
 		return 0;
 	default:



CVS commit: src/sys/nfs

2009-05-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat May 23 15:31:21 UTC 2009

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

Log Message:
- Fix a race between umount()/mount() and nfssvc().
- Toss netexport state on nfsserver module unload.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/nfs/nfs_export.c
cvs rdiff -u -r1.145 -r1.146 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.86 -r1.87 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_export.c
diff -u src/sys/nfs/nfs_export.c:1.44 src/sys/nfs/nfs_export.c:1.45
--- src/sys/nfs/nfs_export.c:1.44	Wed Dec 17 20:51:38 2008
+++ src/sys/nfs/nfs_export.c	Sat May 23 15:31:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.44 2008/12/17 20:51:38 cegger Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.45 2009/05/23 15:31:21 ad Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -75,10 +75,11 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.44 2008/12/17 20:51:38 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.45 2009/05/23 15:31:21 ad Exp $);
 
 #include sys/param.h
 #include sys/systm.h
+#include sys/kernel.h
 #include sys/queue.h
 #include sys/proc.h
 #include sys/mount.h
@@ -147,6 +148,7 @@
 static void netexport_wrunlock(void);
 static int nfs_export_update_30(struct mount *mp, const char *path, void *);
 
+static krwlock_t netexport_lock;
 
 /*
  * PUBLIC INTERFACE
@@ -155,11 +157,11 @@
 /*
  * Declare and initialize the file system export hooks.
  */
-static void nfs_export_unmount(struct mount *);
+static void netexport_unmount(struct mount *);
 
 struct vfs_hooks nfs_export_hooks = {
 	{ NULL, NULL },
-	.vh_unmount = nfs_export_unmount,
+	.vh_unmount = netexport_unmount,
 	.vh_reexport = nfs_export_update_30,
 };
 
@@ -171,7 +173,7 @@
  * information, although it theorically should.
  */
 static void
-nfs_export_unmount(struct mount *mp)
+netexport_unmount(struct mount *mp)
 {
 	struct netexport *ne;
 
@@ -189,6 +191,44 @@
 	kmem_free(ne, sizeof(*ne));
 }
 
+void
+netexport_init(void)
+{
+
+	rw_init(netexport_lock);
+}
+
+void
+netexport_fini(void)
+{
+	struct netexport *ne;
+	struct mount *mp;
+	int error;
+
+	KASSERT(mp != NULL);
+
+	for (;;) {
+		if (CIRCLEQ_EMPTY(netexport_list)) {
+			break;
+		}
+		netexport_wrlock();
+		ne = CIRCLEQ_FIRST(netexport_list);
+		mp = ne-ne_mount;
+		error = vfs_busy(mp, NULL);
+		netexport_wrunlock();
+		if (error != 0) {
+			kpause(nfsfini, false, hz, NULL);
+			continue;
+		}
+		mutex_enter(mp-mnt_updating);	/* mnt_flag */
+		netexport_unmount(mp);
+		mutex_exit(mp-mnt_updating);	/* mnt_flag */
+		vfs_unbusy(mp, false, NULL);
+	}
+	rw_destroy(netexport_lock);
+}
+
+
 /*
  * Atomically set the NFS exports list of the given file system, replacing
  * it with a new list of entries.
@@ -241,7 +281,7 @@
 	vput(vp);
 	if (error != 0)
 		return error;
-
+	mutex_enter(mp-mnt_updating);	/* mnt_flag */
 	netexport_wrlock();
 	ne = netexport_lookup(mp);
 	if (ne == NULL) {
@@ -282,6 +322,7 @@
 
 out:
 	netexport_wrunlock();
+	mutex_exit(mp-mnt_updating);	/* mnt_flag */
 	vfs_unbusy(mp, false, NULL);
 	return error;
 }
@@ -798,8 +839,6 @@
 	return np;
 }
 
-krwlock_t netexport_lock;
-
 void
 netexport_rdlock(void)
 {

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.145 src/sys/nfs/nfs_serv.c:1.146
--- src/sys/nfs/nfs_serv.c:1.145	Sat May 23 14:45:18 2009
+++ src/sys/nfs/nfs_serv.c	Sat May 23 15:31:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.145 2009/05/23 14:45:18 ad Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.145 2009/05/23 14:45:18 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -108,7 +108,6 @@
 static int
 nfsserver_modcmd(modcmd_t cmd, void *arg)
 {
-	extern krwlock_t netexport_lock;		/* XXX */
 	extern struct vfs_hooks nfs_export_hooks;	/* XXX */
 	int error;
 
@@ -119,7 +118,7 @@
 			return error;
 		}
 		nfs_init();	/* XXX for monolithic kernel */
-		rw_init(netexport_lock);
+		netexport_init();
 		nfsrv_initcache();	/* Init the server request cache */
 		nfsrv_init(0);		/* Init server data structures */
 		vfs_hooks_attach(nfs_export_hooks);
@@ -130,11 +129,19 @@
 		if (error != 0) {
 			return error;
 		}
-		nfs_timer_srvfini();
+		/*
+		 * Kill export list before detaching VFS hooks, so we
+		 * we don't leak state due to a concurrent umount().
+		 */
+		netexport_fini();
 		vfs_hooks_detach(nfs_export_hooks);
+
+		/* Kill timer before server goes away. */
+		nfs_timer_srvfini();
 		nfsrv_fini();
+
+		/* Server uses server cache, so kill cache last. */
 		nfsrv_finicache();
-		rw_destroy(netexport_lock);
 		

CVS commit: src/sys/nfs

2009-05-23 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Sat May 23 18:19:19 UTC 2009

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

Log Message:
Broken assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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.46 src/sys/nfs/nfs_export.c:1.47
--- src/sys/nfs/nfs_export.c:1.46	Sat May 23 15:59:30 2009
+++ src/sys/nfs/nfs_export.c	Sat May 23 18:19:19 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_export.c,v 1.46 2009/05/23 15:59:30 ad Exp $	*/
+/*	$NetBSD: nfs_export.c,v 1.47 2009/05/23 18:19:19 ad Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2008 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.46 2009/05/23 15:59:30 ad Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_export.c,v 1.47 2009/05/23 18:19:19 ad Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -207,8 +207,6 @@
 	struct mount *mp;
 	int error;
 
-	KASSERT(mp != NULL);
-
 	while (!CIRCLEQ_EMPTY(netexport_list)) {
 		netexport_wrlock();
 		ne = CIRCLEQ_FIRST(netexport_list);



CVS commit: src/sys/nfs

2009-05-14 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Thu May 14 15:42:22 UTC 2009

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

Log Message:
nfs_clearcommit: fix a race with vnode cleaning.


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 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.216 src/sys/nfs/nfs_subs.c:1.217
--- src/sys/nfs/nfs_subs.c:1.216	Sun Mar 15 17:20:10 2009
+++ src/sys/nfs/nfs_subs.c	Thu May 14 15:42:22 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_subs.c,v 1.216 2009/03/15 17:20:10 cegger Exp $	*/
+/*	$NetBSD: nfs_subs.c,v 1.217 2009/05/14 15:42:22 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.216 2009/03/15 17:20:10 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_subs.c,v 1.217 2009/05/14 15:42:22 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include fs_nfs.h
@@ -2192,16 +2192,20 @@
 		KASSERT(vp-v_mount == mp);
 		if (vp-v_type != VREG)
 			continue;
+		mutex_enter(vp-v_interlock);
+		if (vp-v_iflag  (VI_XLOCK | VI_CLEAN)) {
+			mutex_exit(vp-v_interlock);
+			continue;
+		}
 		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);
-		mutex_enter(vp-v_uobj.vmobjlock);
 		TAILQ_FOREACH(pg, vp-v_uobj.memq, listq.queue) {
 			pg-flags = ~PG_NEEDCOMMIT;
 		}
-		mutex_exit(vp-v_uobj.vmobjlock);
+		mutex_exit(vp-v_interlock);
 	}
 	mutex_exit(mntvnode_lock);
 	mutex_enter(nmp-nm_lock);



CVS commit: src/sys/nfs

2009-05-09 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Sun May 10 03:51:44 UTC 2009

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

Log Message:
restore lines, esp. a vrele() call, which i mistakenly removed
in the previous.  (rev.1.276)


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 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.276 src/sys/nfs/nfs_vnops.c:1.277
--- src/sys/nfs/nfs_vnops.c:1.276	Mon May  4 05:59:35 2009
+++ src/sys/nfs/nfs_vnops.c	Sun May 10 03:51:43 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.276 2009/05/04 05:59:35 yamt Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.277 2009/05/10 03:51:43 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.276 2009/05/04 05:59:35 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.277 2009/05/10 03:51:43 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -869,6 +869,8 @@
 			}
 			if (error != 0) {
 /* newvp has been revoked. */
+vrele(newvp);
+*vpp = NULLVP;
 goto dorpc;
 			}
 			if (cnp-cn_nameiop != LOOKUP  (flags  ISLASTCN))



CVS commit: src/sys/nfs

2009-05-05 Thread Christoph Egger
Module Name:src
Committed By:   cegger
Date:   Tue May  5 12:48:31 UTC 2009

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

Log Message:
buildfix: use %d for BOOTP_SIZE_(MIN,MAX).
Makes i386 ALL kernel build again.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 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.46 src/sys/nfs/nfs_bootdhcp.c:1.47
--- src/sys/nfs/nfs_bootdhcp.c:1.46	Sat May  2 21:06:51 2009
+++ src/sys/nfs/nfs_bootdhcp.c	Tue May  5 12:48:31 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootdhcp.c,v 1.46 2009/05/02 21:06:51 manu Exp $	*/
+/*	$NetBSD: nfs_bootdhcp.c,v 1.47 2009/05/05 12:48:31 cegger 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.46 2009/05/02 21:06:51 manu Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bootdhcp.c,v 1.47 2009/05/05 12:48:31 cegger Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs_boot.h
@@ -325,12 +325,12 @@
 	 * Is this a valid reply?
 	 */
 	if (m-m_pkthdr.len  BOOTP_SIZE_MIN) {
-		DPRINTF((bootpcheck: short packet %d  %ld\n, 
+		DPRINTF((bootpcheck: short packet %d  %d\n, 
 		m-m_pkthdr.len, BOOTP_SIZE_MIN));
 		return (-1);
 	}
 	if (m-m_pkthdr.len  BOOTP_SIZE_MAX) {
-		DPRINTF((Bootpcheck: long packet %d  %ld\n, 
+		DPRINTF((Bootpcheck: long packet %d  %d\n, 
 		   m-m_pkthdr.len, BOOTP_SIZE_MAX));
 		return (-1);
 	}



CVS commit: src/sys/nfs

2009-05-05 Thread Christoph Egger
Module Name:src
Committed By:   cegger
Date:   Wed May  6 05:34:12 UTC 2009

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

Log Message:
correct previous: use %zu for BOOTP_SIZE_(MIN,MAX).
Pointed out by David Holland


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 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.47 src/sys/nfs/nfs_bootdhcp.c:1.48
--- src/sys/nfs/nfs_bootdhcp.c:1.47	Tue May  5 12:48:31 2009
+++ src/sys/nfs/nfs_bootdhcp.c	Wed May  6 05:34:12 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_bootdhcp.c,v 1.47 2009/05/05 12:48:31 cegger Exp $	*/
+/*	$NetBSD: nfs_bootdhcp.c,v 1.48 2009/05/06 05:34:12 cegger 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.47 2009/05/05 12:48:31 cegger Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_bootdhcp.c,v 1.48 2009/05/06 05:34:12 cegger Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs_boot.h
@@ -325,12 +325,12 @@
 	 * Is this a valid reply?
 	 */
 	if (m-m_pkthdr.len  BOOTP_SIZE_MIN) {
-		DPRINTF((bootpcheck: short packet %d  %d\n, 
+		DPRINTF((bootpcheck: short packet %d  %zu\n, 
 		m-m_pkthdr.len, BOOTP_SIZE_MIN));
 		return (-1);
 	}
 	if (m-m_pkthdr.len  BOOTP_SIZE_MAX) {
-		DPRINTF((Bootpcheck: long packet %d  %d\n, 
+		DPRINTF((Bootpcheck: long packet %d  %zu\n, 
 		   m-m_pkthdr.len, BOOTP_SIZE_MAX));
 		return (-1);
 	}



CVS commit: src/sys/nfs

2009-05-03 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Mon May  4 05:49:00 UTC 2009

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

Log Message:
nfs_lookup: comments.  no functional changes.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 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.273 src/sys/nfs/nfs_vnops.c:1.274
--- src/sys/nfs/nfs_vnops.c:1.273	Sat Mar 14 21:04:26 2009
+++ src/sys/nfs/nfs_vnops.c	Mon May  4 05:49:00 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.273 2009/03/14 21:04:26 dsl Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.274 2009/05/04 05:49:00 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.273 2009/03/14 21:04:26 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.274 2009/05/04 05:49:00 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -752,13 +752,7 @@
 /*
  * nfs lookup call, one step at a time...
  * First look in cache
- * If not found, unlock the directory nfsnode and do the rpc
- *
- * This code is full of lock/unlock statements and checks, because
- * we continue after cache_lookup has finished (we need to check
- * with the attr cache and do an rpc if it has timed out). This means
- * that the locking effects of cache_lookup have to be taken into
- * account.
+ * If not found, do the rpc.
  */
 int
 nfs_lookup(void *v)
@@ -856,6 +850,11 @@
 			goto noentry;
 		}
 
+		/*
+		 * investigate the vnode returned by cache_lookup_raw.
+		 * if it isn't appropriate, do an rpc.
+		 */
+
 		newvp = *vpp;
 		if (!VOP_GETATTR(newvp, vattr, cnp-cn_cred)
 		 vattr.va_ctime.tv_sec == VTONFS(newvp)-n_ctime) {
@@ -952,7 +951,8 @@
 
 	if (NFS_CMPFH(np, fhp, fhsize)) {
 		/*
-		 * . lookup
+		 * as we handle . lookup locally, this should be
+		 * a broken server.
 		 */
 		VREF(dvp);
 		newvp = dvp;



CVS commit: src/sys/nfs

2009-05-03 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Mon May  4 05:50:17 UTC 2009

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

Log Message:
nfs_lookup: add an assertion.


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 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.274 src/sys/nfs/nfs_vnops.c:1.275
--- src/sys/nfs/nfs_vnops.c:1.274	Mon May  4 05:49:00 2009
+++ src/sys/nfs/nfs_vnops.c	Mon May  4 05:50:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vnops.c,v 1.274 2009/05/04 05:49:00 yamt Exp $	*/
+/*	$NetBSD: nfs_vnops.c,v 1.275 2009/05/04 05:50:17 yamt Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -39,7 +39,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.274 2009/05/04 05:49:00 yamt Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_vnops.c,v 1.275 2009/05/04 05:50:17 yamt Exp $);
 
 #ifdef _KERNEL_OPT
 #include opt_nfs.h
@@ -817,6 +817,7 @@
 	 */
 	error = cache_lookup_raw(dvp, vpp, cnp);
 	KASSERT(dvp != *vpp);
+	KASSERT((cnp-cn_flags  ISWHITEOUT) == 0);
 	if (error = 0) {
 		struct vattr vattr;
 		int err2;



CVS commit: src/sys/nfs

2009-04-10 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Fri Apr 10 18:58:51 UTC 2009

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

Log Message:
PR kern/41158: nfs_rename() locking against myself
nfsrv_rename() can exit without calling genfs_renamelock_exit() because
the nfsm_reply() can do return (0) on error.
Change nfsm_reply to use 'error = 0; goto nfsmout' instead.
Fix a few place so it's safe to goto nfsmout from nfsm_reply, or other
macros calling it.
As a side effect it could fix a missing vrele(dirp) in various place where
nfsm_reply could return(0).


To generate a diff of this commit:
cvs rdiff -u -r1.143 -r1.144 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.50 -r1.51 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.143 src/sys/nfs/nfs_serv.c:1.144
--- src/sys/nfs/nfs_serv.c:1.143	Sat Mar 14 15:36:24 2009
+++ src/sys/nfs/nfs_serv.c	Fri Apr 10 18:58:50 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.143 2009/03/14 15:36:24 dsl Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.143 2009/03/14 15:36:24 dsl Exp $);
+__KERNEL_RCSID(0, $NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $);
 
 #include sys/param.h
 #include sys/systm.h
@@ -1392,7 +1392,7 @@
 	int32_t t1;
 	char *bpos;
 	int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1;
-	int rdev = 0;
+	int rdev = 0, abort = 0;
 	int v3 = (nfsd-nd_flag  ND_NFSV3), how, exclusive_flag = 0;
 	char *cp2;
 	struct mbuf *mb, *mreq;
@@ -1419,6 +1419,7 @@
 			vrele(dirp);
 		return (0);
 	}
+	abort = 1;
 	VATTR_NULL(va);
 	if (v3) {
 		va.va_mode = 0;
@@ -1494,6 +1495,7 @@
 			KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) {
 VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
 vput(nd.ni_dvp);
+abort = 0;
 nfsm_reply(0);
 return (error);
 			} else
@@ -1509,12 +1511,14 @@
 vrele(nd.ni_dvp);
 VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
 error = EINVAL;
+abort = 0;
 nfsm_reply(0);
 			}
 		} else {
 			VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
 			vput(nd.ni_dvp);
 			error = ENXIO;
+			abort = 0;
 		}
 		vp = nd.ni_vp;
 	} else {
@@ -1524,6 +1528,7 @@
 			vrele(nd.ni_dvp);
 		else
 			vput(nd.ni_dvp);
+		abort = 0;
 		if (!error  va.va_size != -1) {
 			error = nfsrv_access(vp, VWRITE, cred,
 			(nd.ni_cnd.cn_flags  RDONLY), lwp, 0);
@@ -1561,7 +1566,9 @@
 	}
 	if (dirp) {
 		vrele(dirp);
+		dirp = NULL;
 	}
+	abort = 0;
 	nfsm_reply(NFSX_SRVFH(nsfh, v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3));
 	if (v3) {
 		if (!error) {
@@ -1578,13 +1585,15 @@
 nfsmout:
 	if (dirp)
 		vrele(dirp);
-	VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
-	if (nd.ni_dvp == nd.ni_vp)
-		vrele(nd.ni_dvp);
-	else
-		vput(nd.ni_dvp);
-	if (nd.ni_vp)
-		vput(nd.ni_vp);
+	if (abort) {
+		VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
+		if (nd.ni_dvp == nd.ni_vp)
+			vrele(nd.ni_dvp);
+		else
+			vput(nd.ni_dvp);
+		if (nd.ni_vp)
+			vput(nd.ni_vp);
+	}
 	return (error);
 }
 
@@ -1604,6 +1613,7 @@
 	int32_t t1;
 	char *bpos;
 	int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1;
+	int abort = 0;
 	u_int32_t major, minor;
 	enum vtype vtyp;
 	char *cp2;
@@ -1629,6 +1639,7 @@
 			vrele(dirp);
 		return (0);
 	}
+	abort = 1;
 	nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED);
 	vtyp = nfsv3tov_type(*tl);
 	if (vtyp != VCHR  vtyp != VBLK  vtyp != VSOCK  vtyp != VFIFO) {
@@ -1700,7 +1711,9 @@
 	if (dirp) {
 		diraft_ret = VOP_GETATTR(dirp, diraft, cred);
 		vrele(dirp);
+		dirp = NULL;
 	}
+	abort = 0;
 	nfsm_reply(NFSX_SRVFH(nsfh, true) + NFSX_POSTOPATTR(1) +
 	NFSX_WCCDATA(1));
 	if (!error) {
@@ -1710,13 +1723,15 @@
 	nfsm_srvwcc_data(dirfor_ret, dirfor, diraft_ret, diraft);
 	return (0);
 nfsmout:
-	VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
-	if (nd.ni_dvp == nd.ni_vp)
-		vrele(nd.ni_dvp);
-	else
-		vput(nd.ni_dvp);
-	if (nd.ni_vp)
-		vput(nd.ni_vp);
+	if (abort) {
+		VOP_ABORTOP(nd.ni_dvp, nd.ni_cnd);
+		if (nd.ni_dvp == nd.ni_vp)
+			vrele(nd.ni_dvp);
+		else
+			vput(nd.ni_dvp);
+		if (nd.ni_vp)
+			vput(nd.ni_vp);
+	}
 	if (dirp)
 		vrele(dirp);
 	return (error);
@@ -2006,21 +2021,26 @@
 	}
 	vrele(tond.ni_startdir);
 	PNBUF_PUT(tond.ni_cnd.cn_pnbuf);
+	tond.ni_cnd.cn_nameiop = 0;
 out1:
 	if (fdirp) {
 		if (v3) {
 			fdiraft_ret = VOP_GETATTR(fdirp, fdiraft, cred);
 		}
 		vrele(fdirp);
+		fdirp = NULL;
 	}
 	if (tdirp) {
 		if (v3) {
 			tdiraft_ret = VOP_GETATTR(tdirp, tdiraft, cred);
 		}
 		vrele(tdirp);
+		tdirp = NULL;
 	}
 	vrele(fromnd.ni_startdir);
 	PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf);
+	fromnd.ni_cnd.cn_nameiop = 0;
+	localfs = NULL;
 	nfsm_reply(2 * NFSX_WCCDATA(v3));
 	if (v3) {
 		nfsm_srvwcc_data(fdirfor_ret, fdirfor, fdiraft_ret, fdiraft);
@@ -2159,7 +2179,7 @@
 	char *bpos, *pathcp = NULL, *cp2;
 	struct uio io;
 	struct iovec