[pnfs] [PATCH 06/37] pnfs: obliterate use_pagecache policy op and non page cache paths

Benny Halevy bhalevy at panasas.com
Tue Jan 1 05:49:40 EST 2008


This patch gets rid of non page cache paths for read[v], write[v], and fsync
since there's no layout driver implementing these at the moment.

Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
 fs/nfs/file.c             |    6 +-
 fs/nfs/nfs4filelayout.c   |   22 -----
 fs/nfs/pnfs.c             |  217 ---------------------------------------------
 fs/nfs/pnfs.h             |    3 -
 include/linux/nfs4_pnfs.h |   15 ---
 5 files changed, 3 insertions(+), 260 deletions(-)

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 458b58d..7d22162 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -89,15 +89,15 @@ const struct inode_operations nfs_file_inode_operations = {
 #ifdef CONFIG_PNFS
 const struct file_operations pnfs_file_operations = {
 	.llseek		= nfs_file_llseek,
-	.read		= pnfs_file_read,
-	.write		= pnfs_file_write,
+	.read		= do_sync_read,
+	.write		= do_sync_write,
 	.aio_read	= nfs_file_read,
 	.aio_write	= nfs_file_write,
 	.mmap		= nfs_file_mmap,
 	.open		= nfs_file_open,
 	.flush		= nfs_file_flush,
 	.release	= nfs_file_release,
-	.fsync		= pnfs_fsync,
+	.fsync		= nfs_fsync,
 	.lock		= nfs_lock,
 	.flock		= nfs_flock,
 	.splice_read	= nfs_file_splice_read,
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 73ba031..6bea89e 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -497,18 +497,6 @@ nfserr:
 	return NULL;
 }
 
-/* Call nfs fsync function to flush buffers and eventually call
- * the filelayout_write_pagelist and filelayout_commit functions.
- */
-int
-filelayout_fsync(struct pnfs_layout_type *layoutid,
-		struct file *file,
-		struct dentry *dentry,
-		int datasync)
-{
-	return pnfs_callback_ops->nfs_fsync(file, dentry, datasync);
-}
-
 /* TODO: Technically we would need to execute a COMMIT op to each
  * data server on which a page in 'pages' exists.
  * Once we fix this, we will need to invoke the pnfs_commit_complete callback.
@@ -646,14 +634,6 @@ filelayout_pg_test(int boundary, struct nfs_page *prev, struct nfs_page *req)
 	return (p_stripe == r_stripe);
 }
 
-/* Use the NFSv4 page cache
-*/
-int
-filelayout_use_pagecache(struct pnfs_layout_type *layoutid, struct inode *inode)
-{
-	return 1;
-}
-
 /* Issue a layoutget in the same compound as OPEN
  */
 int
@@ -669,7 +649,6 @@ filelayout_get_io_threshold(struct pnfs_layout_type *layoutid, struct inode *ino
 }
 
 struct layoutdriver_io_operations filelayout_io_operations = {
-	.fsync                   = filelayout_fsync,
 	.commit                  = filelayout_commit,
 	.read_pagelist           = filelayout_read_pagelist,
 	.write_pagelist          = filelayout_write_pagelist,
@@ -684,7 +663,6 @@ struct layoutdriver_policy_operations filelayout_policy_operations = {
 	.get_stripesize        = filelayout_get_stripesize,
 	.gather_across_stripes = filelayout_gather_across_stripes,
 	.pg_test               = filelayout_pg_test,
-	.use_pagecache         = filelayout_use_pagecache,
 	.layoutget_on_open     = filelayout_layoutget_on_open,
 	.get_read_threshold    = filelayout_get_io_threshold,
 	.get_write_threshold   = filelayout_get_io_threshold,
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 9e54064..72c740f 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -583,29 +583,6 @@ pnfs_enabled_sb(struct nfs_server *nfss)
 	return 1;
 }
 
-/* Retrieve and return whether the layout driver wants I/O requests
- * to first travel through NFS I/O processing functions and the page
- * cache.  By default return 1;
- */
-static int
-use_page_cache(struct inode *inode)
-{
-	struct nfs_server *nfss = NFS_SERVER(inode);
-	struct nfs_inode *nfsi = NFS_I(inode);
-	int use_pagecache = 0;
-
-	if (!pnfs_enabled_sb(nfss) ||
-	    !nfss->pnfs_curr_ld->ld_policy_ops ||
-	    !nfss->pnfs_curr_ld->ld_policy_ops->use_pagecache)
-		return 1;
-
-	use_pagecache = nfss->pnfs_curr_ld->ld_policy_ops->use_pagecache(nfsi->current_layout, inode);
-	if (use_pagecache > 0)
-		return 1;
-	else
-		return 0;
-}
-
 /*
  * 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
@@ -1071,67 +1048,6 @@ int pnfs_try_to_read_data(struct nfs_read_data *data,
 	}
 }
 
-/*
- * Call the appropriate parallel I/O subsystem read function.
- * If no I/O device driver exists, or one does match the returned
- * fstype, then call regular NFS processing.
- */
-ssize_t
-pnfs_file_read(struct file *filp,
-	       char __user *buf,
-	       size_t count,
-	       loff_t *pos)
-{
-	struct dentry  *dentry = filp->f_dentry;
-	struct inode *inode = dentry->d_inode;
-	ssize_t result = count;
-	struct nfs_inode *nfsi = NFS_I(inode);
-	struct nfs_server *nfss = NFS_SERVER(inode);
-
-	dfprintk(IO, "%s:(%s/%s, %lu@%lu)\n",
-		 __FUNCTION__,
-		 dentry->d_parent->d_name.name,
-		 dentry->d_name.name,
-		 (unsigned long) count,
-		 (unsigned long) *pos);
-
-	/* Using NFS page cache with pNFS */
-	if (use_page_cache(inode))
-		goto fallback;
-
-	/* Small I/O Optimization */
-	if (below_threshold(inode, count, 0)) {
-		dfprintk(IO, "%s: Below Read threshold, using NFSv4 read\n", __FUNCTION__);
-		goto fallback;
-	}
-
-	/* Step 1: Retrieve and set layout if not allready cached*/
-	result = virtual_update_layout(inode,
-				(struct nfs_open_context *)filp->private_data,
-				count,
-				*pos,
-				IOMODE_READ);
-	if (result) {
-		dfprintk(IO, "%s: Could not get layout result=%Zd, using NFSv4 read\n", __FUNCTION__, result);
-		goto fallback;
-	}
-
-	/* Step 2: Call I/O device driver's read function */
-	if (!nfss->pnfs_curr_ld->ld_io_ops &&
-	    nfss->pnfs_curr_ld->ld_io_ops->read) {
-		dfprintk(IO, "%s: No LD read function, using NFSv4 read\n", __FUNCTION__);
-		goto fallback;
-	}
-
-	result = nfss->pnfs_curr_ld->ld_io_ops->read(nfsi->current_layout,
-						     filp, buf, count, pos);
-	dprintk("%s end (err:%Zd)\n", __FUNCTION__, result);
-	return result;
-
-fallback:
-	return do_sync_read(filp, buf, count, pos);
-}
-
 int pnfs_try_to_write_data(struct nfs_write_data *data,
 				const struct rpc_call_ops *call_ops, int how)
 {
@@ -1148,85 +1064,6 @@ int pnfs_try_to_write_data(struct nfs_write_data *data,
 	}
 }
 
-/*
- * Call the appropriate parallel I/O subsystem write function.
- * If no I/O device driver exists, or one does match the returned
- * fstype, then call regular NFS processing.
- */
-ssize_t
-pnfs_file_write(struct file *filp,
-		const char __user *buf,
-		size_t count,
-		loff_t *pos)
-{
-	struct dentry  *dentry = filp->f_dentry;
-	struct inode *inode = dentry->d_inode;
-	ssize_t result = count;
-	loff_t pos_orig = *pos;
-	const int isblk = S_ISBLK(inode->i_mode);
-	struct nfs_server *nfss = NFS_SERVER(inode);
-	struct nfs_inode *nfsi = NFS_I(inode);
-
-	dfprintk(IO, "%s:(%s/%s(%ld), %lu@%lu)\n",
-		 __FUNCTION__,
-		 dentry->d_parent->d_name.name,
-		 dentry->d_name.name,
-		 inode->i_ino,
-		 (unsigned long) count,
-		 (unsigned long) *pos);
-
-	/* Using NFS page cache with pNFS */
-	if (use_page_cache(inode))
-		goto fallback;
-
-	/* Small I/O Optimization */
-	if (below_threshold(inode, count, 1)) {
-		dfprintk(IO, "%s: Below write threshold, using NFSv4 write\n", __FUNCTION__);
-		goto fallback;
-	}
-
-	/* Need to adjust write param if this is an append, etc */
-	generic_write_checks(filp, pos, &count, isblk);
-
-	dprintk("%s:Readjusted %lu@%lu)\n", __FUNCTION__,
-		(unsigned long) count, (unsigned long) *pos);
-
-	/* Step 1: Retrieve and set layout if not allready cached */
-	result = virtual_update_layout(inode,
-				(struct nfs_open_context *)filp->private_data,
-				count,
-				*pos,
-				IOMODE_RW);
-	if (result) {
-		dfprintk(IO, "%s: Could not get layout result=%Zd, using NFSv4 write\n", __FUNCTION__, result);
-		goto fallback;
-	}
-
-	/* Step 2: Call I/O device driver's write function */
-	if (!nfss->pnfs_curr_ld->ld_io_ops &&
-	    nfss->pnfs_curr_ld->ld_io_ops->write) {
-		dfprintk(IO, "%s: No LD write function, using NFSv4 write\n", __FUNCTION__);
-		goto fallback;
-	}
-
-	result = nfss->pnfs_curr_ld->ld_io_ops->write(nfsi->current_layout,
-						      filp, buf, count, pos);
-
-	/* Update layoutcommit info.
-	 * TODO: This assumes the layout driver wrote synchronously.
-	 * This is fine for PVFS2, the only current layout driver to
-	 * use the read/write interface. */
-	if (result > 0) {
-		pnfs_update_last_write(nfsi, pos_orig, result);
-		pnfs_need_layoutcommit(nfsi, (struct nfs_open_context *)filp->private_data);
-	}
-	dprintk("%s end (err:%Zd)\n", __FUNCTION__, result);
-	return result;
-
-fallback:
-	return do_sync_write(filp, buf, count, pos);
-}
-
 int pnfs_try_to_commit(struct inode *inode, struct nfs_write_data *data, struct list_head *head, int how)
 {
 	int status;
@@ -1296,59 +1133,6 @@ pnfs_commit(struct inode *inode,
 }
 
 int
-pnfs_fsync(struct file *file, struct dentry *dentry, int datasync)
-{
-	int result = 0;
-	struct inode *inode = dentry->d_inode;
-	struct nfs_inode *nfsi = NFS_I(inode);
-	struct nfs_server *nfss = NFS_SERVER(inode);
-	dprintk("%s: Begin\n", __FUNCTION__);
-
-	/* pNFS is only for v4
-	 * Only fsync nfs if an outstanding nfs request requires it
-	 * Some problems seem to be happening if ncommit and ndirty
-	 * are both 0 and I still don't call nfs_fsync
-	 */
-	if (use_page_cache(inode)) {
-		dfprintk(IO, "%s: Calling nfs_fsync\n", __FUNCTION__);
-		result = nfs_fsync(file, dentry, datasync);
-		goto out;
-	}
-
-	if (!nfss->pnfs_curr_ld->ld_io_ops->fsync) {
-		dprintk("%s: Layoutdriver lacks fsync function!\n", __FUNCTION__);
-		result = -EIO;
-		goto out;
-	}
-
-	/* Retrieve and set layout if not allready cached.
-	 * This is necessary since read/write may not have necessarily
-	 * been already called.  Just put in any random count and offset.
-	 * TODO: May need special count and offset depending on how file system
-	 * work that actually pay attention to such values.
-	 */
-	result = virtual_update_layout(inode,
-				(struct nfs_open_context *)file->private_data,
-				0,
-				0,
-				IOMODE_RW);
-	if (result) {
-		result = -EIO;
-		goto out;
-	}
-
-	dprintk("%s: Calling layout driver fsync\n", __FUNCTION__);
-	result = nfss->pnfs_curr_ld->ld_io_ops->fsync(nfsi->current_layout,
-						      file,
-						      dentry,
-						      datasync);
-
-out:
-	dprintk("%s end (err:%d)\n", __FUNCTION__, result);
-	return result;
-}
-
-int
 pnfs_getdevicelist(struct super_block *sb, struct nfs_fh *fh,
 		   struct pnfs_devicelist *devlist)
 {
@@ -1563,7 +1347,6 @@ out_unlock:
 /* Callback operations for layout drivers.
  */
 struct pnfs_client_operations pnfs_ops = {
-	.nfs_fsync = nfs_fsync,
 	.nfs_getdevicelist = pnfs_getdevicelist,
 	.nfs_getdeviceinfo = pnfs_getdeviceinfo,
 	.nfs_readlist_complete = pnfs_read_done,
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index f1b5862..6a5931f 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -22,8 +22,6 @@ int pnfs_return_layout(struct inode *ino, struct nfs4_pnfs_layout_segment *range
 int pnfs_return_layout_rpc(struct nfs_server *server, struct nfs4_pnfs_layoutreturn_arg *argp);
 void set_pnfs_layoutdriver(struct super_block *sb, struct nfs_fh *fh, u32 id);
 void unmount_pnfs_layoutdriver(struct super_block *sb);
-ssize_t pnfs_file_write(struct file *filp, const char __user *buf, size_t count, loff_t *pos);
-ssize_t pnfs_file_read(struct file *filp, char __user *buf, size_t count, loff_t *pos);
 int pnfs_use_read(struct inode *inode, ssize_t count);
 int pnfs_use_ds_io(struct list_head *, struct inode *, int);
 
@@ -32,7 +30,6 @@ int pnfs_writepages(struct nfs_write_data *wdata, int how);
 int pnfs_try_to_write_data(struct nfs_write_data *, const struct rpc_call_ops *, int);
 int pnfs_readpages(struct nfs_read_data *rdata);
 int pnfs_try_to_read_data(struct nfs_read_data *data, const struct rpc_call_ops *call_ops);
-int pnfs_fsync(struct file *file, struct dentry *dentry, int datasync);
 int pnfs_initialize(void);
 void pnfs_uninitialize(void);
 void pnfs_layoutcommit_done(struct pnfs_layoutcommit_data *data, int status);
diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
index 529f522..941dda7 100644
--- a/include/linux/nfs4_pnfs.h
+++ b/include/linux/nfs4_pnfs.h
@@ -44,16 +44,7 @@ struct layoutdriver_io_operations {
 	ssize_t (*read_pagelist) (struct pnfs_layout_type *layoutid, struct inode *, struct page **pages, unsigned int pgbase, unsigned nr_pages, loff_t offset, size_t count, struct nfs_read_data *nfs_data);
 	ssize_t (*write_pagelist) (struct pnfs_layout_type *layoutid, struct inode *, struct page **pages, unsigned int pgbase, unsigned nr_pages, loff_t offset, size_t count, int sync, struct nfs_write_data *nfs_data);
 
-	/* Functions that do not use the pagecache.
-	 * If use_pagecache == 0, then these functions must be implemented.
-	 */
-	ssize_t (*read) (struct pnfs_layout_type *layoutid, struct file *, char __user *, size_t, loff_t *);
-	ssize_t (*write) (struct pnfs_layout_type *layoutid, struct file *, const char __user *, size_t, loff_t *);
-	ssize_t (*readv) (struct pnfs_layout_type *layoutid, struct file *, const struct iovec *, unsigned long, loff_t *);
-	ssize_t (*writev) (struct pnfs_layout_type *layoutid, struct file *, const struct iovec *, unsigned long, loff_t *);
-
 	/* Consistency ops */
-	int (*fsync) (struct pnfs_layout_type *layoutid, struct file *, struct dentry *, int);
 	/* 2 problems:
 	 * 1) the page list contains nfs_pages, NOT pages
 	 * 2) currently the NFS code doesn't create a page array (as it does with read/write)
@@ -102,11 +93,6 @@ struct layoutdriver_policy_operations {
 	/* Write requests under this value are sent to the NFSv4 server */
 	ssize_t (*get_write_threshold) (struct pnfs_layout_type *, struct inode *);
 
-	/* Use the linux page cache prior to calling layout driver
-	 * read/write functions
-	 */
-	int (*use_pagecache) (struct pnfs_layout_type *, struct inode *);
-
 	/* Should the pNFS client issue a layoutget call in the
 	 * same compound as the OPEN operation?
 	 */
@@ -146,7 +132,6 @@ struct pnfs_devicelist {
  * E.g., getdeviceinfo, I/O callbacks, etc
  */
 struct pnfs_client_operations {
-	int (*nfs_fsync) (struct file *file, struct dentry *dentry, int datasync);
 	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);
 
-- 
1.5.3.3



More information about the pNFS mailing list