aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pnfs.h
diff options
context:
space:
mode:
authorFred Isaman <iisaman@netapp.com>2012-04-20 14:47:53 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-04-27 14:10:38 -0400
commitea2cf2282b4278461266013e9c002ee1c66700ff (patch)
tree244de055925710de27206ee0d5d09caa6353bd62 /fs/nfs/pnfs.h
parent84c53ab5c093058c756dcef1879d38be6de90a3c (diff)
NFS: create struct nfs_commit_info
It is COMMIT that is handled the most differently between the paged and direct paths. Create a structure that encapsulates everything either path needs to know about the commit state. We could use void to hide some of the layout driver stuff, but Trond suggests pulling it out to ensure type checking, given the huge changes being made, and the fact that it doesn't interfere with other drivers. Signed-off-by: Fred Isaman <iisaman@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/pnfs.h')
-rw-r--r--fs/nfs/pnfs.h72
1 files changed, 48 insertions, 24 deletions
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 734e4eff7fb0..4cd8760c2f89 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -94,11 +94,18 @@ struct pnfs_layoutdriver_type {
94 const struct nfs_pageio_ops *pg_read_ops; 94 const struct nfs_pageio_ops *pg_read_ops;
95 const struct nfs_pageio_ops *pg_write_ops; 95 const struct nfs_pageio_ops *pg_write_ops;
96 96
97 struct pnfs_ds_commit_info *(*get_ds_info) (struct inode *inode);
97 void (*mark_request_commit) (struct nfs_page *req, 98 void (*mark_request_commit) (struct nfs_page *req,
98 struct pnfs_layout_segment *lseg); 99 struct pnfs_layout_segment *lseg,
99 void (*clear_request_commit) (struct nfs_page *req); 100 struct nfs_commit_info *cinfo);
100 int (*scan_commit_lists) (struct inode *inode, int max, spinlock_t *lock); 101 void (*clear_request_commit) (struct nfs_page *req,
101 int (*commit_pagelist)(struct inode *inode, struct list_head *mds_pages, int how); 102 struct nfs_commit_info *cinfo);
103 int (*scan_commit_lists) (struct nfs_commit_info *cinfo,
104 int max);
105 int (*commit_pagelist)(struct inode *inode,
106 struct list_head *mds_pages,
107 int how,
108 struct nfs_commit_info *cinfo);
102 109
103 /* 110 /*
104 * Return PNFS_ATTEMPTED to indicate the layout code has attempted 111 * Return PNFS_ATTEMPTED to indicate the layout code has attempted
@@ -263,49 +270,57 @@ static inline int pnfs_enabled_sb(struct nfs_server *nfss)
263} 270}
264 271
265static inline int 272static inline int
266pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how) 273pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how,
274 struct nfs_commit_info *cinfo)
267{ 275{
268 if (!test_and_clear_bit(NFS_INO_PNFS_COMMIT, &NFS_I(inode)->flags)) 276 if (cinfo->ds == NULL || cinfo->ds->ncommitting == 0)
269 return PNFS_NOT_ATTEMPTED; 277 return PNFS_NOT_ATTEMPTED;
270 return NFS_SERVER(inode)->pnfs_curr_ld->commit_pagelist(inode, mds_pages, how); 278 return NFS_SERVER(inode)->pnfs_curr_ld->commit_pagelist(inode, mds_pages, how, cinfo);
279}
280
281static inline struct pnfs_ds_commit_info *
282pnfs_get_ds_info(struct inode *inode)
283{
284 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
285
286 if (ld == NULL || ld->get_ds_info == NULL)
287 return NULL;
288 return ld->get_ds_info(inode);
271} 289}
272 290
273static inline bool 291static inline bool
274pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg) 292pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg,
293 struct nfs_commit_info *cinfo)
275{ 294{
276 struct inode *inode = req->wb_context->dentry->d_inode; 295 struct inode *inode = req->wb_context->dentry->d_inode;
277 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; 296 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
278 297
279 if (lseg == NULL || ld->mark_request_commit == NULL) 298 if (lseg == NULL || ld->mark_request_commit == NULL)
280 return false; 299 return false;
281 ld->mark_request_commit(req, lseg); 300 ld->mark_request_commit(req, lseg, cinfo);
282 return true; 301 return true;
283} 302}
284 303
285static inline bool 304static inline bool
286pnfs_clear_request_commit(struct nfs_page *req) 305pnfs_clear_request_commit(struct nfs_page *req, struct nfs_commit_info *cinfo)
287{ 306{
288 struct inode *inode = req->wb_context->dentry->d_inode; 307 struct inode *inode = req->wb_context->dentry->d_inode;
289 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; 308 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
290 309
291 if (ld == NULL || ld->clear_request_commit == NULL) 310 if (ld == NULL || ld->clear_request_commit == NULL)
292 return false; 311 return false;
293 ld->clear_request_commit(req); 312 ld->clear_request_commit(req, cinfo);
294 return true; 313 return true;
295} 314}
296 315
297static inline int 316static inline int
298pnfs_scan_commit_lists(struct inode *inode, int max, spinlock_t *lock) 317pnfs_scan_commit_lists(struct inode *inode, struct nfs_commit_info *cinfo,
318 int max)
299{ 319{
300 struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; 320 if (cinfo->ds == NULL || cinfo->ds->nwritten == 0)
301 int ret;
302
303 if (ld == NULL || ld->scan_commit_lists == NULL)
304 return 0; 321 return 0;
305 ret = ld->scan_commit_lists(inode, max, lock); 322 else
306 if (ret != 0) 323 return NFS_SERVER(inode)->pnfs_curr_ld->scan_commit_lists(cinfo, max);
307 set_bit(NFS_INO_PNFS_COMMIT, &NFS_I(inode)->flags);
308 return ret;
309} 324}
310 325
311/* Should the pNFS client commit and return the layout upon a setattr */ 326/* Should the pNFS client commit and return the layout upon a setattr */
@@ -409,25 +424,34 @@ static inline bool pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, st
409} 424}
410 425
411static inline int 426static inline int
412pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how) 427pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how,
428 struct nfs_commit_info *cinfo)
413{ 429{
414 return PNFS_NOT_ATTEMPTED; 430 return PNFS_NOT_ATTEMPTED;
415} 431}
416 432
433static inline struct pnfs_ds_commit_info *
434pnfs_get_ds_info(struct inode *inode)
435{
436 return NULL;
437}
438
417static inline bool 439static inline bool
418pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg) 440pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg,
441 struct nfs_commit_info *cinfo)
419{ 442{
420 return false; 443 return false;
421} 444}
422 445
423static inline bool 446static inline bool
424pnfs_clear_request_commit(struct nfs_page *req) 447pnfs_clear_request_commit(struct nfs_page *req, struct nfs_commit_info *cinfo)
425{ 448{
426 return false; 449 return false;
427} 450}
428 451
429static inline int 452static inline int
430pnfs_scan_commit_lists(struct inode *inode, int max, spinlock_t *lock) 453pnfs_scan_commit_lists(struct inode *inode, struct nfs_commit_info *cinfo,
454 int max)
431{ 455{
432 return 0; 456 return 0;
433} 457}