internal.h (e558100fda7e8c7888f523920214bcb35ed9382b) internal.h (f2aedb713c284429987dc66c7aaf38decfc8da2a)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * NFS internal definitions
4 */
5
6#include "nfs4_fs.h"
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * NFS internal definitions
4 */
5
6#include "nfs4_fs.h"
7#include <linux/mount.h>
7#include <linux/fs_context.h>
8#include <linux/security.h>
9#include <linux/crc32.h>
10#include <linux/sunrpc/addr.h>
11#include <linux/nfs_page.h>
12#include <linux/wait_bit.h>
13
14#define NFS_MS_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
15
16extern const struct export_operations nfs_export_ops;
17
18struct nfs_string;
8#include <linux/security.h>
9#include <linux/crc32.h>
10#include <linux/sunrpc/addr.h>
11#include <linux/nfs_page.h>
12#include <linux/wait_bit.h>
13
14#define NFS_MS_MASK (SB_RDONLY|SB_NOSUID|SB_NODEV|SB_NOEXEC|SB_SYNCHRONOUS)
15
16extern const struct export_operations nfs_export_ops;
17
18struct nfs_string;
19struct nfs_pageio_descriptor;
19
20static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct nfs_fattr *fattr)
21{
22 if (!nfs_fsid_equal(&NFS_SB(parent)->fsid, &fattr->fsid))
23 fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT;
24}
25
26static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr)
27{
28 if (((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) == 0) ||
29 (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) &&
30 ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0)))
31 return 0;
32 return 1;
33}
34
35struct nfs_clone_mount {
36 const struct super_block *sb;
20
21static inline void nfs_attr_check_mountpoint(struct super_block *parent, struct nfs_fattr *fattr)
22{
23 if (!nfs_fsid_equal(&NFS_SB(parent)->fsid, &fattr->fsid))
24 fattr->valid |= NFS_ATTR_FATTR_MOUNTPOINT;
25}
26
27static inline int nfs_attr_use_mounted_on_fileid(struct nfs_fattr *fattr)
28{
29 if (((fattr->valid & NFS_ATTR_FATTR_MOUNTED_ON_FILEID) == 0) ||
30 (((fattr->valid & NFS_ATTR_FATTR_MOUNTPOINT) == 0) &&
31 ((fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL) == 0)))
32 return 0;
33 return 1;
34}
35
36struct nfs_clone_mount {
37 const struct super_block *sb;
37 const struct dentry *dentry;
38 struct dentry *dentry;
38 char *hostname;
39 char *mnt_path;
40 struct sockaddr *addr;
41 size_t addrlen;
42 rpc_authflavor_t authflavor;
39 char *hostname;
40 char *mnt_path;
41 struct sockaddr *addr;
42 size_t addrlen;
43 rpc_authflavor_t authflavor;
44 struct nfs_fattr *fattr;
43};
44
45/*
46 * Note: RFC 1813 doesn't limit the number of auth flavors that
47 * a server can return, so make something up.
48 */
49#define NFS_MAX_SECFLAVORS (12)
50

--- 22 unchanged lines hidden (view full) ---

73 int proto;
74 u32 minorversion;
75 unsigned int nconnect;
76 struct net *net;
77 const struct rpc_timeout *timeparms;
78 const struct cred *cred;
79};
80
45};
46
47/*
48 * Note: RFC 1813 doesn't limit the number of auth flavors that
49 * a server can return, so make something up.
50 */
51#define NFS_MAX_SECFLAVORS (12)
52

--- 22 unchanged lines hidden (view full) ---

