extern int __init nfs_init_directcache(void);
extern void nfs_destroy_directcache(void);
-extern bool nfs_pgarray_set(struct nfs_page_array *p, unsigned int pagecount);
extern void nfs_pgheader_init(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr,
void (*release)(struct nfs_pgio_header *hdr));
void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos);
int nfs_iocounter_wait(struct nfs_io_counter *c);
+struct nfs_pgio_data *nfs_pgio_data_alloc(struct nfs_pgio_header *, unsigned int);
+void nfs_pgio_data_release(struct nfs_pgio_data *);
+
static inline void nfs_iocounter_init(struct nfs_io_counter *c)
{
c->flags = 0;
extern int nfs_generic_pagein(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr);
extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio);
-extern void nfs_readdata_release(struct nfs_pgio_data *rdata);
/* super.c */
void nfs_clone_super(struct super_block *, struct nfs_mount_info *);
extern int nfs_generic_flush(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr);
extern void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio);
-extern void nfs_writedata_release(struct nfs_pgio_data *wdata);
extern void nfs_commit_free(struct nfs_commit_data *p);
extern int nfs_initiate_write(struct rpc_clnt *clnt,
struct nfs_pgio_data *data,
static struct kmem_cache *nfs_page_cachep;
-bool nfs_pgarray_set(struct nfs_page_array *p, unsigned int pagecount)
+static bool nfs_pgarray_set(struct nfs_page_array *p, unsigned int pagecount)
{
p->npages = pagecount;
if (pagecount <= ARRAY_SIZE(p->page_array))
}
EXPORT_SYMBOL_GPL(nfs_generic_pg_test);
+static inline struct nfs_rw_header *NFS_RW_HEADER(struct nfs_pgio_header *hdr)
+{
+ return container_of(hdr, struct nfs_rw_header, header);
+}
+
+/**
+ * nfs_pgio_data_alloc - Allocate pageio data
+ * @hdr: The header making a request
+ * @pagecount: Number of pages to create
+ */
+struct nfs_pgio_data *nfs_pgio_data_alloc(struct nfs_pgio_header *hdr,
+ unsigned int pagecount)
+{
+ struct nfs_pgio_data *data, *prealloc;
+
+ prealloc = &NFS_RW_HEADER(hdr)->rpc_data;
+ if (prealloc->header == NULL)
+ data = prealloc;
+ else
+ data = kzalloc(sizeof(*data), GFP_KERNEL);
+ if (!data)
+ goto out;
+
+ if (nfs_pgarray_set(&data->pages, pagecount)) {
+ data->header = hdr;
+ atomic_inc(&hdr->refcnt);
+ } else {
+ if (data != prealloc)
+ kfree(data);
+ data = NULL;
+ }
+out:
+ return data;
+}
+
+/**
+ * nfs_pgio_data_release - Properly free pageio data
+ * @data: The data to release
+ */
+void nfs_pgio_data_release(struct nfs_pgio_data *data)
+{
+ struct nfs_pgio_header *hdr = data->header;
+ struct nfs_rw_header *pageio_header = NFS_RW_HEADER(hdr);
+
+ put_nfs_open_context(data->args.context);
+ if (data->pages.pagevec != data->pages.page_array)
+ kfree(data->pages.pagevec);
+ if (data == &pageio_header->rpc_data) {
+ data->header = NULL;
+ data = NULL;
+ }
+ if (atomic_dec_and_test(&hdr->refcnt))
+ hdr->completion_ops->completion(hdr);
+ /* Note: we only free the rpc_task after callbacks are done.
+ * See the comment in rpc_free_task() for why
+ */
+ kfree(data);
+}
+EXPORT_SYMBOL_GPL(nfs_pgio_data_release);
+
/**
* nfs_pageio_init - initialise a page io descriptor
* @desc: pointer to descriptor
nfs_pageio_reset_write_mds(desc);
desc->pg_recoalesce = 1;
}
- nfs_writedata_release(data);
+ nfs_pgio_data_release(data);
}
static enum pnfs_try_status
nfs_pageio_reset_read_mds(desc);
desc->pg_recoalesce = 1;
}
- nfs_readdata_release(data);
+ nfs_pgio_data_release(data);
}
/*
}
EXPORT_SYMBOL_GPL(nfs_readhdr_alloc);
-static struct nfs_pgio_data *nfs_readdata_alloc(struct nfs_pgio_header *hdr,
- unsigned int pagecount)
-{
- struct nfs_pgio_data *data, *prealloc;
-
- prealloc = &container_of(hdr, struct nfs_rw_header, header)->rpc_data;
- if (prealloc->header == NULL)
- data = prealloc;
- else
- data = kzalloc(sizeof(*data), GFP_KERNEL);
- if (!data)
- goto out;
-
- if (nfs_pgarray_set(&data->pages, pagecount)) {
- data->header = hdr;
- atomic_inc(&hdr->refcnt);
- } else {
- if (data != prealloc)
- kfree(data);
- data = NULL;
- }
-out:
- return data;
-}
-
void nfs_readhdr_free(struct nfs_pgio_header *hdr)
{
struct nfs_rw_header *rhdr = container_of(hdr, struct nfs_rw_header, header);
}
EXPORT_SYMBOL_GPL(nfs_readhdr_free);
-void nfs_readdata_release(struct nfs_pgio_data *rdata)
-{
- struct nfs_pgio_header *hdr = rdata->header;
- struct nfs_rw_header *read_header = container_of(hdr, struct nfs_rw_header, header);
-
- put_nfs_open_context(rdata->args.context);
- if (rdata->pages.pagevec != rdata->pages.page_array)
- kfree(rdata->pages.pagevec);
- if (rdata == &read_header->rpc_data) {
- rdata->header = NULL;
- rdata = NULL;
- }
- if (atomic_dec_and_test(&hdr->refcnt))
- hdr->completion_ops->completion(hdr);
- /* Note: we only free the rpc_task after callbacks are done.
- * See the comment in rpc_free_task() for why
- */
- kfree(rdata);
-}
-EXPORT_SYMBOL_GPL(nfs_readdata_release);
-
static
int nfs_return_empty_page(struct page *page)
{
struct nfs_pgio_data *data = list_first_entry(&hdr->rpc_list,
struct nfs_pgio_data, list);
list_del(&data->list);
- nfs_readdata_release(data);
+ nfs_pgio_data_release(data);
}
desc->pg_completion_ops->error_cleanup(&desc->pg_list);
}
do {
size_t len = min(nbytes,rsize);
- data = nfs_readdata_alloc(hdr, 1);
+ data = nfs_pgio_data_alloc(hdr, 1);
if (!data) {
nfs_pagein_error(desc, hdr);
return -ENOMEM;
struct nfs_pgio_data *data;
struct list_head *head = &desc->pg_list;
- data = nfs_readdata_alloc(hdr, nfs_page_array_len(desc->pg_base,
+ data = nfs_pgio_data_alloc(hdr, nfs_page_array_len(desc->pg_base,
desc->pg_count));
if (!data) {
nfs_pagein_error(desc, hdr);
static void nfs_readpage_release_common(void *calldata)
{
- nfs_readdata_release(calldata);
+ nfs_pgio_data_release(calldata);
}
void nfs_read_prepare(struct rpc_task *task, void *calldata)
}
EXPORT_SYMBOL_GPL(nfs_writehdr_alloc);
-static struct nfs_pgio_data *nfs_writedata_alloc(struct nfs_pgio_header *hdr,
- unsigned int pagecount)
-{
- struct nfs_pgio_data *data, *prealloc;
-
- prealloc = &container_of(hdr, struct nfs_rw_header, header)->rpc_data;
- if (prealloc->header == NULL)
- data = prealloc;
- else
- data = kzalloc(sizeof(*data), GFP_KERNEL);
- if (!data)
- goto out;
-
- if (nfs_pgarray_set(&data->pages, pagecount)) {
- data->header = hdr;
- atomic_inc(&hdr->refcnt);
- } else {
- if (data != prealloc)
- kfree(data);
- data = NULL;
- }
-out:
- return data;
-}
-
void nfs_writehdr_free(struct nfs_pgio_header *hdr)
{
struct nfs_rw_header *whdr = container_of(hdr, struct nfs_rw_header, header);
}
EXPORT_SYMBOL_GPL(nfs_writehdr_free);
-void nfs_writedata_release(struct nfs_pgio_data *wdata)
-{
- struct nfs_pgio_header *hdr = wdata->header;
- struct nfs_rw_header *write_header = container_of(hdr, struct nfs_rw_header, header);
-
- put_nfs_open_context(wdata->args.context);
- if (wdata->pages.pagevec != wdata->pages.page_array)
- kfree(wdata->pages.pagevec);
- if (wdata == &write_header->rpc_data) {
- wdata->header = NULL;
- wdata = NULL;
- }
- if (atomic_dec_and_test(&hdr->refcnt))
- hdr->completion_ops->completion(hdr);
- /* Note: we only free the rpc_task after callbacks are done.
- * See the comment in rpc_free_task() for why
- */
- kfree(wdata);
-}
-EXPORT_SYMBOL_GPL(nfs_writedata_release);
-
static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
{
ctx->error = error;
struct nfs_pgio_data *data = list_first_entry(&hdr->rpc_list,
struct nfs_pgio_data, list);
list_del(&data->list);
- nfs_writedata_release(data);
+ nfs_pgio_data_release(data);
}
desc->pg_completion_ops->error_cleanup(&desc->pg_list);
}
do {
size_t len = min(nbytes, wsize);
- data = nfs_writedata_alloc(hdr, 1);
+ data = nfs_pgio_data_alloc(hdr, 1);
if (!data) {
nfs_flush_error(desc, hdr);
return -ENOMEM;
struct list_head *head = &desc->pg_list;
struct nfs_commit_info cinfo;
- data = nfs_writedata_alloc(hdr, nfs_page_array_len(desc->pg_base,
+ data = nfs_pgio_data_alloc(hdr, nfs_page_array_len(desc->pg_base,
desc->pg_count));
if (!data) {
nfs_flush_error(desc, hdr);
set_bit(NFS_IOHDR_NEED_RESCHED, &hdr->flags);
spin_unlock(&hdr->lock);
}
- nfs_writedata_release(data);
+ nfs_pgio_data_release(data);
}
static const struct rpc_call_ops nfs_write_common_ops = {