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