diff mbox series

[10/14] nfsd: implement the xattr procedure functions.

Message ID 20200311195954.27117-11-fllinden@amazon.com (mailing list archive)
State New, archived
Headers show
Series server side user xattr support (RFC 8276) | expand

Commit Message

Frank van der Linden March 11, 2020, 7:59 p.m. UTC
Implement the main entry points for the *XATTR operations.

Signed-off-by: Frank van der Linden <fllinden@amazon.com>
---
 fs/nfsd/nfs4proc.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfsd/nfs4xdr.c  |  2 ++
 2 files changed, 75 insertions(+)

Comments

kernel test robot March 12, 2020, 10:28 a.m. UTC | #1
Hi Frank,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on nfsd/nfsd-next]
[also build test WARNING on nfs/linux-next linus/master v5.6-rc5 next-20200311]
[cannot apply to cel/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Frank-van-der-Linden/server-side-user-xattr-support-RFC-8276/20200312-064928
base:   git://linux-nfs.org/~bfields/linux.git nfsd-next
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-174-g094d5a94-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

   fs/nfsd/nfs4proc.c:1541:24: sparse: sparse: incorrect type in assignment (different base types) @@    expected restricted __be32 [assigned] [usertype] status @@    got e] status @@
   fs/nfsd/nfs4proc.c:1541:24: sparse:    expected restricted __be32 [assigned] [usertype] status
   fs/nfsd/nfs4proc.c:1541:24: sparse:    got int
>> fs/nfsd/nfs4proc.c:2122:13: sparse: sparse: incorrect type in assignment (different base types) @@    expected int ret @@    got restricted __int ret @@
>> fs/nfsd/nfs4proc.c:2122:13: sparse:    expected int ret
>> fs/nfsd/nfs4proc.c:2122:13: sparse:    got restricted __be32
>> fs/nfsd/nfs4proc.c:2129:16: sparse: sparse: incorrect type in return expression (different base types) @@    expected restricted __be32 @@    got be32 @@
>> fs/nfsd/nfs4proc.c:2129:16: sparse:    expected restricted __be32
>> fs/nfsd/nfs4proc.c:2129:16: sparse:    got int ret
   fs/nfsd/nfs4proc.c:2145:13: sparse: sparse: incorrect type in assignment (different base types) @@    expected int ret @@    got restricted __int ret @@
   fs/nfsd/nfs4proc.c:2145:13: sparse:    expected int ret
   fs/nfsd/nfs4proc.c:2145:13: sparse:    got restricted __be32
   fs/nfsd/nfs4proc.c:2148:24: sparse: sparse: incorrect type in return expression (different base types) @@    expected restricted __be32 @@    got be32 @@
   fs/nfsd/nfs4proc.c:2148:24: sparse:    expected restricted __be32
   fs/nfsd/nfs4proc.c:2148:24: sparse:    got int ret
   fs/nfsd/nfs4proc.c:2165:13: sparse: sparse: incorrect type in assignment (different base types) @@    expected int ret @@    got restricted __int ret @@
   fs/nfsd/nfs4proc.c:2165:13: sparse:    expected int ret
   fs/nfsd/nfs4proc.c:2165:13: sparse:    got restricted __be32
   fs/nfsd/nfs4proc.c:2171:16: sparse: sparse: incorrect type in return expression (different base types) @@    expected restricted __be32 @@    got be32 @@
   fs/nfsd/nfs4proc.c:2171:16: sparse:    expected restricted __be32
   fs/nfsd/nfs4proc.c:2171:16: sparse:    got int ret

vim +2122 fs/nfsd/nfs4proc.c

  2111	
  2112	static __be32
  2113	nfsd4_setxattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
  2114		   union nfsd4_op_u *u)
  2115	{
  2116		struct nfsd4_setxattr *setxattr = &u->setxattr;
  2117		int ret;
  2118	
  2119		if (opens_in_grace(SVC_NET(rqstp)))
  2120			return nfserr_grace;
  2121	
> 2122		ret = nfsd_setxattr(rqstp, &cstate->current_fh, setxattr->setxa_name,
  2123				    setxattr->setxa_buf, setxattr->setxa_len,
  2124				    setxattr->setxa_flags);
  2125	
  2126		if (!ret)
  2127			set_change_info(&setxattr->setxa_cinfo, &cstate->current_fh);
  2128	
> 2129		return ret;
  2130	}
  2131	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Chuck Lever March 12, 2020, 4:24 p.m. UTC | #2
> On Mar 11, 2020, at 3:59 PM, Frank van der Linden <fllinden@amazon.com> wrote:
> 
> Implement the main entry points for the *XATTR operations.

This patch triggers "defined but not used" compiler warnings.
These new functions need to be introduced in the same patch
that adds their callsites.

You might consider squashing together all the patches that
only add new NFSD code, for instance.


