Commit 4714fb51 authored by Weston Andros Adamson's avatar Weston Andros Adamson Committed by Trond Myklebust

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: default avatarWeston Andros Adamson <dros@primarydata.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent c65e6254
...@@ -459,7 +459,6 @@ struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *ops) ...@@ -459,7 +459,6 @@ struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *ops)
if (hdr) { if (hdr) {
INIT_LIST_HEAD(&hdr->pages); INIT_LIST_HEAD(&hdr->pages);
spin_lock_init(&hdr->lock); spin_lock_init(&hdr->lock);
atomic_set(&hdr->refcnt, 0);
hdr->rw_ops = ops; hdr->rw_ops = ops;
} }
return hdr; return hdr;
...@@ -477,31 +476,18 @@ void nfs_pgio_header_free(struct nfs_pgio_header *hdr) ...@@ -477,31 +476,18 @@ void nfs_pgio_header_free(struct nfs_pgio_header *hdr)
EXPORT_SYMBOL_GPL(nfs_pgio_header_free); EXPORT_SYMBOL_GPL(nfs_pgio_header_free);
/** /**
* nfs_pgio_data_alloc - Allocate pageio data * nfs_pgio_data_destroy - make @hdr suitable for reuse
* @hdr: The header making a request *
* @pagecount: Number of pages to create * Frees memory and releases refs from nfs_generic_pgio, so that it may
*/ * be called again.
static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, *
unsigned int pagecount) * @hdr: A header that has had nfs_generic_pgio called
{
if (nfs_pgarray_set(&hdr->page_array, pagecount)) {
atomic_inc(&hdr->refcnt);
return true;
}
return false;
}
/**
* nfs_pgio_data_destroy - Properly release pageio data
* @hdr: The header with data to destroy
*/ */
void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr) void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr)
{ {
put_nfs_open_context(hdr->args.context); put_nfs_open_context(hdr->args.context);
if (hdr->page_array.pagevec != hdr->page_array.page_array) if (hdr->page_array.pagevec != hdr->page_array.page_array)
kfree(hdr->page_array.pagevec); kfree(hdr->page_array.pagevec);
if (atomic_dec_and_test(&hdr->refcnt))
hdr->completion_ops->completion(hdr);
} }
EXPORT_SYMBOL_GPL(nfs_pgio_data_destroy); EXPORT_SYMBOL_GPL(nfs_pgio_data_destroy);
...@@ -620,6 +606,7 @@ static int nfs_pgio_error(struct nfs_pageio_descriptor *desc, ...@@ -620,6 +606,7 @@ static int nfs_pgio_error(struct nfs_pageio_descriptor *desc,
{ {
set_bit(NFS_IOHDR_REDO, &hdr->flags); set_bit(NFS_IOHDR_REDO, &hdr->flags);
nfs_pgio_data_destroy(hdr); nfs_pgio_data_destroy(hdr);
hdr->completion_ops->completion(hdr);
desc->pg_completion_ops->error_cleanup(&desc->pg_list); desc->pg_completion_ops->error_cleanup(&desc->pg_list);
return -ENOMEM; return -ENOMEM;
} }
...@@ -634,6 +621,7 @@ static void nfs_pgio_release(void *calldata) ...@@ -634,6 +621,7 @@ static void nfs_pgio_release(void *calldata)
if (hdr->rw_ops->rw_release) if (hdr->rw_ops->rw_release)
hdr->rw_ops->rw_release(hdr); hdr->rw_ops->rw_release(hdr);
nfs_pgio_data_destroy(hdr); nfs_pgio_data_destroy(hdr);
hdr->completion_ops->completion(hdr);
} }
/** /**
...@@ -707,9 +695,10 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, ...@@ -707,9 +695,10 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc,
struct page **pages; struct page **pages;
struct list_head *head = &desc->pg_list; struct list_head *head = &desc->pg_list;
struct nfs_commit_info cinfo; struct nfs_commit_info cinfo;
unsigned int pagecount;
if (!nfs_pgio_data_init(hdr, nfs_page_array_len(desc->pg_base, pagecount = nfs_page_array_len(desc->pg_base, desc->pg_count);
desc->pg_count))) if (!nfs_pgarray_set(&hdr->page_array, pagecount))
return nfs_pgio_error(desc, hdr); return nfs_pgio_error(desc, hdr);
nfs_init_cinfo(&cinfo, desc->pg_inode, desc->pg_dreq); 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,14 +732,11 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc)
return -ENOMEM; return -ENOMEM;
} }
nfs_pgheader_init(desc, hdr, nfs_pgio_header_free); nfs_pgheader_init(desc, hdr, nfs_pgio_header_free);
atomic_inc(&hdr->refcnt);
ret = nfs_generic_pgio(desc, hdr); ret = nfs_generic_pgio(desc, hdr);
if (ret == 0) if (ret == 0)
ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode), ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode),
hdr, desc->pg_rpc_callops, hdr, desc->pg_rpc_callops,
desc->pg_ioflags, 0); desc->pg_ioflags, 0);
if (atomic_dec_and_test(&hdr->refcnt))
hdr->completion_ops->completion(hdr);
return ret; return ret;
} }
......
...@@ -1602,15 +1602,12 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc) ...@@ -1602,15 +1602,12 @@ pnfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
} }
nfs_pgheader_init(desc, hdr, pnfs_writehdr_free); nfs_pgheader_init(desc, hdr, pnfs_writehdr_free);
hdr->lseg = pnfs_get_lseg(desc->pg_lseg); hdr->lseg = pnfs_get_lseg(desc->pg_lseg);
atomic_inc(&hdr->refcnt);
ret = nfs_generic_pgio(desc, hdr); ret = nfs_generic_pgio(desc, hdr);
if (ret != 0) { if (ret != 0) {
pnfs_put_lseg(desc->pg_lseg); pnfs_put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL; desc->pg_lseg = NULL;
} else } else
pnfs_do_write(desc, hdr, desc->pg_ioflags); pnfs_do_write(desc, hdr, desc->pg_ioflags);
if (atomic_dec_and_test(&hdr->refcnt))
hdr->completion_ops->completion(hdr);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(pnfs_generic_pg_writepages); EXPORT_SYMBOL_GPL(pnfs_generic_pg_writepages);
...@@ -1745,15 +1742,12 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc) ...@@ -1745,15 +1742,12 @@ pnfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
} }
nfs_pgheader_init(desc, hdr, pnfs_readhdr_free); nfs_pgheader_init(desc, hdr, pnfs_readhdr_free);
hdr->lseg = pnfs_get_lseg(desc->pg_lseg); hdr->lseg = pnfs_get_lseg(desc->pg_lseg);
atomic_inc(&hdr->refcnt);
ret = nfs_generic_pgio(desc, hdr); ret = nfs_generic_pgio(desc, hdr);
if (ret != 0) { if (ret != 0) {
pnfs_put_lseg(desc->pg_lseg); pnfs_put_lseg(desc->pg_lseg);
desc->pg_lseg = NULL; desc->pg_lseg = NULL;
} else } else
pnfs_do_read(desc, hdr); pnfs_do_read(desc, hdr);
if (atomic_dec_and_test(&hdr->refcnt))
hdr->completion_ops->completion(hdr);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(pnfs_generic_pg_readpages); EXPORT_SYMBOL_GPL(pnfs_generic_pg_readpages);
......
...@@ -1259,7 +1259,6 @@ struct nfs_pgio_header { ...@@ -1259,7 +1259,6 @@ struct nfs_pgio_header {
struct inode *inode; struct inode *inode;
struct rpc_cred *cred; struct rpc_cred *cred;
struct list_head pages; struct list_head pages;
atomic_t refcnt;
struct nfs_page *req; struct nfs_page *req;
struct nfs_writeverf verf; /* Used for writes */ struct nfs_writeverf verf; /* Used for writes */
struct pnfs_layout_segment *lseg; struct pnfs_layout_segment *lseg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment