diff mbox

[RFC,v0,29/49] pnfsd: support layout_type attribute

Message ID 1380220908-14009-1-git-send-email-bhalevy@primarydata.com (mailing list archive)
State New, archived
Headers show

Commit Message

Benny Halevy Sept. 26, 2013, 6:41 p.m. UTC
From: Benny Halevy <bhalevy@panasas.com>

Provide for getting the (read-only) layout_type attribute

[extraced from pnfsd: Initial pNFS server implementation.]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[pnfsd: Add super block to layout_type()]
Signed-off-by: Marc Eshel <eshel@almaden.ibm.com>
[pnfsd: convert generic code to use new pnfs api]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[Remove the use of struct pnfs_export_operations.]
[pnfsd: support layout_type attribute all layout types]
[pnfsd: check ex_pnfs in nfsd4_verify_layout]
Signed-off-by: Andy Adamson <andros@netapp.com>
[pnfsd: handle s_pnfs_op==NULL]
[pnfsd: test layout_type method in nfsd4_encode_fattr]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Benny Halevy <bhalevy@primarydata.com>
---
 fs/nfsd/nfs4xdr.c | 24 ++++++++++++++++++++++++
 fs/nfsd/nfsd.h    |  5 +++++
 2 files changed, 29 insertions(+)

Comments

Christoph Hellwig Sept. 29, 2013, 12:17 p.m. UTC | #1
Seems like layout_type should just be a field in the export ops instead
of a method.

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Boaz Harrosh Oct. 1, 2013, 1:21 a.m. UTC | #2
On 09/29/2013 05:17 AM, Christoph Hellwig wrote:
> Seems like layout_type should just be a field in the export ops instead
> of a method.

No! this field does not make any sense at all it should just be
removed.

There is a pNFS inquiry a client sends that asks for an array
of all the types supported by this mount point. So these method
should be returning an array. If at all.

The layout_type is just an input to some operations and are
no concern of NFSD. This is not a yes/no flag for pNFS the
opts vector should be the flag.

Cheers
Boaz

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benny Halevy Oct. 1, 2013, 8:32 a.m. UTC | #3
On 2013-10-01 04:21, Boaz Harrosh wrote:
> On 09/29/2013 05:17 AM, Christoph Hellwig wrote:
>> Seems like layout_type should just be a field in the export ops instead
>> of a method.
> 
> No! this field does not make any sense at all it should just be
> removed.
> 
> There is a pNFS inquiry a client sends that asks for an array
> of all the types supported by this mount point. So these method
> should be returning an array. If at all.

We're not there yet.
The pnfs generic implementation and none of the filesystems do that
at the moment.  When we go there we should revise the interface.

> 
> The layout_type is just an input to some operations and are
> no concern of NFSD. This is not a yes/no flag for pNFS the
> opts vector should be the flag.

We can push the check for the layout type down to file system
but then it will have to encode FATTR4_WORD1_FS_LAYOUT_TYPES
and FATTR4_WORD2_LAYOUT_TYPES.

Benny

> 
> Cheers
> Boaz
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index b9c4417..83f7147 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2560,6 +2560,30 @@  static int get_parent_attributes(struct svc_export *exp, struct kstat *stat)
 			get_parent_attributes(exp, &stat);
 		WRITE64(stat.ino);
 	}
+#if defined(CONFIG_PNFSD)
+	if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) {
+		struct super_block *sb = dentry->d_inode->i_sb;
+		int type = 0;
+
+		/* Query the filesystem for supported pNFS layout types.
+		 * Currently, we only support one layout type per file system.
+		 * The export_ops->layout_type() returns the pnfs_layouttype4.
+		 */
+		buflen -= 4;
+		if (buflen < 0)		/* length */
+			goto out_resource;
+
+		if (sb && sb->s_pnfs_op && sb->s_pnfs_op->layout_type)
+			type = sb->s_pnfs_op->layout_type(sb);
+		if (type) {
+			if ((buflen -= 4) < 0)	/* type */
+				goto out_resource;
+			WRITE32(1);	/* length */
+			WRITE32(type);  /* type */
+		} else
+			WRITE32(0);  /* length */
+	}
+#endif /* CONFIG_PNFSD */
 	if (bmval2 & FATTR4_WORD2_SECURITY_LABEL) {
 		status = nfsd4_encode_security_label(rqstp, context,
 				contextlen, &p, &buflen);
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 30f34ab..f49fb0b 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -321,8 +321,13 @@  static inline void nfs4_reset_lease(time_t leasetime) { }
 #define NFSD4_1_SUPPORTED_ATTRS_WORD0 \
 	NFSD4_SUPPORTED_ATTRS_WORD0
 
+#if defined(CONFIG_PNFSD)
+#define NFSD4_1_SUPPORTED_ATTRS_WORD1 \
+	(NFSD4_SUPPORTED_ATTRS_WORD1 | FATTR4_WORD1_FS_LAYOUT_TYPES)
+#else /* CONFIG_PNFSD */
 #define NFSD4_1_SUPPORTED_ATTRS_WORD1 \
 	NFSD4_SUPPORTED_ATTRS_WORD1
+#endif /* CONFIG_PNFSD */
 
 #define NFSD4_1_SUPPORTED_ATTRS_WORD2 \
 	(NFSD4_SUPPORTED_ATTRS_WORD2 | FATTR4_WORD2_SUPPATTR_EXCLCREAT)