> Signed-off-by: Frank van der Linden <fllinden@amazon.com>
> ---
> fs/nfsd/nfs4proc.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> fs/nfsd/nfs4xdr.c  |  2 ++
> 2 files changed, 75 insertions(+)
> 
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index b573ae1121af..a76b9025a357 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -2098,6 +2098,79 @@ nfsd4_layoutreturn(struct svc_rqst *rqstp,
> }
> #endif /* CONFIG_NFSD_PNFS */
> 
> +static __be32
> +nfsd4_getxattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> +	       union nfsd4_op_u *u)
> +{
> +	struct nfsd4_getxattr *getxattr = &u->getxattr;
> +
> +	return nfsd_getxattr(rqstp, &cstate->current_fh,
> +			     getxattr->getxa_name, getxattr->getxa_buf,
> +			     &getxattr->getxa_len);
> +}
> +
> +static __be32
> +nfsd4_setxattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> +	   union nfsd4_op_u *u)
> +{
> +	struct nfsd4_setxattr *setxattr = &u->setxattr;
> +	int ret;
> +
> +	if (opens_in_grace(SVC_NET(rqstp)))
> +		return nfserr_grace;
> +
> +	ret = nfsd_setxattr(rqstp, &cstate->current_fh, setxattr->setxa_name,
> +			    setxattr->setxa_buf, setxattr->setxa_len,
> +			    setxattr->setxa_flags);
> +
> +	if (!ret)
> +		set_change_info(&setxattr->setxa_cinfo, &cstate->current_fh);
> +
> +	return ret;
> +}
> +
> +static __be32
> +nfsd4_listxattrs(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> +	   union nfsd4_op_u *u)
> +{
> +	int ret, len;
> +
> +	/*
> +	 * Get the entire list, then copy out only the user attributes
> +	 * in the encode function. lsxa_buf was previously allocated as
> +	 * tmp svc space, and will be automatically freed later.
> +	 */
> +	len = XATTR_LIST_MAX;
> +
> +	ret = nfsd_listxattr(rqstp, &cstate->current_fh, u->listxattrs.lsxa_buf,
> +			     &len);
> +	if (ret)
> +		return ret;
> +
> +	u->listxattrs.lsxa_len = len;
> +
> +	return nfs_ok;
> +}
> +
> +static __be32
> +nfsd4_removexattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
> +	   union nfsd4_op_u *u)
> +{
> +	struct nfsd4_removexattr *removexattr = &u->removexattr;
> +	int ret;
> +
> +	if (opens_in_grace(SVC_NET(rqstp)))
> +		return nfserr_grace;
> +
> +	ret = nfsd_removexattr(rqstp, &cstate->current_fh,
> +	    removexattr->rmxa_name);
> +
> +	if (!ret)
> +		set_change_info(&removexattr->rmxa_cinfo, &cstate->current_fh);
> +
> +	return ret;
> +}
> +
> /*
>  * NULL call.
>  */
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index f6322add2992..b12d7ac6f52c 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -41,6 +41,8 @@
> #include <linux/pagemap.h>
> #include <linux/sunrpc/svcauth_gss.h>
> #include <linux/sunrpc/addr.h>
> +#include <linux/xattr.h>
> +#include <uapi/linux/xattr.h>
> 
> #include "idmap.h"
> #include "acl.h"
> -- 
> 2.16.6
> 

--
Chuck Lever
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index b573ae1121af..a76b9025a357 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -2098,6 +2098,79 @@  nfsd4_layoutreturn(struct svc_rqst *rqstp,
 }
 #endif /* CONFIG_NFSD_PNFS */
 
+static __be32
+nfsd4_getxattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
+	       union nfsd4_op_u *u)
+{
+	struct nfsd4_getxattr *getxattr = &u->getxattr;
+
+	return nfsd_getxattr(rqstp, &cstate->current_fh,
+			     getxattr->getxa_name, getxattr->getxa_buf,
+			     &getxattr->getxa_len);
+}
+
+static __be32
+nfsd4_setxattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
+	   union nfsd4_op_u *u)
+{
+	struct nfsd4_setxattr *setxattr = &u->setxattr;
+	int ret;
+
+	if (opens_in_grace(SVC_NET(rqstp)))
+		return nfserr_grace;
+
+	ret = nfsd_setxattr(rqstp, &cstate->current_fh, setxattr->setxa_name,
+			    setxattr->setxa_buf, setxattr->setxa_len,
+			    setxattr->setxa_flags);
+
+	if (!ret)
+		set_change_info(&setxattr->setxa_cinfo, &cstate->current_fh);
+
+	return ret;
+}
+
+static __be32
+nfsd4_listxattrs(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
+	   union nfsd4_op_u *u)
+{
+	int ret, len;
+
+	/*
+	 * Get the entire list, then copy out only the user attributes
+	 * in the encode function. lsxa_buf was previously allocated as
+	 * tmp svc space, and will be automatically freed later.
+	 */
+	len = XATTR_LIST_MAX;
+
+	ret = nfsd_listxattr(rqstp, &cstate->current_fh, u->listxattrs.lsxa_buf,
+			     &len);
+	if (ret)
+		return ret;
+
+	u->listxattrs.lsxa_len = len;
+
+	return nfs_ok;
+}
+
+static __be32
+nfsd4_removexattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
+	   union nfsd4_op_u *u)
+{
+	struct nfsd4_removexattr *removexattr = &u->removexattr;
+	int ret;
+
+	if (opens_in_grace(SVC_NET(rqstp)))
+		return nfserr_grace;
+
+	ret = nfsd_removexattr(rqstp, &cstate->current_fh,
+	    removexattr->rmxa_name);
+
+	if (!ret)
+		set_change_info(&removexattr->rmxa_cinfo, &cstate->current_fh);
+
+	return ret;
+}
+
 /*
  * NULL call.
  */
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index f6322add2992..b12d7ac6f52c 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -41,6 +41,8 @@ 
 #include <linux/pagemap.h>
 #include <linux/sunrpc/svcauth_gss.h>
 #include <linux/sunrpc/addr.h>
+#include <linux/xattr.h>
+#include <uapi/linux/xattr.h>
 
 #include "idmap.h"
 #include "acl.h"