aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pagelist.c
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@primarydata.com>2014-06-09 11:48:37 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-06-24 18:47:01 -0400
commit4714fb51fd03a14d8c73001438283e7f7b752f1e (patch)
treecb138e6479fb7a4fc4109f440b4138e2e00369ee /fs/nfs/pagelist.c
parentc65e6254ca4db1584c5bf5f228ee26556477a9fd (diff)
nfs: remove pgio_header refcount, related cleanup
The refcounting on nfs_pgio_header was related to there being (possibly) more than one nfs_pgio_data. Now that nfs_pgio_data has been merged into nfs_pgio_header, there is no reason to do this ref counting. Just call the completion callback on nfs_pgio_release/nfs_pgio_error. Signed-off-by: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/pagelist.c')
-rw-r--r--fs/nfs/pagelist.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 7dd0d5f101a4..580fc0c982e6 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -459,7 +459,6 @@ struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *ops)
459 if (hdr) { 459 if (hdr) {
460 INIT_LIST_HEAD(&hdr->pages); 460 INIT_LIST_HEAD(&hdr->pages);
461 spin_lock_init(&hdr->lock); 461 spin_lock_init(&hdr->lock);
462 atomic_set(&hdr->refcnt, 0);
463 hdr->rw_ops = ops; 462 hdr->rw_ops = ops;
464 } 463 }
465 return hdr; 464 return hdr;
@@ -477,31 +476,18 @@ void nfs_pgio_header_free(struct nfs_pgio_header *hdr)
477EXPORT_SYMBOL_GPL(nfs_pgio_header_free); 476EXPORT_SYMBOL_GPL(nfs_pgio_header_free);
478 477
479/** 478/**
480 * nfs_pgio_data_alloc - Allocate pageio data 479 * nfs_pgio_data_destroy - make @hdr suitable for reuse
481 * @hdr: The header making a request 480 *
482 * @pagecount: Number of pages to create 481 * Frees memory and releases refs from nfs_generic_pgio, so that it may
483 */ 482 * be called again.
484static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, 483 *
485 unsigned int pagecount) 484 * @hdr: A header that has had nfs_generic_pgio called
486{
487 if (nfs_pgarray_set(&hdr->page_array, pagecount)) {
488 atomic_inc(&hdr->refcnt);
489 return true;
490 }
491 return false;
492}
493
494/**
495 * nfs_pgio_data_destroy - Properly release pageio data
496 * @hdr: The header with data to destroy
497 */ 485 */
498void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr) 486void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr)
499{ 487{
500 put_nfs_open_context(hdr->args.context); 488 put_nfs_open_context(hdr->args.context);
501 if (hdr->page_array.pagevec != hdr->page_array.page_array) 489 if (hdr->page_array.pagevec != hdr->page_array.page_array)
502 kfree(hdr->page_array.pagevec); 490 kfree(hdr->page_array.pagevec);
503 if (atomic_dec_and_test(&hdr->refcnt))
504 hdr->completion_ops->completion(hdr);
505} 491}
506EXPORT_SYMBOL_GPL(nfs_pgio_data_destroy); 492EXPORT_SYMBOL_GPL(nfs_pgio_data_destroy);
507 493
@@ -620,6 +606,7 @@ static int nfs_pgio_error(struct nfs_pageio_descriptor *desc,
620{ 606{
621 set_bit(NFS_IOHDR_REDO, &hdr->flags); 607 set_bit(NFS_IOHDR_REDO, &hdr->flags);
622 nfs_pgio_data_destroy(hdr); 608 nfs_pgio_data_destroy(hdr);
609 hdr->completion_ops->completion(hdr);
623 desc->pg_completion_ops->error_cleanup(&desc->pg_list); 610 desc->pg_completion_ops->error_cleanup(&desc->pg_list);
624 return -ENOMEM; 611 return -ENOMEM;
625} 612}
@@ -634,6 +621,7 @@ static void nfs_pgio_release(void *calldata)
634 if (hdr->rw_ops->rw_release) 621 if (hdr->rw_ops->rw_release)
635 hdr->rw_ops->rw_release(hdr); 622 hdr->rw_ops->rw_release(hdr);
636 nfs_pgio_data_destroy(hdr); 623 nfs_pgio_data_destroy(hdr);
624 hdr->completion_ops->completion(hdr);
637} 625}
638 626
639/** 627/**
@@ -707,9 +695,10 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,
707 struct page **pages; 695 struct page **pages;
708 struct list_head *head = &desc->pg_list; 696 struct list_head *head = &desc->pg_list;
709 struct nfs_commit_info cinfo; 697 struct nfs_commit_info cinfo;
698 unsigned int pagecount;
710 699
711 if (!nfs_pgio_data_init(hdr, nfs_page_array_len(desc->pg_base, 700 pagecount = nfs_page_array_len(desc->pg_base, desc->pg_count);
712 desc->pg_count))) 701 if (!nfs_pgarray_set(&hdr->page_array, pagecount))
713 return nfs_pgio_error(desc, hdr); 702 return nfs_pgio_error(desc, hdr);
714 703
715 nfs_init_cinfo(&cinfo, desc->pg_inode, desc->pg_dreq); 704 nfs_init_cinfo(&cinfo, desc->pg_inode, desc->pg_dreq);
@@ -743,14 +732,11 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc)
743 return -ENOMEM; 732 return -ENOMEM;
744 } 733 }
745 nfs_pgheader_init(desc, hdr, nfs_pgio_header_free); 734 nfs_pgheader_init(desc, hdr, nfs_pgio_header_free);
746 atomic_inc(&hdr->refcnt);
747 ret = nfs_generic_pgio(desc, hdr); 735 ret = nfs_generic_pgio(desc, hdr);
748 if (ret == 0) 736 if (ret == 0)
749 ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode), 737 ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode),
750 hdr, desc->pg_rpc_callops, 738 hdr, desc->pg_rpc_callops,
751 desc->pg_ioflags, 0); 739 desc->pg_ioflags, 0);
752 if (atomic_dec_and_test(&hdr->refcnt))
753 hdr->completion_ops->completion(hdr);
754 return ret; 740 return ret;
755} 741}
756 742