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

[PATCH] PATCH 6/7: knfsd cleanups - syscall cleanup

Cleanup the syscall interface to nfsd

1/ add an "owner" field to the nfsd_linkage structure
2/ grab a reference to that module before calling the syscall
3/ Remove the reference counting from inside the module
4/ Always allow nfsd module to be called, even if compile with
	CONFIG_NFSD == N
   ( but not if CONFIG_MODULES also == N)
parent c4dd7702
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (C) 1991, 1992 Linus Torvalds * Copyright (C) 1991, 1992 Linus Torvalds
* *
* table of configured filesystems * nfsservctl system-call when nfsd is not compiled in.
*/ */
#include <linux/config.h> #include <linux/config.h>
...@@ -14,28 +14,28 @@ ...@@ -14,28 +14,28 @@
#include <linux/nfsd/interface.h> #include <linux/nfsd/interface.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#if defined(CONFIG_NFSD_MODULE) #if ! defined(CONFIG_NFSD)
struct nfsd_linkage *nfsd_linkage = NULL; struct nfsd_linkage *nfsd_linkage;
long long
asmlinkage sys_nfsservctl(int cmd, void *argp, void *resp) asmlinkage sys_nfsservctl(int cmd, void *argp, void *resp)
{ {
int ret = -ENOSYS; int ret = -ENOSYS;
#if defined(CONFIG_MODULES)
lock_kernel(); lock_kernel();
if (nfsd_linkage || if (nfsd_linkage ||
(request_module ("nfsd") == 0 && nfsd_linkage)) (request_module ("nfsd") == 0 && nfsd_linkage)) {
__MOD_INC_USE_COUNT(nfsd_linkage->owner);
unlock_kernel();
ret = nfsd_linkage->do_nfsservctl(cmd, argp, resp); ret = nfsd_linkage->do_nfsservctl(cmd, argp, resp);
__MOD_DEC_USE_COUNT(nfsd_linkage->owner);
unlock_kernel(); } else
unlock_kernel();
#endif
return ret; return ret;
} }
EXPORT_SYMBOL(nfsd_linkage); EXPORT_SYMBOL(nfsd_linkage);
#elif ! defined (CONFIG_NFSD)
asmlinkage int sys_nfsservctl(int cmd, void *argp, void *resp)
{
return -ENOSYS;
}
#endif /* CONFIG_NFSD */ #endif /* CONFIG_NFSD */
...@@ -203,7 +203,6 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp) ...@@ -203,7 +203,6 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp)
int err; int err;
int argsize, respsize; int argsize, respsize;
MOD_INC_USE_COUNT;
lock_kernel (); lock_kernel ();
if (!initialized) if (!initialized)
nfsd_init(); nfsd_init();
...@@ -276,7 +275,6 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp) ...@@ -276,7 +275,6 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp)
kfree(res); kfree(res);
unlock_kernel (); unlock_kernel ();
MOD_DEC_USE_COUNT;
return err; return err;
} }
...@@ -288,6 +286,7 @@ MODULE_LICENSE("GPL"); ...@@ -288,6 +286,7 @@ MODULE_LICENSE("GPL");
struct nfsd_linkage nfsd_linkage_s = { struct nfsd_linkage nfsd_linkage_s = {
do_nfsservctl: handle_sys_nfsservctl, do_nfsservctl: handle_sys_nfsservctl,
owner: THIS_MODULE,
}; };
/* /*
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
extern struct nfsd_linkage { extern struct nfsd_linkage {
long (*do_nfsservctl)(int cmd, void *argp, void *resp); long (*do_nfsservctl)(int cmd, void *argp, void *resp);
struct module *owner;
} * nfsd_linkage; } * nfsd_linkage;
#endif #endif
......
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