Deleted Added
full compact
36c36
< __FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clnfsiod.c 210455 2010-07-24 22:11:11Z rmacklem $");
---
> __FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clnfsiod.c 220683 2011-04-15 23:07:48Z rmacklem $");
61a62
> #include <sys/taskqueue.h>
71c72,73
< extern struct mtx ncl_iod_mutex;
---
> extern struct mtx ncl_iod_mutex;
> extern struct task ncl_nfsiodnew_task;
74,75c76,77
< enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
< struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
---
> enum nfsiod_state ncl_iodwant[NFS_MAXASYNCDAEMON];
> struct nfsmount *ncl_iodmount[NFS_MAXASYNCDAEMON];
79c81
< static int nfs_asyncdaemon[NFS_MAXRAHEAD];
---
> static int nfs_asyncdaemon[NFS_MAXASYNCDAEMON];
84,85c86,88
< static unsigned int ncl_iodmaxidle = 120;
< SYSCTL_UINT(_vfs_newnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &ncl_iodmaxidle, 0, "");
---
> static unsigned int nfs_iodmaxidle = 120;
> SYSCTL_UINT(_vfs_newnfs, OID_AUTO, iodmaxidle, CTLFLAG_RW, &nfs_iodmaxidle, 0,
> "Max number of seconds an nfsiod kthread will sleep before exiting");
88c91
< unsigned int ncl_iodmax = NFS_MAXRAHEAD;
---
> unsigned int ncl_iodmax = 20;
92a96,97
> static int nfs_nfsiodnew_sync(void);
>
116c121
< ncl_nfsiodnew(0);
---
> nfs_nfsiodnew_sync();
122c127,128
< sizeof (nfs_iodmin), sysctl_iodmin, "IU", "");
---
> sizeof (nfs_iodmin), sysctl_iodmin, "IU",
> "Min number of nfsiod kthreads to keep as spares");
124d129
<
135c140
< if (newmax > NFS_MAXRAHEAD)
---
> if (newmax > NFS_MAXASYNCDAEMON)
158c163,164
< sizeof (ncl_iodmax), sysctl_iodmax, "IU", "");
---
> sizeof (ncl_iodmax), sysctl_iodmax, "IU",
> "Max number of nfsiod kthreads");
160,161c166,167
< int
< ncl_nfsiodnew(int set_iodwant)
---
> static int
> nfs_nfsiodnew_sync(void)
164d169
< int newiod;
166,169c171,172
< if (ncl_numasync >= ncl_iodmax)
< return (-1);
< newiod = -1;
< for (i = 0; i < ncl_iodmax; i++)
---
> mtx_assert(&ncl_iod_mutex, MA_OWNED);
> for (i = 0; i < ncl_iodmax; i++) {
171,172c174
< nfs_asyncdaemon[i]++;
< newiod = i;
---
> nfs_asyncdaemon[i] = 1;
175,178c177,179
< if (newiod == -1)
< return (-1);
< if (set_iodwant > 0)
< ncl_iodwant[i] = NFSIOD_CREATED_FOR_NFS_ASYNCIO;
---
> }
> if (i == ncl_iodmax)
> return (0);
180,181c181,182
< error = kproc_create(nfssvc_iod, nfs_asyncdaemon + i, NULL, RFHIGHPID,
< 0, "nfsiod %d", newiod);
---
> error = kproc_create(nfssvc_iod, nfs_asyncdaemon + i, NULL,
> RFHIGHPID, 0, "newnfs %d", i);
183,186c184,199
< if (error) {
< if (set_iodwant > 0)
< ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
< return (-1);
---
> if (error == 0) {
> ncl_numasync++;
> ncl_iodwant[i] = NFSIOD_AVAILABLE;
> } else
> nfs_asyncdaemon[i] = 0;
> return (error);
> }
>
> void
> ncl_nfsiodnew_tq(__unused void *arg, int pending)
> {
>
> mtx_lock(&ncl_iod_mutex);
> while (pending > 0) {
> pending--;
> nfs_nfsiodnew_sync();
188,189c201
< ncl_numasync++;
< return (newiod);
---
> mtx_unlock(&ncl_iod_mutex);
191a204,211
> void
> ncl_nfsiodnew(void)
> {
>
> mtx_assert(&ncl_iod_mutex, MA_OWNED);
> taskqueue_enqueue(taskqueue_thread, &ncl_nfsiodnew_task);
> }
>
195d214
< int i;
202,203c221,222
< if (nfs_iodmin > NFS_MAXRAHEAD)
< nfs_iodmin = NFS_MAXRAHEAD;
---
> if (nfs_iodmin > NFS_MAXASYNCDAEMON)
> nfs_iodmin = NFS_MAXASYNCDAEMON;
205,206c224,225
< for (i = 0; i < nfs_iodmin; i++) {
< error = ncl_nfsiodnew(0);
---
> while (ncl_numasync < nfs_iodmin) {
> error = nfs_nfsiodnew_sync();
208c227
< panic("newnfsiod_setup: ncl_nfsiodnew failed");
---
> panic("nfsiod_setup: nfs_nfsiodnew failed");
215c234,235
< SYSCTL_INT(_vfs_newnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0, "");
---
> SYSCTL_INT(_vfs_newnfs, OID_AUTO, defect, CTLFLAG_RW, &nfs_defect, 0,
> "Allow nfsiods to migrate serving different mounts");
248c268
< timo = (myiod < nfs_iodmin) ? 0 : ncl_iodmaxidle * hz;
---
> timo = (myiod < nfs_iodmin) ? 0 : nfs_iodmaxidle * hz;
266d285
<