export.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (C) 1995-1997 Olaf Kirch <[email protected]>
  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. struct path ex_path;
  57. kuid_t ex_anon_uid;
  58. kgid_t ex_anon_gid;
  59. int ex_fsid;
  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. struct export_stats ex_stats;
  69. };
  70. /* an "export key" (expkey) maps a filehandlefragement to an
  71. * svc_export for a given client. There can be several per export,
  72. * for the different fsid types.
  73. */
  74. struct svc_expkey {
  75. struct cache_head h;
  76. struct auth_domain * ek_client;
  77. int ek_fsidtype;
  78. u32 ek_fsid[6];
  79. struct path ek_path;
  80. struct rcu_head ek_rcu;
  81. };
  82. #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
  83. #define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE)
  84. #define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES)
  85. int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp);
  86. __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
  87. /*
  88. * Function declarations
  89. */
  90. int nfsd_export_init(struct net *);
  91. void nfsd_export_shutdown(struct net *);
  92. void nfsd_export_flush(struct net *);
  93. struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
  94. struct path *);
  95. struct svc_export * rqst_exp_parent(struct svc_rqst *,
  96. struct path *);
  97. struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
  98. int exp_rootfh(struct net *, struct auth_domain *,
  99. char *path, struct knfsd_fh *, int maxsize);
  100. __be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
  101. __be32 nfserrno(int errno);
  102. static inline void exp_put(struct svc_export *exp)
  103. {
  104. cache_put(&exp->h, exp->cd);
  105. }
  106. static inline struct svc_export *exp_get(struct svc_export *exp)
  107. {
  108. cache_get(&exp->h);
  109. return exp;
  110. }
  111. struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
  112. #endif /* NFSD_EXPORT_H */