sunrpc_syms.c 2.65 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * linux/net/sunrpc/sunrpc_syms.c
 *
 * Symbols exported by the sunrpc module.
 *
 * Copyright (C) 1997 Olaf Kirch <okir@monad.swb.de>
 */

#include <linux/module.h>

#include <linux/types.h>
#include <linux/uio.h>
#include <linux/unistd.h>
#include <linux/init.h>

#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/svc.h>
#include <linux/sunrpc/svcsock.h>
#include <linux/sunrpc/auth.h>
#include <linux/workqueue.h>
#include <linux/sunrpc/rpc_pipe_fs.h>
23
#include <linux/sunrpc/xprtsock.h>
Linus Torvalds's avatar
Linus Torvalds committed
24

25 26
#include "netns.h"

27
unsigned int sunrpc_net_id;
28
EXPORT_SYMBOL_GPL(sunrpc_net_id);
29 30 31

static __net_init int sunrpc_init_net(struct net *net)
{
32
	int err;
33
	struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
34 35 36 37 38

	err = rpc_proc_init(net);
	if (err)
		goto err_proc;

39 40 41 42
	err = ip_map_cache_create(net);
	if (err)
		goto err_ipmap;

43 44 45 46
	err = unix_gid_cache_create(net);
	if (err)
		goto err_unixgid;

47 48 49 50
	err = rpc_pipefs_init_net(net);
	if (err)
		goto err_pipefs;

51 52
	INIT_LIST_HEAD(&sn->all_clients);
	spin_lock_init(&sn->rpc_client_lock);
53
	spin_lock_init(&sn->rpcb_clnt_lock);
54
	return 0;
55

56 57
err_pipefs:
	unix_gid_cache_destroy(net);
58 59
err_unixgid:
	ip_map_cache_destroy(net);
60 61
err_ipmap:
	rpc_proc_exit(net);
62 63
err_proc:
	return err;
64 65 66 67
}

static __net_exit void sunrpc_exit_net(struct net *net)
{
68
	rpc_pipefs_exit_net(net);
69
	unix_gid_cache_destroy(net);
70
	ip_map_cache_destroy(net);
71
	rpc_proc_exit(net);
72 73 74 75 76 77 78 79 80
}

static struct pernet_operations sunrpc_net_ops = {
	.init = sunrpc_init_net,
	.exit = sunrpc_exit_net,
	.id = &sunrpc_net_id,
	.size = sizeof(struct sunrpc_net),
};

Linus Torvalds's avatar
Linus Torvalds committed
81 82 83
static int __init
init_sunrpc(void)
{
84
	int err = rpc_init_mempool();
Linus Torvalds's avatar
Linus Torvalds committed
85 86
	if (err)
		goto out;
87 88
	err = rpcauth_init_module();
	if (err)
89
		goto out2;
90 91 92 93

	cache_initialize();

	err = register_pernet_subsys(&sunrpc_net_ops);
94 95 96 97
	if (err)
		goto out3;

	err = register_rpc_pipefs();
98 99
	if (err)
		goto out4;
100

101
	sunrpc_debugfs_init();
Jeff Layton's avatar
Jeff Layton committed
102
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds's avatar
Linus Torvalds committed
103 104
	rpc_register_sysctl();
#endif
105 106
	svc_init_xprt_sock();	/* svc sock transport */
	init_socket_xprt();	/* clnt sock transport */
107
	return 0;
108 109

out4:
110
	unregister_pernet_subsys(&sunrpc_net_ops);
111
out3:
112
	rpcauth_remove_module();
113
out2:
114
	rpc_destroy_mempool();
Linus Torvalds's avatar
Linus Torvalds committed
115 116 117 118 119 120 121
out:
	return err;
}

static void __exit
cleanup_sunrpc(void)
{
122
	rpc_cleanup_clids();
123
	rpcauth_remove_module();
124
	cleanup_socket_xprt();
125
	svc_cleanup_xprt_sock();
126
	sunrpc_debugfs_exit();
Linus Torvalds's avatar
Linus Torvalds committed
127 128
	unregister_rpc_pipefs();
	rpc_destroy_mempool();
129
	unregister_pernet_subsys(&sunrpc_net_ops);
Jeff Layton's avatar
Jeff Layton committed
130
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
Linus Torvalds's avatar
Linus Torvalds committed
131 132
	rpc_unregister_sysctl();
#endif
133
	rcu_barrier(); /* Wait for completion of call_rcu()'s */
Linus Torvalds's avatar
Linus Torvalds committed
134 135
}
MODULE_LICENSE("GPL");
136
fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */
Linus Torvalds's avatar
Linus Torvalds committed
137
module_exit(cleanup_sunrpc);