75 int proto;
76 u32 minorversion;
77 unsigned int nconnect;
78 struct net *net;
79 const struct rpc_timeout *timeparms;
80 const struct cred *cred;
81};
82
83struct nfs_mount_info {
84 unsigned int inherited_bsize;
85 struct nfs_fs_context *ctx;
86 struct nfs_clone_mount *cloned;
87 struct nfs_server *server;
88 struct nfs_fh *mntfh;
89 struct nfs_subversion *nfs_mod;
90};
91
81/*
82 * In-kernel mount arguments
83 */
84struct nfs_fs_context {
92/*
93 * In-kernel mount arguments
94 */
95struct nfs_fs_context {
96 bool internal;
97 bool skip_reconfig_option_check;
98 bool need_mount;
99 bool sloppy;
85 unsigned int flags; /* NFS{,4}_MOUNT_* flags */
86 unsigned int rsize, wsize;
87 unsigned int timeo, retrans;
88 unsigned int acregmin, acregmax;
89 unsigned int acdirmin, acdirmax;
90 unsigned int namlen;
91 unsigned int options;
92 unsigned int bsize;
93 struct nfs_auth_info auth_info;
94 rpc_authflavor_t selected_flavor;
95 char *client_address;
96 unsigned int version;
97 unsigned int minorversion;
98 char *fscache_uniq;
99 unsigned short protofamily;
100 unsigned short mountfamily;
100 unsigned int flags; /* NFS{,4}_MOUNT_* flags */
101 unsigned int rsize, wsize;
102 unsigned int timeo, retrans;
103 unsigned int acregmin, acregmax;
104 unsigned int acdirmin, acdirmax;
105 unsigned int namlen;
106 unsigned int options;
107 unsigned int bsize;
108 struct nfs_auth_info auth_info;
109 rpc_authflavor_t selected_flavor;
110 char *client_address;
111 unsigned int version;
112 unsigned int minorversion;
113 char *fscache_uniq;
114 unsigned short protofamily;
115 unsigned short mountfamily;
101 bool need_mount;
102 bool sloppy;
103
104 struct {
105 union {
106 struct sockaddr address;
107 struct sockaddr_storage _address;
108 };
109 size_t addrlen;
110 char *hostname;

--- 8 unchanged lines hidden (view full) ---

119 struct sockaddr_storage _address;
120 };
121 size_t addrlen;
122 char *hostname;
123 char *export_path;
124 int port;
125 unsigned short protocol;
126 unsigned short nconnect;
116
117 struct {
118 union {
119 struct sockaddr address;
120 struct sockaddr_storage _address;
121 };
122 size_t addrlen;
123 char *hostname;

--- 8 unchanged lines hidden (view full) ---

132 struct sockaddr_storage _address;
133 };
134 size_t addrlen;
135 char *hostname;
136 char *export_path;
137 int port;
138 unsigned short protocol;
139 unsigned short nconnect;
140 unsigned short export_path_len;
127 } nfs_server;
128
129 void *lsm_opts;
130 struct net *net;
131
132 char buf[32]; /* Parse buffer */
141 } nfs_server;
142
143 void *lsm_opts;
144 struct net *net;
145
146 char buf[32]; /* Parse buffer */
147
148 struct nfs_mount_info mount_info;
149 struct nfs_clone_mount clone_data;
133};
134
150};
151
152static inline struct nfs_fs_context *nfs_fc2context(const struct fs_context *fc)
153{
154 return fc->fs_private;
155}
156
135/* mount_clnt.c */
136struct nfs_mount_request {
137 struct sockaddr *sap;
138 size_t salen;
139 char *hostname;
140 char *dirpath;
141 u32 version;
142 unsigned short protocol;
143 struct nfs_fh *fh;
144 int noresvport;
145 unsigned int *auth_flav_len;
146 rpc_authflavor_t *auth_flavs;
147 struct net *net;
148};
149
157/* mount_clnt.c */
158struct nfs_mount_request {
159 struct sockaddr *sap;
160 size_t salen;
161 char *hostname;
162 char *dirpath;
163 u32 version;
164 unsigned short protocol;
165 struct nfs_fh *fh;
166 int noresvport;
167 unsigned int *auth_flav_len;
168 rpc_authflavor_t *auth_flavs;
169 struct net *net;
170};
171
150struct nfs_mount_info {
151 unsigned int inherited_bsize;
152 struct nfs_fs_context *ctx;
153 struct nfs_clone_mount *cloned;
154 struct nfs_server *server;
155 struct nfs_fh *mntfh;
156 struct nfs_subversion *nfs_mod;
157};
158
159extern int nfs_mount(struct nfs_mount_request *info);
160extern void nfs_umount(const struct nfs_mount_request *info);
161
162/* client.c */
163extern const struct rpc_program nfs_program;
164extern void nfs_clients_init(struct net *net);
165extern void nfs_clients_exit(struct net *net);
166extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *);

