Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Copyright (C) 1995-1997 Olaf Kirch <okir@monad.swb.de> |
| 4 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | #ifndef NFSD_EXPORT_H |
| 6 | #define NFSD_EXPORT_H |
| 7 | |
Christoph Hellwig | 9c69de4 | 2014-05-06 19:37:13 +0200 | [diff] [blame] | 8 | #include <linux/sunrpc/cache.h> |
David Howells | 616d1ca | 2012-10-09 09:49:02 +0100 | [diff] [blame] | 9 | #include <uapi/linux/nfsd/export.h> |
Jeff Layton | 4bc6603 | 2015-07-30 09:52:13 -0400 | [diff] [blame] | 10 | #include <linux/nfs4.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Christoph Hellwig | 9c69de4 | 2014-05-06 19:37:13 +0200 | [diff] [blame] | 12 | struct knfsd_fh; |
| 13 | struct svc_fh; |
| 14 | struct svc_rqst; |
| 15 | |
Manoj Naik | 93346919 | 2006-10-04 02:16:18 -0700 | [diff] [blame] | 16 | /* |
| 17 | * FS Locations |
| 18 | */ |
| 19 | |
| 20 | #define MAX_FS_LOCATIONS 128 |
| 21 | |
| 22 | struct nfsd4_fs_location { |
| 23 | char *hosts; /* colon separated list of hosts */ |
| 24 | char *path; /* slash separated list of path components */ |
| 25 | }; |
| 26 | |
| 27 | struct nfsd4_fs_locations { |
| 28 | uint32_t locations_count; |
| 29 | struct nfsd4_fs_location *locations; |
| 30 | /* If we're not actually serving this data ourselves (only providing a |
| 31 | * list of replicas that do serve it) then we set "migrated": */ |
| 32 | int migrated; |
| 33 | }; |
| 34 | |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 35 | /* |
| 36 | * We keep an array of pseudoflavors with the export, in order from most |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 37 | * to least preferred. For the foreseeable future, we don't expect more |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 38 | * than the eight pseudoflavors null, unix, krb5, krb5i, krb5p, skpm3, |
| 39 | * spkm3i, and spkm3p (and using all 8 at once should be rare). |
| 40 | */ |
| 41 | #define MAX_SECINFO_LIST 8 |
Kinglong Mee | 94eb368 | 2014-05-23 20:00:19 +0800 | [diff] [blame] | 42 | #define EX_UUID_LEN 16 |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 43 | |
| 44 | struct exp_flavor_info { |
| 45 | u32 pseudoflavor; |
| 46 | u32 flags; |
| 47 | }; |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | struct svc_export { |
| 50 | struct cache_head h; |
| 51 | struct auth_domain * ex_client; |
| 52 | int ex_flags; |
Jan Blunck | 5477549 | 2008-02-14 19:38:39 -0800 | [diff] [blame] | 53 | struct path ex_path; |
Eric W. Biederman | 4c1e1b3 | 2013-02-02 06:42:53 -0800 | [diff] [blame] | 54 | kuid_t ex_anon_uid; |
| 55 | kgid_t ex_anon_gid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | int ex_fsid; |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 57 | unsigned char * ex_uuid; /* 16 byte fsid */ |
Manoj Naik | 93346919 | 2006-10-04 02:16:18 -0700 | [diff] [blame] | 58 | struct nfsd4_fs_locations ex_fslocs; |
Kinglong Mee | 1f53146 | 2014-05-24 11:26:49 +0800 | [diff] [blame] | 59 | uint32_t ex_nflavors; |
Andy Adamson | e677bfe | 2007-07-17 04:04:42 -0700 | [diff] [blame] | 60 | struct exp_flavor_info ex_flavors[MAX_SECINFO_LIST]; |
Jeff Layton | 8a4c392 | 2016-07-10 15:55:58 -0400 | [diff] [blame] | 61 | u32 ex_layout_types; |
Christoph Hellwig | 9cf514c | 2014-05-05 13:11:59 +0200 | [diff] [blame] | 62 | struct nfsd4_deviceid_map *ex_devid_map; |
Stanislav Kinsbursky | db3a353 | 2012-03-28 19:09:08 +0400 | [diff] [blame] | 63 | struct cache_detail *cd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | /* an "export key" (expkey) maps a filehandlefragement to an |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 67 | * svc_export for a given client. There can be several per export, |
| 68 | * for the different fsid types. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | */ |
| 70 | struct svc_expkey { |
| 71 | struct cache_head h; |
| 72 | |
| 73 | struct auth_domain * ek_client; |
| 74 | int ek_fsidtype; |
NeilBrown | af6a4e2 | 2007-02-14 00:33:12 -0800 | [diff] [blame] | 75 | u32 ek_fsid[6]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
Jan Blunck | e83aece | 2008-02-14 19:38:41 -0800 | [diff] [blame] | 77 | struct path ek_path; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | }; |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | #define EX_NOHIDE(exp) ((exp)->ex_flags & NFSEXP_NOHIDE) |
| 82 | #define EX_WGATHER(exp) ((exp)->ex_flags & NFSEXP_GATHERED_WRITES) |
| 83 | |
J. Bruce Fields | c7d5140 | 2007-07-19 01:49:20 -0700 | [diff] [blame] | 84 | int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp); |
Andy Adamson | 32c1eb0 | 2007-07-17 04:04:48 -0700 | [diff] [blame] | 85 | __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * Function declarations |
| 89 | */ |
Stanislav Kinsbursky | b89109b | 2012-04-11 15:13:14 +0400 | [diff] [blame] | 90 | int nfsd_export_init(struct net *); |
| 91 | void nfsd_export_shutdown(struct net *); |
Stanislav Kinsbursky | b3853e0 | 2012-04-11 15:13:21 +0400 | [diff] [blame] | 92 | void nfsd_export_flush(struct net *); |
J. Bruce Fields | 0989a78 | 2007-07-17 04:04:44 -0700 | [diff] [blame] | 93 | struct svc_export * rqst_exp_get_by_name(struct svc_rqst *, |
Al Viro | 91c9fa8 | 2009-04-18 02:42:05 -0400 | [diff] [blame] | 94 | struct path *); |
J. Bruce Fields | 0989a78 | 2007-07-17 04:04:44 -0700 | [diff] [blame] | 95 | struct svc_export * rqst_exp_parent(struct svc_rqst *, |
Al Viro | e64c390 | 2009-04-18 03:00:46 -0400 | [diff] [blame] | 96 | struct path *); |
Trond Myklebust | ed748aa | 2011-09-12 19:37:06 -0400 | [diff] [blame] | 97 | struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *); |
Stanislav Kinsbursky | b3853e0 | 2012-04-11 15:13:21 +0400 | [diff] [blame] | 98 | int exp_rootfh(struct net *, struct auth_domain *, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | char *path, struct knfsd_fh *, int maxsize); |
J. Bruce Fields | df547ef | 2007-07-17 04:04:43 -0700 | [diff] [blame] | 100 | __be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *); |
Al Viro | 63f10311 | 2006-10-19 23:28:54 -0700 | [diff] [blame] | 101 | __be32 nfserrno(int errno); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | static inline void exp_put(struct svc_export *exp) |
| 104 | { |
Stanislav Kinsbursky | 7123497 | 2012-03-28 19:09:15 +0400 | [diff] [blame] | 105 | cache_put(&exp->h, exp->cd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Kinglong Mee | bf18f16 | 2014-06-10 22:06:44 +0800 | [diff] [blame] | 108 | static inline struct svc_export *exp_get(struct svc_export *exp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | { |
| 110 | cache_get(&exp->h); |
Kinglong Mee | bf18f16 | 2014-06-10 22:06:44 +0800 | [diff] [blame] | 111 | return exp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | } |
J. Bruce Fields | 0989a78 | 2007-07-17 04:04:44 -0700 | [diff] [blame] | 113 | struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | #endif /* NFSD_EXPORT_H */ |