xref: /OK3568_Linux_fs/kernel/fs/nfsd/pnfs.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _FS_NFSD_PNFS_H
3*4882a593Smuzhiyun #define _FS_NFSD_PNFS_H 1
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #ifdef CONFIG_NFSD_V4
6*4882a593Smuzhiyun #include <linux/exportfs.h>
7*4882a593Smuzhiyun #include <linux/nfsd/export.h>
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include "state.h"
10*4882a593Smuzhiyun #include "xdr4.h"
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun struct xdr_stream;
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun struct nfsd4_deviceid_map {
15*4882a593Smuzhiyun 	struct list_head	hash;
16*4882a593Smuzhiyun 	u64			idx;
17*4882a593Smuzhiyun 	int			fsid_type;
18*4882a593Smuzhiyun 	u32			fsid[];
19*4882a593Smuzhiyun };
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun struct nfsd4_layout_ops {
22*4882a593Smuzhiyun 	u32		notify_types;
23*4882a593Smuzhiyun 	bool		disable_recalls;
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun 	__be32 (*proc_getdeviceinfo)(struct super_block *sb,
26*4882a593Smuzhiyun 			struct svc_rqst *rqstp,
27*4882a593Smuzhiyun 			struct nfs4_client *clp,
28*4882a593Smuzhiyun 			struct nfsd4_getdeviceinfo *gdevp);
29*4882a593Smuzhiyun 	__be32 (*encode_getdeviceinfo)(struct xdr_stream *xdr,
30*4882a593Smuzhiyun 			struct nfsd4_getdeviceinfo *gdevp);
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun 	__be32 (*proc_layoutget)(struct inode *, const struct svc_fh *fhp,
33*4882a593Smuzhiyun 			struct nfsd4_layoutget *lgp);
34*4882a593Smuzhiyun 	__be32 (*encode_layoutget)(struct xdr_stream *,
35*4882a593Smuzhiyun 			struct nfsd4_layoutget *lgp);
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun 	__be32 (*proc_layoutcommit)(struct inode *inode,
38*4882a593Smuzhiyun 			struct nfsd4_layoutcommit *lcp);
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun 	void (*fence_client)(struct nfs4_layout_stateid *ls);
41*4882a593Smuzhiyun };
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun extern const struct nfsd4_layout_ops *nfsd4_layout_ops[];
44*4882a593Smuzhiyun #ifdef CONFIG_NFSD_BLOCKLAYOUT
45*4882a593Smuzhiyun extern const struct nfsd4_layout_ops bl_layout_ops;
46*4882a593Smuzhiyun #endif
47*4882a593Smuzhiyun #ifdef CONFIG_NFSD_SCSILAYOUT
48*4882a593Smuzhiyun extern const struct nfsd4_layout_ops scsi_layout_ops;
49*4882a593Smuzhiyun #endif
50*4882a593Smuzhiyun #ifdef CONFIG_NFSD_FLEXFILELAYOUT
51*4882a593Smuzhiyun extern const struct nfsd4_layout_ops ff_layout_ops;
52*4882a593Smuzhiyun #endif
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun __be32 nfsd4_preprocess_layout_stateid(struct svc_rqst *rqstp,
55*4882a593Smuzhiyun 		struct nfsd4_compound_state *cstate, stateid_t *stateid,
56*4882a593Smuzhiyun 		bool create, u32 layout_type, struct nfs4_layout_stateid **lsp);
57*4882a593Smuzhiyun __be32 nfsd4_insert_layout(struct nfsd4_layoutget *lgp,
58*4882a593Smuzhiyun 		struct nfs4_layout_stateid *ls);
59*4882a593Smuzhiyun __be32 nfsd4_return_file_layouts(struct svc_rqst *rqstp,
60*4882a593Smuzhiyun 		struct nfsd4_compound_state *cstate,
61*4882a593Smuzhiyun 		struct nfsd4_layoutreturn *lrp);
62*4882a593Smuzhiyun __be32 nfsd4_return_client_layouts(struct svc_rqst *rqstp,
63*4882a593Smuzhiyun 		struct nfsd4_compound_state *cstate,
64*4882a593Smuzhiyun 		struct nfsd4_layoutreturn *lrp);
65*4882a593Smuzhiyun int nfsd4_set_deviceid(struct nfsd4_deviceid *id, const struct svc_fh *fhp,
66*4882a593Smuzhiyun 		u32 device_generation);
67*4882a593Smuzhiyun struct nfsd4_deviceid_map *nfsd4_find_devid_map(int idx);
68*4882a593Smuzhiyun #endif /* CONFIG_NFSD_V4 */
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun #ifdef CONFIG_NFSD_PNFS
71*4882a593Smuzhiyun void nfsd4_setup_layout_type(struct svc_export *exp);
72*4882a593Smuzhiyun void nfsd4_return_all_client_layouts(struct nfs4_client *);
73*4882a593Smuzhiyun void nfsd4_return_all_file_layouts(struct nfs4_client *clp,
74*4882a593Smuzhiyun 		struct nfs4_file *fp);
75*4882a593Smuzhiyun int nfsd4_init_pnfs(void);
76*4882a593Smuzhiyun void nfsd4_exit_pnfs(void);
77*4882a593Smuzhiyun #else
78*4882a593Smuzhiyun struct nfs4_client;
79*4882a593Smuzhiyun struct nfs4_file;
80*4882a593Smuzhiyun 
nfsd4_setup_layout_type(struct svc_export * exp)81*4882a593Smuzhiyun static inline void nfsd4_setup_layout_type(struct svc_export *exp)
82*4882a593Smuzhiyun {
83*4882a593Smuzhiyun }
84*4882a593Smuzhiyun 
nfsd4_return_all_client_layouts(struct nfs4_client * clp)85*4882a593Smuzhiyun static inline void nfsd4_return_all_client_layouts(struct nfs4_client *clp)
86*4882a593Smuzhiyun {
87*4882a593Smuzhiyun }
nfsd4_return_all_file_layouts(struct nfs4_client * clp,struct nfs4_file * fp)88*4882a593Smuzhiyun static inline void nfsd4_return_all_file_layouts(struct nfs4_client *clp,
89*4882a593Smuzhiyun 		struct nfs4_file *fp)
90*4882a593Smuzhiyun {
91*4882a593Smuzhiyun }
nfsd4_exit_pnfs(void)92*4882a593Smuzhiyun static inline void nfsd4_exit_pnfs(void)
93*4882a593Smuzhiyun {
94*4882a593Smuzhiyun }
nfsd4_init_pnfs(void)95*4882a593Smuzhiyun static inline int nfsd4_init_pnfs(void)
96*4882a593Smuzhiyun {
97*4882a593Smuzhiyun 	return 0;
98*4882a593Smuzhiyun }
99*4882a593Smuzhiyun #endif /* CONFIG_NFSD_PNFS */
100*4882a593Smuzhiyun #endif /* _FS_NFSD_PNFS_H */
101