--- 63 unchanged lines hidden (view full) ---

230{
231}
232#endif
233
234/* callback_xdr.c */
235extern const struct svc_version nfs4_callback_version1;
236extern const struct svc_version nfs4_callback_version4;
237
172extern int nfs_mount(struct nfs_mount_request *info);
173extern void nfs_umount(const struct nfs_mount_request *info);
174
175/* client.c */
176extern const struct rpc_program nfs_program;
177extern void nfs_clients_init(struct net *net);
178extern void nfs_clients_exit(struct net *net);
179extern struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *);

--- 63 unchanged lines hidden (view full) ---

243{
244}
245#endif
246
247/* callback_xdr.c */
248extern const struct svc_version nfs4_callback_version1;
249extern const struct svc_version nfs4_callback_version4;
250
238struct nfs_pageio_descriptor;
251/* fs_context.c */
252extern struct file_system_type nfs_fs_type;
239
253
240/* mount.c */
241#define NFS_TEXT_DATA 1
242
243extern struct nfs_fs_context *nfs_alloc_parsed_mount_data(void);
244extern void nfs_free_parsed_mount_data(struct nfs_fs_context *ctx);
245extern int nfs_parse_mount_options(char *raw, struct nfs_fs_context *ctx);
246extern int nfs_validate_mount_data(struct file_system_type *fs_type,
247 void *options,
248 struct nfs_fs_context *ctx,
249 struct nfs_fh *mntfh,
250 const char *dev_name);
251extern int nfs_validate_text_mount_data(void *options,
252 struct nfs_fs_context *ctx,
253 const char *dev_name);
254
255/* pagelist.c */
256extern int __init nfs_init_nfspagecache(void);
257extern void nfs_destroy_nfspagecache(void);
258extern int __init nfs_init_readpagecache(void);
259extern void nfs_destroy_readpagecache(void);
260extern int __init nfs_init_writepagecache(void);
261extern void nfs_destroy_writepagecache(void);
262

--- 143 unchanged lines hidden (view full) ---

406extern void nfs_evict_inode(struct inode *);
407void nfs_zap_acl_cache(struct inode *inode);
408extern bool nfs_check_cache_invalid(struct inode *, unsigned long);
409extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
410extern int nfs_wait_atomic_killable(atomic_t *p, unsigned int mode);
411
412/* super.c */
413extern const struct super_operations nfs_sops;
254/* pagelist.c */
255extern int __init nfs_init_nfspagecache(void);
256extern void nfs_destroy_nfspagecache(void);
257extern int __init nfs_init_readpagecache(void);
258extern void nfs_destroy_readpagecache(void);
259extern int __init nfs_init_writepagecache(void);
260extern void nfs_destroy_writepagecache(void);
261

--- 143 unchanged lines hidden (view full) ---

405extern void nfs_evict_inode(struct inode *);
406void nfs_zap_acl_cache(struct inode *inode);
407extern bool nfs_check_cache_invalid(struct inode *, unsigned long);
408extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
409extern int nfs_wait_atomic_killable(atomic_t *p, unsigned int mode);
410
411/* super.c */
412extern const struct super_operations nfs_sops;
414extern struct file_system_type nfs_fs_type;
415extern struct file_system_type nfs_prepared_fs_type;
416#if IS_ENABLED(CONFIG_NFS_V4)
417extern struct file_system_type nfs4_referral_fs_type;
418#endif
419bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t);
413bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t);
420struct dentry *nfs_try_mount(int, const char *, struct nfs_mount_info *);
421struct dentry *nfs_fs_mount(struct file_system_type *, int, const char *, void *);
414int nfs_try_get_tree(struct fs_context *);
415int nfs_get_tree_common(struct fs_context *);
422void nfs_kill_super(struct super_block *);
423
424extern struct rpc_stat nfs_rpcstat;
425
426extern int __init register_nfs_fs(void);
427extern void __exit unregister_nfs_fs(void);
428extern bool nfs_sb_active(struct super_block *sb);
429extern void nfs_sb_deactive(struct super_block *sb);

