hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/nfsd/nfs3acl.c
....@@ -13,15 +13,13 @@
1313 #include "xdr3.h"
1414 #include "vfs.h"
1515
16
-#define RETURN_STATUS(st) { resp->status = (st); return (st); }
17
-
1816 /*
1917 * NULL call.
2018 */
2119 static __be32
2220 nfsd3_proc_null(struct svc_rqst *rqstp)
2321 {
24
- return nfs_ok;
22
+ return rpc_success;
2523 }
2624
2725 /*
....@@ -34,17 +32,18 @@
3432 struct posix_acl *acl;
3533 struct inode *inode;
3634 svc_fh *fh;
37
- __be32 nfserr = 0;
3835
3936 fh = fh_copy(&resp->fh, &argp->fh);
40
- nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
41
- if (nfserr)
42
- RETURN_STATUS(nfserr);
37
+ resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP);
38
+ if (resp->status != nfs_ok)
39
+ goto out;
4340
4441 inode = d_inode(fh->fh_dentry);
4542
46
- if (argp->mask & ~NFS_ACL_MASK)
47
- RETURN_STATUS(nfserr_inval);
43
+ if (argp->mask & ~NFS_ACL_MASK) {
44
+ resp->status = nfserr_inval;
45
+ goto out;
46
+ }
4847 resp->mask = argp->mask;
4948
5049 if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
....@@ -54,7 +53,7 @@
5453 acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
5554 }
5655 if (IS_ERR(acl)) {
57
- nfserr = nfserrno(PTR_ERR(acl));
56
+ resp->status = nfserrno(PTR_ERR(acl));
5857 goto fail;
5958 }
6059 resp->acl_access = acl;
....@@ -64,19 +63,20 @@
6463 of a non-directory! */
6564 acl = get_acl(inode, ACL_TYPE_DEFAULT);
6665 if (IS_ERR(acl)) {
67
- nfserr = nfserrno(PTR_ERR(acl));
66
+ resp->status = nfserrno(PTR_ERR(acl));
6867 goto fail;
6968 }
7069 resp->acl_default = acl;
7170 }
7271
7372 /* resp->acl_{access,default} are released in nfs3svc_release_getacl. */
74
- RETURN_STATUS(0);
73
+out:
74
+ return rpc_success;
7575
7676 fail:
7777 posix_acl_release(resp->acl_access);
7878 posix_acl_release(resp->acl_default);
79
- RETURN_STATUS(nfserr);
79
+ goto out;
8080 }
8181
8282 /*
....@@ -88,12 +88,11 @@
8888 struct nfsd3_attrstat *resp = rqstp->rq_resp;
8989 struct inode *inode;
9090 svc_fh *fh;
91
- __be32 nfserr = 0;
9291 int error;
9392
9493 fh = fh_copy(&resp->fh, &argp->fh);
95
- nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
96
- if (nfserr)
94
+ resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR);
95
+ if (resp->status != nfs_ok)
9796 goto out;
9897
9998 inode = d_inode(fh->fh_dentry);
....@@ -113,13 +112,13 @@
113112 fh_unlock(fh);
114113 fh_drop_write(fh);
115114 out_errno:
116
- nfserr = nfserrno(error);
115
+ resp->status = nfserrno(error);
117116 out:
118117 /* argp->acl_{access,default} may have been allocated in
119118 nfs3svc_decode_setaclargs. */
120119 posix_acl_release(argp->acl_access);
121120 posix_acl_release(argp->acl_default);
122
- RETURN_STATUS(nfserr);
121
+ return rpc_success;
123122 }
124123
125124 /*
....@@ -174,6 +173,7 @@
174173 struct nfsd3_getaclres *resp = rqstp->rq_resp;
175174 struct dentry *dentry = resp->fh.fh_dentry;
176175
176
+ *p++ = resp->status;
177177 p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
178178 if (resp->status == 0 && dentry && d_really_is_positive(dentry)) {
179179 struct inode *inode = d_inode(dentry);
....@@ -218,8 +218,8 @@
218218 {
219219 struct nfsd3_attrstat *resp = rqstp->rq_resp;
220220
221
+ *p++ = resp->status;
221222 p = nfs3svc_encode_post_op_attr(rqstp, p, &resp->fh);
222
-
223223 return xdr_ressize_check(rqstp, p);
224224 }
225225
....@@ -235,33 +235,43 @@
235235 posix_acl_release(resp->acl_default);
236236 }
237237
238
-#define nfs3svc_decode_voidargs NULL
239
-#define nfs3svc_release_void NULL
240
-#define nfsd3_setaclres nfsd3_attrstat
241
-#define nfsd3_voidres nfsd3_voidargs
242238 struct nfsd3_voidargs { int dummy; };
243
-
244
-#define PROC(name, argt, rest, relt, cache, respsize) \
245
-{ \
246
- .pc_func = nfsd3_proc_##name, \
247
- .pc_decode = nfs3svc_decode_##argt##args, \
248
- .pc_encode = nfs3svc_encode_##rest##res, \
249
- .pc_release = nfs3svc_release_##relt, \
250
- .pc_argsize = sizeof(struct nfsd3_##argt##args), \
251
- .pc_ressize = sizeof(struct nfsd3_##rest##res), \
252
- .pc_cachetype = cache, \
253
- .pc_xdrressize = respsize, \
254
-}
255239
256240 #define ST 1 /* status*/
257241 #define AT 21 /* attributes */
258242 #define pAT (1+AT) /* post attributes - conditional */
259243 #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */
260244
261
-static const struct svc_procedure nfsd_acl_procedures3[] = {
262
- PROC(null, void, void, void, RC_NOCACHE, ST),
263
- PROC(getacl, getacl, getacl, getacl, RC_NOCACHE, ST+1+2*(1+ACL)),
264
- PROC(setacl, setacl, setacl, fhandle, RC_NOCACHE, ST+pAT),
245
+static const struct svc_procedure nfsd_acl_procedures3[3] = {
246
+ [ACLPROC3_NULL] = {
247
+ .pc_func = nfsd3_proc_null,
248
+ .pc_decode = nfs3svc_decode_voidarg,
249
+ .pc_encode = nfs3svc_encode_voidres,
250
+ .pc_argsize = sizeof(struct nfsd3_voidargs),
251
+ .pc_ressize = sizeof(struct nfsd3_voidargs),
252
+ .pc_cachetype = RC_NOCACHE,
253
+ .pc_xdrressize = ST,
254
+ },
255
+ [ACLPROC3_GETACL] = {
256
+ .pc_func = nfsd3_proc_getacl,
257
+ .pc_decode = nfs3svc_decode_getaclargs,
258
+ .pc_encode = nfs3svc_encode_getaclres,
259
+ .pc_release = nfs3svc_release_getacl,
260
+ .pc_argsize = sizeof(struct nfsd3_getaclargs),
261
+ .pc_ressize = sizeof(struct nfsd3_getaclres),
262
+ .pc_cachetype = RC_NOCACHE,
263
+ .pc_xdrressize = ST+1+2*(1+ACL),
264
+ },
265
+ [ACLPROC3_SETACL] = {
266
+ .pc_func = nfsd3_proc_setacl,
267
+ .pc_decode = nfs3svc_decode_setaclargs,
268
+ .pc_encode = nfs3svc_encode_setaclres,
269
+ .pc_release = nfs3svc_release_fhandle,
270
+ .pc_argsize = sizeof(struct nfsd3_setaclargs),
271
+ .pc_ressize = sizeof(struct nfsd3_attrstat),
272
+ .pc_cachetype = RC_NOCACHE,
273
+ .pc_xdrressize = ST+pAT,
274
+ },
265275 };
266276
267277 static unsigned int nfsd_acl_count3[ARRAY_SIZE(nfsd_acl_procedures3)];