
Retrieves and uses the layout drivers I/O threshold value.  If a read
or write is smaller than the threshold, we use standard NFS processing.

---

 linux-2.6.14-pnfs-current-dhildebz/fs/nfs/pnfs.c |   44 +++++++++++++++++++++++
 1 files changed, 44 insertions(+)

diff -puN fs/nfs/pnfs.c~client-iothresh fs/nfs/pnfs.c
--- linux-2.6.14-pnfs-current/fs/nfs/pnfs.c~client-iothresh	2006-01-12 13:30:48.033206000 -0500
+++ linux-2.6.14-pnfs-current-dhildebz/fs/nfs/pnfs.c	2006-01-12 13:30:55.394927000 -0500
@@ -389,6 +389,36 @@ use_pnfs_io(struct inode *inode,unsigned
 }
 
 /*
+ * Ask the layout driver for the request size at which pNFS should be used
+ * or standard NFSv4 I/O.  Writing directly to the NFSv4 server can
+ * improve performance through its singularity and async behavior to
+ * the underlying parallel file system.
+ */
+int
+below_io_threshold(struct inode *inode, size_t req_size)
+{
+	struct nfs_server* nfss = NFS_SERVER(inode);
+	struct nfs_inode* nfsi = NFS_I(inode);
+	size_t threshold = -1;
+
+	dprintk("%s Begin\n",__FUNCTION__);
+	if (nfss->rpc_ops->version == 4 &&
+	    nfss->pnfs_curr_ld &&
+	    nfss->pnfs_curr_ld->ld_policy_ops &&
+	    nfss->pnfs_curr_ld->ld_policy_ops->get_io_threshold)
+	{
+		threshold = nfss->pnfs_curr_ld->ld_policy_ops->get_io_threshold(nfsi->current_layout, inode);
+	}
+
+	dprintk("%s Threshold for Layout Driver %Zd\n",__FUNCTION__, threshold);
+	/* If the layout driver does not support a I/O threshold, use pNFS I/O */
+	if (req_size <= threshold)
+		return 1;
+	else
+		return 0;
+}
+
+/*
  * Handle a write reply that flushed part of a page.
  */
 static void
@@ -631,6 +661,13 @@ pnfs_file_read(struct file* filp, char _
 		dentry->d_parent->d_name.name, dentry->d_name.name,
 		(unsigned long) count, (unsigned long) *pos);
 
+	/* Small I/O Optimization */
+	if (below_io_threshold(inode, count))
+	{
+		dfprintk(IO, "%s: Below I/O threshold, using NFSv4 read\n",__FUNCTION__);
+		return do_sync_read(filp,buf,count,pos);
+	}
+
 	/* Step 1: Retrieve and set layout if not allready cached*/
 	if ((result = virtual_update_layout(inode,
 					    (struct nfs_open_context *)filp->private_data,
@@ -706,6 +743,13 @@ pnfs_file_write(struct file* filp, const
 		return do_sync_write(filp,buf,count,pos);
 	}
 
+	/* Small I/O Optimization */
+	if (below_io_threshold(inode, count))
+	{
+		dfprintk(IO, "%s: Below I/O threshold, using NFSv4 write\n",__FUNCTION__);
+		return do_sync_write(filp,buf,count,pos);
+	}
+
 	/* Need to adjust write param if this is an append, etc */
 	generic_write_checks(filp,pos,&count,isblk);
 
_