--- 11 unchanged lines hidden (view full) ---

441 return test_bit(NFS_INO_ODIRECT, &nfsi->flags) == 0;
442}
443
444/* namespace.c */
445#define NFS_PATH_CANONICAL 1
446extern char *nfs_path(char **p, struct dentry *dentry,
447 char *buffer, ssize_t buflen, unsigned flags);
448extern struct vfsmount *nfs_d_automount(struct path *path);
416void nfs_kill_super(struct super_block *);
417
418extern struct rpc_stat nfs_rpcstat;
419
420extern int __init register_nfs_fs(void);
421extern void __exit unregister_nfs_fs(void);
422extern bool nfs_sb_active(struct super_block *sb);
423extern void nfs_sb_deactive(struct super_block *sb);

--- 11 unchanged lines hidden (view full) ---

435 return test_bit(NFS_INO_ODIRECT, &nfsi->flags) == 0;
436}
437
438/* namespace.c */
439#define NFS_PATH_CANONICAL 1
440extern char *nfs_path(char **p, struct dentry *dentry,
441 char *buffer, ssize_t buflen, unsigned flags);
442extern struct vfsmount *nfs_d_automount(struct path *path);
449struct vfsmount *nfs_submount(struct nfs_server *, struct dentry *,
450 struct nfs_fh *, struct nfs_fattr *);
451struct vfsmount *nfs_do_submount(struct dentry *, struct nfs_fh *,
452 struct nfs_fattr *, rpc_authflavor_t);
443int nfs_submount(struct fs_context *, struct nfs_server *);
444int nfs_do_submount(struct fs_context *);
453
454/* getroot.c */
455extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *,
456 const char *);
457#if IS_ENABLED(CONFIG_NFS_V4)
458extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *,
459 const char *);
460

--- 10 unchanged lines hidden (view full) ---

471
472/* super.c */
473void nfs_umount_begin(struct super_block *);
474int nfs_statfs(struct dentry *, struct kstatfs *);
475int nfs_show_options(struct seq_file *, struct dentry *);
476int nfs_show_devname(struct seq_file *, struct dentry *);
477int nfs_show_path(struct seq_file *, struct dentry *);
478int nfs_show_stats(struct seq_file *, struct dentry *);
445
446/* getroot.c */
447extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *,
448 const char *);
449#if IS_ENABLED(CONFIG_NFS_V4)
450extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *,
451 const char *);
452

--- 10 unchanged lines hidden (view full) ---

463
464/* super.c */
465void nfs_umount_begin(struct super_block *);
466int nfs_statfs(struct dentry *, struct kstatfs *);
467int nfs_show_options(struct seq_file *, struct dentry *);
468int nfs_show_devname(struct seq_file *, struct dentry *);
469int nfs_show_path(struct seq_file *, struct dentry *);
470int nfs_show_stats(struct seq_file *, struct dentry *);
479int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
471int nfs_reconfigure(struct fs_context *);
480
481/* write.c */
482extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
483 struct inode *inode, int ioflags, bool force_mds,
484 const struct nfs_pgio_completion_ops *compl_ops);
485extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio);
486extern void nfs_commit_free(struct nfs_commit_data *p);
487extern void nfs_write_prepare(struct rpc_task *task, void *calldata);

--- 321 unchanged lines hidden ---
472
473/* write.c */
474extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
475 struct inode *inode, int ioflags, bool force_mds,
476 const struct nfs_pgio_completion_ops *compl_ops);
477extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio);
478extern void nfs_commit_free(struct nfs_commit_data *p);
479extern void nfs_write_prepare(struct rpc_task *task, void *calldata);

--- 321 unchanged lines hidden ---