export.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de>
  4. */
  5. #ifndef NFSD_EXPORT_H
  6. #define NFSD_EXPORT_H
  7. #include <linux/sunrpc/cache.h>
  8. #include <linux/percpu_counter.h>
  9. #include <linux/workqueue.h>
  10. #include <uapi/linux/nfsd/export.h>
  11. #include <linux/nfs4.h>
  12. struct knfsd_fh;
  13. struct svc_fh;
  14. struct svc_rqst;
  15. /*
  16. * FS Locations
  17. */
  18. #define MAX_FS_LOCATIONS 128
  19. struct nfsd4_fs_location {
  20. char *hosts; /* colon separated list of hosts */
  21. char *path; /* slash separated list of path components */
  22. };
  23. struct nfsd4_fs_locations {
  24. uint32_t locations_count;
  25. struct nfsd4_fs_location *locations;
  26. /* If we're not actually serving this data ourselves (only providing a
  27. * list of replicas that do serve it) then we set "migrated": */
  28. int migrated;
  29. };
  30. /*
  31. * We keep an array of pseudoflavors with the export, in order from most
  32. * to least preferred. For the foreseeable future, we don't expect more
  33. * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3,
  34. * spkm3i, and spkm3p (and using all 8 at once should be rare).
  35. */
  36. #define MAX_SECINFO_LIST 8
  37. #define EX_UUID_LEN 16
  38. struct exp_flavor_info {
  39. u32 pseudoflavor;
  40. u32 flags;
  41. };
  42. /* Per-export stats */
  43. enum {
  44. EXP_STATS_FH_STALE,
  45. EXP_STATS_IO_READ,
  46. EXP_STATS_IO_WRITE,
  47. EXP_STATS_COUNTERS_NUM
  48. };
  49. struct export_stats {
  50. time64_t start_time;
  51. struct percpu_counter counter[EXP_STATS_COUNTERS_NUM];
  52. };
  53. struct svc_export {
  54. struct cache_head h;
  55. struct auth_domain * ex_client;
  56. int ex_flags;
  57. int ex_fsid;
  58. struct path ex_path;
  59. kuid_t ex_anon_uid;
  60. kgid_t ex_anon_gid;
  61. unsigned char * ex_uuid; /* 16 byte fsid */
  62. struct nfsd4_fs_locations ex_fslocs;
  63. uint32_t ex_nflavors;
  64. struct exp_flavor_info ex_flavors[MAX_SECINFO_LIST];
  65. u32 ex_layout_types;
  66. struct nfsd4_deviceid_map *ex_devid_map;
  67. struct cache_detail *cd;
  68. struct rcu_work ex_rwork;
  69. unsigned long ex_xprtsec_modes;
  70. struct export_stats *ex_stats;
  71. };
  72. /* an "export key" (expkey) maps a filehandlefragement to an
  73. * svc_export for a given client. There can be several per export,
  74. * for the different fsid types.
  75. */
  76. struct svc_expkey {
  77. struct cache_head h;
  78. struct auth_domain * ek_client;
  79. u8 ek_fsidtype;
  80. u32 ek_fsid[6];
  81. struct path ek_path;
  82. struct rcu_work ek_rwork;
  83. };
  84. #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
  85. #define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
  86. #define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
  87. struct svc_cred;
  88. int nfsexp_flags(struct svc_cred *cred, struct svc_export *exp);
  89. __be32 check_xprtsec_policy(struct svc_export *exp, struct svc_rqst *rqstp);
  90. __be32 check_security_flavor(struct svc_export *exp, struct svc_rqst *rqstp,
  91. bool may_bypass_gss);
  92. __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp,
  93. bool may_bypass_gss);
  94. /*
  95. * Function declarations
  96. */
  97. int nfsd_export_wq_init(void);
  98. void nfsd_export_wq_shutdown(void);
  99. int nfsd_export_init(struct net *);
  100. void nfsd_export_shutdown(struct net *);
  101. void nfsd_export_flush(struct net *);
  102. struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
  103. const struct path *);
  104. struct svc_export * rqst_exp_parent(struct svc_rqst *,
  105. struct path *);
  106. struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
  107. int exp_rootfh(struct net *, struct auth_domain *,
  108. char *path, struct knfsd_fh *, int maxsize);
  109. __be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
  110. static inline void exp_put(struct svc_export *exp)
  111. {
  112. cache_put(&exp->h, exp->cd);
  113. }
  114. static inline struct svc_export *exp_get(struct svc_export *exp)
  115. {
  116. cache_get(&exp->h);
  117. return exp;
  118. }
  119. struct svc_export *rqst_exp_find(struct cache_req *reqp, struct net *net,
  120. struct auth_domain *cl, struct auth_domain *gsscl,
  121. int fsid_type, u32 *fsidv);
  122. #endif /* NFSD_EXPORT_H */