export.h 3.6 KB

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