[pnfs] [PATCH 04/32] pnfs: pnfs_use_rpc_code

Fred Isaman iisaman at citi.umich.edu
Fri Mar 21 16:52:55 EDT 2008


The IO paths were changing behavior based on whether using filelayout or not.
This is properly done via a policy op.

Signed-off-by: Fred Isaman <iisaman at citi.umich.edu>
---
 fs/nfs/nfs4filelayout.c   |    7 +++++++
 fs/nfs/pnfs.c             |   29 ++++++++++++++---------------
 include/linux/nfs4_pnfs.h |    3 +++
 3 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index cadd3c2..05aeae8 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -825,6 +825,12 @@ filelayout_get_io_threshold(struct pnfs_layout_type *layoutid, struct inode *ino
 	return -1;
 }
 
+static int
+filelayout_use_rpc_code(void)
+{
+	return 1;
+}
+
 struct layoutdriver_io_operations filelayout_io_operations = {
 	.commit                  = filelayout_commit,
 	.read_pagelist           = filelayout_read_pagelist,
@@ -846,6 +852,7 @@ struct layoutdriver_policy_operations filelayout_policy_operations = {
 	.layoutget_on_open     = filelayout_layoutget_on_open,
 	.get_read_threshold    = filelayout_get_io_threshold,
 	.get_write_threshold   = filelayout_get_io_threshold,
+	.use_rpc_code          = filelayout_use_rpc_code,
 };
 
 struct pnfs_layoutdriver_type filelayout_type = {
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index a4b1295..e28d8fd 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1240,16 +1240,6 @@ pnfs_use_write(struct inode *inode, ssize_t count)
 	return 1; /* use pNFS I/O */
 }
 
-/* Retrieve layout driver type id */
-static int
-pnfs_get_type(struct inode *inode)
-{
-	struct nfs_server *nfss = NFS_SERVER(inode);
-	if (!pnfs_enabled_sb(nfss))
-		return 0;
-	return nfss->pnfs_curr_ld->id;
-}
-
 /* 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.
@@ -1292,10 +1282,19 @@ pnfs_set_ds_iosize(struct nfs_server *server)
 	}
 }
 
+/* Should the full nfs rpc cleanup code be used after io */
+static int pnfs_use_rpc_code(struct pnfs_layoutdriver_type *ld)
+{
+	if (ld->ld_policy_ops->use_rpc_code)
+		return ld->ld_policy_ops->use_rpc_code();
+	else
+		return 0;
+}
+
 /* Post-write completion function
  * Invoked by all layout drivers when write_pagelist is done.
  *
- * NOTE: callers must set data->pnfsflags PNFS_NO_RPC
+ * NOTE: callers set data->pnfsflags PNFS_NO_RPC
  * so that the NFS cleanup routines perform only the page cache
  * cleanup.
  */
@@ -1306,9 +1305,9 @@ pnfs_writeback_done(struct nfs_write_data *data)
 
 	/* update last write offset and need layout commit
 	 * for non-files layout types (files layout calls
-	 * pnfs_writeback_done_update for this
+	 * pnfs4_write_done for this)
 	 */
-	if (pnfs_get_type(data->inode) != LAYOUT_NFSV4_FILES &&
+	if ((data->pnfsflags & PNFS_NO_RPC) &&
 	    data->task.tk_status >= 0 && data->res.count > 0) {
 		struct nfs_inode *nfsi = NFS_I(data->inode);
 
@@ -1438,7 +1437,7 @@ pnfs_writepages(struct nfs_write_data *wdata, int how)
 		__func__,
 		how,
 		numpages);
-	if (pnfs_get_type(inode) != LAYOUT_NFSV4_FILES)
+	if (!pnfs_use_rpc_code(nfss->pnfs_curr_ld))
 		wdata->pnfsflags |= PNFS_NO_RPC;
 	wdata->lseg = lseg;
 	status = nfss->pnfs_curr_ld->ld_io_ops->write_pagelist(
@@ -1515,7 +1514,7 @@ pnfs_readpages(struct nfs_read_data *rdata)
 
 	dprintk("%s: Calling layout driver read with %d pages\n",
 		__func__, numpages);
-	if (pnfs_get_type(inode) != LAYOUT_NFSV4_FILES)
+	if (!pnfs_use_rpc_code(nfss->pnfs_curr_ld))
 		rdata->pnfsflags |= PNFS_NO_RPC;
 	rdata->lseg = lseg;
 	status = nfss->pnfs_curr_ld->ld_io_ops->read_pagelist(
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index 031c1b9..6dae5a0 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -188,6 +188,9 @@ struct layoutdriver_policy_operations {
 	/* Should the pNFS client commit and return the layout upon a setattr
 	 */
 	int (*layoutret_on_setattr) (struct pnfs_mount_type *);
+
+	/* Should the full nfs rpc cleanup code be used after io */
+	int (*use_rpc_code) (void);
 };
 
 struct pnfs_device {
-- 
1.5.3.3



More information about the pNFS mailing list