Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Feb 2010 21:25:48 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r203789 - stable/8/sys/fs/nfsclient
Message-ID:  <201002112125.o1BLPmeF092467@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Thu Feb 11 21:25:48 2010
New Revision: 203789
URL: http://svn.freebsd.org/changeset/base/203789

Log:
  MFC: r203119
  Patch the experimental NFS client in a manner analogous to
  r203072 for the regular NFS client. Also, delete two fields
  of struct nfsmount that are not used by the FreeBSD port of
  the client.

Modified:
  stable/8/sys/fs/nfsclient/nfs.h
  stable/8/sys/fs/nfsclient/nfs_clbio.c
  stable/8/sys/fs/nfsclient/nfs_clnfsiod.c
  stable/8/sys/fs/nfsclient/nfs_clsubs.c
  stable/8/sys/fs/nfsclient/nfsmount.h
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/netinet/   (props changed)

Modified: stable/8/sys/fs/nfsclient/nfs.h
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs.h	Thu Feb 11 21:10:56 2010	(r203788)
+++ stable/8/sys/fs/nfsclient/nfs.h	Thu Feb 11 21:25:48 2010	(r203789)
@@ -56,6 +56,19 @@
 	(VFSTONFS((v)->v_mount)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4))
 
 /*
+ * NFS iod threads can be in one of these three states once spawned.
+ * NFSIOD_NOT_AVAILABLE - Cannot be assigned an I/O operation at this time.
+ * NFSIOD_AVAILABLE - Available to be assigned an I/O operation.
+ * NFSIOD_CREATED_FOR_NFS_ASYNCIO - Newly created for nfs_asyncio() and
+ *	will be used by the thread that called nfs_asyncio().
+ */
+enum nfsiod_state {
+	NFSIOD_NOT_AVAILABLE = 0,
+	NFSIOD_AVAILABLE = 1,
+	NFSIOD_CREATED_FOR_NFS_ASYNCIO = 2,
+};
+
+/*
  * Function prototypes.
  */
 int ncl_meta_setsize(struct vnode *, struct ucred *, struct thread *,
@@ -87,7 +100,7 @@ int ncl_fsinfo(struct nfsmount *, struct
 int ncl_init(struct vfsconf *);
 int ncl_uninit(struct vfsconf *);
 int ncl_mountroot(struct mount *);
-int ncl_nfsiodnew(void);
+int ncl_nfsiodnew(int);
 
 #endif	/* _KERNEL */
 

Modified: stable/8/sys/fs/nfsclient/nfs_clbio.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clbio.c	Thu Feb 11 21:10:56 2010	(r203788)
+++ stable/8/sys/fs/nfsclient/nfs_clbio.c	Thu Feb 11 21:25:48 2010	(r203789)
@@ -63,7 +63,7 @@ extern int newnfs_directio_allow_mmap;
 extern struct nfsstats newnfsstats;
 extern struct mtx ncl_iod_mutex;
 extern int ncl_numasync;
-extern struct proc *ncl_iodwant[NFS_MAXRAHEAD];
+extern enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
 extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
 extern int newnfs_directio_enable;
 
@@ -1396,7 +1396,7 @@ again:
 	 * Find a free iod to process this request.
 	 */
 	for (iod = 0; iod < ncl_numasync; iod++)
-		if (ncl_iodwant[iod]) {
+		if (ncl_iodwant[iod] == NFSIOD_AVAILABLE) {
 			gotiod = TRUE;
 			break;
 		}
@@ -1405,7 +1405,7 @@ again:
 	 * Try to create one if none are free.
 	 */
 	if (!gotiod) {
-		iod = ncl_nfsiodnew();
+		iod = ncl_nfsiodnew(1);
 		if (iod != -1)
 			gotiod = TRUE;
 	}
@@ -1417,7 +1417,7 @@ again:
 		 */
 		NFS_DPF(ASYNCIO, ("ncl_asyncio: waking iod %d for mount %p\n",
 		    iod, nmp));
-		ncl_iodwant[iod] = NULL;
+		ncl_iodwant[iod] = NFSIOD_NOT_AVAILABLE;
 		ncl_iodmount[iod] = nmp;
 		nmp->nm_bufqiods++;
 		wakeup(&ncl_iodwant[iod]);

Modified: stable/8/sys/fs/nfsclient/nfs_clnfsiod.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clnfsiod.c	Thu Feb 11 21:10:56 2010	(r203788)
+++ stable/8/sys/fs/nfsclient/nfs_clnfsiod.c	Thu Feb 11 21:25:48 2010	(r203789)
@@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$");
 extern struct mtx ncl_iod_mutex;
 
 int ncl_numasync;
-struct proc *ncl_iodwant[NFS_MAXRAHEAD];
+enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
 struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
 
 static void	nfssvc_iod(void *);
@@ -114,7 +114,7 @@ sysctl_iodmin(SYSCTL_HANDLER_ARGS)
 	 * than the new minimum, create some more.
 	 */
 	for (i = nfs_iodmin - ncl_numasync; i > 0; i--)
-		ncl_nfsiodnew();
+		ncl_nfsiodnew(0);
 out:
 	mtx_unlock(&ncl_iod_mutex);	
 	return (0);
@@ -147,7 +147,7 @@ sysctl_iodmax(SYSCTL_HANDLER_ARGS)
 	 */
 	iod = ncl_numasync - 1;
 	for (i = 0; i < ncl_numasync - ncl_iodmax; i++) {
-		if (ncl_iodwant[iod])
+		if (ncl_iodwant[iod] == NFSIOD_AVAILABLE)
 			wakeup(&ncl_iodwant[iod]);
 		iod--;
 	}
@@ -159,7 +159,7 @@ SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodma
     sizeof (ncl_iodmax), sysctl_iodmax, "IU", "");
 
 int
-ncl_nfsiodnew(void)
+ncl_nfsiodnew(int set_iodwant)
 {
 	int error, i;
 	int newiod;
@@ -175,12 +175,17 @@ ncl_nfsiodnew(void)
 		}
 	if (newiod == -1)
 		return (-1);
+	if (set_iodwant > 0)
+		ncl_iodwant[i] = NFSIOD_CREATED_FOR_NFS_ASYNCIO;
 	mtx_unlock(&ncl_iod_mutex);
 	error = kproc_create(nfssvc_iod, nfs_asyncdaemon + i, NULL, RFHIGHPID,
 	    0, "nfsiod %d", newiod);
 	mtx_lock(&ncl_iod_mutex);
-	if (error)
+	if (error) {
+		if (set_iodwant > 0)
+			ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
 		return (-1);
+	}
 	ncl_numasync++;
 	return (newiod);
 }
@@ -199,7 +204,7 @@ nfsiod_setup(void *dummy)
 		nfs_iodmin = NFS_MAXRAHEAD;
 
 	for (i = 0; i < nfs_iodmin; i++) {
-		error = ncl_nfsiodnew();
+		error = ncl_nfsiodnew(0);
 		if (error == -1)
 			panic("newnfsiod_setup: ncl_nfsiodnew failed");
 	}
@@ -235,7 +240,8 @@ nfssvc_iod(void *instance)
 			goto finish;
 		if (nmp)
 			nmp->nm_bufqiods--;
-		ncl_iodwant[myiod] = curthread->td_proc;
+		if (ncl_iodwant[myiod] == NFSIOD_NOT_AVAILABLE)
+			ncl_iodwant[myiod] = NFSIOD_AVAILABLE;
 		ncl_iodmount[myiod] = NULL;
 		/*
 		 * Always keep at least nfs_iodmin kthreads.
@@ -295,7 +301,7 @@ finish:
 	nfs_asyncdaemon[myiod] = 0;
 	if (nmp)
 	    nmp->nm_bufqiods--;
-	ncl_iodwant[myiod] = NULL;
+	ncl_iodwant[myiod] = NFSIOD_NOT_AVAILABLE;
 	ncl_iodmount[myiod] = NULL;
 	/* Someone may be waiting for the last nfsiod to terminate. */
 	if (--ncl_numasync == 0)

Modified: stable/8/sys/fs/nfsclient/nfs_clsubs.c
==============================================================================
--- stable/8/sys/fs/nfsclient/nfs_clsubs.c	Thu Feb 11 21:10:56 2010	(r203788)
+++ stable/8/sys/fs/nfsclient/nfs_clsubs.c	Thu Feb 11 21:25:48 2010	(r203789)
@@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/stdarg.h>
 
 extern struct mtx ncl_iod_mutex;
-extern struct proc *ncl_iodwant[NFS_MAXRAHEAD];
+extern enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
 extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
 extern int ncl_numasync;
 extern unsigned int ncl_iodmax;
@@ -100,7 +100,7 @@ ncl_uninit(struct vfsconf *vfsp)
 	mtx_lock(&ncl_iod_mutex);
 	ncl_iodmax = 0;
 	for (i = 0; i < ncl_numasync; i++)
-		if (ncl_iodwant[i])
+		if (ncl_iodwant[i] == NFSIOD_AVAILABLE)
 			wakeup(&ncl_iodwant[i]);
 	/* The last nfsiod to exit will wake us up when ncl_numasync hits 0 */
 	while (ncl_numasync)
@@ -396,7 +396,7 @@ ncl_init(struct vfsconf *vfsp)
 
 	/* Ensure async daemons disabled */
 	for (i = 0; i < NFS_MAXRAHEAD; i++) {
-		ncl_iodwant[i] = NULL;
+		ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
 		ncl_iodmount[i] = NULL;
 	}
 	ncl_nhinit();			/* Init the nfsnode table */

Modified: stable/8/sys/fs/nfsclient/nfsmount.h
==============================================================================
--- stable/8/sys/fs/nfsclient/nfsmount.h	Thu Feb 11 21:10:56 2010	(r203788)
+++ stable/8/sys/fs/nfsclient/nfsmount.h	Thu Feb 11 21:25:48 2010	(r203789)
@@ -71,8 +71,6 @@ struct	nfsmount {
 	int	nm_tprintf_delay;	/* interval for messages */
 
 	/* Newnfs additions */
-	int	nm_iothreadcnt;
-	struct proc *nm_iodwant[NFS_MAXRAHEAD];
 	struct	nfsclclient *nm_clp;
 	uid_t	nm_uid;			/* Uid for SetClientID etc. */
 	u_int64_t nm_clval;		/* identifies which clientid */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002112125.o1BLPmeF092467>