9 #include <linux/sched.h>
11 #include <linux/module.h>
19 #include <linux/nfsacl.h>
26 #define NFSDDBG_FACILITY NFSDDBG_SVC
29 static int nfsd(
void *vrqstp);
67 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
68 static struct svc_stat nfsd_acl_svcstats;
74 #define NFSD_ACL_MINVERS 2
75 #define NFSD_ACL_NRVERS ARRAY_SIZE(nfsd_acl_version)
76 static struct svc_version *nfsd_acl_versions[NFSD_ACL_NRVERS];
80 .pg_nvers = NFSD_ACL_NRVERS,
81 .pg_vers = nfsd_acl_versions,
84 .pg_stats = &nfsd_acl_svcstats,
88 static struct svc_stat nfsd_acl_svcstats = {
95 #if defined(CONFIG_NFSD_V3)
98 #if defined(CONFIG_NFSD_V4)
103 #define NFSD_MINVERS 2
104 #define NFSD_NRVERS ARRAY_SIZE(nfsd_version)
108 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
109 .pg_next = &nfsd_acl_program,
113 .pg_vers = nfsd_versions,
129 nfsd_versions[vers] = nfsd_version[vers];
130 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
131 if (vers < NFSD_ACL_NRVERS)
132 nfsd_acl_versions[vers] = nfsd_acl_version[vers];
136 nfsd_versions[vers] =
NULL;
137 #if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
138 if (vers < NFSD_ACL_NRVERS)
139 nfsd_acl_versions[vers] =
NULL;
143 return nfsd_versions[vers] !=
NULL;
145 return nfsd_version[vers] !=
NULL;
159 if (minorversion == 0)
174 #define NFSD_MAXSERVS 8192
186 static int nfsd_init_socks(
void)
205 static bool nfsd_up =
false;
207 static int nfsd_startup(
int nrservs)
221 ret = nfsd_init_socks();
239 static void nfsd_shutdown(
void)
255 static void nfsd_last_thread(
struct svc_serv *serv,
struct net *
net)
278 nfsd_program.
pg_vers[i] = nfsd_version[i];
279 #
if defined(CONFIG_NFSD_V2_ACL) || defined(CONFIG_NFSD_V3_ACL)
280 for (i = NFSD_ACL_MINVERS; i < NFSD_ACL_NRVERS; i++)
299 static void set_max_drc(
void)
301 #define NFSD_DRC_SIZE_SHIFT 10
309 static int nfsd_get_default_max_blksize(
void)
312 unsigned long long target;
325 while (ret > target && ret >= 8*1024*2)
345 if (nfsd_serv ==
NULL)
361 if (nfsd_serv ==
NULL)
371 if (nfsd_serv !=
NULL) {
372 for (i = 0; i < nfsd_serv->
sv_nrpools && i <
n; i++)
373 nthreads[i] = nfsd_serv->
sv_pools[i].sp_nrthreads;
388 if (nfsd_serv ==
NULL || n <= 0)
396 for (i = 0; i <
n; i++) {
403 for (i = 0; i < n && tot > 0; i++) {
405 tot -= (nthreads[
i] -
new);
408 for (i = 0; i < n && tot > 0; i++) {
418 if (nthreads[0] == 0)
423 for (i = 0; i <
n; i++) {
446 dprintk(
"nfsd: creating service\n");
452 if (nrservs == 0 && nfsd_serv ==
NULL)
459 nfsd_up_before = nfsd_up;
461 error = nfsd_startup(nrservs);
473 if (error < 0 && !nfsd_up_before)
499 printk(
"Unable to start nfsd thread: out of memory\n");
537 validate_process_creds();
539 validate_process_creds();
579 dprintk(
"nfsd_dispatch: vers %d proc %d\n",
590 if (xdr && !xdr(rqstp, (
__be32*)rqstp->
rq_arg.head[0].iov_base,
592 dprintk(
"nfsd: failed to decode arguments!\n");
593 *statp = rpc_garbage_args;
611 nfserrp = rqstp->
rq_res.head[0].iov_base
612 + rqstp->
rq_res.head[0].iov_len;
617 nfserr = map_new_errors(rqstp->
rq_vers, nfserr);
619 dprintk(
"nfsd: Dropping request; may be revisited later\n");
630 if (!(nfserr && rqstp->
rq_vers == 2)) {
632 if (xdr && !xdr(rqstp, nfserrp,
635 dprintk(
"nfsd: failed to encode result!\n");
637 *statp = rpc_system_err;
651 if (nfsd_serv ==
NULL) {