All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fred Isaman <iisaman@netapp.com>
To: linux-nfs@vger.kernel.org
Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
Subject: [PATCH 22/26] NFS: create nfs_commit_completion_ops
Date: Mon,  9 Apr 2012 16:52:20 -0400	[thread overview]
Message-ID: <1334004744-31842-23-git-send-email-iisaman@netapp.com> (raw)
In-Reply-To: <1334004744-31842-1-git-send-email-iisaman@netapp.com>

Factors out the code that needs to change when directio
starts using these code paths.

Signed-off-by: Fred Isaman <iisaman@netapp.com>
---
 fs/nfs/internal.h       |    5 ++---
 fs/nfs/nfs4filelayout.c |   12 ++++--------
 fs/nfs/write.c          |   31 +++++++++++++++++++++----------
 include/linux/nfs_xdr.h |    9 +++++++++
 4 files changed, 36 insertions(+), 21 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index cbdea5e..d08f048 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -347,13 +347,12 @@ extern int nfs_initiate_commit(struct rpc_clnt *clnt,
 			       int how);
 extern void nfs_init_commit(struct nfs_commit_data *data,
 			    struct list_head *head,
-			    struct pnfs_layout_segment *lseg);
+			    struct pnfs_layout_segment *lseg,
+			    struct nfs_commit_info *cinfo);
 void nfs_retry_commit(struct list_head *page_list,
 		      struct pnfs_layout_segment *lseg,
 		      struct nfs_commit_info *cinfo);
-void nfs_commit_clear_lock(struct nfs_inode *nfsi);
 void nfs_commitdata_release(struct nfs_commit_data *data);
-void nfs_commit_release_pages(struct nfs_commit_data *data);
 void nfs_request_add_commit_list(struct nfs_page *req, struct list_head *dst,
 				 struct nfs_commit_info *cinfo);
 void nfs_request_remove_commit_list(struct nfs_page *req,
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index a1860ac..96a6141 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -347,12 +347,8 @@ static void filelayout_commit_count_stats(struct rpc_task *task, void *data)
 static void filelayout_commit_release(void *calldata)
 {
 	struct nfs_commit_data *data = calldata;
-	struct nfs_commit_info cinfo;
 
-	nfs_commit_release_pages(data);
-	nfs_init_cinfo(&cinfo, data->inode, data->dreq);
-	if (atomic_dec_and_test(&cinfo.mds->rpcs_out))
-		nfs_commit_clear_lock(NFS_I(data->inode));
+	data->compl_ops->completion(data);
 	put_lseg(data->lseg);
 	nfs_commitdata_release(data);
 }
@@ -1082,7 +1078,7 @@ filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
 	nreq += alloc_ds_commits(cinfo, &list);
 
 	if (nreq == 0) {
-		nfs_commit_clear_lock(NFS_I(inode));
+		cinfo->compl_ops->error_cleanup(NFS_I(inode));
 		goto out;
 	}
 
@@ -1091,14 +1087,14 @@ filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
 	list_for_each_entry_safe(data, tmp, &list, pages) {
 		list_del_init(&data->pages);
 		if (!data->lseg) {
-			nfs_init_commit(data, mds_pages, NULL);
+			nfs_init_commit(data, mds_pages, NULL, cinfo);
 			nfs_initiate_commit(NFS_CLIENT(inode), data,
 					    data->mds_ops, how);
 		} else {
 			struct pnfs_commit_bucket *buckets;
 
 			buckets = cinfo->ds->buckets;
-			nfs_init_commit(data, &buckets[data->ds_commit_index].committing, data->lseg);
+			nfs_init_commit(data, &buckets[data->ds_commit_index].committing, data->lseg, cinfo);
 			filelayout_initiate_commit(data, how);
 		}
 	}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 30dcc4f..ceb3979 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -46,6 +46,7 @@ static void nfs_redirty_request(struct nfs_page *req);
 static const struct rpc_call_ops nfs_write_common_ops;
 static const struct rpc_call_ops nfs_commit_ops;
 static const struct nfs_io_completion_ops nfs_asynch_write_compl_ops;
+static const struct nfs_commit_completion_ops nfs_commit_compl_ops;
 
 static struct kmem_cache *nfs_wdata_cachep;
 static mempool_t *nfs_wdata_mempool;
@@ -499,6 +500,7 @@ static void nfs_init_cinfo_from_inode(struct nfs_commit_info *cinfo,
 	cinfo->lock = &inode->i_lock;
 	cinfo->mds = &NFS_I(inode)->commit_info;
 	cinfo->ds = pnfs_get_ds_info(inode);
+	cinfo->compl_ops = &nfs_commit_compl_ops;
 }
 
 void nfs_init_cinfo(struct nfs_commit_info *cinfo,
@@ -1356,13 +1358,12 @@ static int nfs_commit_set_lock(struct nfs_inode *nfsi, int may_wait)
 	return (ret < 0) ? ret : 1;
 }
 
-void nfs_commit_clear_lock(struct nfs_inode *nfsi)
+static void nfs_commit_clear_lock(struct nfs_inode *nfsi)
 {
 	clear_bit(NFS_INO_COMMIT, &nfsi->flags);
 	smp_mb__after_clear_bit();
 	wake_up_bit(&nfsi->flags, NFS_INO_COMMIT);
 }
-EXPORT_SYMBOL_GPL(nfs_commit_clear_lock);
 
 void nfs_commitdata_release(struct nfs_commit_data *data)
 {
@@ -1411,8 +1412,9 @@ EXPORT_SYMBOL_GPL(nfs_initiate_commit);
  * Set up the argument/result storage required for the RPC call.
  */
 void nfs_init_commit(struct nfs_commit_data *data,
-			    struct list_head *head,
-			    struct pnfs_layout_segment *lseg)
+		     struct list_head *head,
+		     struct pnfs_layout_segment *lseg,
+		     struct nfs_commit_info *cinfo)
 {
 	struct nfs_page *first = nfs_list_entry(head->next);
 	struct inode *inode = first->wb_context->dentry->d_inode;
@@ -1426,6 +1428,7 @@ void nfs_init_commit(struct nfs_commit_data *data,
 	data->cred	  = first->wb_context->cred;
 	data->lseg	  = lseg; /* reference transferred */
 	data->mds_ops     = &nfs_commit_ops;
+	data->compl_ops	  = cinfo->compl_ops;
 
 	data->args.fh     = NFS_FH(data->inode);
 	/* Note: we always request a commit of the entire inode */
@@ -1471,11 +1474,12 @@ nfs_commit_list(struct inode *inode, struct list_head *head, int how,
 		goto out_bad;
 
 	/* Set up the argument struct */
-	nfs_init_commit(data, head, NULL);
+	nfs_init_commit(data, head, NULL, cinfo);
+	atomic_inc(&cinfo->mds->rpcs_out);
 	return nfs_initiate_commit(NFS_CLIENT(inode), data, data->mds_ops, how);
  out_bad:
 	nfs_retry_commit(head, NULL, cinfo);
-	nfs_commit_clear_lock(NFS_I(inode));
+	cinfo->compl_ops->error_cleanup(NFS_I(inode));
 	return -ENOMEM;
 }
 
@@ -1493,10 +1497,11 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata)
 	NFS_PROTO(data->inode)->commit_done(task, data);
 }
 
-void nfs_commit_release_pages(struct nfs_commit_data *data)
+static void nfs_commit_release_pages(struct nfs_commit_data *data)
 {
 	struct nfs_page	*req;
 	int status = data->task.tk_status;
+	struct nfs_commit_info cinfo;
 
 	while (!list_empty(&data->pages)) {
 		req = nfs_list_entry(data->pages.next);
@@ -1529,15 +1534,16 @@ void nfs_commit_release_pages(struct nfs_commit_data *data)
 	next:
 		nfs_unlock_request(req);
 	}
+	nfs_init_cinfo(&cinfo, data->inode, data->dreq);
+	if (atomic_dec_and_test(&cinfo.mds->rpcs_out))
+		nfs_commit_clear_lock(NFS_I(data->inode));
 }
-EXPORT_SYMBOL_GPL(nfs_commit_release_pages);
 
 static void nfs_commit_release(void *calldata)
 {
 	struct nfs_commit_data *data = calldata;
 
-	nfs_commit_release_pages(data);
-	nfs_commit_clear_lock(NFS_I(data->inode));
+	data->compl_ops->completion(data);
 	nfs_commitdata_release(calldata);
 }
 
@@ -1547,6 +1553,11 @@ static const struct rpc_call_ops nfs_commit_ops = {
 	.rpc_release = nfs_commit_release,
 };
 
+static const struct nfs_commit_completion_ops nfs_commit_compl_ops = {
+	.completion = nfs_commit_release_pages,
+	.error_cleanup = nfs_commit_clear_lock,
+};
+
 static int nfs_generic_commit_list(struct inode *inode, struct list_head *head,
 				   int how, struct nfs_commit_info *cinfo)
 {
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 646100c..0ee7b3a 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1258,10 +1258,18 @@ struct nfs_mds_commit_info {
 	struct list_head	list;
 };
 
+struct nfs_commit_data;
+struct nfs_inode;
+struct nfs_commit_completion_ops {
+	void (*error_cleanup) (struct nfs_inode *nfsi);
+	void (*completion) (struct nfs_commit_data *data);
+};
+
 struct nfs_commit_info {
 	spinlock_t			*lock;
 	struct nfs_mds_commit_info	*mds;
 	struct pnfs_ds_commit_info	*ds;
+	const struct nfs_commit_completion_ops *compl_ops;
 };
 
 struct nfs_commit_data {
@@ -1280,6 +1288,7 @@ struct nfs_commit_data {
 	struct nfs_client	*ds_clp;	/* pNFS data server */
 	int			ds_commit_index;
 	const struct rpc_call_ops *mds_ops;
+	const struct nfs_commit_completion_ops *compl_ops;
 	int (*commit_done_cb) (struct rpc_task *task, struct nfs_commit_data *data);
 };
 
-- 
1.7.2.1


  parent reply	other threads:[~2012-04-09 20:53 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-09 20:51 [PATCH 00/26] directio rewrite Fred Isaman
2012-04-09 20:51 ` [PATCH 01/26] NFS: check for req==NULL in nfs_try_to_update_request cleanup Fred Isaman
2012-04-09 20:52 ` [PATCH 02/26] NFS4.1: make pnfs_ld_[read|write]_done consistent Fred Isaman
2012-04-09 20:52 ` [PATCH 03/26] NFS4.1: Add lseg to struct nfs4_fl_commit_bucket Fred Isaman
2012-04-13 15:47   ` Myklebust, Trond
2012-04-13 16:50     ` Fred Isaman
2012-04-09 20:52 ` [PATCH 04/26] NFS: add a struct nfs_commit_data to replace nfs_write_data in commits Fred Isaman
2012-04-09 20:52 ` [PATCH 05/26] NFS: grab open context in direct read Fred Isaman
2012-04-09 20:52 ` [PATCH 06/26] NFS: dprintks in directio code were referencing task after put Fred Isaman
2012-04-09 20:52 ` [PATCH 07/26] NFS: reverse arg order in nfs_initiate_[read|write] Fred Isaman
2012-04-09 20:52 ` [PATCH 08/26] NFS: remove unnecessary casts of void pointers in nfs4filelayout.c Fred Isaman
2012-04-09 20:52 ` [PATCH 09/26] NFS: use req_offset where appropriate Fred Isaman
2012-04-09 20:52 ` [PATCH 10/26] NFS: put open context on error in nfs_pagein_multi Fred Isaman
2012-04-13 15:52   ` Myklebust, Trond
2012-04-09 20:52 ` [PATCH 11/26] NFS: put open context on error in nfs_flush_multi Fred Isaman
2012-04-13 15:52   ` Myklebust, Trond
2012-04-09 20:52 ` [PATCH 12/26] NFS: create common nfs_pgio_header for both read and write Fred Isaman
2012-04-09 20:52 ` [PATCH 13/26] NFS: create struct nfs_page_array Fred Isaman
2012-04-09 20:52 ` [PATCH 14/26] NFS: merge _full and _partial read rpc_ops Fred Isaman
2012-04-16 20:28   ` Myklebust, Trond
2012-04-17 15:37     ` Fred Isaman
2012-04-17 16:13       ` Myklebust, Trond
2012-04-17 16:16         ` Fred Isaman
2012-04-16 20:41   ` Myklebust, Trond
2012-04-17 15:38     ` Fred Isaman
2012-04-09 20:52 ` [PATCH 15/26] NFS: merge _full and _partial write rpc_ops Fred Isaman
2012-04-09 20:52 ` [PATCH 16/26] NFS: create completion structure to pass into page_init functions Fred Isaman
2012-04-16 21:07   ` Myklebust, Trond
2012-04-09 20:52 ` [PATCH 17/26] NFS: remove unused wb_complete field from struct nfs_page Fred Isaman
2012-04-09 20:52 ` [PATCH 18/26] NFS: prepare coalesce testing for directio Fred Isaman
2012-04-09 20:52 ` [PATCH 19/26] NFS: rewrite directio read to use async coalesce code Fred Isaman
2012-04-16 21:22   ` Myklebust, Trond
2012-04-17 15:41     ` Fred Isaman
2012-04-09 20:52 ` [PATCH 20/26] NFS: create nfs_generic_commit_list Fred Isaman
2012-04-09 20:52 ` [PATCH 21/26] NFS: create struct nfs_commit_info Fred Isaman
2012-04-09 20:52 ` Fred Isaman [this message]
2012-04-09 20:52 ` [PATCH 23/26] NFS: add dreq to nfs_commit_info Fred Isaman
2012-04-09 20:52 ` [PATCH 24/26] NFS: avoid some stat gathering for direct io Fred Isaman
2012-04-09 20:52 ` [PATCH 25/26] NFS: move allocation of nfs4_fl_commit_info to write's pg_init Fred Isaman
2012-04-09 20:52 ` [PATCH 26/26] NFS: rewrite directio write to use async coalesce code Fred Isaman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1334004744-31842-23-git-send-email-iisaman@netapp.com \
    --to=iisaman@netapp.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.