sunrpc_syms.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * linux/net/sunrpc/sunrpc_syms.c
  3. *
  4. * Symbols exported by the sunrpc module.
  5. *
  6. * Copyright (C) 1997 Olaf Kirch <okir@monad.swb.de>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/types.h>
  10. #include <linux/uio.h>
  11. #include <linux/unistd.h>
  12. #include <linux/init.h>
  13. #include <linux/sunrpc/sched.h>
  14. #include <linux/sunrpc/clnt.h>
  15. #include <linux/sunrpc/svc.h>
  16. #include <linux/sunrpc/svcsock.h>
  17. #include <linux/sunrpc/auth.h>
  18. #include <linux/workqueue.h>
  19. #include <linux/sunrpc/rpc_pipe_fs.h>
  20. #include <linux/sunrpc/xprtsock.h>
  21. #include "netns.h"
  22. unsigned int sunrpc_net_id;
  23. EXPORT_SYMBOL_GPL(sunrpc_net_id);
  24. static __net_init int sunrpc_init_net(struct net *net)
  25. {
  26. int err;
  27. struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
  28. err = rpc_proc_init(net);
  29. if (err)
  30. goto err_proc;
  31. err = ip_map_cache_create(net);
  32. if (err)
  33. goto err_ipmap;
  34. err = unix_gid_cache_create(net);
  35. if (err)
  36. goto err_unixgid;
  37. err = rpc_pipefs_init_net(net);
  38. if (err)
  39. goto err_pipefs;
  40. INIT_LIST_HEAD(&sn->all_clients);
  41. spin_lock_init(&sn->rpc_client_lock);
  42. spin_lock_init(&sn->rpcb_clnt_lock);
  43. return 0;
  44. err_pipefs:
  45. unix_gid_cache_destroy(net);
  46. err_unixgid:
  47. ip_map_cache_destroy(net);
  48. err_ipmap:
  49. rpc_proc_exit(net);
  50. err_proc:
  51. return err;
  52. }
  53. static __net_exit void sunrpc_exit_net(struct net *net)
  54. {
  55. struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
  56. rpc_pipefs_exit_net(net);
  57. unix_gid_cache_destroy(net);
  58. ip_map_cache_destroy(net);
  59. rpc_proc_exit(net);
  60. WARN_ON_ONCE(!list_empty(&sn->all_clients));
  61. }
  62. static struct pernet_operations sunrpc_net_ops = {
  63. .init = sunrpc_init_net,
  64. .exit = sunrpc_exit_net,
  65. .id = &sunrpc_net_id,
  66. .size = sizeof(struct sunrpc_net),
  67. };
  68. static int __init
  69. init_sunrpc(void)
  70. {
  71. int err = rpc_init_mempool();
  72. if (err)
  73. goto out;
  74. err = rpcauth_init_module();
  75. if (err)
  76. goto out2;
  77. cache_initialize();
  78. err = register_pernet_subsys(&sunrpc_net_ops);
  79. if (err)
  80. goto out3;
  81. err = register_rpc_pipefs();
  82. if (err)
  83. goto out4;
  84. sunrpc_debugfs_init();
  85. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  86. rpc_register_sysctl();
  87. #endif
  88. svc_init_xprt_sock(); /* svc sock transport */
  89. init_socket_xprt(); /* clnt sock transport */
  90. return 0;
  91. out4:
  92. unregister_pernet_subsys(&sunrpc_net_ops);
  93. out3:
  94. rpcauth_remove_module();
  95. out2:
  96. rpc_destroy_mempool();
  97. out:
  98. return err;
  99. }
  100. static void __exit
  101. cleanup_sunrpc(void)
  102. {
  103. rpc_cleanup_clids();
  104. rpcauth_remove_module();
  105. cleanup_socket_xprt();
  106. svc_cleanup_xprt_sock();
  107. sunrpc_debugfs_exit();
  108. unregister_rpc_pipefs();
  109. rpc_destroy_mempool();
  110. unregister_pernet_subsys(&sunrpc_net_ops);
  111. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  112. rpc_unregister_sysctl();
  113. #endif
  114. rcu_barrier(); /* Wait for completion of call_rcu()'s */
  115. }
  116. MODULE_LICENSE("GPL");
  117. fs_initcall(init_sunrpc); /* Ensure we're initialised before nfs */
  118. module_exit(cleanup_sunrpc);