aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2011-06-04 06:13:06 -0400
committerIngo Molnar <mingo@elte.hu>2011-06-04 06:13:06 -0400
commit710054ba25c0d1f8f41c22ce13ba336503fb5318 (patch)
treef9b09b722bf511841539173d946f90a20fc2e59a /fs/nfs/pnfs.h
parent74c355fbdfedd3820046dba4f537876cea54c207 (diff)
parentb273fa9716aa1564bee88ceee62f9042981cdc81 (diff)
Merge branch 'perf/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Diffstat (limited to 'fs/nfs/pnfs.h')
-rw-r--r--fs/nfs/pnfs.h117
1 files changed, 102 insertions, 15 deletions
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 0c015bad9e7a..48d0a8e4d062 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -30,6 +30,7 @@
30#ifndef FS_NFS_PNFS_H 30#ifndef FS_NFS_PNFS_H
31#define FS_NFS_PNFS_H 31#define FS_NFS_PNFS_H
32 32
33#include <linux/nfs_fs.h>
33#include <linux/nfs_page.h> 34#include <linux/nfs_page.h>
34 35
35enum { 36enum {
@@ -64,17 +65,29 @@ enum {
64 NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */ 65 NFS_LAYOUT_DESTROYED, /* no new use of layout allowed */
65}; 66};
66 67
68enum layoutdriver_policy_flags {
69 /* Should the pNFS client commit and return the layout upon a setattr */
70 PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
71};
72
73struct nfs4_deviceid_node;
74
67/* Per-layout driver specific registration structure */ 75/* Per-layout driver specific registration structure */
68struct pnfs_layoutdriver_type { 76struct pnfs_layoutdriver_type {
69 struct list_head pnfs_tblid; 77 struct list_head pnfs_tblid;
70 const u32 id; 78 const u32 id;
71 const char *name; 79 const char *name;
72 struct module *owner; 80 struct module *owner;
81 unsigned flags;
82
83 struct pnfs_layout_hdr * (*alloc_layout_hdr) (struct inode *inode, gfp_t gfp_flags);
84 void (*free_layout_hdr) (struct pnfs_layout_hdr *);
85
73 struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags); 86 struct pnfs_layout_segment * (*alloc_lseg) (struct pnfs_layout_hdr *layoutid, struct nfs4_layoutget_res *lgr, gfp_t gfp_flags);
74 void (*free_lseg) (struct pnfs_layout_segment *lseg); 87 void (*free_lseg) (struct pnfs_layout_segment *lseg);
75 88
76 /* test for nfs page cache coalescing */ 89 /* test for nfs page cache coalescing */
77 int (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *); 90 bool (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
78 91
79 /* Returns true if layoutdriver wants to divert this request to 92 /* Returns true if layoutdriver wants to divert this request to
80 * driver's commit routine. 93 * driver's commit routine.
@@ -89,6 +102,16 @@ struct pnfs_layoutdriver_type {
89 */ 102 */
90 enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data); 103 enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data);
91 enum pnfs_try_status (*write_pagelist) (struct nfs_write_data *nfs_data, int how); 104 enum pnfs_try_status (*write_pagelist) (struct nfs_write_data *nfs_data, int how);
105
106 void (*free_deviceid_node) (struct nfs4_deviceid_node *);
107
108 void (*encode_layoutreturn) (struct pnfs_layout_hdr *layoutid,
109 struct xdr_stream *xdr,
110 const struct nfs4_layoutreturn_args *args);
111
112 void (*encode_layoutcommit) (struct pnfs_layout_hdr *layoutid,
113 struct xdr_stream *xdr,
114 const struct nfs4_layoutcommit_args *args);
92}; 115};
93 116
94struct pnfs_layout_hdr { 117struct pnfs_layout_hdr {
@@ -120,21 +143,22 @@ extern void pnfs_unregister_layoutdriver(struct pnfs_layoutdriver_type *);
120extern int nfs4_proc_getdeviceinfo(struct nfs_server *server, 143extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,
121 struct pnfs_device *dev); 144 struct pnfs_device *dev);
122extern int nfs4_proc_layoutget(struct nfs4_layoutget *lgp); 145extern int nfs4_proc_layoutget(struct nfs4_layoutget *lgp);
146extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp);
123 147
124/* pnfs.c */ 148/* pnfs.c */
125void get_layout_hdr(struct pnfs_layout_hdr *lo); 149void get_layout_hdr(struct pnfs_layout_hdr *lo);
126void put_lseg(struct pnfs_layout_segment *lseg); 150void put_lseg(struct pnfs_layout_segment *lseg);
127struct pnfs_layout_segment * 151struct pnfs_layout_segment *
128pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, 152pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
129 enum pnfs_iomode access_type, gfp_t gfp_flags); 153 loff_t pos, u64 count, enum pnfs_iomode access_type,
154 gfp_t gfp_flags);
130void set_pnfs_layoutdriver(struct nfs_server *, u32 id); 155void set_pnfs_layoutdriver(struct nfs_server *, u32 id);
131void unset_pnfs_layoutdriver(struct nfs_server *); 156void unset_pnfs_layoutdriver(struct nfs_server *);
132enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *, 157enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
133 const struct rpc_call_ops *, int); 158 const struct rpc_call_ops *, int);
134enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *, 159enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *,
135 const struct rpc_call_ops *); 160 const struct rpc_call_ops *);
136void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *); 161bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req);
137void pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *);
138int pnfs_layout_process(struct nfs4_layoutget *lgp); 162int pnfs_layout_process(struct nfs4_layoutget *lgp);
139void pnfs_free_lseg_list(struct list_head *tmp_list); 163void pnfs_free_lseg_list(struct list_head *tmp_list);
140void pnfs_destroy_layout(struct nfs_inode *); 164void pnfs_destroy_layout(struct nfs_inode *);
@@ -148,13 +172,37 @@ int pnfs_choose_layoutget_stateid(nfs4_stateid *dst,
148 struct nfs4_state *open_state); 172 struct nfs4_state *open_state);
149int mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo, 173int mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,
150 struct list_head *tmp_list, 174 struct list_head *tmp_list,
151 u32 iomode); 175 struct pnfs_layout_range *recall_range);
152bool pnfs_roc(struct inode *ino); 176bool pnfs_roc(struct inode *ino);
153void pnfs_roc_release(struct inode *ino); 177void pnfs_roc_release(struct inode *ino);
154void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); 178void pnfs_roc_set_barrier(struct inode *ino, u32 barrier);
155bool pnfs_roc_drain(struct inode *ino, u32 *barrier); 179bool pnfs_roc_drain(struct inode *ino, u32 *barrier);
156void pnfs_set_layoutcommit(struct nfs_write_data *wdata); 180void pnfs_set_layoutcommit(struct nfs_write_data *wdata);
157int pnfs_layoutcommit_inode(struct inode *inode, bool sync); 181int pnfs_layoutcommit_inode(struct inode *inode, bool sync);
182int _pnfs_return_layout(struct inode *);
183int pnfs_ld_write_done(struct nfs_write_data *);
184int pnfs_ld_read_done(struct nfs_read_data *);
185
186/* pnfs_dev.c */
187struct nfs4_deviceid_node {
188 struct hlist_node node;
189 const struct pnfs_layoutdriver_type *ld;
190 const struct nfs_client *nfs_client;
191 struct nfs4_deviceid deviceid;
192 atomic_t ref;
193};
194
195void nfs4_print_deviceid(const struct nfs4_deviceid *dev_id);
196struct nfs4_deviceid_node *nfs4_find_get_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *);
197struct nfs4_deviceid_node *nfs4_unhash_put_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *);
198void nfs4_delete_deviceid(const struct pnfs_layoutdriver_type *, const struct nfs_client *, const struct nfs4_deviceid *);
199void nfs4_init_deviceid_node(struct nfs4_deviceid_node *,
200 const struct pnfs_layoutdriver_type *,
201 const struct nfs_client *,
202 const struct nfs4_deviceid *);
203struct nfs4_deviceid_node *nfs4_insert_deviceid_node(struct nfs4_deviceid_node *);
204bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *);
205void nfs4_deviceid_purge_client(const struct nfs_client *);
158 206
159static inline int lo_fail_bit(u32 iomode) 207static inline int lo_fail_bit(u32 iomode)
160{ 208{
@@ -223,6 +271,36 @@ static inline void pnfs_clear_request_commit(struct nfs_page *req)
223 put_lseg(req->wb_commit_lseg); 271 put_lseg(req->wb_commit_lseg);
224} 272}
225 273
274/* Should the pNFS client commit and return the layout upon a setattr */
275static inline bool
276pnfs_ld_layoutret_on_setattr(struct inode *inode)
277{
278 if (!pnfs_enabled_sb(NFS_SERVER(inode)))
279 return false;
280 return NFS_SERVER(inode)->pnfs_curr_ld->flags &
281 PNFS_LAYOUTRET_ON_SETATTR;
282}
283
284static inline int pnfs_return_layout(struct inode *ino)
285{
286 struct nfs_inode *nfsi = NFS_I(ino);
287 struct nfs_server *nfss = NFS_SERVER(ino);
288
289 if (pnfs_enabled_sb(nfss) && nfsi->layout)
290 return _pnfs_return_layout(ino);
291
292 return 0;
293}
294
295static inline void pnfs_pageio_init(struct nfs_pageio_descriptor *pgio,
296 struct inode *inode)
297{
298 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
299
300 if (ld)
301 pgio->pg_test = ld->pg_test;
302}
303
226#else /* CONFIG_NFS_V4_1 */ 304#else /* CONFIG_NFS_V4_1 */
227 305
228static inline void pnfs_destroy_all_layouts(struct nfs_client *clp) 306static inline void pnfs_destroy_all_layouts(struct nfs_client *clp)
@@ -245,7 +323,8 @@ static inline void put_lseg(struct pnfs_layout_segment *lseg)
245 323
246static inline struct pnfs_layout_segment * 324static inline struct pnfs_layout_segment *
247pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, 325pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx,
248 enum pnfs_iomode access_type, gfp_t gfp_flags) 326 loff_t pos, u64 count, enum pnfs_iomode access_type,
327 gfp_t gfp_flags)
249{ 328{
250 return NULL; 329 return NULL;
251} 330}
@@ -264,6 +343,17 @@ pnfs_try_to_write_data(struct nfs_write_data *data,
264 return PNFS_NOT_ATTEMPTED; 343 return PNFS_NOT_ATTEMPTED;
265} 344}
266 345
346static inline int pnfs_return_layout(struct inode *ino)
347{
348 return 0;
349}
350
351static inline bool
352pnfs_ld_layoutret_on_setattr(struct inode *inode)
353{
354 return false;
355}
356
267static inline bool 357static inline bool
268pnfs_roc(struct inode *ino) 358pnfs_roc(struct inode *ino)
269{ 359{
@@ -294,16 +384,9 @@ static inline void unset_pnfs_layoutdriver(struct nfs_server *s)
294{ 384{
295} 385}
296 386
297static inline void 387static inline void pnfs_pageio_init(struct nfs_pageio_descriptor *pgio,
298pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *ino) 388 struct inode *inode)
299{
300 pgio->pg_test = NULL;
301}
302
303static inline void
304pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *ino)
305{ 389{
306 pgio->pg_test = NULL;
307} 390}
308 391
309static inline void 392static inline void
@@ -331,6 +414,10 @@ static inline int pnfs_layoutcommit_inode(struct inode *inode, bool sync)
331{ 414{
332 return 0; 415 return 0;
333} 416}
417
418static inline void nfs4_deviceid_purge_client(struct nfs_client *ncl)
419{
420}
334#endif /* CONFIG_NFS_V4_1 */ 421#endif /* CONFIG_NFS_V4_1 */
335 422
336#endif /* FS_NFS_PNFS_H */ 423#endif /* FS_NFS_PNFS_H */