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 @@
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* table of configured filesystems
* nfsservctl system-call when nfsd is not compiled in.
*/
#include <linux/config.h>
......@@ -14,28 +14,28 @@
#include <linux/nfsd/interface.h>
#include <linux/linkage.h>
#if defined(CONFIG_NFSD_MODULE)
struct nfsd_linkage *nfsd_linkage = NULL;
#if ! defined(CONFIG_NFSD)
struct nfsd_linkage *nfsd_linkage;
long
asmlinkage sys_nfsservctl(int cmd, void *argp, void *resp)
{
int ret = -ENOSYS;
#if defined(CONFIG_MODULES)
lock_kernel();
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);
unlock_kernel();
__MOD_DEC_USE_COUNT(nfsd_linkage->owner);
} else
unlock_kernel();
#endif
return ret;
}
EXPORT_SYMBOL(nfsd_linkage);
#elif ! defined (CONFIG_NFSD)
asmlinkage int sys_nfsservctl(int cmd, void *argp, void *resp)
{
return -ENOSYS;
}
#endif /* CONFIG_NFSD */
......@@ -203,7 +203,6 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp)
int err;
int argsize, respsize;
MOD_INC_USE_COUNT;
lock_kernel ();
if (!initialized)
nfsd_init();
......@@ -276,7 +275,6 @@ asmlinkage handle_sys_nfsservctl(int cmd, void *opaque_argp, void *opaque_resp)
kfree(res);
unlock_kernel ();
MOD_DEC_USE_COUNT;
return err;
}
......@@ -288,6 +286,7 @@ MODULE_LICENSE("GPL");
struct nfsd_linkage nfsd_linkage_s = {
do_nfsservctl: handle_sys_nfsservctl,
owner: THIS_MODULE,
};
/*
......
......@@ -16,6 +16,7 @@
extern struct nfsd_linkage {
long (*do_nfsservctl)(int cmd, void *argp, void *resp);
struct module *owner;
} * nfsd_linkage;
#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