of: MSI: Simplify irqdomain lookup
[linux/fpc-iii.git] / fs / nfs / flexfilelayout / flexfilelayout.h
blob2bb08bc6aaf0cc36e20c98dc37061fc9b07fa642
1 /*
2 * NFSv4 flexfile layout driver data structures.
4 * Copyright (c) 2014, Primary Data, Inc. All rights reserved.
6 * Tao Peng <bergwolf@primarydata.com>
7 */
9 #ifndef FS_NFS_NFS4FLEXFILELAYOUT_H
10 #define FS_NFS_NFS4FLEXFILELAYOUT_H
12 #define FF_FLAGS_NO_LAYOUTCOMMIT 1
13 #define FF_FLAGS_NO_IO_THRU_MDS 2
15 #include "../pnfs.h"
17 /* XXX: Let's filter out insanely large mirror count for now to avoid oom
18 * due to network error etc. */
19 #define NFS4_FLEXFILE_LAYOUT_MAX_MIRROR_CNT 4096
21 /* LAYOUTSTATS report interval in ms */
22 #define FF_LAYOUTSTATS_REPORT_INTERVAL (60000L)
24 struct nfs4_ff_ds_version {
25 u32 version;
26 u32 minor_version;
27 u32 rsize;
28 u32 wsize;
29 bool tightly_coupled;
32 /* chained in global deviceid hlist */
33 struct nfs4_ff_layout_ds {
34 struct nfs4_deviceid_node id_node;
35 u32 ds_versions_cnt;
36 struct nfs4_ff_ds_version *ds_versions;
37 struct nfs4_pnfs_ds *ds;
40 struct nfs4_ff_layout_ds_err {
41 struct list_head list; /* linked in mirror error_list */
42 u64 offset;
43 u64 length;
44 int status;
45 enum nfs_opnum4 opnum;
46 nfs4_stateid stateid;
47 struct nfs4_deviceid deviceid;
50 struct nfs4_ff_io_stat {
51 __u64 ops_requested;
52 __u64 bytes_requested;
53 __u64 ops_completed;
54 __u64 bytes_completed;
55 __u64 bytes_not_delivered;
56 ktime_t total_busy_time;
57 ktime_t aggregate_completion_time;
60 struct nfs4_ff_busy_timer {
61 ktime_t start_time;
62 atomic_t n_ops;
65 struct nfs4_ff_layoutstat {
66 struct nfs4_ff_io_stat io_stat;
67 struct nfs4_ff_busy_timer busy_timer;
70 struct nfs4_ff_layout_mirror {
71 struct pnfs_layout_hdr *layout;
72 struct list_head mirrors;
73 u32 ds_count;
74 u32 efficiency;
75 struct nfs4_ff_layout_ds *mirror_ds;
76 u32 fh_versions_cnt;
77 struct nfs_fh *fh_versions;
78 nfs4_stateid stateid;
79 u32 uid;
80 u32 gid;
81 struct rpc_cred *cred;
82 atomic_t ref;
83 spinlock_t lock;
84 struct nfs4_ff_layoutstat read_stat;
85 struct nfs4_ff_layoutstat write_stat;
86 ktime_t start_time;
87 ktime_t last_report_time;
90 struct nfs4_ff_layout_segment {
91 struct pnfs_layout_segment generic_hdr;
92 u64 stripe_unit;
93 u32 flags;
94 u32 mirror_array_cnt;
95 struct nfs4_ff_layout_mirror **mirror_array;
98 struct nfs4_flexfile_layout {
99 struct pnfs_layout_hdr generic_hdr;
100 struct pnfs_ds_commit_info commit_info;
101 struct list_head mirrors;
102 struct list_head error_list; /* nfs4_ff_layout_ds_err */
105 static inline struct nfs4_flexfile_layout *
106 FF_LAYOUT_FROM_HDR(struct pnfs_layout_hdr *lo)
108 return container_of(lo, struct nfs4_flexfile_layout, generic_hdr);
111 static inline struct nfs4_ff_layout_segment *
112 FF_LAYOUT_LSEG(struct pnfs_layout_segment *lseg)
114 return container_of(lseg,
115 struct nfs4_ff_layout_segment,
116 generic_hdr);
119 static inline struct nfs4_deviceid_node *
120 FF_LAYOUT_DEVID_NODE(struct pnfs_layout_segment *lseg, u32 idx)
122 if (idx >= FF_LAYOUT_LSEG(lseg)->mirror_array_cnt ||
123 FF_LAYOUT_LSEG(lseg)->mirror_array[idx] == NULL ||
124 FF_LAYOUT_LSEG(lseg)->mirror_array[idx]->mirror_ds == NULL)
125 return NULL;
126 return &FF_LAYOUT_LSEG(lseg)->mirror_array[idx]->mirror_ds->id_node;
129 static inline struct nfs4_ff_layout_ds *
130 FF_LAYOUT_MIRROR_DS(struct nfs4_deviceid_node *node)
132 return container_of(node, struct nfs4_ff_layout_ds, id_node);
135 static inline struct nfs4_ff_layout_mirror *
136 FF_LAYOUT_COMP(struct pnfs_layout_segment *lseg, u32 idx)
138 if (idx >= FF_LAYOUT_LSEG(lseg)->mirror_array_cnt)
139 return NULL;
140 return FF_LAYOUT_LSEG(lseg)->mirror_array[idx];
143 static inline u32
144 FF_LAYOUT_MIRROR_COUNT(struct pnfs_layout_segment *lseg)
146 return FF_LAYOUT_LSEG(lseg)->mirror_array_cnt;
149 static inline bool
150 ff_layout_no_fallback_to_mds(struct pnfs_layout_segment *lseg)
152 return FF_LAYOUT_LSEG(lseg)->flags & FF_FLAGS_NO_IO_THRU_MDS;
155 static inline bool
156 ff_layout_test_devid_unavailable(struct nfs4_deviceid_node *node)
158 return nfs4_test_deviceid_unavailable(node);
161 static inline int
162 nfs4_ff_layout_ds_version(struct pnfs_layout_segment *lseg, u32 ds_idx)
164 return FF_LAYOUT_COMP(lseg, ds_idx)->mirror_ds->ds_versions[0].version;
167 struct nfs4_ff_layout_ds *
168 nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
169 gfp_t gfp_flags);
170 void nfs4_ff_layout_put_deviceid(struct nfs4_ff_layout_ds *mirror_ds);
171 void nfs4_ff_layout_free_deviceid(struct nfs4_ff_layout_ds *mirror_ds);
172 int ff_layout_track_ds_error(struct nfs4_flexfile_layout *flo,
173 struct nfs4_ff_layout_mirror *mirror, u64 offset,
174 u64 length, int status, enum nfs_opnum4 opnum,
175 gfp_t gfp_flags);
176 int ff_layout_encode_ds_ioerr(struct nfs4_flexfile_layout *flo,
177 struct xdr_stream *xdr, int *count,
178 const struct pnfs_layout_range *range);
179 struct nfs_fh *
180 nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx);
182 struct nfs4_pnfs_ds *
183 nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
184 bool fail_return);
186 struct rpc_clnt *
187 nfs4_ff_find_or_create_ds_client(struct pnfs_layout_segment *lseg,
188 u32 ds_idx,
189 struct nfs_client *ds_clp,
190 struct inode *inode);
191 struct rpc_cred *ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg,
192 u32 ds_idx, struct rpc_cred *mdscred);
193 bool ff_layout_has_available_ds(struct pnfs_layout_segment *lseg);
194 #endif /* FS_NFS_NFS4FLEXFILELAYOUT_H */