[pnfs] [PATCH 04/37] pnfs: simplify pnfs_getboundary

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


pnfs_getboundary made static, no need to check for pnfs_enabled_sb,
since that's done in its only caller - pnfs_set_ds_rsize.

optimized checks for policy_ops and LD methods used.

Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
 fs/nfs/pnfs.c |   50 ++++++++++++++++++++++++++------------------------
 fs/nfs/pnfs.h |    1 -
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 7514472..9e54064 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -661,6 +661,32 @@ pnfs_set_pg_test(struct inode *inode, struct nfs_pageio_descriptor *pgio)
 	}
 }
 
+static u32
+pnfs_getboundary(struct inode *inode)
+{
+	u32 stripe_size = 0;
+	struct nfs_server *nfss = NFS_SERVER(inode);
+	struct layoutdriver_policy_operations *policy_ops;
+	struct nfs_inode *nfsi;
+	struct pnfs_layout_type *lo;
+
+	policy_ops = nfss->pnfs_curr_ld->ld_policy_ops;
+	if (!policy_ops || !policy_ops->get_stripesize)
+		goto out;
+
+	/* The default is to not gather across stripes */
+	if (policy_ops->gather_across_stripes &&
+	    policy_ops->gather_across_stripes(nfss->pnfs_mountid))
+		goto out;
+
+	nfsi = NFS_I(inode);
+	lo = nfsi->current_layout;
+	if (lo)
+		stripe_size = policy_ops->get_stripesize(lo, inode);
+out:
+	return stripe_size;
+}
+
 /*
  * rsize is already set by caller to MDS rsize.
  */
@@ -810,30 +836,6 @@ pnfs_use_nfsv4_rproto(struct inode *inode, ssize_t count)
 	return 0;
 }
 
-u32
-pnfs_getboundary(struct inode *inode)
-{
-	struct pnfs_layout_type *laytype;
-	struct layoutdriver_policy_operations *policy_ops;
-	struct pnfs_layoutdriver_type *ld;
-
-	laytype = NFS_I(inode)->current_layout;
-	ld = NFS_SERVER(inode)->pnfs_curr_ld;
-	if (!pnfs_enabled_sb(NFS_SERVER(inode)) || !laytype)
-		return 0;
-	policy_ops = ld->ld_policy_ops;
-
-	/* The default is to not gather across stripes */
-	if (policy_ops && policy_ops->gather_across_stripes) {
-		if (policy_ops->gather_across_stripes(laytype->mountid))
-			return 0;
-	}
-	if (policy_ops && policy_ops->get_stripesize)
-		return policy_ops->get_stripesize(laytype, inode);
-
-	return 0; /* Gather up to wsize/rsize */
-}
-
 /* 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.
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 4309918..7e2be52 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -33,7 +33,6 @@ int pnfs_try_to_write_data(struct nfs_write_data *, const struct rpc_call_ops *,
 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);
-unsigned int pnfs_getboundary(struct inode *inode);
 unsigned int pnfs_getpages(struct inode *inode, int iswrite);
 int pnfs_initialize(void);
 void pnfs_uninitialize(void);
-- 
1.5.3.3



More information about the pNFS mailing list