Commit bb1eb94c authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] knfsd: Add 'threads' file to nfsd filesystem to allow changing number of threads.

This uses the read-without-write style transaction files in nfsctl.
We can write a number of threads, and then read back the number of
threads that resulted, or we can just open and read in which case
we read back the number of threads without changing it.
parent 9838159a
...@@ -47,6 +47,7 @@ enum { ...@@ -47,6 +47,7 @@ enum {
NFSD_Getfs, NFSD_Getfs,
NFSD_List, NFSD_List,
NFSD_Fh, NFSD_Fh,
NFSD_Threads,
NFSD_END NFSD_END
}; };
...@@ -61,6 +62,7 @@ static ssize_t write_unexport(struct file *file, char *buf, size_t size); ...@@ -61,6 +62,7 @@ static ssize_t write_unexport(struct file *file, char *buf, size_t size);
static ssize_t write_getfd(struct file *file, char *buf, size_t size); static ssize_t write_getfd(struct file *file, char *buf, size_t size);
static ssize_t write_getfs(struct file *file, char *buf, size_t size); static ssize_t write_getfs(struct file *file, char *buf, size_t size);
static ssize_t write_filehandle(struct file *file, char *buf, size_t size); static ssize_t write_filehandle(struct file *file, char *buf, size_t size);
static ssize_t write_threads(struct file *file, char *buf, size_t size);
static ssize_t (*write_op[])(struct file *, char *, size_t) = { static ssize_t (*write_op[])(struct file *, char *, size_t) = {
[NFSD_Svc] = write_svc, [NFSD_Svc] = write_svc,
...@@ -71,6 +73,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { ...@@ -71,6 +73,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = {
[NFSD_Getfd] = write_getfd, [NFSD_Getfd] = write_getfd,
[NFSD_Getfs] = write_getfs, [NFSD_Getfs] = write_getfs,
[NFSD_Fh] = write_filehandle, [NFSD_Fh] = write_filehandle,
[NFSD_Threads] = write_threads,
}; };
/* an argresp is stored in an allocated page and holds the /* an argresp is stored in an allocated page and holds the
...@@ -214,6 +217,7 @@ static struct { char *name; struct file_operations *ops; int mode; } files[] = { ...@@ -214,6 +217,7 @@ static struct { char *name; struct file_operations *ops; int mode; } files[] = {
[NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_List] = {"exports", &exports_operations, S_IRUGO}, [NFSD_List] = {"exports", &exports_operations, S_IRUGO},
[NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR},
[NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR},
}; };
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
...@@ -398,6 +402,30 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size) ...@@ -398,6 +402,30 @@ static ssize_t write_filehandle(struct file *file, char *buf, size_t size)
return mesg - buf; return mesg - buf;
} }
extern int nfsd_nrthreads(void);
static ssize_t write_threads(struct file *file, char *buf, size_t size)
{
/* if size > 0, look for a number of threads and call nfsd_svc
* then write out number of threads as reply
*/
char *mesg = buf;
int rv;
if (size > 0) {
int newthreads;
rv = get_int(&mesg, &newthreads);
if (rv)
return rv;
if (newthreads <0)
return -EINVAL;
rv = nfsd_svc(2049, newthreads);
if (rv)
return rv;
}
sprintf(buf, "%d\n", nfsd_nrthreads());
return strlen(buf);
}
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* /*
* populating the filesystem. * populating the filesystem.
......
...@@ -66,6 +66,14 @@ struct list_head nfsd_list = LIST_HEAD_INIT(nfsd_list); ...@@ -66,6 +66,14 @@ struct list_head nfsd_list = LIST_HEAD_INIT(nfsd_list);
*/ */
#define NFSD_MAXSERVS 8192 #define NFSD_MAXSERVS 8192
int nfsd_nrthreads(void)
{
if (nfsd_serv == NULL)
return 0;
else
return nfsd_serv->sv_nrthreads;
}
int int
nfsd_svc(unsigned short port, int nrservs) nfsd_svc(unsigned short port, int nrservs)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment