[pnfs] [PATCH 15/37] pnfs: simplify layout driver I/O callback functions

Benny Halevy bhalevy at panasas.com
Tue Jan 1 05:50:27 EST 2008


layout driver sets nfs_{read,write}_data status and result fields (e.g.
count, eof) and always calls the pnfs_{readlist,writelist,commit}_done method.

The pnfs callback calls the rpc done function.  with the client layout cache
it will also clean up cache structures passed down to the layout driver.

Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
 fs/nfs/nfs4filelayout.c   |    6 +--
 fs/nfs/pnfs.c             |   89 ++++++---------------------------------------
 fs/nfs/pnfs.h             |    5 ---
 fs/nfs/read.c             |    7 ----
 fs/nfs/write.c            |   12 ------
 include/linux/nfs4_pnfs.h |   18 +++------
 6 files changed, 19 insertions(+), 118 deletions(-)

diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 93b2abc..30a853c 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -223,8 +223,7 @@ static void filelayout_read_call_done(struct rpc_task *task, void *data)
 	if (rdata->orig_offset)
 		rdata->args.offset = rdata->orig_offset;
 
-	/* Call the NFS call ops now */
-	rdata->call_ops->rpc_call_done(task, data);
+	pnfs_callback_ops->nfs_readlist_complete(rdata);
 }
 
 static void filelayout_write_call_done(struct rpc_task *task, void *data)
@@ -234,8 +233,7 @@ static void filelayout_write_call_done(struct rpc_task *task, void *data)
 	if (wdata->orig_offset)
 		wdata->args.offset = wdata->orig_offset;
 
-	/* Call the NFS call ops now */
-	wdata->call_ops->rpc_call_done(task, data);
+	pnfs_callback_ops->nfs_writelist_complete(wdata);
 }
 
 struct rpc_call_ops filelayout_read_call_ops = {
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index fdb3d40..ced7f30 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -775,40 +775,6 @@ pnfs_get_type(struct inode *inode)
 	return nfss->pnfs_curr_ld->id;
 }
 
-/* Determine if the the NFSv4 protocol is to be used for writes,
- * whether pNFS is being used or not.
- * TODO: Instead of checking for the file layout type, maybe
- * we should make this a policy option in the future if more
- * layout drivers uses NFSv4 I/O.
- */
-int
-pnfs_use_nfsv4_wproto(struct inode *inode, ssize_t count)
-{
-	struct nfs_server *nfss = NFS_SERVER(inode);
-	if (!pnfs_enabled_sb(nfss) ||
-	    pnfs_get_type(inode) == LAYOUT_NFSV4_FILES ||
-	    !pnfs_use_write(inode, count))
-		return 1;
-
-	return 0;
-}
-
-/* Determine if the the NFSv4 protocol is to be used for reads,
- * whether pNFS is being used or not.
- * TODO: See pnfs_use_nfsv4_wproto.
- */
-int
-pnfs_use_nfsv4_rproto(struct inode *inode, ssize_t count)
-{
-	struct nfs_server *nfss = NFS_SERVER(inode);
-	if (!pnfs_enabled_sb(nfss) ||
-	    pnfs_get_type(inode) == LAYOUT_NFSV4_FILES ||
-	    !pnfs_use_read(inode, count))
-		return 1;
-
-	return 0;
-}
-
 /* Return I/O buffer size for a layout driver
  * This value will determine what size reads and writes
  * will be gathered into and sent to the data servers.
@@ -831,23 +797,14 @@ pnfs_getiosize(struct nfs_server *server)
 	return ld->ld_policy_ops->get_blocksize(mounttype);
 }
 
-/* Invoked by all non-NFSv4 I/O layout drivers to mark pages for commit
+/* Invoked by all layout drivers when write_pagelist is done
  */
 static void
-pnfs_writeback_done(struct nfs_write_data *data, ssize_t status)
+pnfs_writeback_done(struct nfs_write_data *data)
 {
-	dprintk("%s: Begin (status %Zd)\n", __FUNCTION__, status);
+	dprintk("%s: Begin (status %d)\n", __FUNCTION__, data->task.tk_status);
 
-	/* NFSv4 will have sunrpc call the callbacks */
-	if (data->call_ops == NULL ||
-	    pnfs_use_nfsv4_wproto(data->inode, data->args.count))
-		return;
-
-	/* Status is the number of bytes written or an error code */
-	data->task.tk_status = status;
-	data->res.count = status;
-	pnfs_writeback_done_norpc(&data->task, data);
-	data->call_ops->rpc_release(data);
+	data->call_ops->rpc_call_done(&data->task, data);
 }
 
 /*
@@ -923,32 +880,15 @@ out:
 	return status;
 }
 
-/* Post-read completion function.  Invoked by non RPC layout drivers
- * to clean up read pages.
- *
- * NOTE: called must set data->pnfsflags PNFS_NO_RPC
+/* Post-read completion function.  Invoked by all layout drivers when
+ * read_pagelist is done
  */
 static void
-pnfs_read_done(struct nfs_read_data *data, ssize_t status, int eof)
+pnfs_read_done(struct nfs_read_data *data)
 {
-	dprintk("%s: Begin (status %Zd)\n", __FUNCTION__, status);
+	dprintk("%s: Begin (status %d)\n", __FUNCTION__, data->task.tk_status);
 
-	/* NFSv4 will have sunrpc call the callbacks */
-	if (data->call_ops == NULL ||
-	    pnfs_use_nfsv4_rproto(data->inode, data->args.count))
-		return;
-
-	/* Status is the number of bytes written or an error code
-	 * the rpc_task is uninitialized, and tk_status is all that
-	 * is used in the call done routines.
-	 */
-	data->task.tk_status = status;
-	data->res.eof = eof;
-	data->res.count = status;
-
-	/* call the NFS cleanup routines. */
 	data->call_ops->rpc_call_done(&data->task, data);
-	data->call_ops->rpc_release(data);
 }
 
 /*
@@ -1072,18 +1012,11 @@ int pnfs_try_to_commit(struct inode *inode, struct nfs_write_data *data, struct
 
 /* pNFS Commit callback function for non-file layout drivers */
 static void
-pnfs_commit_done(struct nfs_write_data *data, ssize_t status)
+pnfs_commit_done(struct nfs_write_data *data)
 {
-	dprintk("%s: Begin (status %Zd)\n", __FUNCTION__, status);
+	dprintk("%s: Begin (status %d)\n", __FUNCTION__, data->task.tk_status);
 
-	/* NFSv4 will have sunrpc call the callbacks */
-	if (pnfs_use_nfsv4_wproto(data->inode, -1))
-		return;
-
-	/* Status is the number of bytes written or an error code */
-	data->task.tk_status = status;
-	pnfs_commit_done_norpc(&data->task, data);
-	data->call_ops->rpc_release(data);
+	data->call_ops->rpc_call_done(&data->task, data);
 }
 
 int
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index a562d12..ed1445e 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -36,17 +36,12 @@ void pnfs_writeback_done_update(struct nfs_write_data *);
 void pnfs_update_last_write(struct nfs_inode *nfsi, loff_t offset, size_t extent);
 void pnfs_need_layoutcommit(struct nfs_inode *nfsi, struct nfs_open_context *ctx);
 int pnfs_enabled_sb(struct nfs_server *nfss);
-int pnfs_use_nfsv4_wproto(struct inode *inode, ssize_t count);
-int pnfs_use_nfsv4_rproto(struct inode *inode, ssize_t count);
 unsigned int pnfs_getiosize(struct nfs_server *server);
 int pnfs_commit(struct inode *inode, struct list_head *head, int sync, struct nfs_write_data *data);
 int pnfs_try_to_commit(struct inode *, struct nfs_write_data *, struct list_head *, int);
 int pnfs_wsize(struct inode *, unsigned int, struct nfs_write_data *);
 int pnfs_rpages(struct inode *);
 int pnfs_wpages(struct inode *);
-void pnfs_readpage_result_norpc(struct rpc_task *task, void *calldata);
-void pnfs_writeback_done_norpc(struct rpc_task *, void *);
-void pnfs_commit_done_norpc(struct rpc_task *, void *);
 void pnfs_set_ds_rsize(struct inode *, struct nfs_open_context *, struct list_head *, loff_t, size_t *, struct nfs_pageio_descriptor *);
 
 
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index be283b4..689722e 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -485,13 +485,6 @@ static void nfs_readpage_set_pages_uptodate(struct nfs_read_data *data)
 		SetPageUptodate(*pages);
 }
 
-#ifdef CONFIG_PNFS
-void pnfs_readpage_result_norpc(struct rpc_task *task, void *calldata)
-{
-	/* XXX Need to implement */
-}
-#endif
-
 /*
  * This is the callback from RPC telling us whether a reply was
  * received or some error occurred (timeout or socket shutdown).
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 31f2745..fe16b09 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -985,18 +985,6 @@ static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
 		nfs_pageio_init(pgio, inode, nfs_flush_one, wsize, ioflags);
 }
 
-#ifdef CONFIG_PNFS
-void pnfs_writeback_done_norpc(struct rpc_task *task, void *calldata)
-{
-	/* XXX Need to Implement */
-}
-
-void pnfs_commit_done_norpc(struct rpc_task *task, void *calldata)
-{
-	/* XXX Need to Implement */
-}
-#endif /* CONFIG_PNFS */
-
 /*
  * Handle a write reply that flushed part of a page.
  */
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index fdc4622..6a98f59 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -177,20 +177,14 @@ struct pnfs_client_operations {
 	int (*nfs_getdevicelist) (struct super_block *sb, struct nfs_fh *fh, struct pnfs_devicelist *devlist);
 	int (*nfs_getdeviceinfo) (struct inode *inode, u32 dev_id, struct pnfs_device *dev);
 
-	/* Post read callback.  Layout driver calls this function if unstable data was
-	 * written and requires a commit call
-	 */
-	void (*nfs_readlist_complete) (struct nfs_read_data *nfs_data, ssize_t status, int eof);
+	/* Post read callback. */
+	void (*nfs_readlist_complete) (struct nfs_read_data *nfs_data);
 
-	/* Post write callback.  Layout driver calls this function if unstable data was
-	 * written and requires a commit call
-	 */
-	void (*nfs_writelist_complete) (struct nfs_write_data *nfs_data, ssize_t status);
+	/* Post write callback. */
+	void (*nfs_writelist_complete) (struct nfs_write_data *nfs_data);
 
-	/* Post commit callback.  Layout driver calls this function once data is
-	 * on stable storage.
-	 */
-	void (*nfs_commit_complete) (struct nfs_write_data *nfs_data, ssize_t status);
+	/* Post commit callback. */
+	void (*nfs_commit_complete) (struct nfs_write_data *nfs_data);
 	void (*nfs_return_layout) (struct inode *);
 };
 
-- 
1.5.3.3



More information about the pNFS mailing list