aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/pagelist.c
diff options
context:
space:
mode:
authorAnna Schumaker <Anna.Schumaker@netapp.com>2014-05-06 09:12:30 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-05-28 18:40:04 -0400
commit4a0de55c565a36cac8422b76a948c4634a90781e (patch)
tree749ab695ab23756f1f7c791a17a2125eac993d9c /fs/nfs/pagelist.c
parent00bfa30abe86982ce1929e9cabd703e5546106bd (diff)
NFS: Create a common rw_header_alloc and rw_header_free function
I create a new struct nfs_rw_ops to decide the differences between reads and writes. This struct will be set when initializing a new nfs_pgio_descriptor, and then passed on to the nfs_rw_header when a new header is allocated. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/pagelist.c')
-rw-r--r--fs/nfs/pagelist.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index a98ccf722d7b..ca356fe0836b 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -301,6 +301,37 @@ static inline struct nfs_rw_header *NFS_RW_HEADER(struct nfs_pgio_header *hdr)
301} 301}
302 302
303/** 303/**
304 * nfs_rw_header_alloc - Allocate a header for a read or write
305 * @ops: Read or write function vector
306 */
307struct nfs_rw_header *nfs_rw_header_alloc(const struct nfs_rw_ops *ops)
308{
309 struct nfs_rw_header *header = ops->rw_alloc_header();
310
311 if (header) {
312 struct nfs_pgio_header *hdr = &header->header;
313
314 INIT_LIST_HEAD(&hdr->pages);
315 INIT_LIST_HEAD(&hdr->rpc_list);
316 spin_lock_init(&hdr->lock);
317 atomic_set(&hdr->refcnt, 0);
318 hdr->rw_ops = ops;
319 }
320 return header;
321}
322EXPORT_SYMBOL_GPL(nfs_rw_header_alloc);
323
324/*
325 * nfs_rw_header_free - Free a read or write header
326 * @hdr: The header to free
327 */
328void nfs_rw_header_free(struct nfs_pgio_header *hdr)
329{
330 hdr->rw_ops->rw_free_header(NFS_RW_HEADER(hdr));
331}
332EXPORT_SYMBOL_GPL(nfs_rw_header_free);
333
334/**
304 * nfs_pgio_data_alloc - Allocate pageio data 335 * nfs_pgio_data_alloc - Allocate pageio data
305 * @hdr: The header making a request 336 * @hdr: The header making a request
306 * @pagecount: Number of pages to create 337 * @pagecount: Number of pages to create
@@ -367,6 +398,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
367 struct inode *inode, 398 struct inode *inode,
368 const struct nfs_pageio_ops *pg_ops, 399 const struct nfs_pageio_ops *pg_ops,
369 const struct nfs_pgio_completion_ops *compl_ops, 400 const struct nfs_pgio_completion_ops *compl_ops,
401 const struct nfs_rw_ops *rw_ops,
370 size_t bsize, 402 size_t bsize,
371 int io_flags) 403 int io_flags)
372{ 404{
@@ -380,6 +412,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
380 desc->pg_inode = inode; 412 desc->pg_inode = inode;
381 desc->pg_ops = pg_ops; 413 desc->pg_ops = pg_ops;
382 desc->pg_completion_ops = compl_ops; 414 desc->pg_completion_ops = compl_ops;
415 desc->pg_rw_ops = rw_ops;
383 desc->pg_ioflags = io_flags; 416 desc->pg_ioflags = io_flags;
384 desc->pg_error = 0; 417 desc->pg_error = 0;
385 desc->pg_lseg = NULL; 418 desc->pg_lseg = NULL;