summaryrefslogtreecommitdiffstats
path: root/drivers/staging/lustre/lnet/lnet/module.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-05-21 14:35:12 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-25 18:29:10 +0200
commit912a846027c203370f4837a2b2db7ba2ebe1b47c (patch)
treee6c84e792969753e2d6cfc24baf0aff42571dde3 /drivers/staging/lustre/lnet/lnet/module.c
parent6afe572bc76688cd840032254217a4877b66e916 (diff)
downloadop-kernel-dev-912a846027c203370f4837a2b2db7ba2ebe1b47c.zip
op-kernel-dev-912a846027c203370f4837a2b2db7ba2ebe1b47c.tar.gz
staging: lustre: replace libcfs_register_ioctl with a blocking notifier_chain
libcfs allows other modules to register handlers for ioctls. The implementation it uses for this is nearly identical to a blocking notifier chain, so change to use that. The biggest difference is that the return value from notifier has a defined format, where libcfs_register_ioctl uses -EINVAL to mean "continue". This requires a little bit of conversion. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/lustre/lnet/lnet/module.c')
-rw-r--r--drivers/staging/lustre/lnet/lnet/module.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c
index f6e912e..9d06664 100644
--- a/drivers/staging/lustre/lnet/lnet/module.c
+++ b/drivers/staging/lustre/lnet/lnet/module.c
@@ -136,30 +136,37 @@ out_unlock:
}
static int
-lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
+lnet_ioctl(struct notifier_block *nb,
+ unsigned long cmd, void *vdata)
{
int rc;
+ struct libcfs_ioctl_hdr *hdr = vdata;
switch (cmd) {
case IOC_LIBCFS_CONFIGURE: {
struct libcfs_ioctl_data *data =
(struct libcfs_ioctl_data *)hdr;
- if (data->ioc_hdr.ioc_len < sizeof(*data))
- return -EINVAL;
-
- the_lnet.ln_nis_from_mod_params = data->ioc_flags;
- return lnet_configure(NULL);
+ if (data->ioc_hdr.ioc_len < sizeof(*data)) {
+ rc = -EINVAL;
+ } else {
+ the_lnet.ln_nis_from_mod_params = data->ioc_flags;
+ rc = lnet_configure(NULL);
+ }
+ break;
}
case IOC_LIBCFS_UNCONFIGURE:
- return lnet_unconfigure();
+ rc = lnet_unconfigure();
+ break;
case IOC_LIBCFS_ADD_NET:
- return lnet_dyn_configure(hdr);
+ rc = lnet_dyn_configure(hdr);
+ break;
case IOC_LIBCFS_DEL_NET:
- return lnet_dyn_unconfigure(hdr);
+ rc = lnet_dyn_unconfigure(hdr);
+ break;
default:
/*
@@ -172,11 +179,14 @@ lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr)
rc = LNetCtl(cmd, hdr);
LNetNIFini();
}
- return rc;
+ break;
}
+ return notifier_from_ioctl_errno(rc);
}
-static DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
+static struct notifier_block lnet_ioctl_handler = {
+ .notifier_call = lnet_ioctl,
+};
static int __init lnet_init(void)
{
@@ -194,7 +204,8 @@ static int __init lnet_init(void)
return rc;
}
- rc = libcfs_register_ioctl(&lnet_ioctl_handler);
+ rc = blocking_notifier_chain_register(&libcfs_ioctl_list,
+ &lnet_ioctl_handler);
LASSERT(!rc);
if (config_on_load) {
@@ -212,7 +223,8 @@ static void __exit lnet_exit(void)
{
int rc;
- rc = libcfs_deregister_ioctl(&lnet_ioctl_handler);
+ rc = blocking_notifier_chain_unregister(&libcfs_ioctl_list,
+ &lnet_ioctl_handler);
LASSERT(!rc);
lnet_lib_exit();
OpenPOWER on IntegriCloud