blob: 2cb56a0d6625f07db79447768fac92c86940d9b7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Process version 3 NFS requests.
3 *
4 * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
5 */
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/fs.h>
8#include <linux/ext2_fs.h>
Qinghuang Feng12214cb2009-01-12 03:13:53 +08009#include <linux/magic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Boaz Harrosh9a74af22009-12-03 20:30:56 +020011#include "cache.h"
12#include "xdr3.h"
J. Bruce Fields0a3adad2009-11-04 18:12:35 -050013#include "vfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15#define NFSDDBG_FACILITY NFSDDBG_PROC
16
17#define RETURN_STATUS(st) { resp->status = (st); return (st); }
18
19static int nfs3_ftypes[] = {
20 0, /* NF3NON */
21 S_IFREG, /* NF3REG */
22 S_IFDIR, /* NF3DIR */
23 S_IFBLK, /* NF3BLK */
24 S_IFCHR, /* NF3CHR */
25 S_IFLNK, /* NF3LNK */
26 S_IFSOCK, /* NF3SOCK */
27 S_IFIFO, /* NF3FIFO */
28};
29
30/*
31 * NULL call.
32 */
Al Viro7111c662006-10-19 23:28:45 -070033static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020034nfsd3_proc_null(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070035{
36 return nfs_ok;
37}
38
39/*
40 * Get a file's attributes
41 */
Al Viro7111c662006-10-19 23:28:45 -070042static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020043nfsd3_proc_getattr(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
Christoph Hellwiga6beb732017-05-08 17:35:49 +020045 struct nfsd_fhandle *argp = rqstp->rq_argp;
46 struct nfsd3_attrstat *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -070047 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49 dprintk("nfsd: GETATTR(3) %s\n",
David Shawa334de22006-01-06 00:19:58 -080050 SVCFH_fmt(&argp->fh));
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52 fh_copy(&resp->fh, &argp->fh);
J. Bruce Fields04716e62008-08-07 13:00:20 -040053 nfserr = fh_verify(rqstp, &resp->fh, 0,
54 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
David Shawa334de22006-01-06 00:19:58 -080055 if (nfserr)
56 RETURN_STATUS(nfserr);
57
Al Viro3dadecc2013-01-24 02:18:08 -050058 nfserr = fh_getattr(&resp->fh, &resp->stat);
David Shawa334de22006-01-06 00:19:58 -080059
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 RETURN_STATUS(nfserr);
61}
62
63/*
64 * Set a file's attributes
65 */
Al Viro7111c662006-10-19 23:28:45 -070066static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020067nfsd3_proc_setattr(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Christoph Hellwiga6beb732017-05-08 17:35:49 +020069 struct nfsd3_sattrargs *argp = rqstp->rq_argp;
70 struct nfsd3_attrstat *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -070071 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73 dprintk("nfsd: SETATTR(3) %s\n",
74 SVCFH_fmt(&argp->fh));
75
76 fh_copy(&resp->fh, &argp->fh);
77 nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
78 argp->check_guard, argp->guardtime);
79 RETURN_STATUS(nfserr);
80}
81
82/*
83 * Look up a path name component
84 */
Al Viro7111c662006-10-19 23:28:45 -070085static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020086nfsd3_proc_lookup(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070087{
Christoph Hellwiga6beb732017-05-08 17:35:49 +020088 struct nfsd3_diropargs *argp = rqstp->rq_argp;
89 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -070090 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92 dprintk("nfsd: LOOKUP(3) %s %.*s\n",
93 SVCFH_fmt(&argp->fh),
94 argp->len,
95 argp->name);
96
97 fh_copy(&resp->dirfh, &argp->fh);
98 fh_init(&resp->fh, NFS3_FHSIZE);
99
100 nfserr = nfsd_lookup(rqstp, &resp->dirfh,
101 argp->name,
102 argp->len,
103 &resp->fh);
104 RETURN_STATUS(nfserr);
105}
106
107/*
108 * Check file access
109 */
Al Viro7111c662006-10-19 23:28:45 -0700110static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200111nfsd3_proc_access(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200113 struct nfsd3_accessargs *argp = rqstp->rq_argp;
114 struct nfsd3_accessres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700115 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117 dprintk("nfsd: ACCESS(3) %s 0x%x\n",
118 SVCFH_fmt(&argp->fh),
119 argp->access);
120
121 fh_copy(&resp->fh, &argp->fh);
122 resp->access = argp->access;
123 nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
124 RETURN_STATUS(nfserr);
125}
126
127/*
128 * Read a symlink.
129 */
Al Viro7111c662006-10-19 23:28:45 -0700130static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200131nfsd3_proc_readlink(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200133 struct nfsd3_readlinkargs *argp = rqstp->rq_argp;
134 struct nfsd3_readlinkres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700135 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137 dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
138
139 /* Read the symlink. */
140 fh_copy(&resp->fh, &argp->fh);
141 resp->len = NFS3_MAXPATHLEN;
142 nfserr = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len);
143 RETURN_STATUS(nfserr);
144}
145
146/*
147 * Read a portion of a file.
148 */
Al Viro7111c662006-10-19 23:28:45 -0700149static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200150nfsd3_proc_read(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200152 struct nfsd3_readargs *argp = rqstp->rq_argp;
153 struct nfsd3_readres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700154 __be32 nfserr;
Greg Banks7adae482006-10-04 02:15:47 -0700155 u32 max_blocksize = svc_max_payload(rqstp);
Benjamin Coddingtonac503e42016-03-22 10:28:36 -0400156 unsigned long cnt = min(argp->count, max_blocksize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500158 dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 SVCFH_fmt(&argp->fh),
160 (unsigned long) argp->count,
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500161 (unsigned long long) argp->offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163 /* Obtain buffer pointer for payload.
164 * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
165 * + 1 (xdr opaque byte count) = 26
166 */
Benjamin Coddingtonac503e42016-03-22 10:28:36 -0400167 resp->count = cnt;
Jeff Laytoncd123012007-05-09 02:34:50 -0700168 svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170 fh_copy(&resp->fh, &argp->fh);
J. Bruce Fields039a87c2010-07-30 11:33:32 -0400171 nfserr = nfsd_read(rqstp, &resp->fh,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 argp->offset,
NeilBrown3cc03b12006-10-04 02:15:47 -0700173 rqstp->rq_vec, argp->vlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174 &resp->count);
175 if (nfserr == 0) {
David Howells2b0143b2015-03-17 22:25:59 +0000176 struct inode *inode = d_inode(resp->fh.fh_dentry);
Benjamin Coddingtonac503e42016-03-22 10:28:36 -0400177 resp->eof = nfsd_eof_on_read(cnt, resp->count, argp->offset,
178 inode->i_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 }
180
181 RETURN_STATUS(nfserr);
182}
183
184/*
185 * Write data to a file
186 */
Al Viro7111c662006-10-19 23:28:45 -0700187static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200188nfsd3_proc_write(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200190 struct nfsd3_writeargs *argp = rqstp->rq_argp;
191 struct nfsd3_writeres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700192 __be32 nfserr;
David Shaw31dec252009-03-05 20:16:14 -0500193 unsigned long cnt = argp->len;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500195 dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 SVCFH_fmt(&argp->fh),
197 argp->len,
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500198 (unsigned long long) argp->offset,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 argp->stable? " stable" : "");
200
201 fh_copy(&resp->fh, &argp->fh);
202 resp->committed = argp->stable;
Kinglong Mee52e380e2016-12-31 21:00:13 +0800203 nfserr = nfsd_write(rqstp, &resp->fh, argp->offset,
204 rqstp->rq_vec, argp->vlen,
205 &cnt, resp->committed);
David Shaw31dec252009-03-05 20:16:14 -0500206 resp->count = cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 RETURN_STATUS(nfserr);
208}
209
210/*
211 * With NFSv3, CREATE processing is a lot easier than with NFSv2.
212 * At least in theory; we'll see how it fares in practice when the
213 * first reports about SunOS compatibility problems start to pour in...
214 */
Al Viro7111c662006-10-19 23:28:45 -0700215static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200216nfsd3_proc_create(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200218 struct nfsd3_createargs *argp = rqstp->rq_argp;
219 struct nfsd3_diropres *resp = rqstp->rq_resp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 svc_fh *dirfhp, *newfhp = NULL;
221 struct iattr *attr;
Al Viroc4d987b2006-10-19 23:29:00 -0700222 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224 dprintk("nfsd: CREATE(3) %s %.*s\n",
225 SVCFH_fmt(&argp->fh),
226 argp->len,
227 argp->name);
228
229 dirfhp = fh_copy(&resp->dirfh, &argp->fh);
230 newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
231 attr = &argp->attrs;
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 /* Unfudge the mode bits */
234 attr->ia_mode &= ~S_IFMT;
235 if (!(attr->ia_valid & ATTR_MODE)) {
236 attr->ia_valid |= ATTR_MODE;
237 attr->ia_mode = S_IFREG;
238 } else {
239 attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG;
240 }
241
242 /* Now create the file and set attributes */
Mi Jinlongac6721a2011-04-20 17:06:25 +0800243 nfserr = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 attr, newfhp,
J. Bruce Fields95c7a202012-07-27 15:50:11 -0400245 argp->createmode, (u32 *)argp->verf, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247 RETURN_STATUS(nfserr);
248}
249
250/*
251 * Make directory. This operation is not idempotent.
252 */
Al Viro7111c662006-10-19 23:28:45 -0700253static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200254nfsd3_proc_mkdir(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200256 struct nfsd3_createargs *argp = rqstp->rq_argp;
257 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700258 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260 dprintk("nfsd: MKDIR(3) %s %.*s\n",
261 SVCFH_fmt(&argp->fh),
262 argp->len,
263 argp->name);
264
265 argp->attrs.ia_valid &= ~ATTR_SIZE;
266 fh_copy(&resp->dirfh, &argp->fh);
267 fh_init(&resp->fh, NFS3_FHSIZE);
268 nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
269 &argp->attrs, S_IFDIR, 0, &resp->fh);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400270 fh_unlock(&resp->dirfh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 RETURN_STATUS(nfserr);
272}
273
Al Viro7111c662006-10-19 23:28:45 -0700274static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200275nfsd3_proc_symlink(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200277 struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
278 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700279 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280
281 dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
282 SVCFH_fmt(&argp->ffh),
283 argp->flen, argp->fname,
284 argp->tlen, argp->tname);
285
286 fh_copy(&resp->dirfh, &argp->ffh);
287 fh_init(&resp->fh, NFS3_FHSIZE);
288 nfserr = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, argp->flen,
Kinglong Mee1e444f52014-07-01 17:48:02 +0800289 argp->tname, &resp->fh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 RETURN_STATUS(nfserr);
291}
292
293/*
294 * Make socket/fifo/device.
295 */
Al Viro7111c662006-10-19 23:28:45 -0700296static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200297nfsd3_proc_mknod(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200299 struct nfsd3_mknodargs *argp = rqstp->rq_argp;
300 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700301 __be32 nfserr;
302 int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 dev_t rdev = 0;
304
305 dprintk("nfsd: MKNOD(3) %s %.*s\n",
306 SVCFH_fmt(&argp->fh),
307 argp->len,
308 argp->name);
309
310 fh_copy(&resp->dirfh, &argp->fh);
311 fh_init(&resp->fh, NFS3_FHSIZE);
312
313 if (argp->ftype == 0 || argp->ftype >= NF3BAD)
314 RETURN_STATUS(nfserr_inval);
315 if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
316 rdev = MKDEV(argp->major, argp->minor);
317 if (MAJOR(rdev) != argp->major ||
318 MINOR(rdev) != argp->minor)
319 RETURN_STATUS(nfserr_inval);
320 } else
321 if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO)
322 RETURN_STATUS(nfserr_inval);
323
324 type = nfs3_ftypes[argp->ftype];
325 nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
326 &argp->attrs, type, rdev, &resp->fh);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400327 fh_unlock(&resp->dirfh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 RETURN_STATUS(nfserr);
329}
330
331/*
332 * Remove file/fifo/socket etc.
333 */
Al Viro7111c662006-10-19 23:28:45 -0700334static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200335nfsd3_proc_remove(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200337 struct nfsd3_diropargs *argp = rqstp->rq_argp;
338 struct nfsd3_attrstat *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700339 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
341 dprintk("nfsd: REMOVE(3) %s %.*s\n",
342 SVCFH_fmt(&argp->fh),
343 argp->len,
344 argp->name);
345
346 /* Unlink. -S_IFDIR means file must not be a directory */
347 fh_copy(&resp->fh, &argp->fh);
348 nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400349 fh_unlock(&resp->fh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 RETURN_STATUS(nfserr);
351}
352
353/*
354 * Remove a directory
355 */
Al Viro7111c662006-10-19 23:28:45 -0700356static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200357nfsd3_proc_rmdir(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200359 struct nfsd3_diropargs *argp = rqstp->rq_argp;
360 struct nfsd3_attrstat *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700361 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362
363 dprintk("nfsd: RMDIR(3) %s %.*s\n",
364 SVCFH_fmt(&argp->fh),
365 argp->len,
366 argp->name);
367
368 fh_copy(&resp->fh, &argp->fh);
369 nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400370 fh_unlock(&resp->fh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 RETURN_STATUS(nfserr);
372}
373
Al Viro7111c662006-10-19 23:28:45 -0700374static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200375nfsd3_proc_rename(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200377 struct nfsd3_renameargs *argp = rqstp->rq_argp;
378 struct nfsd3_renameres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700379 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
381 dprintk("nfsd: RENAME(3) %s %.*s ->\n",
382 SVCFH_fmt(&argp->ffh),
383 argp->flen,
384 argp->fname);
385 dprintk("nfsd: -> %s %.*s\n",
386 SVCFH_fmt(&argp->tfh),
387 argp->tlen,
388 argp->tname);
389
390 fh_copy(&resp->ffh, &argp->ffh);
391 fh_copy(&resp->tfh, &argp->tfh);
392 nfserr = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
393 &resp->tfh, argp->tname, argp->tlen);
394 RETURN_STATUS(nfserr);
395}
396
Al Viro7111c662006-10-19 23:28:45 -0700397static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200398nfsd3_proc_link(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200400 struct nfsd3_linkargs *argp = rqstp->rq_argp;
401 struct nfsd3_linkres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700402 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403
404 dprintk("nfsd: LINK(3) %s ->\n",
405 SVCFH_fmt(&argp->ffh));
406 dprintk("nfsd: -> %s %.*s\n",
407 SVCFH_fmt(&argp->tfh),
408 argp->tlen,
409 argp->tname);
410
411 fh_copy(&resp->fh, &argp->ffh);
412 fh_copy(&resp->tfh, &argp->tfh);
413 nfserr = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
414 &resp->fh);
415 RETURN_STATUS(nfserr);
416}
417
418/*
419 * Read a portion of a directory.
420 */
Al Viro7111c662006-10-19 23:28:45 -0700421static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200422nfsd3_proc_readdir(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200424 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
425 struct nfsd3_readdirres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700426 __be32 nfserr;
427 int count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
429 dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
430 SVCFH_fmt(&argp->fh),
431 argp->count, (u32) argp->cookie);
432
433 /* Make sure we've room for the NULL ptr & eof flag, and shrink to
434 * client read size */
435 count = (argp->count >> 2) - 2;
436
437 /* Read directory and encode entries on the fly */
438 fh_copy(&resp->fh, &argp->fh);
439
440 resp->buflen = count;
441 resp->common.err = nfs_ok;
442 resp->buffer = argp->buffer;
443 resp->rqstp = rqstp;
444 nfserr = nfsd_readdir(rqstp, &resp->fh, (loff_t*) &argp->cookie,
445 &resp->common, nfs3svc_encode_entry);
446 memcpy(resp->verf, argp->verf, 8);
447 resp->count = resp->buffer - argp->buffer;
448 if (resp->offset)
449 xdr_encode_hyper(resp->offset, argp->cookie);
450
451 RETURN_STATUS(nfserr);
452}
453
454/*
455 * Read a portion of a directory, including file handles and attrs.
456 * For now, we choose to ignore the dircount parameter.
457 */
Al Viro7111c662006-10-19 23:28:45 -0700458static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200459nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200461 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
462 struct nfsd3_readdirres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700463 __be32 nfserr;
464 int count = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 loff_t offset;
J. Bruce Fieldsafc59402012-12-10 18:01:37 -0500466 struct page **p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 caddr_t page_addr = NULL;
468
469 dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
470 SVCFH_fmt(&argp->fh),
471 argp->count, (u32) argp->cookie);
472
473 /* Convert byte count to number of words (i.e. >> 2),
474 * and reserve room for the NULL ptr & eof flag (-2 words) */
475 resp->count = (argp->count >> 2) - 2;
476
477 /* Read directory and encode entries on the fly */
478 fh_copy(&resp->fh, &argp->fh);
479
480 resp->common.err = nfs_ok;
481 resp->buffer = argp->buffer;
482 resp->buflen = resp->count;
483 resp->rqstp = rqstp;
484 offset = argp->cookie;
Rajesh Ghanekar18c01ab2014-08-01 22:17:30 -0400485
486 nfserr = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
487 if (nfserr)
488 RETURN_STATUS(nfserr);
489
490 if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS)
491 RETURN_STATUS(nfserr_notsupp);
492
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 nfserr = nfsd_readdir(rqstp, &resp->fh,
494 &offset,
495 &resp->common,
496 nfs3svc_encode_entry_plus);
497 memcpy(resp->verf, argp->verf, 8);
J. Bruce Fieldsafc59402012-12-10 18:01:37 -0500498 for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
499 page_addr = page_address(*p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
501 if (((caddr_t)resp->buffer >= page_addr) &&
502 ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
503 count += (caddr_t)resp->buffer - page_addr;
504 break;
505 }
506 count += PAGE_SIZE;
507 }
508 resp->count = count >> 2;
509 if (resp->offset) {
510 if (unlikely(resp->offset1)) {
511 /* we ended up with offset on a page boundary */
512 *resp->offset = htonl(offset >> 32);
513 *resp->offset1 = htonl(offset & 0xffffffff);
514 resp->offset1 = NULL;
515 } else {
516 xdr_encode_hyper(resp->offset, offset);
517 }
518 }
519
520 RETURN_STATUS(nfserr);
521}
522
523/*
524 * Get file system stats
525 */
Al Viro7111c662006-10-19 23:28:45 -0700526static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200527nfsd3_proc_fsstat(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200529 struct nfsd_fhandle *argp = rqstp->rq_argp;
530 struct nfsd3_fsstatres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700531 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532
533 dprintk("nfsd: FSSTAT(3) %s\n",
534 SVCFH_fmt(&argp->fh));
535
J. Bruce Fields04716e62008-08-07 13:00:20 -0400536 nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 fh_put(&argp->fh);
538 RETURN_STATUS(nfserr);
539}
540
541/*
542 * Get file system info
543 */
Al Viro7111c662006-10-19 23:28:45 -0700544static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200545nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200547 struct nfsd_fhandle *argp = rqstp->rq_argp;
548 struct nfsd3_fsinfores *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700549 __be32 nfserr;
Greg Banks7adae482006-10-04 02:15:47 -0700550 u32 max_blocksize = svc_max_payload(rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551
552 dprintk("nfsd: FSINFO(3) %s\n",
553 SVCFH_fmt(&argp->fh));
554
Greg Banks7adae482006-10-04 02:15:47 -0700555 resp->f_rtmax = max_blocksize;
556 resp->f_rtpref = max_blocksize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 resp->f_rtmult = PAGE_SIZE;
Greg Banks7adae482006-10-04 02:15:47 -0700558 resp->f_wtmax = max_blocksize;
559 resp->f_wtpref = max_blocksize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 resp->f_wtmult = PAGE_SIZE;
561 resp->f_dtpref = PAGE_SIZE;
562 resp->f_maxfilesize = ~(u32) 0;
563 resp->f_properties = NFS3_FSF_DEFAULT;
564
J. Bruce Fields04716e62008-08-07 13:00:20 -0400565 nfserr = fh_verify(rqstp, &argp->fh, 0,
566 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567
568 /* Check special features of the file system. May request
569 * different read/write sizes for file systems known to have
570 * problems with large blocks */
571 if (nfserr == 0) {
Al Virofc640052016-04-10 01:33:30 -0400572 struct super_block *sb = argp->fh.fh_dentry->d_sb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573
574 /* Note that we don't care for remote fs's here */
Qinghuang Feng12214cb2009-01-12 03:13:53 +0800575 if (sb->s_magic == MSDOS_SUPER_MAGIC) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 resp->f_properties = NFS3_FSF_BILLYBOY;
577 }
578 resp->f_maxfilesize = sb->s_maxbytes;
579 }
580
581 fh_put(&argp->fh);
582 RETURN_STATUS(nfserr);
583}
584
585/*
586 * Get pathconf info for the specified file
587 */
Al Viro7111c662006-10-19 23:28:45 -0700588static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200589nfsd3_proc_pathconf(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200591 struct nfsd_fhandle *argp = rqstp->rq_argp;
592 struct nfsd3_pathconfres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700593 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594
595 dprintk("nfsd: PATHCONF(3) %s\n",
596 SVCFH_fmt(&argp->fh));
597
598 /* Set default pathconf */
599 resp->p_link_max = 255; /* at least */
600 resp->p_name_max = 255; /* at least */
601 resp->p_no_trunc = 0;
602 resp->p_chown_restricted = 1;
603 resp->p_case_insensitive = 0;
604 resp->p_case_preserving = 1;
605
Miklos Szeredi8837abc2008-06-16 13:20:29 +0200606 nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607
608 if (nfserr == 0) {
Al Virofc640052016-04-10 01:33:30 -0400609 struct super_block *sb = argp->fh.fh_dentry->d_sb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610
611 /* Note that we don't care for remote fs's here */
612 switch (sb->s_magic) {
613 case EXT2_SUPER_MAGIC:
614 resp->p_link_max = EXT2_LINK_MAX;
615 resp->p_name_max = EXT2_NAME_LEN;
616 break;
Qinghuang Feng12214cb2009-01-12 03:13:53 +0800617 case MSDOS_SUPER_MAGIC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 resp->p_case_insensitive = 1;
619 resp->p_case_preserving = 0;
620 break;
621 }
622 }
623
624 fh_put(&argp->fh);
625 RETURN_STATUS(nfserr);
626}
627
628
629/*
630 * Commit a file (range) to stable storage.
631 */
Al Viro7111c662006-10-19 23:28:45 -0700632static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200633nfsd3_proc_commit(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200635 struct nfsd3_commitargs *argp = rqstp->rq_argp;
636 struct nfsd3_commitres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700637 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638
639 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
640 SVCFH_fmt(&argp->fh),
641 argp->count,
642 (unsigned long long) argp->offset);
643
644 if (argp->offset > NFS_OFFSET_MAX)
645 RETURN_STATUS(nfserr_inval);
646
647 fh_copy(&resp->fh, &argp->fh);
648 nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count);
649
650 RETURN_STATUS(nfserr);
651}
652
653
654/*
655 * NFSv3 Server procedures.
656 * Only the results of non-idempotent operations are cached.
657 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658#define nfs3svc_decode_fhandleargs nfs3svc_decode_fhandle
659#define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
660#define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
661#define nfsd3_mkdirargs nfsd3_createargs
662#define nfsd3_readdirplusargs nfsd3_readdirargs
663#define nfsd3_fhandleargs nfsd_fhandle
664#define nfsd3_fhandleres nfsd3_attrstat
665#define nfsd3_attrstatres nfsd3_attrstat
666#define nfsd3_wccstatres nfsd3_attrstat
667#define nfsd3_createres nfsd3_diropres
668#define nfsd3_voidres nfsd3_voidargs
669struct nfsd3_voidargs { int dummy; };
670
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671#define ST 1 /* status*/
672#define FH 17 /* filehandle with length */
673#define AT 21 /* attributes */
674#define pAT (1+AT) /* post attributes - conditional */
675#define WC (7+pAT) /* WCC attributes */
676
Christoph Hellwig860bda22017-05-12 16:11:49 +0200677static const struct svc_procedure nfsd_procedures3[22] = {
Yu Zhiguob9081d92009-06-09 17:33:34 +0800678 [NFS3PROC_NULL] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200679 .pc_func = nfsd3_proc_null,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200680 .pc_encode = nfs3svc_encode_voidres,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800681 .pc_argsize = sizeof(struct nfsd3_voidargs),
682 .pc_ressize = sizeof(struct nfsd3_voidres),
683 .pc_cachetype = RC_NOCACHE,
684 .pc_xdrressize = ST,
685 },
686 [NFS3PROC_GETATTR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200687 .pc_func = nfsd3_proc_getattr,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200688 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200689 .pc_encode = nfs3svc_encode_attrstatres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200690 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800691 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
692 .pc_ressize = sizeof(struct nfsd3_attrstatres),
693 .pc_cachetype = RC_NOCACHE,
694 .pc_xdrressize = ST+AT,
695 },
696 [NFS3PROC_SETATTR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200697 .pc_func = nfsd3_proc_setattr,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200698 .pc_decode = nfs3svc_decode_sattrargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200699 .pc_encode = nfs3svc_encode_wccstatres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200700 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800701 .pc_argsize = sizeof(struct nfsd3_sattrargs),
702 .pc_ressize = sizeof(struct nfsd3_wccstatres),
703 .pc_cachetype = RC_REPLBUFF,
704 .pc_xdrressize = ST+WC,
705 },
706 [NFS3PROC_LOOKUP] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200707 .pc_func = nfsd3_proc_lookup,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200708 .pc_decode = nfs3svc_decode_diropargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200709 .pc_encode = nfs3svc_encode_diropres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200710 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800711 .pc_argsize = sizeof(struct nfsd3_diropargs),
712 .pc_ressize = sizeof(struct nfsd3_diropres),
713 .pc_cachetype = RC_NOCACHE,
714 .pc_xdrressize = ST+FH+pAT+pAT,
715 },
716 [NFS3PROC_ACCESS] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200717 .pc_func = nfsd3_proc_access,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200718 .pc_decode = nfs3svc_decode_accessargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200719 .pc_encode = nfs3svc_encode_accessres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200720 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800721 .pc_argsize = sizeof(struct nfsd3_accessargs),
722 .pc_ressize = sizeof(struct nfsd3_accessres),
723 .pc_cachetype = RC_NOCACHE,
724 .pc_xdrressize = ST+pAT+1,
725 },
726 [NFS3PROC_READLINK] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200727 .pc_func = nfsd3_proc_readlink,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200728 .pc_decode = nfs3svc_decode_readlinkargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200729 .pc_encode = nfs3svc_encode_readlinkres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200730 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800731 .pc_argsize = sizeof(struct nfsd3_readlinkargs),
732 .pc_ressize = sizeof(struct nfsd3_readlinkres),
733 .pc_cachetype = RC_NOCACHE,
734 .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
735 },
736 [NFS3PROC_READ] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200737 .pc_func = nfsd3_proc_read,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200738 .pc_decode = nfs3svc_decode_readargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200739 .pc_encode = nfs3svc_encode_readres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200740 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800741 .pc_argsize = sizeof(struct nfsd3_readargs),
742 .pc_ressize = sizeof(struct nfsd3_readres),
743 .pc_cachetype = RC_NOCACHE,
744 .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
745 },
746 [NFS3PROC_WRITE] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200747 .pc_func = nfsd3_proc_write,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200748 .pc_decode = nfs3svc_decode_writeargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200749 .pc_encode = nfs3svc_encode_writeres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200750 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800751 .pc_argsize = sizeof(struct nfsd3_writeargs),
752 .pc_ressize = sizeof(struct nfsd3_writeres),
753 .pc_cachetype = RC_REPLBUFF,
754 .pc_xdrressize = ST+WC+4,
755 },
756 [NFS3PROC_CREATE] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200757 .pc_func = nfsd3_proc_create,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200758 .pc_decode = nfs3svc_decode_createargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200759 .pc_encode = nfs3svc_encode_createres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200760 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800761 .pc_argsize = sizeof(struct nfsd3_createargs),
762 .pc_ressize = sizeof(struct nfsd3_createres),
763 .pc_cachetype = RC_REPLBUFF,
764 .pc_xdrressize = ST+(1+FH+pAT)+WC,
765 },
766 [NFS3PROC_MKDIR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200767 .pc_func = nfsd3_proc_mkdir,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200768 .pc_decode = nfs3svc_decode_mkdirargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200769 .pc_encode = nfs3svc_encode_createres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200770 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800771 .pc_argsize = sizeof(struct nfsd3_mkdirargs),
772 .pc_ressize = sizeof(struct nfsd3_createres),
773 .pc_cachetype = RC_REPLBUFF,
774 .pc_xdrressize = ST+(1+FH+pAT)+WC,
775 },
776 [NFS3PROC_SYMLINK] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200777 .pc_func = nfsd3_proc_symlink,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200778 .pc_decode = nfs3svc_decode_symlinkargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200779 .pc_encode = nfs3svc_encode_createres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200780 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800781 .pc_argsize = sizeof(struct nfsd3_symlinkargs),
782 .pc_ressize = sizeof(struct nfsd3_createres),
783 .pc_cachetype = RC_REPLBUFF,
784 .pc_xdrressize = ST+(1+FH+pAT)+WC,
785 },
786 [NFS3PROC_MKNOD] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200787 .pc_func = nfsd3_proc_mknod,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200788 .pc_decode = nfs3svc_decode_mknodargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200789 .pc_encode = nfs3svc_encode_createres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200790 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800791 .pc_argsize = sizeof(struct nfsd3_mknodargs),
792 .pc_ressize = sizeof(struct nfsd3_createres),
793 .pc_cachetype = RC_REPLBUFF,
794 .pc_xdrressize = ST+(1+FH+pAT)+WC,
795 },
796 [NFS3PROC_REMOVE] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200797 .pc_func = nfsd3_proc_remove,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200798 .pc_decode = nfs3svc_decode_diropargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200799 .pc_encode = nfs3svc_encode_wccstatres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200800 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800801 .pc_argsize = sizeof(struct nfsd3_diropargs),
802 .pc_ressize = sizeof(struct nfsd3_wccstatres),
803 .pc_cachetype = RC_REPLBUFF,
804 .pc_xdrressize = ST+WC,
805 },
806 [NFS3PROC_RMDIR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200807 .pc_func = nfsd3_proc_rmdir,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200808 .pc_decode = nfs3svc_decode_diropargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200809 .pc_encode = nfs3svc_encode_wccstatres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200810 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800811 .pc_argsize = sizeof(struct nfsd3_diropargs),
812 .pc_ressize = sizeof(struct nfsd3_wccstatres),
813 .pc_cachetype = RC_REPLBUFF,
814 .pc_xdrressize = ST+WC,
815 },
816 [NFS3PROC_RENAME] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200817 .pc_func = nfsd3_proc_rename,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200818 .pc_decode = nfs3svc_decode_renameargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200819 .pc_encode = nfs3svc_encode_renameres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200820 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800821 .pc_argsize = sizeof(struct nfsd3_renameargs),
822 .pc_ressize = sizeof(struct nfsd3_renameres),
823 .pc_cachetype = RC_REPLBUFF,
824 .pc_xdrressize = ST+WC+WC,
825 },
826 [NFS3PROC_LINK] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200827 .pc_func = nfsd3_proc_link,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200828 .pc_decode = nfs3svc_decode_linkargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200829 .pc_encode = nfs3svc_encode_linkres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200830 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800831 .pc_argsize = sizeof(struct nfsd3_linkargs),
832 .pc_ressize = sizeof(struct nfsd3_linkres),
833 .pc_cachetype = RC_REPLBUFF,
834 .pc_xdrressize = ST+pAT+WC,
835 },
836 [NFS3PROC_READDIR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200837 .pc_func = nfsd3_proc_readdir,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200838 .pc_decode = nfs3svc_decode_readdirargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200839 .pc_encode = nfs3svc_encode_readdirres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200840 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800841 .pc_argsize = sizeof(struct nfsd3_readdirargs),
842 .pc_ressize = sizeof(struct nfsd3_readdirres),
843 .pc_cachetype = RC_NOCACHE,
844 },
845 [NFS3PROC_READDIRPLUS] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200846 .pc_func = nfsd3_proc_readdirplus,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200847 .pc_decode = nfs3svc_decode_readdirplusargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200848 .pc_encode = nfs3svc_encode_readdirres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200849 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800850 .pc_argsize = sizeof(struct nfsd3_readdirplusargs),
851 .pc_ressize = sizeof(struct nfsd3_readdirres),
852 .pc_cachetype = RC_NOCACHE,
853 },
854 [NFS3PROC_FSSTAT] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200855 .pc_func = nfsd3_proc_fsstat,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200856 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200857 .pc_encode = nfs3svc_encode_fsstatres,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800858 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
859 .pc_ressize = sizeof(struct nfsd3_fsstatres),
860 .pc_cachetype = RC_NOCACHE,
861 .pc_xdrressize = ST+pAT+2*6+1,
862 },
863 [NFS3PROC_FSINFO] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200864 .pc_func = nfsd3_proc_fsinfo,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200865 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200866 .pc_encode = nfs3svc_encode_fsinfores,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800867 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
868 .pc_ressize = sizeof(struct nfsd3_fsinfores),
869 .pc_cachetype = RC_NOCACHE,
870 .pc_xdrressize = ST+pAT+12,
871 },
872 [NFS3PROC_PATHCONF] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200873 .pc_func = nfsd3_proc_pathconf,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200874 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200875 .pc_encode = nfs3svc_encode_pathconfres,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800876 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
877 .pc_ressize = sizeof(struct nfsd3_pathconfres),
878 .pc_cachetype = RC_NOCACHE,
879 .pc_xdrressize = ST+pAT+6,
880 },
881 [NFS3PROC_COMMIT] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200882 .pc_func = nfsd3_proc_commit,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200883 .pc_decode = nfs3svc_decode_commitargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200884 .pc_encode = nfs3svc_encode_commitres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200885 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800886 .pc_argsize = sizeof(struct nfsd3_commitargs),
887 .pc_ressize = sizeof(struct nfsd3_commitres),
888 .pc_cachetype = RC_NOCACHE,
889 .pc_xdrressize = ST+WC+2,
890 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891};
892
Christoph Hellwig7fd38af2017-05-08 23:40:27 +0200893static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
Christoph Hellwige9679182017-05-12 16:21:37 +0200894const struct svc_version nfsd_version3 = {
895 .vs_vers = 3,
896 .vs_nproc = 22,
897 .vs_proc = nfsd_procedures3,
898 .vs_dispatch = nfsd_dispatch,
899 .vs_count = nfsd_count3,
900 .vs_xdrsize = NFS3_SVC_XDRSIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901};