[pnfs] [PATCH 08/12] pnfsd-lexp: layout_get
Benny Halevy
bhalevy at panasas.com
Mon Jun 16 14:25:45 EDT 2008
Signed-off-by: Benny Halevy <bhalevy at panasas.com>
---
fs/nfsd/pnfsd_lexp.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/fs/nfsd/pnfsd_lexp.c b/fs/nfsd/pnfsd_lexp.c
index 5dc48dc..1d6cb08 100644
--- a/fs/nfsd/pnfsd_lexp.c
+++ b/fs/nfsd/pnfsd_lexp.c
@@ -124,4 +124,64 @@ out:
return err;
}
+static int get_stripe_unit(int blocksize)
+{
+ if (blocksize < NFSSVC_MAXBLKSIZE)
+ blocksize = NFSSVC_MAXBLKSIZE - (NFSSVC_MAXBLKSIZE % blocksize);
+ dprintk("%s: return %d\n", __func__, blocksize);
+ return blocksize;
+}
+
+static int pnfsd_lexp_layout_get(struct inode *inode, struct pnfs_layoutget_arg *arg)
+{
+ int rc = 0;
+ struct pnfs_filelayout_layout *layout = NULL;
+ struct knfsd_fh *fhp = NULL;
+
+ dprintk("--> %s: inode=%p\n", __func__, inode);
+
+ arg->seg.layout_type = LAYOUT_NFSV4_FILES;
+ arg->seg.offset = 0;
+ arg->seg.length = NFS4_LENGTH_EOF;
+
+ layout = kzalloc(sizeof(*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 = get_stripe_unit(inode->i_sb->s_blocksize);
+ layout->lg_fh_length = 1;
+ layout->device_id.pnfs_fsid = arg->fsid;
+ layout->device_id.pnfs_devid = 1; /*FSFTEMP*/
+ layout->lg_first_stripe_index = 0; /*FSFTEMP*/
+ layout->lg_pattern_offset = 0;
+
+ fhp = kmalloc(sizeof(*fhp), GFP_KERNEL);
+ if (fhp == NULL) {
+ rc = -ENOMEM;
+ goto error;
+ }
+
+ memcpy(fhp, arg->fh, sizeof(*fhp));
+ pnfs_fh_mark_ds(fhp);
+ layout->lg_fh_list = fhp;
+
+ /* Call nfsd to encode layout */
+ rc = arg->func(&arg->xdr, layout);
+exit:
+ kfree(layout);
+ kfree(fhp);
+ dprintk("<-- %s: return %d\n", __func__, rc);
+ return rc;
+
+error:
+ arg->seg.length = 0;
+ goto exit;
+}
+
#endif /* CONFIG_PNFSD_LOCAL_EXPORT */
--
1.5.3.3
More information about the pNFS
mailing list