blob: 8f933e84cec18221f4645b769ea9d1914bc3e627 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Process version 3 NFS requests.
4 *
5 * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
6 */
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#include <linux/fs.h>
9#include <linux/ext2_fs.h>
Qinghuang Feng12214cb2009-01-12 03:13:53 +080010#include <linux/magic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Boaz Harrosh9a74af22009-12-03 20:30:56 +020012#include "cache.h"
13#include "xdr3.h"
J. Bruce Fields0a3adad2009-11-04 18:12:35 -050014#include "vfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
16#define NFSDDBG_FACILITY NFSDDBG_PROC
17
18#define RETURN_STATUS(st) { resp->status = (st); return (st); }
19
20static int nfs3_ftypes[] = {
21 0, /* NF3NON */
22 S_IFREG, /* NF3REG */
23 S_IFDIR, /* NF3DIR */
24 S_IFBLK, /* NF3BLK */
25 S_IFCHR, /* NF3CHR */
26 S_IFLNK, /* NF3LNK */
27 S_IFSOCK, /* NF3SOCK */
28 S_IFIFO, /* NF3FIFO */
29};
30
31/*
32 * NULL call.
33 */
Al Viro7111c662006-10-19 23:28:45 -070034static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020035nfsd3_proc_null(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
37 return nfs_ok;
38}
39
40/*
41 * Get a file's attributes
42 */
Al Viro7111c662006-10-19 23:28:45 -070043static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020044nfsd3_proc_getattr(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070045{
Christoph Hellwiga6beb732017-05-08 17:35:49 +020046 struct nfsd_fhandle *argp = rqstp->rq_argp;
47 struct nfsd3_attrstat *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -070048 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50 dprintk("nfsd: GETATTR(3) %s\n",
David Shawa334de22006-01-06 00:19:58 -080051 SVCFH_fmt(&argp->fh));
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53 fh_copy(&resp->fh, &argp->fh);
J. Bruce Fields04716e62008-08-07 13:00:20 -040054 nfserr = fh_verify(rqstp, &resp->fh, 0,
55 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
David Shawa334de22006-01-06 00:19:58 -080056 if (nfserr)
57 RETURN_STATUS(nfserr);
58
Al Viro3dadecc2013-01-24 02:18:08 -050059 nfserr = fh_getattr(&resp->fh, &resp->stat);
David Shawa334de22006-01-06 00:19:58 -080060
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 RETURN_STATUS(nfserr);
62}
63
64/*
65 * Set a file's attributes
66 */
Al Viro7111c662006-10-19 23:28:45 -070067static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020068nfsd3_proc_setattr(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069{
Christoph Hellwiga6beb732017-05-08 17:35:49 +020070 struct nfsd3_sattrargs *argp = rqstp->rq_argp;
71 struct nfsd3_attrstat *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -070072 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74 dprintk("nfsd: SETATTR(3) %s\n",
75 SVCFH_fmt(&argp->fh));
76
77 fh_copy(&resp->fh, &argp->fh);
78 nfserr = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
79 argp->check_guard, argp->guardtime);
80 RETURN_STATUS(nfserr);
81}
82
83/*
84 * Look up a path name component
85 */
Al Viro7111c662006-10-19 23:28:45 -070086static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +020087nfsd3_proc_lookup(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088{
Christoph Hellwiga6beb732017-05-08 17:35:49 +020089 struct nfsd3_diropargs *argp = rqstp->rq_argp;
90 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -070091 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 dprintk("nfsd: LOOKUP(3) %s %.*s\n",
94 SVCFH_fmt(&argp->fh),
95 argp->len,
96 argp->name);
97
98 fh_copy(&resp->dirfh, &argp->fh);
99 fh_init(&resp->fh, NFS3_FHSIZE);
100
101 nfserr = nfsd_lookup(rqstp, &resp->dirfh,
102 argp->name,
103 argp->len,
104 &resp->fh);
105 RETURN_STATUS(nfserr);
106}
107
108/*
109 * Check file access
110 */
Al Viro7111c662006-10-19 23:28:45 -0700111static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200112nfsd3_proc_access(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200114 struct nfsd3_accessargs *argp = rqstp->rq_argp;
115 struct nfsd3_accessres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700116 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118 dprintk("nfsd: ACCESS(3) %s 0x%x\n",
119 SVCFH_fmt(&argp->fh),
120 argp->access);
121
122 fh_copy(&resp->fh, &argp->fh);
123 resp->access = argp->access;
124 nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
125 RETURN_STATUS(nfserr);
126}
127
128/*
129 * Read a symlink.
130 */
Al Viro7111c662006-10-19 23:28:45 -0700131static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200132nfsd3_proc_readlink(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200134 struct nfsd3_readlinkargs *argp = rqstp->rq_argp;
135 struct nfsd3_readlinkres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700136 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138 dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
139
140 /* Read the symlink. */
141 fh_copy(&resp->fh, &argp->fh);
142 resp->len = NFS3_MAXPATHLEN;
143 nfserr = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len);
144 RETURN_STATUS(nfserr);
145}
146
147/*
148 * Read a portion of a file.
149 */
Al Viro7111c662006-10-19 23:28:45 -0700150static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200151nfsd3_proc_read(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200153 struct nfsd3_readargs *argp = rqstp->rq_argp;
154 struct nfsd3_readres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700155 __be32 nfserr;
Greg Banks7adae482006-10-04 02:15:47 -0700156 u32 max_blocksize = svc_max_payload(rqstp);
Benjamin Coddingtonac503e42016-03-22 10:28:36 -0400157 unsigned long cnt = min(argp->count, max_blocksize);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500159 dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 SVCFH_fmt(&argp->fh),
161 (unsigned long) argp->count,
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500162 (unsigned long long) argp->offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164 /* Obtain buffer pointer for payload.
165 * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
166 * + 1 (xdr opaque byte count) = 26
167 */
Benjamin Coddingtonac503e42016-03-22 10:28:36 -0400168 resp->count = cnt;
Jeff Laytoncd123012007-05-09 02:34:50 -0700169 svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
171 fh_copy(&resp->fh, &argp->fh);
J. Bruce Fields039a87c2010-07-30 11:33:32 -0400172 nfserr = nfsd_read(rqstp, &resp->fh,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 argp->offset,
NeilBrown3cc03b12006-10-04 02:15:47 -0700174 rqstp->rq_vec, argp->vlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 &resp->count);
176 if (nfserr == 0) {
David Howells2b0143b2015-03-17 22:25:59 +0000177 struct inode *inode = d_inode(resp->fh.fh_dentry);
Benjamin Coddingtonac503e42016-03-22 10:28:36 -0400178 resp->eof = nfsd_eof_on_read(cnt, resp->count, argp->offset,
179 inode->i_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 }
181
182 RETURN_STATUS(nfserr);
183}
184
185/*
186 * Write data to a file
187 */
Al Viro7111c662006-10-19 23:28:45 -0700188static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200189nfsd3_proc_write(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200191 struct nfsd3_writeargs *argp = rqstp->rq_argp;
192 struct nfsd3_writeres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700193 __be32 nfserr;
David Shaw31dec252009-03-05 20:16:14 -0500194 unsigned long cnt = argp->len;
Chuck Lever8154ef22018-03-27 10:54:07 -0400195 unsigned int nvecs;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500197 dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198 SVCFH_fmt(&argp->fh),
199 argp->len,
J. Bruce Fields18b631f2010-11-29 15:28:10 -0500200 (unsigned long long) argp->offset,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 argp->stable? " stable" : "");
202
203 fh_copy(&resp->fh, &argp->fh);
204 resp->committed = argp->stable;
Chuck Lever3fd95572018-07-27 11:19:05 -0400205 nvecs = svc_fill_write_vector(rqstp, rqstp->rq_arg.pages,
206 &argp->first, cnt);
Chuck Lever8154ef22018-03-27 10:54:07 -0400207 if (!nvecs)
208 RETURN_STATUS(nfserr_io);
Kinglong Mee52e380e2016-12-31 21:00:13 +0800209 nfserr = nfsd_write(rqstp, &resp->fh, argp->offset,
Chuck Lever8154ef22018-03-27 10:54:07 -0400210 rqstp->rq_vec, nvecs, &cnt,
211 resp->committed);
David Shaw31dec252009-03-05 20:16:14 -0500212 resp->count = cnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 RETURN_STATUS(nfserr);
214}
215
216/*
217 * With NFSv3, CREATE processing is a lot easier than with NFSv2.
218 * At least in theory; we'll see how it fares in practice when the
219 * first reports about SunOS compatibility problems start to pour in...
220 */
Al Viro7111c662006-10-19 23:28:45 -0700221static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200222nfsd3_proc_create(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200224 struct nfsd3_createargs *argp = rqstp->rq_argp;
225 struct nfsd3_diropres *resp = rqstp->rq_resp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 svc_fh *dirfhp, *newfhp = NULL;
227 struct iattr *attr;
Al Viroc4d987b2006-10-19 23:29:00 -0700228 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
230 dprintk("nfsd: CREATE(3) %s %.*s\n",
231 SVCFH_fmt(&argp->fh),
232 argp->len,
233 argp->name);
234
235 dirfhp = fh_copy(&resp->dirfh, &argp->fh);
236 newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
237 attr = &argp->attrs;
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 /* Unfudge the mode bits */
240 attr->ia_mode &= ~S_IFMT;
241 if (!(attr->ia_valid & ATTR_MODE)) {
242 attr->ia_valid |= ATTR_MODE;
243 attr->ia_mode = S_IFREG;
244 } else {
245 attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG;
246 }
247
248 /* Now create the file and set attributes */
Mi Jinlongac6721a2011-04-20 17:06:25 +0800249 nfserr = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 attr, newfhp,
J. Bruce Fields95c7a202012-07-27 15:50:11 -0400251 argp->createmode, (u32 *)argp->verf, NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253 RETURN_STATUS(nfserr);
254}
255
256/*
257 * Make directory. This operation is not idempotent.
258 */
Al Viro7111c662006-10-19 23:28:45 -0700259static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200260nfsd3_proc_mkdir(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200262 struct nfsd3_createargs *argp = rqstp->rq_argp;
263 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700264 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
266 dprintk("nfsd: MKDIR(3) %s %.*s\n",
267 SVCFH_fmt(&argp->fh),
268 argp->len,
269 argp->name);
270
271 argp->attrs.ia_valid &= ~ATTR_SIZE;
272 fh_copy(&resp->dirfh, &argp->fh);
273 fh_init(&resp->fh, NFS3_FHSIZE);
274 nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
275 &argp->attrs, S_IFDIR, 0, &resp->fh);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400276 fh_unlock(&resp->dirfh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 RETURN_STATUS(nfserr);
278}
279
Al Viro7111c662006-10-19 23:28:45 -0700280static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200281nfsd3_proc_symlink(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200283 struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
284 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700285 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
Chuck Lever38a70312018-03-27 10:54:21 -0400287 if (argp->tlen == 0)
288 RETURN_STATUS(nfserr_inval);
289 if (argp->tlen > NFS3_MAXPATHLEN)
290 RETURN_STATUS(nfserr_nametoolong);
291
292 argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
Chuck Lever11b4d662018-07-27 11:19:10 -0400293 page_address(rqstp->rq_arg.pages[0]),
Chuck Lever38a70312018-03-27 10:54:21 -0400294 argp->tlen);
295 if (IS_ERR(argp->tname))
296 RETURN_STATUS(nfserrno(PTR_ERR(argp->tname)));
297
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
299 SVCFH_fmt(&argp->ffh),
300 argp->flen, argp->fname,
301 argp->tlen, argp->tname);
302
303 fh_copy(&resp->dirfh, &argp->ffh);
304 fh_init(&resp->fh, NFS3_FHSIZE);
305 nfserr = nfsd_symlink(rqstp, &resp->dirfh, argp->fname, argp->flen,
Kinglong Mee1e444f52014-07-01 17:48:02 +0800306 argp->tname, &resp->fh);
Chuck Lever11b4d662018-07-27 11:19:10 -0400307 kfree(argp->tname);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308 RETURN_STATUS(nfserr);
309}
310
311/*
312 * Make socket/fifo/device.
313 */
Al Viro7111c662006-10-19 23:28:45 -0700314static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200315nfsd3_proc_mknod(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200317 struct nfsd3_mknodargs *argp = rqstp->rq_argp;
318 struct nfsd3_diropres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700319 __be32 nfserr;
320 int type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 dev_t rdev = 0;
322
323 dprintk("nfsd: MKNOD(3) %s %.*s\n",
324 SVCFH_fmt(&argp->fh),
325 argp->len,
326 argp->name);
327
328 fh_copy(&resp->dirfh, &argp->fh);
329 fh_init(&resp->fh, NFS3_FHSIZE);
330
331 if (argp->ftype == 0 || argp->ftype >= NF3BAD)
332 RETURN_STATUS(nfserr_inval);
333 if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
334 rdev = MKDEV(argp->major, argp->minor);
335 if (MAJOR(rdev) != argp->major ||
336 MINOR(rdev) != argp->minor)
337 RETURN_STATUS(nfserr_inval);
338 } else
339 if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO)
340 RETURN_STATUS(nfserr_inval);
341
342 type = nfs3_ftypes[argp->ftype];
343 nfserr = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
344 &argp->attrs, type, rdev, &resp->fh);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400345 fh_unlock(&resp->dirfh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 RETURN_STATUS(nfserr);
347}
348
349/*
350 * Remove file/fifo/socket etc.
351 */
Al Viro7111c662006-10-19 23:28:45 -0700352static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200353nfsd3_proc_remove(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200355 struct nfsd3_diropargs *argp = rqstp->rq_argp;
356 struct nfsd3_attrstat *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700357 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358
359 dprintk("nfsd: REMOVE(3) %s %.*s\n",
360 SVCFH_fmt(&argp->fh),
361 argp->len,
362 argp->name);
363
364 /* Unlink. -S_IFDIR means file must not be a directory */
365 fh_copy(&resp->fh, &argp->fh);
366 nfserr = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR, argp->name, argp->len);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400367 fh_unlock(&resp->fh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 RETURN_STATUS(nfserr);
369}
370
371/*
372 * Remove a directory
373 */
Al Viro7111c662006-10-19 23:28:45 -0700374static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200375nfsd3_proc_rmdir(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200377 struct nfsd3_diropargs *argp = rqstp->rq_argp;
378 struct nfsd3_attrstat *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: RMDIR(3) %s %.*s\n",
382 SVCFH_fmt(&argp->fh),
383 argp->len,
384 argp->name);
385
386 fh_copy(&resp->fh, &argp->fh);
387 nfserr = nfsd_unlink(rqstp, &resp->fh, S_IFDIR, argp->name, argp->len);
Chuck Lever43a9aa62010-07-06 16:53:34 -0400388 fh_unlock(&resp->fh);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 RETURN_STATUS(nfserr);
390}
391
Al Viro7111c662006-10-19 23:28:45 -0700392static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200393nfsd3_proc_rename(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200395 struct nfsd3_renameargs *argp = rqstp->rq_argp;
396 struct nfsd3_renameres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700397 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398
399 dprintk("nfsd: RENAME(3) %s %.*s ->\n",
400 SVCFH_fmt(&argp->ffh),
401 argp->flen,
402 argp->fname);
403 dprintk("nfsd: -> %s %.*s\n",
404 SVCFH_fmt(&argp->tfh),
405 argp->tlen,
406 argp->tname);
407
408 fh_copy(&resp->ffh, &argp->ffh);
409 fh_copy(&resp->tfh, &argp->tfh);
410 nfserr = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
411 &resp->tfh, argp->tname, argp->tlen);
412 RETURN_STATUS(nfserr);
413}
414
Al Viro7111c662006-10-19 23:28:45 -0700415static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200416nfsd3_proc_link(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200418 struct nfsd3_linkargs *argp = rqstp->rq_argp;
419 struct nfsd3_linkres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700420 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
422 dprintk("nfsd: LINK(3) %s ->\n",
423 SVCFH_fmt(&argp->ffh));
424 dprintk("nfsd: -> %s %.*s\n",
425 SVCFH_fmt(&argp->tfh),
426 argp->tlen,
427 argp->tname);
428
429 fh_copy(&resp->fh, &argp->ffh);
430 fh_copy(&resp->tfh, &argp->tfh);
431 nfserr = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
432 &resp->fh);
433 RETURN_STATUS(nfserr);
434}
435
436/*
437 * Read a portion of a directory.
438 */
Al Viro7111c662006-10-19 23:28:45 -0700439static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200440nfsd3_proc_readdir(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200442 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
443 struct nfsd3_readdirres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700444 __be32 nfserr;
445 int count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
447 dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
448 SVCFH_fmt(&argp->fh),
449 argp->count, (u32) argp->cookie);
450
451 /* Make sure we've room for the NULL ptr & eof flag, and shrink to
452 * client read size */
453 count = (argp->count >> 2) - 2;
454
455 /* Read directory and encode entries on the fly */
456 fh_copy(&resp->fh, &argp->fh);
457
458 resp->buflen = count;
459 resp->common.err = nfs_ok;
460 resp->buffer = argp->buffer;
461 resp->rqstp = rqstp;
462 nfserr = nfsd_readdir(rqstp, &resp->fh, (loff_t*) &argp->cookie,
463 &resp->common, nfs3svc_encode_entry);
464 memcpy(resp->verf, argp->verf, 8);
465 resp->count = resp->buffer - argp->buffer;
NeilBrownb6023452019-03-04 14:08:22 +1100466 if (resp->offset) {
467 loff_t offset = argp->cookie;
468
469 if (unlikely(resp->offset1)) {
470 /* we ended up with offset on a page boundary */
471 *resp->offset = htonl(offset >> 32);
472 *resp->offset1 = htonl(offset & 0xffffffff);
473 resp->offset1 = NULL;
474 } else {
475 xdr_encode_hyper(resp->offset, offset);
476 }
477 resp->offset = NULL;
478 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
480 RETURN_STATUS(nfserr);
481}
482
483/*
484 * Read a portion of a directory, including file handles and attrs.
485 * For now, we choose to ignore the dircount parameter.
486 */
Al Viro7111c662006-10-19 23:28:45 -0700487static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200488nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200490 struct nfsd3_readdirargs *argp = rqstp->rq_argp;
491 struct nfsd3_readdirres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700492 __be32 nfserr;
493 int count = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 loff_t offset;
J. Bruce Fieldsafc59402012-12-10 18:01:37 -0500495 struct page **p;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 caddr_t page_addr = NULL;
497
498 dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
499 SVCFH_fmt(&argp->fh),
500 argp->count, (u32) argp->cookie);
501
502 /* Convert byte count to number of words (i.e. >> 2),
503 * and reserve room for the NULL ptr & eof flag (-2 words) */
504 resp->count = (argp->count >> 2) - 2;
505
506 /* Read directory and encode entries on the fly */
507 fh_copy(&resp->fh, &argp->fh);
508
509 resp->common.err = nfs_ok;
510 resp->buffer = argp->buffer;
511 resp->buflen = resp->count;
512 resp->rqstp = rqstp;
513 offset = argp->cookie;
Rajesh Ghanekar18c01ab2014-08-01 22:17:30 -0400514
515 nfserr = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
516 if (nfserr)
517 RETURN_STATUS(nfserr);
518
519 if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS)
520 RETURN_STATUS(nfserr_notsupp);
521
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 nfserr = nfsd_readdir(rqstp, &resp->fh,
523 &offset,
524 &resp->common,
525 nfs3svc_encode_entry_plus);
526 memcpy(resp->verf, argp->verf, 8);
J. Bruce Fieldsafc59402012-12-10 18:01:37 -0500527 for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
528 page_addr = page_address(*p);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529
530 if (((caddr_t)resp->buffer >= page_addr) &&
531 ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
532 count += (caddr_t)resp->buffer - page_addr;
533 break;
534 }
535 count += PAGE_SIZE;
536 }
537 resp->count = count >> 2;
538 if (resp->offset) {
539 if (unlikely(resp->offset1)) {
540 /* we ended up with offset on a page boundary */
541 *resp->offset = htonl(offset >> 32);
542 *resp->offset1 = htonl(offset & 0xffffffff);
543 resp->offset1 = NULL;
544 } else {
545 xdr_encode_hyper(resp->offset, offset);
546 }
NeilBrownb6023452019-03-04 14:08:22 +1100547 resp->offset = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 }
549
550 RETURN_STATUS(nfserr);
551}
552
553/*
554 * Get file system stats
555 */
Al Viro7111c662006-10-19 23:28:45 -0700556static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200557nfsd3_proc_fsstat(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200559 struct nfsd_fhandle *argp = rqstp->rq_argp;
560 struct nfsd3_fsstatres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700561 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562
563 dprintk("nfsd: FSSTAT(3) %s\n",
564 SVCFH_fmt(&argp->fh));
565
J. Bruce Fields04716e62008-08-07 13:00:20 -0400566 nfserr = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 fh_put(&argp->fh);
568 RETURN_STATUS(nfserr);
569}
570
571/*
572 * Get file system info
573 */
Al Viro7111c662006-10-19 23:28:45 -0700574static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200575nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200577 struct nfsd_fhandle *argp = rqstp->rq_argp;
578 struct nfsd3_fsinfores *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700579 __be32 nfserr;
Greg Banks7adae482006-10-04 02:15:47 -0700580 u32 max_blocksize = svc_max_payload(rqstp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581
582 dprintk("nfsd: FSINFO(3) %s\n",
583 SVCFH_fmt(&argp->fh));
584
Greg Banks7adae482006-10-04 02:15:47 -0700585 resp->f_rtmax = max_blocksize;
586 resp->f_rtpref = max_blocksize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 resp->f_rtmult = PAGE_SIZE;
Greg Banks7adae482006-10-04 02:15:47 -0700588 resp->f_wtmax = max_blocksize;
589 resp->f_wtpref = max_blocksize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 resp->f_wtmult = PAGE_SIZE;
NeilBrownf875a792019-03-07 09:49:46 +1100591 resp->f_dtpref = max_blocksize;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 resp->f_maxfilesize = ~(u32) 0;
593 resp->f_properties = NFS3_FSF_DEFAULT;
594
J. Bruce Fields04716e62008-08-07 13:00:20 -0400595 nfserr = fh_verify(rqstp, &argp->fh, 0,
596 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597
598 /* Check special features of the file system. May request
599 * different read/write sizes for file systems known to have
600 * problems with large blocks */
601 if (nfserr == 0) {
Al Virofc640052016-04-10 01:33:30 -0400602 struct super_block *sb = argp->fh.fh_dentry->d_sb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603
604 /* Note that we don't care for remote fs's here */
Qinghuang Feng12214cb2009-01-12 03:13:53 +0800605 if (sb->s_magic == MSDOS_SUPER_MAGIC) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 resp->f_properties = NFS3_FSF_BILLYBOY;
607 }
608 resp->f_maxfilesize = sb->s_maxbytes;
609 }
610
611 fh_put(&argp->fh);
612 RETURN_STATUS(nfserr);
613}
614
615/*
616 * Get pathconf info for the specified file
617 */
Al Viro7111c662006-10-19 23:28:45 -0700618static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200619nfsd3_proc_pathconf(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200621 struct nfsd_fhandle *argp = rqstp->rq_argp;
622 struct nfsd3_pathconfres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700623 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624
625 dprintk("nfsd: PATHCONF(3) %s\n",
626 SVCFH_fmt(&argp->fh));
627
628 /* Set default pathconf */
629 resp->p_link_max = 255; /* at least */
630 resp->p_name_max = 255; /* at least */
631 resp->p_no_trunc = 0;
632 resp->p_chown_restricted = 1;
633 resp->p_case_insensitive = 0;
634 resp->p_case_preserving = 1;
635
Miklos Szeredi8837abc2008-06-16 13:20:29 +0200636 nfserr = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637
638 if (nfserr == 0) {
Al Virofc640052016-04-10 01:33:30 -0400639 struct super_block *sb = argp->fh.fh_dentry->d_sb;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640
641 /* Note that we don't care for remote fs's here */
642 switch (sb->s_magic) {
643 case EXT2_SUPER_MAGIC:
644 resp->p_link_max = EXT2_LINK_MAX;
645 resp->p_name_max = EXT2_NAME_LEN;
646 break;
Qinghuang Feng12214cb2009-01-12 03:13:53 +0800647 case MSDOS_SUPER_MAGIC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 resp->p_case_insensitive = 1;
649 resp->p_case_preserving = 0;
650 break;
651 }
652 }
653
654 fh_put(&argp->fh);
655 RETURN_STATUS(nfserr);
656}
657
658
659/*
660 * Commit a file (range) to stable storage.
661 */
Al Viro7111c662006-10-19 23:28:45 -0700662static __be32
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200663nfsd3_proc_commit(struct svc_rqst *rqstp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664{
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200665 struct nfsd3_commitargs *argp = rqstp->rq_argp;
666 struct nfsd3_commitres *resp = rqstp->rq_resp;
Al Viroc4d987b2006-10-19 23:29:00 -0700667 __be32 nfserr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668
669 dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
670 SVCFH_fmt(&argp->fh),
671 argp->count,
672 (unsigned long long) argp->offset);
673
674 if (argp->offset > NFS_OFFSET_MAX)
675 RETURN_STATUS(nfserr_inval);
676
677 fh_copy(&resp->fh, &argp->fh);
678 nfserr = nfsd_commit(rqstp, &resp->fh, argp->offset, argp->count);
679
680 RETURN_STATUS(nfserr);
681}
682
683
684/*
685 * NFSv3 Server procedures.
686 * Only the results of non-idempotent operations are cached.
687 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688#define nfs3svc_decode_fhandleargs nfs3svc_decode_fhandle
689#define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
690#define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
691#define nfsd3_mkdirargs nfsd3_createargs
692#define nfsd3_readdirplusargs nfsd3_readdirargs
693#define nfsd3_fhandleargs nfsd_fhandle
694#define nfsd3_fhandleres nfsd3_attrstat
695#define nfsd3_attrstatres nfsd3_attrstat
696#define nfsd3_wccstatres nfsd3_attrstat
697#define nfsd3_createres nfsd3_diropres
698#define nfsd3_voidres nfsd3_voidargs
699struct nfsd3_voidargs { int dummy; };
700
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701#define ST 1 /* status*/
702#define FH 17 /* filehandle with length */
703#define AT 21 /* attributes */
704#define pAT (1+AT) /* post attributes - conditional */
705#define WC (7+pAT) /* WCC attributes */
706
Christoph Hellwig860bda22017-05-12 16:11:49 +0200707static const struct svc_procedure nfsd_procedures3[22] = {
Yu Zhiguob9081d92009-06-09 17:33:34 +0800708 [NFS3PROC_NULL] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200709 .pc_func = nfsd3_proc_null,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200710 .pc_encode = nfs3svc_encode_voidres,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800711 .pc_argsize = sizeof(struct nfsd3_voidargs),
712 .pc_ressize = sizeof(struct nfsd3_voidres),
713 .pc_cachetype = RC_NOCACHE,
714 .pc_xdrressize = ST,
715 },
716 [NFS3PROC_GETATTR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200717 .pc_func = nfsd3_proc_getattr,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200718 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200719 .pc_encode = nfs3svc_encode_attrstatres,
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_fhandleargs),
722 .pc_ressize = sizeof(struct nfsd3_attrstatres),
723 .pc_cachetype = RC_NOCACHE,
724 .pc_xdrressize = ST+AT,
725 },
726 [NFS3PROC_SETATTR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200727 .pc_func = nfsd3_proc_setattr,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200728 .pc_decode = nfs3svc_decode_sattrargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200729 .pc_encode = nfs3svc_encode_wccstatres,
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_sattrargs),
732 .pc_ressize = sizeof(struct nfsd3_wccstatres),
733 .pc_cachetype = RC_REPLBUFF,
734 .pc_xdrressize = ST+WC,
735 },
736 [NFS3PROC_LOOKUP] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200737 .pc_func = nfsd3_proc_lookup,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200738 .pc_decode = nfs3svc_decode_diropargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200739 .pc_encode = nfs3svc_encode_diropres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200740 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800741 .pc_argsize = sizeof(struct nfsd3_diropargs),
742 .pc_ressize = sizeof(struct nfsd3_diropres),
743 .pc_cachetype = RC_NOCACHE,
744 .pc_xdrressize = ST+FH+pAT+pAT,
745 },
746 [NFS3PROC_ACCESS] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200747 .pc_func = nfsd3_proc_access,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200748 .pc_decode = nfs3svc_decode_accessargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200749 .pc_encode = nfs3svc_encode_accessres,
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_accessargs),
752 .pc_ressize = sizeof(struct nfsd3_accessres),
753 .pc_cachetype = RC_NOCACHE,
754 .pc_xdrressize = ST+pAT+1,
755 },
756 [NFS3PROC_READLINK] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200757 .pc_func = nfsd3_proc_readlink,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200758 .pc_decode = nfs3svc_decode_readlinkargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200759 .pc_encode = nfs3svc_encode_readlinkres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200760 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800761 .pc_argsize = sizeof(struct nfsd3_readlinkargs),
762 .pc_ressize = sizeof(struct nfsd3_readlinkres),
763 .pc_cachetype = RC_NOCACHE,
764 .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
765 },
766 [NFS3PROC_READ] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200767 .pc_func = nfsd3_proc_read,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200768 .pc_decode = nfs3svc_decode_readargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200769 .pc_encode = nfs3svc_encode_readres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200770 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800771 .pc_argsize = sizeof(struct nfsd3_readargs),
772 .pc_ressize = sizeof(struct nfsd3_readres),
773 .pc_cachetype = RC_NOCACHE,
774 .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
775 },
776 [NFS3PROC_WRITE] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200777 .pc_func = nfsd3_proc_write,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200778 .pc_decode = nfs3svc_decode_writeargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200779 .pc_encode = nfs3svc_encode_writeres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200780 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800781 .pc_argsize = sizeof(struct nfsd3_writeargs),
782 .pc_ressize = sizeof(struct nfsd3_writeres),
783 .pc_cachetype = RC_REPLBUFF,
784 .pc_xdrressize = ST+WC+4,
785 },
786 [NFS3PROC_CREATE] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200787 .pc_func = nfsd3_proc_create,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200788 .pc_decode = nfs3svc_decode_createargs,
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_createargs),
792 .pc_ressize = sizeof(struct nfsd3_createres),
793 .pc_cachetype = RC_REPLBUFF,
794 .pc_xdrressize = ST+(1+FH+pAT)+WC,
795 },
796 [NFS3PROC_MKDIR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200797 .pc_func = nfsd3_proc_mkdir,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200798 .pc_decode = nfs3svc_decode_mkdirargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200799 .pc_encode = nfs3svc_encode_createres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200800 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800801 .pc_argsize = sizeof(struct nfsd3_mkdirargs),
802 .pc_ressize = sizeof(struct nfsd3_createres),
803 .pc_cachetype = RC_REPLBUFF,
804 .pc_xdrressize = ST+(1+FH+pAT)+WC,
805 },
806 [NFS3PROC_SYMLINK] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200807 .pc_func = nfsd3_proc_symlink,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200808 .pc_decode = nfs3svc_decode_symlinkargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200809 .pc_encode = nfs3svc_encode_createres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200810 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800811 .pc_argsize = sizeof(struct nfsd3_symlinkargs),
812 .pc_ressize = sizeof(struct nfsd3_createres),
813 .pc_cachetype = RC_REPLBUFF,
814 .pc_xdrressize = ST+(1+FH+pAT)+WC,
815 },
816 [NFS3PROC_MKNOD] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200817 .pc_func = nfsd3_proc_mknod,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200818 .pc_decode = nfs3svc_decode_mknodargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200819 .pc_encode = nfs3svc_encode_createres,
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_mknodargs),
822 .pc_ressize = sizeof(struct nfsd3_createres),
823 .pc_cachetype = RC_REPLBUFF,
824 .pc_xdrressize = ST+(1+FH+pAT)+WC,
825 },
826 [NFS3PROC_REMOVE] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200827 .pc_func = nfsd3_proc_remove,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200828 .pc_decode = nfs3svc_decode_diropargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200829 .pc_encode = nfs3svc_encode_wccstatres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200830 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800831 .pc_argsize = sizeof(struct nfsd3_diropargs),
832 .pc_ressize = sizeof(struct nfsd3_wccstatres),
833 .pc_cachetype = RC_REPLBUFF,
834 .pc_xdrressize = ST+WC,
835 },
836 [NFS3PROC_RMDIR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200837 .pc_func = nfsd3_proc_rmdir,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200838 .pc_decode = nfs3svc_decode_diropargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200839 .pc_encode = nfs3svc_encode_wccstatres,
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_diropargs),
842 .pc_ressize = sizeof(struct nfsd3_wccstatres),
843 .pc_cachetype = RC_REPLBUFF,
844 .pc_xdrressize = ST+WC,
845 },
846 [NFS3PROC_RENAME] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200847 .pc_func = nfsd3_proc_rename,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200848 .pc_decode = nfs3svc_decode_renameargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200849 .pc_encode = nfs3svc_encode_renameres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200850 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800851 .pc_argsize = sizeof(struct nfsd3_renameargs),
852 .pc_ressize = sizeof(struct nfsd3_renameres),
853 .pc_cachetype = RC_REPLBUFF,
854 .pc_xdrressize = ST+WC+WC,
855 },
856 [NFS3PROC_LINK] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200857 .pc_func = nfsd3_proc_link,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200858 .pc_decode = nfs3svc_decode_linkargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200859 .pc_encode = nfs3svc_encode_linkres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200860 .pc_release = nfs3svc_release_fhandle2,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800861 .pc_argsize = sizeof(struct nfsd3_linkargs),
862 .pc_ressize = sizeof(struct nfsd3_linkres),
863 .pc_cachetype = RC_REPLBUFF,
864 .pc_xdrressize = ST+pAT+WC,
865 },
866 [NFS3PROC_READDIR] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200867 .pc_func = nfsd3_proc_readdir,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200868 .pc_decode = nfs3svc_decode_readdirargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200869 .pc_encode = nfs3svc_encode_readdirres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200870 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800871 .pc_argsize = sizeof(struct nfsd3_readdirargs),
872 .pc_ressize = sizeof(struct nfsd3_readdirres),
873 .pc_cachetype = RC_NOCACHE,
874 },
875 [NFS3PROC_READDIRPLUS] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200876 .pc_func = nfsd3_proc_readdirplus,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200877 .pc_decode = nfs3svc_decode_readdirplusargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200878 .pc_encode = nfs3svc_encode_readdirres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200879 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800880 .pc_argsize = sizeof(struct nfsd3_readdirplusargs),
881 .pc_ressize = sizeof(struct nfsd3_readdirres),
882 .pc_cachetype = RC_NOCACHE,
883 },
884 [NFS3PROC_FSSTAT] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200885 .pc_func = nfsd3_proc_fsstat,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200886 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200887 .pc_encode = nfs3svc_encode_fsstatres,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800888 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
889 .pc_ressize = sizeof(struct nfsd3_fsstatres),
890 .pc_cachetype = RC_NOCACHE,
891 .pc_xdrressize = ST+pAT+2*6+1,
892 },
893 [NFS3PROC_FSINFO] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200894 .pc_func = nfsd3_proc_fsinfo,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200895 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200896 .pc_encode = nfs3svc_encode_fsinfores,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800897 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
898 .pc_ressize = sizeof(struct nfsd3_fsinfores),
899 .pc_cachetype = RC_NOCACHE,
900 .pc_xdrressize = ST+pAT+12,
901 },
902 [NFS3PROC_PATHCONF] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200903 .pc_func = nfsd3_proc_pathconf,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200904 .pc_decode = nfs3svc_decode_fhandleargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200905 .pc_encode = nfs3svc_encode_pathconfres,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800906 .pc_argsize = sizeof(struct nfsd3_fhandleargs),
907 .pc_ressize = sizeof(struct nfsd3_pathconfres),
908 .pc_cachetype = RC_NOCACHE,
909 .pc_xdrressize = ST+pAT+6,
910 },
911 [NFS3PROC_COMMIT] = {
Christoph Hellwiga6beb732017-05-08 17:35:49 +0200912 .pc_func = nfsd3_proc_commit,
Christoph Hellwig026fec72017-05-08 19:01:48 +0200913 .pc_decode = nfs3svc_decode_commitargs,
Christoph Hellwig63f8de32017-05-08 19:42:02 +0200914 .pc_encode = nfs3svc_encode_commitres,
Christoph Hellwig85374882017-05-08 18:48:24 +0200915 .pc_release = nfs3svc_release_fhandle,
Yu Zhiguob9081d92009-06-09 17:33:34 +0800916 .pc_argsize = sizeof(struct nfsd3_commitargs),
917 .pc_ressize = sizeof(struct nfsd3_commitres),
918 .pc_cachetype = RC_NOCACHE,
919 .pc_xdrressize = ST+WC+2,
920 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921};
922
Christoph Hellwig7fd38af2017-05-08 23:40:27 +0200923static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
Christoph Hellwige9679182017-05-12 16:21:37 +0200924const struct svc_version nfsd_version3 = {
925 .vs_vers = 3,
926 .vs_nproc = 22,
927 .vs_proc = nfsd_procedures3,
928 .vs_dispatch = nfsd_dispatch,
929 .vs_count = nfsd_count3,
930 .vs_xdrsize = NFS3_SVC_XDRSIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931};