diff options
| author | Neil Brown <neilb@cse.unsw.edu.au> | 2003-01-05 03:43:31 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2003-01-05 03:43:31 -0800 |
| commit | bb1eb94c5ef612857f439db9fb7fb449dd39a91f (patch) | |
| tree | 6f5f2a6a615e4f43d68df5d3c853f25a56b15ec3 | |
| parent | 9838159a677e1ec70c7af68e370e8bb0ed39cf1e (diff) | |
[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.
| -rw-r--r-- | fs/nfsd/nfsctl.c | 28 | ||||
| -rw-r--r-- | fs/nfsd/nfssvc.c | 8 |
2 files changed, 36 insertions, 0 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index e99b7cee9a1f..7cc70b08b27d 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -47,6 +47,7 @@ enum { NFSD_Getfs, NFSD_List, NFSD_Fh, + NFSD_Threads, NFSD_END }; @@ -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_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_threads(struct file *file, char *buf, size_t size); static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Svc] = write_svc, @@ -71,6 +73,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { [NFSD_Getfd] = write_getfd, [NFSD_Getfs] = write_getfs, [NFSD_Fh] = write_filehandle, + [NFSD_Threads] = write_threads, }; /* 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[] = { [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, [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) 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. diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index da4271183ef7..94f48ae35e95 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -66,6 +66,14 @@ struct list_head nfsd_list = LIST_HEAD_INIT(nfsd_list); */ #define NFSD_MAXSERVS 8192 +int nfsd_nrthreads(void) +{ + if (nfsd_serv == NULL) + return 0; + else + return nfsd_serv->sv_nrthreads; +} + int nfsd_svc(unsigned short port, int nrservs) { |
