]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFSD: Remove svc_serv_ops::svo_module
authorChuck Lever <chuck.lever@oracle.com>
Wed, 16 Feb 2022 17:31:09 +0000 (12:31 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:01 +0000 (16:19 +0200)
[ Upstream commit f49169c97fceb21ad6a0aaf671c50b0f520f15a5 ]

struct svc_serv_ops is about to be removed.

Neil Brown says:
> I suspect svo_module can go as well - I don't think the thread is
> ever the thing that primarily keeps a module active.

A random sample of kthread_create() callers shows sunrpc is the only
one that manages module reference count in this way.

Suggested-by: Neil Brown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/svc.c
fs/nfs/callback.c
fs/nfs/nfs4state.c
fs/nfsd/nfssvc.c
include/linux/sunrpc/svc.h
kernel/module.c
net/sunrpc/svc.c

index c83ec4a375bc1a3dd4826ca509895ed2f99a1b4f..bfde31124f3af7f2999ffbcf93b9ea0622617e6f 100644 (file)
@@ -184,8 +184,7 @@ lockd(void *vrqstp)
        dprintk("lockd_down: service stopped\n");
 
        svc_exit_thread(rqstp);
-
-       module_put_and_kthread_exit(0);
+       return 0;
 }
 
 static int create_lockd_listener(struct svc_serv *serv, const char *name,
@@ -352,7 +351,6 @@ static struct notifier_block lockd_inet6addr_notifier = {
 
 static const struct svc_serv_ops lockd_sv_ops = {
        .svo_function           = lockd,
-       .svo_module             = THIS_MODULE,
 };
 
 static int lockd_get(void)
index c98c68513590f91f4be093c1bbb160f45132652f..a494f9e7bd0a05e4e3f813c7296964d16d77bdf1 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/errno.h>
 #include <linux/mutex.h>
 #include <linux/freezer.h>
-#include <linux/kthread.h>
 #include <linux/sunrpc/svcauth_gss.h>
 #include <linux/sunrpc/bc_xprt.h>
 
@@ -92,8 +91,8 @@ nfs4_callback_svc(void *vrqstp)
                        continue;
                svc_process(rqstp);
        }
+
        svc_exit_thread(rqstp);
-       module_put_and_kthread_exit(0);
        return 0;
 }
 
@@ -136,8 +135,8 @@ nfs41_callback_svc(void *vrqstp)
                        finish_wait(&serv->sv_cb_waitq, &wq);
                }
        }
+
        svc_exit_thread(rqstp);
-       module_put_and_kthread_exit(0);
        return 0;
 }
 
@@ -234,12 +233,10 @@ err_bind:
 
 static const struct svc_serv_ops nfs40_cb_sv_ops = {
        .svo_function           = nfs4_callback_svc,
-       .svo_module             = THIS_MODULE,
 };
 #if defined(CONFIG_NFS_V4_1)
 static const struct svc_serv_ops nfs41_cb_sv_ops = {
        .svo_function           = nfs41_callback_svc,
-       .svo_module             = THIS_MODULE,
 };
 
 static const struct svc_serv_ops *nfs4_cb_sv_ops[] = {
index d7868cc52780562c2b22316347aa78efcf64dc2e..61050ffac93ef19bd040dd40c71b14c1999ebf4d 100644 (file)
@@ -2766,6 +2766,5 @@ again:
                goto again;
 
        nfs_put_client(clp);
-       module_put_and_kthread_exit(0);
        return 0;
 }
index 38895372ec393d93d72e91e4f70d61a5a1f76467..d25d4c12a499a25edfa8243bd076b70eda0262f8 100644 (file)
@@ -614,7 +614,6 @@ static int nfsd_get_default_max_blksize(void)
 
 static const struct svc_serv_ops nfsd_thread_sv_ops = {
        .svo_function           = nfsd,
-       .svo_module             = THIS_MODULE,
 };
 
 void nfsd_shutdown_threads(struct net *net)
@@ -1018,8 +1017,6 @@ out:
                msleep(20);
        }
 
-       /* Release module */
-       module_put_and_kthread_exit(0);
        return 0;
 }
 
index fd7ccba415f51ec12a3046c0341cc699246e9f2f..61768495354a033b3ddb78bd7d94fbf8c35ffc11 100644 (file)
@@ -57,11 +57,6 @@ struct svc_serv;
 struct svc_serv_ops {
        /* function for service threads to run */
        int             (*svo_function)(void *);
-
-       /* optional module to count when adding threads.
-        * Thread function must call module_put_and_kthread_exit() to exit.
-        */
-       struct module   *svo_module;
 };
 
 /*
index f2b8314546f177137f5edf58e27e119dcbbf4947..2226b591b52e0e1aa30cb1401f0aba4b3b9a6b59 100644 (file)
@@ -335,7 +335,7 @@ static inline void add_taint_module(struct module *mod, unsigned flag,
 
 /*
  * A thread that wants to hold a reference to a module only while it
- * is running can call this to safely exit.  nfsd and lockd use this.
+ * is running can call this to safely exit.
  */
 void __noreturn __module_put_and_kthread_exit(struct module *mod, long code)
 {
index 6f45f3f45514c82756799cb32af01cd749807f83..239d10018216ad9186cd13af824b3474780bf363 100644 (file)
@@ -736,11 +736,9 @@ svc_start_kthreads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
                if (IS_ERR(rqstp))
                        return PTR_ERR(rqstp);
 
-               __module_get(serv->sv_ops->svo_module);
                task = kthread_create_on_node(serv->sv_ops->svo_function, rqstp,
                                              node, "%s", serv->sv_name);
                if (IS_ERR(task)) {
-                       module_put(serv->sv_ops->svo_module);
                        svc_exit_thread(rqstp);
                        return PTR_ERR(task);
                }