From owner-svn-src-all@FreeBSD.ORG Thu Jan 28 16:17:25 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EECF2106566B; Thu, 28 Jan 2010 16:17:24 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DD3038FC19; Thu, 28 Jan 2010 16:17:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0SGHOHh089024; Thu, 28 Jan 2010 16:17:24 GMT (envelope-from rmacklem@svn.freebsd.org) Received: (from rmacklem@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0SGHOMF089018; Thu, 28 Jan 2010 16:17:24 GMT (envelope-from rmacklem@svn.freebsd.org) Message-Id: <201001281617.o0SGHOMF089018@svn.freebsd.org> From: Rick Macklem Date: Thu, 28 Jan 2010 16:17:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203119 - head/sys/fs/nfsclient X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jan 2010 16:17:25 -0000 Author: rmacklem Date: Thu Jan 28 16:17:24 2010 New Revision: 203119 URL: http://svn.freebsd.org/changeset/base/203119 Log: 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. MFC after: 2 weeks Modified: head/sys/fs/nfsclient/nfs.h head/sys/fs/nfsclient/nfs_clbio.c head/sys/fs/nfsclient/nfs_clnfsiod.c head/sys/fs/nfsclient/nfs_clsubs.c head/sys/fs/nfsclient/nfsmount.h Modified: head/sys/fs/nfsclient/nfs.h ============================================================================== --- head/sys/fs/nfsclient/nfs.h Thu Jan 28 15:09:40 2010 (r203118) +++ head/sys/fs/nfsclient/nfs.h Thu Jan 28 16:17:24 2010 (r203119) @@ -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: head/sys/fs/nfsclient/nfs_clbio.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clbio.c Thu Jan 28 15:09:40 2010 (r203118) +++ head/sys/fs/nfsclient/nfs_clbio.c Thu Jan 28 16:17:24 2010 (r203119) @@ -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: head/sys/fs/nfsclient/nfs_clnfsiod.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clnfsiod.c Thu Jan 28 15:09:40 2010 (r203118) +++ head/sys/fs/nfsclient/nfs_clnfsiod.c Thu Jan 28 16:17:24 2010 (r203119) @@ -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: head/sys/fs/nfsclient/nfs_clsubs.c ============================================================================== --- head/sys/fs/nfsclient/nfs_clsubs.c Thu Jan 28 15:09:40 2010 (r203118) +++ head/sys/fs/nfsclient/nfs_clsubs.c Thu Jan 28 16:17:24 2010 (r203119) @@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$"); #include 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: head/sys/fs/nfsclient/nfsmount.h ============================================================================== --- head/sys/fs/nfsclient/nfsmount.h Thu Jan 28 15:09:40 2010 (r203118) +++ head/sys/fs/nfsclient/nfsmount.h Thu Jan 28 16:17:24 2010 (r203119) @@ -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 */