diff options
author | rmacklem <rmacklem@FreeBSD.org> | 2010-01-28 16:17:24 +0000 |
---|---|---|
committer | rmacklem <rmacklem@FreeBSD.org> | 2010-01-28 16:17:24 +0000 |
commit | c20e37e81a2006a8ecfc2b09616eb4fe8e21d1d9 (patch) | |
tree | 67521d5fa4256ede09d0fd00c384fb6a29538050 | |
parent | b007106a58ad04020b7f9b2729dcc01605de6452 (diff) | |
download | FreeBSD-src-c20e37e81a2006a8ecfc2b09616eb4fe8e21d1d9.zip FreeBSD-src-c20e37e81a2006a8ecfc2b09616eb4fe8e21d1d9.tar.gz |
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
-rw-r--r-- | sys/fs/nfsclient/nfs.h | 15 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfs_clbio.c | 8 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfs_clnfsiod.c | 22 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfs_clsubs.c | 6 | ||||
-rw-r--r-- | sys/fs/nfsclient/nfsmount.h | 2 |
5 files changed, 35 insertions, 18 deletions
diff --git a/sys/fs/nfsclient/nfs.h b/sys/fs/nfsclient/nfs.h index a72ec6d..4b54286 100644 --- a/sys/fs/nfsclient/nfs.h +++ b/sys/fs/nfsclient/nfs.h @@ -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 vnode *, struct ucred *, 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 */ diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c index 3193822..d0dd2cc 100644 --- a/sys/fs/nfsclient/nfs_clbio.c +++ b/sys/fs/nfsclient/nfs_clbio.c @@ -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]); diff --git a/sys/fs/nfsclient/nfs_clnfsiod.c b/sys/fs/nfsclient/nfs_clnfsiod.c index f38aed8..6649fc0 100644 --- a/sys/fs/nfsclient/nfs_clnfsiod.c +++ b/sys/fs/nfsclient/nfs_clnfsiod.c @@ -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, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0, 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) diff --git a/sys/fs/nfsclient/nfs_clsubs.c b/sys/fs/nfsclient/nfs_clsubs.c index 3cd7e5c..1553509 100644 --- a/sys/fs/nfsclient/nfs_clsubs.c +++ b/sys/fs/nfsclient/nfs_clsubs.c @@ -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 */ diff --git a/sys/fs/nfsclient/nfsmount.h b/sys/fs/nfsclient/nfsmount.h index acf438e..2f0ada6 100644 --- a/sys/fs/nfsclient/nfsmount.h +++ b/sys/fs/nfsclient/nfsmount.h @@ -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 */ |