sysctl.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * linux/fs/nfs/sysctl.c
  3. *
  4. * Sysctl interface to NFS parameters
  5. */
  6. #include <linux/types.h>
  7. #include <linux/linkage.h>
  8. #include <linux/ctype.h>
  9. #include <linux/fs.h>
  10. #include <linux/sysctl.h>
  11. #include <linux/module.h>
  12. #include <linux/nfs4.h>
  13. #include <linux/nfs_idmap.h>
  14. #include <linux/nfs_fs.h>
  15. #include "callback.h"
  16. #ifdef CONFIG_NFS_V4
  17. static const int nfs_set_port_min = 0;
  18. static const int nfs_set_port_max = 65535;
  19. #endif
  20. static struct ctl_table_header *nfs_callback_sysctl_table;
  21. static ctl_table nfs_cb_sysctls[] = {
  22. #ifdef CONFIG_NFS_V4
  23. {
  24. .procname = "nfs_callback_tcpport",
  25. .data = &nfs_callback_set_tcpport,
  26. .maxlen = sizeof(int),
  27. .mode = 0644,
  28. .proc_handler = proc_dointvec_minmax,
  29. .extra1 = (int *)&nfs_set_port_min,
  30. .extra2 = (int *)&nfs_set_port_max,
  31. },
  32. #ifndef CONFIG_NFS_USE_NEW_IDMAPPER
  33. {
  34. .procname = "idmap_cache_timeout",
  35. .data = &nfs_idmap_cache_timeout,
  36. .maxlen = sizeof(int),
  37. .mode = 0644,
  38. .proc_handler = proc_dointvec_jiffies,
  39. },
  40. #endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
  41. #endif
  42. {
  43. .procname = "nfs_mountpoint_timeout",
  44. .data = &nfs_mountpoint_expiry_timeout,
  45. .maxlen = sizeof(nfs_mountpoint_expiry_timeout),
  46. .mode = 0644,
  47. .proc_handler = proc_dointvec_jiffies,
  48. },
  49. {
  50. .procname = "nfs_congestion_kb",
  51. .data = &nfs_congestion_kb,
  52. .maxlen = sizeof(nfs_congestion_kb),
  53. .mode = 0644,
  54. .proc_handler = proc_dointvec,
  55. },
  56. { }
  57. };
  58. static ctl_table nfs_cb_sysctl_dir[] = {
  59. {
  60. .procname = "nfs",
  61. .mode = 0555,
  62. .child = nfs_cb_sysctls,
  63. },
  64. { }
  65. };
  66. static ctl_table nfs_cb_sysctl_root[] = {
  67. {
  68. .procname = "fs",
  69. .mode = 0555,
  70. .child = nfs_cb_sysctl_dir,
  71. },
  72. { }
  73. };
  74. int nfs_register_sysctl(void)
  75. {
  76. nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root);
  77. if (nfs_callback_sysctl_table == NULL)
  78. return -ENOMEM;
  79. return 0;
  80. }
  81. void nfs_unregister_sysctl(void)
  82. {
  83. unregister_sysctl_table(nfs_callback_sysctl_table);
  84. nfs_callback_sysctl_table = NULL;
  85. }