[pnfs] pnfs/gfs2 stubs

Frank Filz ffilzlnx at us.ibm.com
Mon May 5 14:09:27 EDT 2008


And here's what I was working on before, it includes an attempt at a
stub for get_device_iter:

diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index 334c7f8..ab54fc9 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -15,6 +15,17 @@
 #include <linux/gfs2_ondisk.h>
 #include <linux/crc32.h>
 #include <linux/lm_interface.h>
+#ifdef CONFIG_PNFSD
+#include <linux/nfs4.h>
+#include <linux/sunrpc/svc.h>
+#include <linux/nfsd/nfsfh.h>
+#include <linux/nfsd/state.h>
+#include <linux/nfsd/nfsd4_pnfs.h>
+#include <linux/nfsd/pnfsd.h>
+#include <linux/nfs_fs.h>
+#include <linux/nfs4_pnfs.h>
+#include <linux/nfsd/nfs4layoutxdr.h>
+#endif
 
 #include "gfs2.h"
 #include "incore.h"
@@ -294,11 +305,155 @@ static struct dentry *gfs2_fh_to_parent(struct super_block *sb, struct fid *fid,
 	}
 }
 
+#ifdef CONFIG_PNFSD
+/* Retrieve and encode a layout onto the xdr stream.
+ * Args:
+ * inode - inode for which to retrieve layout
+ * arg.xdr - xdr stream for encoding
+ * arg.func - Optional function called by file system to encode
+ * layout on xdr stream.
+ */
+static int gfs2_layout_get(struct inode *inode,
+			   struct pnfs_layoutget_arg *arg)
+{
+	int i, left, fhlen;
+	struct pnfs_filelayout_layout *layout = NULL;
+	struct knfsd_fh *fh_list = NULL;
+	int rc = 0;
+	int num_dests = 1;			/*FSFTEMP*/
+
+	printk(KERN_WARNING "gfs2_layout_get got here!\n");
+	/* Set layout indep response args */
+	arg->seg.layout_type = LAYOUT_NFSV4_FILES;
+	arg->seg.offset = 0;
+	arg->seg.length = inode->i_sb->s_maxbytes;        /* The maximum file size */
+
+	fhlen = sizeof(struct knfsd_fh) * num_dests;
+	left = arg->xdr.maxcount - sizeof(struct pnfs_filelayout_layout) - fhlen;
+	if (left < 0) {
+		rc = -ETOOSMALL;
+		goto error;
+	}
+
+	layout = kmalloc(sizeof(struct pnfs_filelayout_layout), GFP_KERNEL);
+	if (layout == NULL) {
+		rc = -ENOMEM;
+		goto error;
+	}
+
+	/* Set file layout response args */
+	layout->lg_layout_type = LAYOUT_NFSV4_FILES;
+	layout->lg_stripe_type = STRIPE_SPARSE;
+	layout->lg_commit_through_mds = true;
+	layout->lg_stripe_unit = inode->i_sb->s_blocksize;	/*preferred size*/
+	layout->lg_fh_length = num_dests;
+	layout->device_id.pnfs_fsid = arg->fsid;
+	layout->device_id.pnfs_devid = 1;			/*FSFTEMP*/
+	layout->lg_first_stripe_index = 0;			/*FSFTEMP*/
+
+	fh_list = kmalloc(fhlen, GFP_KERNEL);
+	if (fh_list == NULL) {
+		rc = -ENOMEM;
+		goto error;
+	}
+
+	memset(fh_list, 0, fhlen);
+	layout->lg_fh_list = fh_list;
+
+	for (i = 0; i < num_dests; i++)
+		memcpy(&fh_list[i], arg->fh, sizeof(struct knfsd_fh));
+
+	/* Call nfsd code to encode layout */
+	rc = arg->func(&arg->xdr, layout);
+
+exit:
+	if (layout)
+		kfree(layout);
+	if (fh_list)
+		kfree(fh_list);
+	return rc;
+
+error:
+	arg->seg.length = 0;
+	goto exit;
+}
+
+/* pNFS: commit changes to layout */
+static int gfs2_layout_commit(struct inode *inode, void *p)
+{
+	return 0;
+}
+
+/* pNFS: returns the layout */
+static int gfs2_layout_return(struct inode *inode, void *p)
+{
+	return 0;
+}
+
+/* pNFS: Returns the supported pnfs_layouttype4. */
+static int gfs2_layout_type(void)
+{
+	return LAYOUT_NFSV4_FILES;
+}
+
+static int gfs2_get_state(struct inode *inode, void *fh, void *state)
+{
+	return 0;
+}
+
+/* pNFS: returns the verifier */
+static void gfs2_get_verifier(struct super_block *sb, u32 *p)
+{
+}
+
+static
+int gfs2_get_device_iter(struct super_block *sb, struct pnfs_deviter_arg *arg)
+{
+	/* If this is the first invocation, return the only device id
+	 * (for now at least) and update the cookie.
+	 * With a single devid, the client will never call getdevicelist
+	 * more than once, so the verifier can be ignored.
+	 * Else indicate there are no more devices
+	 */
+	printk(KERN_WARNING "gfs2_get_device_iter\n");
+	if (arg->cookie == 0) {
+		arg->devid = 0;
+		arg->cookie = 1;  // incr for next invocation
+	} else {
+		arg->eof = 1;
+	}
+	return 0;
+}
+
+static int
+gfs2_get_deviceinfo(struct super_block *sb,
+		    struct pnfs_devinfo_arg *arg)
+{
+  int rc;
+
+  rc = gpfs_ops.gpfsGetDeviceInfo(privVfsP, arg);
+
+
+xerror:
+
+  return rc;
+}
+#endif
+
 const struct export_operations gfs2_export_ops = {
 	.encode_fh = gfs2_encode_fh,
 	.fh_to_dentry = gfs2_fh_to_dentry,
 	.fh_to_parent = gfs2_fh_to_parent,
 	.get_name = gfs2_get_name,
 	.get_parent = gfs2_get_parent,
+#ifdef CONFIG_PNFSD
+	.get_device_iter = gfs2_get_device_iter,
+	.layout_get = gfs2_layout_get,
+//	.get_deviceinfo = gfs2_get_deviceinfo,
+	.layout_return = gfs2_layout_return,
+	.get_state = gfs2_get_state,
+	.layout_type = gfs2_layout_type,
+	.get_verifier = gfs2_get_verifier,
+#endif
 };
 




More information about the pNFS mailing list