Blame view

fs/nfsd/nfs3proc.c 24.4 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  // SPDX-License-Identifier: GPL-2.0
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
5
6
   * Process version 3 NFS requests.
   *
   * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
  #include <linux/fs.h>
  #include <linux/ext2_fs.h>
12214cb78   Qinghuang Feng   NFSD: cleanup for...
9
  #include <linux/magic.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10

9a74af213   Boaz Harrosh   nfsd: Move privat...
11
12
  #include "cache.h"
  #include "xdr3.h"
0a3adadee   J. Bruce Fields   nfsd: make fs/nfs...
13
  #include "vfs.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
14
15
  
  #define NFSDDBG_FACILITY		NFSDDBG_PROC
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  static int	nfs3_ftypes[] = {
  	0,			/* NF3NON */
  	S_IFREG,		/* NF3REG */
  	S_IFDIR,		/* NF3DIR */
  	S_IFBLK,		/* NF3BLK */
  	S_IFCHR,		/* NF3CHR */
  	S_IFLNK,		/* NF3LNK */
  	S_IFSOCK,		/* NF3SOCK */
  	S_IFIFO,		/* NF3FIFO */
  };
  
  /*
   * NULL call.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
30
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
31
  nfsd3_proc_null(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
  {
cc028a10a   Chuck Lever   NFSD: Hoist statu...
33
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
35
36
37
38
  }
  
  /*
   * Get a file's attributes
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
39
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
40
  nfsd3_proc_getattr(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
42
43
  	struct nfsd_fhandle *argp = rqstp->rq_argp;
  	struct nfsd3_attrstat *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44
45
46
  
  	dprintk("nfsd: GETATTR(3)  %s
  ",
a334de286   David Shaw   [PATCH] knfsd: ch...
47
  		SVCFH_fmt(&argp->fh));
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
  
  	fh_copy(&resp->fh, &argp->fh);
14168d678   Chuck Lever   NFSD: Remove the ...
50
51
52
53
54
55
56
  	resp->status = fh_verify(rqstp, &resp->fh, 0,
  				 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
  	if (resp->status != nfs_ok)
  		goto out;
  
  	resp->status = fh_getattr(&resp->fh, &resp->stat);
  out:
cc028a10a   Chuck Lever   NFSD: Hoist statu...
57
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
58
59
60
61
62
  }
  
  /*
   * Set a file's attributes
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
63
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
64
  nfsd3_proc_setattr(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
65
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
66
67
  	struct nfsd3_sattrargs *argp = rqstp->rq_argp;
  	struct nfsd3_attrstat *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
70
71
72
73
  
  	dprintk("nfsd: SETATTR(3)  %s
  ",
  				SVCFH_fmt(&argp->fh));
  
  	fh_copy(&resp->fh, &argp->fh);
14168d678   Chuck Lever   NFSD: Remove the ...
74
75
  	resp->status = nfsd_setattr(rqstp, &resp->fh, &argp->attrs,
  				    argp->check_guard, argp->guardtime);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
76
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
79
80
81
  }
  
  /*
   * Look up a path name component
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
82
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
83
  nfsd3_proc_lookup(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
84
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
85
86
  	struct nfsd3_diropargs *argp = rqstp->rq_argp;
  	struct nfsd3_diropres  *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
87
88
89
90
91
92
93
94
95
  
  	dprintk("nfsd: LOOKUP(3)   %s %.*s
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->len,
  				argp->name);
  
  	fh_copy(&resp->dirfh, &argp->fh);
  	fh_init(&resp->fh, NFS3_FHSIZE);
14168d678   Chuck Lever   NFSD: Remove the ...
96
97
98
  	resp->status = nfsd_lookup(rqstp, &resp->dirfh,
  				   argp->name, argp->len,
  				   &resp->fh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
99
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
101
102
103
104
  }
  
  /*
   * Check file access
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
105
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
106
  nfsd3_proc_access(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
108
109
  	struct nfsd3_accessargs *argp = rqstp->rq_argp;
  	struct nfsd3_accessres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
113
114
115
116
117
  
  	dprintk("nfsd: ACCESS(3)   %s 0x%x
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->access);
  
  	fh_copy(&resp->fh, &argp->fh);
  	resp->access = argp->access;
14168d678   Chuck Lever   NFSD: Remove the ...
118
  	resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
119
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
121
122
123
124
  }
  
  /*
   * Read a symlink.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
125
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
126
  nfsd3_proc_readlink(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
128
129
  	struct nfsd3_readlinkargs *argp = rqstp->rq_argp;
  	struct nfsd3_readlinkres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
130
131
132
133
134
135
136
  
  	dprintk("nfsd: READLINK(3) %s
  ", SVCFH_fmt(&argp->fh));
  
  	/* Read the symlink. */
  	fh_copy(&resp->fh, &argp->fh);
  	resp->len = NFS3_MAXPATHLEN;
14168d678   Chuck Lever   NFSD: Remove the ...
137
  	resp->status = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
138
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139
140
141
142
143
  }
  
  /*
   * Read a portion of a file.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
144
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
145
  nfsd3_proc_read(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
146
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
147
148
  	struct nfsd3_readargs *argp = rqstp->rq_argp;
  	struct nfsd3_readres *resp = rqstp->rq_resp;
7adae489f   Greg Banks   [PATCH] knfsd: Pr...
149
  	u32	max_blocksize = svc_max_payload(rqstp);
ac503e4a3   Benjamin Coddington   nfsd: use short r...
150
  	unsigned long cnt = min(argp->count, max_blocksize);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
151

18b631f83   J. Bruce Fields   nfsd: fix offset ...
152
153
  	dprintk("nfsd: READ(3) %s %lu bytes at %Lu
  ",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
155
  				SVCFH_fmt(&argp->fh),
  				(unsigned long) argp->count,
18b631f83   J. Bruce Fields   nfsd: fix offset ...
156
  				(unsigned long long) argp->offset);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
157
158
159
160
161
  
  	/* Obtain buffer pointer for payload.
  	 * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
  	 * + 1 (xdr opaque byte count) = 26
  	 */
ac503e4a3   Benjamin Coddington   nfsd: use short r...
162
  	resp->count = cnt;
cd123012d   Jeff Layton   RPC: add wrapper ...
163
  	svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
164
165
  
  	fh_copy(&resp->fh, &argp->fh);
14168d678   Chuck Lever   NFSD: Remove the ...
166
167
168
  	resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
  				 rqstp->rq_vec, argp->vlen, &resp->count,
  				 &resp->eof);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
169
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
170
171
172
173
174
  }
  
  /*
   * Write data to a file
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
175
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
176
  nfsd3_proc_write(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
177
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
178
179
  	struct nfsd3_writeargs *argp = rqstp->rq_argp;
  	struct nfsd3_writeres *resp = rqstp->rq_resp;
31dec2538   David Shaw   Short write in nf...
180
  	unsigned long cnt = argp->len;
8154ef277   Chuck Lever   NFSD: Clean up le...
181
  	unsigned int nvecs;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
182

18b631f83   J. Bruce Fields   nfsd: fix offset ...
183
184
  	dprintk("nfsd: WRITE(3)    %s %d bytes at %Lu%s
  ",
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
185
186
  				SVCFH_fmt(&argp->fh),
  				argp->len,
18b631f83   J. Bruce Fields   nfsd: fix offset ...
187
  				(unsigned long long) argp->offset,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
188
189
190
191
  				argp->stable? " stable" : "");
  
  	fh_copy(&resp->fh, &argp->fh);
  	resp->committed = argp->stable;
3fd9557ae   Chuck Lever   NFSD: Refactor th...
192
193
  	nvecs = svc_fill_write_vector(rqstp, rqstp->rq_arg.pages,
  				      &argp->first, cnt);
14168d678   Chuck Lever   NFSD: Remove the ...
194
195
196
197
198
199
200
  	if (!nvecs) {
  		resp->status = nfserr_io;
  		goto out;
  	}
  	resp->status = nfsd_write(rqstp, &resp->fh, argp->offset,
  				  rqstp->rq_vec, nvecs, &cnt,
  				  resp->committed, resp->verf);
31dec2538   David Shaw   Short write in nf...
201
  	resp->count = cnt;
14168d678   Chuck Lever   NFSD: Remove the ...
202
  out:
cc028a10a   Chuck Lever   NFSD: Hoist statu...
203
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
204
205
206
207
208
209
210
  }
  
  /*
   * With NFSv3, CREATE processing is a lot easier than with NFSv2.
   * At least in theory; we'll see how it fares in practice when the
   * first reports about SunOS compatibility problems start to pour in...
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
211
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
212
  nfsd3_proc_create(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
213
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
214
215
  	struct nfsd3_createargs *argp = rqstp->rq_argp;
  	struct nfsd3_diropres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
216
217
  	svc_fh		*dirfhp, *newfhp = NULL;
  	struct iattr	*attr;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
218
219
220
221
222
223
224
225
226
227
  
  	dprintk("nfsd: CREATE(3)   %s %.*s
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->len,
  				argp->name);
  
  	dirfhp = fh_copy(&resp->dirfh, &argp->fh);
  	newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
  	attr   = &argp->attrs;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
228
229
230
231
232
233
234
235
236
237
  	/* Unfudge the mode bits */
  	attr->ia_mode &= ~S_IFMT;
  	if (!(attr->ia_valid & ATTR_MODE)) { 
  		attr->ia_valid |= ATTR_MODE;
  		attr->ia_mode = S_IFREG;
  	} else {
  		attr->ia_mode = (attr->ia_mode & ~S_IFMT) | S_IFREG;
  	}
  
  	/* Now create the file and set attributes */
14168d678   Chuck Lever   NFSD: Remove the ...
238
239
240
  	resp->status = do_nfsd_create(rqstp, dirfhp, argp->name, argp->len,
  				      attr, newfhp, argp->createmode,
  				      (u32 *)argp->verf, NULL, NULL);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
241
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
242
243
244
245
246
  }
  
  /*
   * Make directory. This operation is not idempotent.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
247
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
248
  nfsd3_proc_mkdir(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
249
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
250
251
  	struct nfsd3_createargs *argp = rqstp->rq_argp;
  	struct nfsd3_diropres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
252
253
254
255
256
257
258
259
260
261
  
  	dprintk("nfsd: MKDIR(3)    %s %.*s
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->len,
  				argp->name);
  
  	argp->attrs.ia_valid &= ~ATTR_SIZE;
  	fh_copy(&resp->dirfh, &argp->fh);
  	fh_init(&resp->fh, NFS3_FHSIZE);
14168d678   Chuck Lever   NFSD: Remove the ...
262
263
  	resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
  				   &argp->attrs, S_IFDIR, 0, &resp->fh);
43a9aa64a   Chuck Lever   NFSD: Fill in WCC...
264
  	fh_unlock(&resp->dirfh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
265
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
266
  }
7111c66e4   Al Viro   [PATCH] fix svc_p...
267
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
268
  nfsd3_proc_symlink(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
269
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
270
271
  	struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
  	struct nfsd3_diropres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
272

14168d678   Chuck Lever   NFSD: Remove the ...
273
274
275
276
277
278
279
280
  	if (argp->tlen == 0) {
  		resp->status = nfserr_inval;
  		goto out;
  	}
  	if (argp->tlen > NFS3_MAXPATHLEN) {
  		resp->status = nfserr_nametoolong;
  		goto out;
  	}
38a703155   Chuck Lever   NFSD: Clean up le...
281
282
  
  	argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
11b4d66ea   Chuck Lever   NFSD: Handle full...
283
  						page_address(rqstp->rq_arg.pages[0]),
38a703155   Chuck Lever   NFSD: Clean up le...
284
  						argp->tlen);
14168d678   Chuck Lever   NFSD: Remove the ...
285
286
287
288
  	if (IS_ERR(argp->tname)) {
  		resp->status = nfserrno(PTR_ERR(argp->tname));
  		goto out;
  	}
38a703155   Chuck Lever   NFSD: Clean up le...
289

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
290
291
292
293
294
295
296
297
  	dprintk("nfsd: SYMLINK(3)  %s %.*s -> %.*s
  ",
  				SVCFH_fmt(&argp->ffh),
  				argp->flen, argp->fname,
  				argp->tlen, argp->tname);
  
  	fh_copy(&resp->dirfh, &argp->ffh);
  	fh_init(&resp->fh, NFS3_FHSIZE);
14168d678   Chuck Lever   NFSD: Remove the ...
298
299
  	resp->status = nfsd_symlink(rqstp, &resp->dirfh, argp->fname,
  				    argp->flen, argp->tname, &resp->fh);
11b4d66ea   Chuck Lever   NFSD: Handle full...
300
  	kfree(argp->tname);
14168d678   Chuck Lever   NFSD: Remove the ...
301
  out:
cc028a10a   Chuck Lever   NFSD: Hoist statu...
302
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
303
304
305
306
307
  }
  
  /*
   * Make socket/fifo/device.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
308
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
309
  nfsd3_proc_mknod(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
310
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
311
312
  	struct nfsd3_mknodargs *argp = rqstp->rq_argp;
  	struct nfsd3_diropres  *resp = rqstp->rq_resp;
c4d987ba8   Al Viro   [PATCH] nfsd: NFS...
313
  	int type;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
314
315
316
317
318
319
320
321
322
323
  	dev_t	rdev = 0;
  
  	dprintk("nfsd: MKNOD(3)    %s %.*s
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->len,
  				argp->name);
  
  	fh_copy(&resp->dirfh, &argp->fh);
  	fh_init(&resp->fh, NFS3_FHSIZE);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
324
325
326
  	if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
  		rdev = MKDEV(argp->major, argp->minor);
  		if (MAJOR(rdev) != argp->major ||
14168d678   Chuck Lever   NFSD: Remove the ...
327
328
329
330
331
  		    MINOR(rdev) != argp->minor) {
  			resp->status = nfserr_inval;
  			goto out;
  		}
  	} else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) {
66d60e3ad   Chuck Lever   NFSD: MKNOD shoul...
332
  		resp->status = nfserr_badtype;
14168d678   Chuck Lever   NFSD: Remove the ...
333
334
  		goto out;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
335
336
  
  	type = nfs3_ftypes[argp->ftype];
14168d678   Chuck Lever   NFSD: Remove the ...
337
338
  	resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
  				   &argp->attrs, type, rdev, &resp->fh);
43a9aa64a   Chuck Lever   NFSD: Fill in WCC...
339
  	fh_unlock(&resp->dirfh);
14168d678   Chuck Lever   NFSD: Remove the ...
340
  out:
cc028a10a   Chuck Lever   NFSD: Hoist statu...
341
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
342
343
344
345
346
  }
  
  /*
   * Remove file/fifo/socket etc.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
347
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
348
  nfsd3_proc_remove(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
349
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
350
351
  	struct nfsd3_diropargs *argp = rqstp->rq_argp;
  	struct nfsd3_attrstat *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
352
353
354
355
356
357
358
359
360
  
  	dprintk("nfsd: REMOVE(3)   %s %.*s
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->len,
  				argp->name);
  
  	/* Unlink. -S_IFDIR means file must not be a directory */
  	fh_copy(&resp->fh, &argp->fh);
14168d678   Chuck Lever   NFSD: Remove the ...
361
362
  	resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR,
  				   argp->name, argp->len);
43a9aa64a   Chuck Lever   NFSD: Fill in WCC...
363
  	fh_unlock(&resp->fh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
364
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
365
366
367
368
369
  }
  
  /*
   * Remove a directory
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
370
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
371
  nfsd3_proc_rmdir(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
372
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
373
374
  	struct nfsd3_diropargs *argp = rqstp->rq_argp;
  	struct nfsd3_attrstat *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
375
376
377
378
379
380
381
382
  
  	dprintk("nfsd: RMDIR(3)    %s %.*s
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->len,
  				argp->name);
  
  	fh_copy(&resp->fh, &argp->fh);
14168d678   Chuck Lever   NFSD: Remove the ...
383
384
  	resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR,
  				   argp->name, argp->len);
43a9aa64a   Chuck Lever   NFSD: Fill in WCC...
385
  	fh_unlock(&resp->fh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
386
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
387
  }
7111c66e4   Al Viro   [PATCH] fix svc_p...
388
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
389
  nfsd3_proc_rename(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
390
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
391
392
  	struct nfsd3_renameargs *argp = rqstp->rq_argp;
  	struct nfsd3_renameres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
393
394
395
396
397
398
399
400
401
402
403
404
405
406
  
  	dprintk("nfsd: RENAME(3)   %s %.*s ->
  ",
  				SVCFH_fmt(&argp->ffh),
  				argp->flen,
  				argp->fname);
  	dprintk("nfsd: -> %s %.*s
  ",
  				SVCFH_fmt(&argp->tfh),
  				argp->tlen,
  				argp->tname);
  
  	fh_copy(&resp->ffh, &argp->ffh);
  	fh_copy(&resp->tfh, &argp->tfh);
14168d678   Chuck Lever   NFSD: Remove the ...
407
408
  	resp->status = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
  				   &resp->tfh, argp->tname, argp->tlen);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
409
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
410
  }
7111c66e4   Al Viro   [PATCH] fix svc_p...
411
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
412
  nfsd3_proc_link(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
413
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
414
415
  	struct nfsd3_linkargs *argp = rqstp->rq_argp;
  	struct nfsd3_linkres  *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
416
417
418
419
420
421
422
423
424
425
426
427
  
  	dprintk("nfsd: LINK(3)     %s ->
  ",
  				SVCFH_fmt(&argp->ffh));
  	dprintk("nfsd:   -> %s %.*s
  ",
  				SVCFH_fmt(&argp->tfh),
  				argp->tlen,
  				argp->tname);
  
  	fh_copy(&resp->fh,  &argp->ffh);
  	fh_copy(&resp->tfh, &argp->tfh);
14168d678   Chuck Lever   NFSD: Remove the ...
428
429
  	resp->status = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
  				 &resp->fh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
430
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
431
432
433
434
435
  }
  
  /*
   * Read a portion of a directory.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
436
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
437
  nfsd3_proc_readdir(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
438
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
439
440
  	struct nfsd3_readdirargs *argp = rqstp->rq_argp;
  	struct nfsd3_readdirres  *resp = rqstp->rq_resp;
3c86794ac   Murphy Zhou   nfsd/nfsd3_proc_r...
441
442
443
  	int		count = 0;
  	struct page	**p;
  	caddr_t		page_addr = NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
  
  	dprintk("nfsd: READDIR(3)  %s %d bytes at %d
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->count, (u32) argp->cookie);
  
  	/* Make sure we've room for the NULL ptr & eof flag, and shrink to
  	 * client read size */
  	count = (argp->count >> 2) - 2;
  
  	/* Read directory and encode entries on the fly */
  	fh_copy(&resp->fh, &argp->fh);
  
  	resp->buflen = count;
  	resp->common.err = nfs_ok;
  	resp->buffer = argp->buffer;
  	resp->rqstp = rqstp;
14168d678   Chuck Lever   NFSD: Remove the ...
461
462
  	resp->status = nfsd_readdir(rqstp, &resp->fh, (loff_t *)&argp->cookie,
  				    &resp->common, nfs3svc_encode_entry);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
463
  	memcpy(resp->verf, argp->verf, 8);
3c86794ac   Murphy Zhou   nfsd/nfsd3_proc_r...
464
465
466
467
468
469
470
471
472
473
474
475
  	count = 0;
  	for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
  		page_addr = page_address(*p);
  
  		if (((caddr_t)resp->buffer >= page_addr) &&
  		    ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
  			count += (caddr_t)resp->buffer - page_addr;
  			break;
  		}
  		count += PAGE_SIZE;
  	}
  	resp->count = count >> 2;
b602345da   NeilBrown   nfsd: fix memory ...
476
477
478
479
480
481
482
483
484
485
486
487
488
  	if (resp->offset) {
  		loff_t offset = argp->cookie;
  
  		if (unlikely(resp->offset1)) {
  			/* we ended up with offset on a page boundary */
  			*resp->offset = htonl(offset >> 32);
  			*resp->offset1 = htonl(offset & 0xffffffff);
  			resp->offset1 = NULL;
  		} else {
  			xdr_encode_hyper(resp->offset, offset);
  		}
  		resp->offset = NULL;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
489

cc028a10a   Chuck Lever   NFSD: Hoist statu...
490
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
491
492
493
494
495
496
  }
  
  /*
   * Read a portion of a directory, including file handles and attrs.
   * For now, we choose to ignore the dircount parameter.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
497
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
498
  nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
499
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
500
501
  	struct nfsd3_readdirargs *argp = rqstp->rq_argp;
  	struct nfsd3_readdirres  *resp = rqstp->rq_resp;
c4d987ba8   Al Viro   [PATCH] nfsd: NFS...
502
  	int	count = 0;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
503
  	loff_t	offset;
afc59400d   J. Bruce Fields   nfsd4: cleanup: r...
504
  	struct page **p;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
  	caddr_t	page_addr = NULL;
  
  	dprintk("nfsd: READDIR+(3) %s %d bytes at %d
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->count, (u32) argp->cookie);
  
  	/* Convert byte count to number of words (i.e. >> 2),
  	 * and reserve room for the NULL ptr & eof flag (-2 words) */
  	resp->count = (argp->count >> 2) - 2;
  
  	/* Read directory and encode entries on the fly */
  	fh_copy(&resp->fh, &argp->fh);
  
  	resp->common.err = nfs_ok;
  	resp->buffer = argp->buffer;
  	resp->buflen = resp->count;
  	resp->rqstp = rqstp;
  	offset = argp->cookie;
18c01ab30   Rajesh Ghanekar   nfsd: allow turni...
524

14168d678   Chuck Lever   NFSD: Remove the ...
525
526
527
  	resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
  	if (resp->status != nfs_ok)
  		goto out;
18c01ab30   Rajesh Ghanekar   nfsd: allow turni...
528

14168d678   Chuck Lever   NFSD: Remove the ...
529
530
531
532
  	if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) {
  		resp->status = nfserr_notsupp;
  		goto out;
  	}
18c01ab30   Rajesh Ghanekar   nfsd: allow turni...
533

14168d678   Chuck Lever   NFSD: Remove the ...
534
535
  	resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
  				    &resp->common, nfs3svc_encode_entry_plus);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
536
  	memcpy(resp->verf, argp->verf, 8);
afc59400d   J. Bruce Fields   nfsd4: cleanup: r...
537
538
  	for (p = rqstp->rq_respages + 1; p < rqstp->rq_next_page; p++) {
  		page_addr = page_address(*p);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
  
  		if (((caddr_t)resp->buffer >= page_addr) &&
  		    ((caddr_t)resp->buffer < page_addr + PAGE_SIZE)) {
  			count += (caddr_t)resp->buffer - page_addr;
  			break;
  		}
  		count += PAGE_SIZE;
  	}
  	resp->count = count >> 2;
  	if (resp->offset) {
  		if (unlikely(resp->offset1)) {
  			/* we ended up with offset on a page boundary */
  			*resp->offset = htonl(offset >> 32);
  			*resp->offset1 = htonl(offset & 0xffffffff);
  			resp->offset1 = NULL;
  		} else {
  			xdr_encode_hyper(resp->offset, offset);
  		}
b602345da   NeilBrown   nfsd: fix memory ...
557
  		resp->offset = NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
558
  	}
14168d678   Chuck Lever   NFSD: Remove the ...
559
  out:
cc028a10a   Chuck Lever   NFSD: Hoist statu...
560
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
561
562
563
564
565
  }
  
  /*
   * Get file system stats
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
566
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
567
  nfsd3_proc_fsstat(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
568
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
569
570
  	struct nfsd_fhandle *argp = rqstp->rq_argp;
  	struct nfsd3_fsstatres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
571
572
573
574
  
  	dprintk("nfsd: FSSTAT(3)   %s
  ",
  				SVCFH_fmt(&argp->fh));
14168d678   Chuck Lever   NFSD: Remove the ...
575
  	resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
576
  	fh_put(&argp->fh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
577
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
578
579
580
581
582
  }
  
  /*
   * Get file system info
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
583
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
584
  nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
585
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
586
587
  	struct nfsd_fhandle *argp = rqstp->rq_argp;
  	struct nfsd3_fsinfores *resp = rqstp->rq_resp;
7adae489f   Greg Banks   [PATCH] knfsd: Pr...
588
  	u32	max_blocksize = svc_max_payload(rqstp);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
589
590
591
592
  
  	dprintk("nfsd: FSINFO(3)   %s
  ",
  				SVCFH_fmt(&argp->fh));
7adae489f   Greg Banks   [PATCH] knfsd: Pr...
593
594
  	resp->f_rtmax  = max_blocksize;
  	resp->f_rtpref = max_blocksize;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
595
  	resp->f_rtmult = PAGE_SIZE;
7adae489f   Greg Banks   [PATCH] knfsd: Pr...
596
597
  	resp->f_wtmax  = max_blocksize;
  	resp->f_wtpref = max_blocksize;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
598
  	resp->f_wtmult = PAGE_SIZE;
f875a792a   NeilBrown   nfsd: allow nfsv3...
599
  	resp->f_dtpref = max_blocksize;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
600
601
  	resp->f_maxfilesize = ~(u32) 0;
  	resp->f_properties = NFS3_FSF_DEFAULT;
14168d678   Chuck Lever   NFSD: Remove the ...
602
603
  	resp->status = fh_verify(rqstp, &argp->fh, 0,
  				 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
604
605
606
607
  
  	/* Check special features of the file system. May request
  	 * different read/write sizes for file systems known to have
  	 * problems with large blocks */
14168d678   Chuck Lever   NFSD: Remove the ...
608
  	if (resp->status == nfs_ok) {
fc64005c9   Al Viro   don't bother with...
609
  		struct super_block *sb = argp->fh.fh_dentry->d_sb;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
610
611
  
  		/* Note that we don't care for remote fs's here */
12214cb78   Qinghuang Feng   NFSD: cleanup for...
612
  		if (sb->s_magic == MSDOS_SUPER_MAGIC) {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
613
614
615
616
617
618
  			resp->f_properties = NFS3_FSF_BILLYBOY;
  		}
  		resp->f_maxfilesize = sb->s_maxbytes;
  	}
  
  	fh_put(&argp->fh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
619
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
620
621
622
623
624
  }
  
  /*
   * Get pathconf info for the specified file
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
625
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
626
  nfsd3_proc_pathconf(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
627
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
628
629
  	struct nfsd_fhandle *argp = rqstp->rq_argp;
  	struct nfsd3_pathconfres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
630
631
632
633
634
635
636
637
638
639
640
641
  
  	dprintk("nfsd: PATHCONF(3) %s
  ",
  				SVCFH_fmt(&argp->fh));
  
  	/* Set default pathconf */
  	resp->p_link_max = 255;		/* at least */
  	resp->p_name_max = 255;		/* at least */
  	resp->p_no_trunc = 0;
  	resp->p_chown_restricted = 1;
  	resp->p_case_insensitive = 0;
  	resp->p_case_preserving = 1;
14168d678   Chuck Lever   NFSD: Remove the ...
642
  	resp->status = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
643

14168d678   Chuck Lever   NFSD: Remove the ...
644
  	if (resp->status == nfs_ok) {
fc64005c9   Al Viro   don't bother with...
645
  		struct super_block *sb = argp->fh.fh_dentry->d_sb;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
646
647
648
649
650
651
652
  
  		/* Note that we don't care for remote fs's here */
  		switch (sb->s_magic) {
  		case EXT2_SUPER_MAGIC:
  			resp->p_link_max = EXT2_LINK_MAX;
  			resp->p_name_max = EXT2_NAME_LEN;
  			break;
12214cb78   Qinghuang Feng   NFSD: cleanup for...
653
  		case MSDOS_SUPER_MAGIC:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
654
655
656
657
658
659
660
  			resp->p_case_insensitive = 1;
  			resp->p_case_preserving  = 0;
  			break;
  		}
  	}
  
  	fh_put(&argp->fh);
cc028a10a   Chuck Lever   NFSD: Hoist statu...
661
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
662
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
663
664
665
  /*
   * Commit a file (range) to stable storage.
   */
7111c66e4   Al Viro   [PATCH] fix svc_p...
666
  static __be32
a6beb7327   Christoph Hellwig   sunrpc: properly ...
667
  nfsd3_proc_commit(struct svc_rqst *rqstp)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
668
  {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
669
670
  	struct nfsd3_commitargs *argp = rqstp->rq_argp;
  	struct nfsd3_commitres *resp = rqstp->rq_resp;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
671
672
673
674
675
676
  
  	dprintk("nfsd: COMMIT(3)   %s %u@%Lu
  ",
  				SVCFH_fmt(&argp->fh),
  				argp->count,
  				(unsigned long long) argp->offset);
14168d678   Chuck Lever   NFSD: Remove the ...
677
678
679
680
  	if (argp->offset > NFS_OFFSET_MAX) {
  		resp->status = nfserr_inval;
  		goto out;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
681
682
  
  	fh_copy(&resp->fh, &argp->fh);
14168d678   Chuck Lever   NFSD: Remove the ...
683
684
685
  	resp->status = nfsd_commit(rqstp, &resp->fh, argp->offset,
  				   argp->count, resp->verf);
  out:
cc028a10a   Chuck Lever   NFSD: Hoist statu...
686
  	return rpc_success;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
687
688
689
690
691
692
693
  }
  
  
  /*
   * NFSv3 Server procedures.
   * Only the results of non-idempotent operations are cached.
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
694
695
696
697
698
699
700
701
702
703
704
705
  #define nfs3svc_decode_fhandleargs	nfs3svc_decode_fhandle
  #define nfs3svc_encode_attrstatres	nfs3svc_encode_attrstat
  #define nfs3svc_encode_wccstatres	nfs3svc_encode_wccstat
  #define nfsd3_mkdirargs			nfsd3_createargs
  #define nfsd3_readdirplusargs		nfsd3_readdirargs
  #define nfsd3_fhandleargs		nfsd_fhandle
  #define nfsd3_fhandleres		nfsd3_attrstat
  #define nfsd3_attrstatres		nfsd3_attrstat
  #define nfsd3_wccstatres		nfsd3_attrstat
  #define nfsd3_createres			nfsd3_diropres
  #define nfsd3_voidres			nfsd3_voidargs
  struct nfsd3_voidargs { int dummy; };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
706
707
708
709
710
  #define ST 1		/* status*/
  #define FH 17		/* filehandle with length */
  #define AT 21		/* attributes */
  #define pAT (1+AT)	/* post attributes - conditional */
  #define WC (7+pAT)	/* WCC attributes */
860bda29b   Christoph Hellwig   sunrpc: mark all ...
711
  static const struct svc_procedure nfsd_procedures3[22] = {
b9081d90f   Yu Zhiguo   NFS: kill off com...
712
  	[NFS3PROC_NULL] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
713
  		.pc_func = nfsd3_proc_null,
dcc46991d   Chuck Lever   NFSD: Encoder and...
714
  		.pc_decode = nfs3svc_decode_voidarg,
63f8de379   Christoph Hellwig   sunrpc: properly ...
715
  		.pc_encode = nfs3svc_encode_voidres,
b9081d90f   Yu Zhiguo   NFS: kill off com...
716
717
718
719
720
721
  		.pc_argsize = sizeof(struct nfsd3_voidargs),
  		.pc_ressize = sizeof(struct nfsd3_voidres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST,
  	},
  	[NFS3PROC_GETATTR] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
722
  		.pc_func = nfsd3_proc_getattr,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
723
  		.pc_decode = nfs3svc_decode_fhandleargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
724
  		.pc_encode = nfs3svc_encode_attrstatres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
725
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
726
727
728
729
730
731
  		.pc_argsize = sizeof(struct nfsd3_fhandleargs),
  		.pc_ressize = sizeof(struct nfsd3_attrstatres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+AT,
  	},
  	[NFS3PROC_SETATTR] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
732
  		.pc_func = nfsd3_proc_setattr,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
733
  		.pc_decode = nfs3svc_decode_sattrargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
734
  		.pc_encode = nfs3svc_encode_wccstatres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
735
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
736
737
738
739
740
741
  		.pc_argsize = sizeof(struct nfsd3_sattrargs),
  		.pc_ressize = sizeof(struct nfsd3_wccstatres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+WC,
  	},
  	[NFS3PROC_LOOKUP] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
742
  		.pc_func = nfsd3_proc_lookup,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
743
  		.pc_decode = nfs3svc_decode_diropargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
744
  		.pc_encode = nfs3svc_encode_diropres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
745
  		.pc_release = nfs3svc_release_fhandle2,
b9081d90f   Yu Zhiguo   NFS: kill off com...
746
747
748
749
750
751
  		.pc_argsize = sizeof(struct nfsd3_diropargs),
  		.pc_ressize = sizeof(struct nfsd3_diropres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+FH+pAT+pAT,
  	},
  	[NFS3PROC_ACCESS] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
752
  		.pc_func = nfsd3_proc_access,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
753
  		.pc_decode = nfs3svc_decode_accessargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
754
  		.pc_encode = nfs3svc_encode_accessres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
755
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
756
757
758
759
760
761
  		.pc_argsize = sizeof(struct nfsd3_accessargs),
  		.pc_ressize = sizeof(struct nfsd3_accessres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+pAT+1,
  	},
  	[NFS3PROC_READLINK] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
762
  		.pc_func = nfsd3_proc_readlink,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
763
  		.pc_decode = nfs3svc_decode_readlinkargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
764
  		.pc_encode = nfs3svc_encode_readlinkres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
765
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
766
767
768
769
770
771
  		.pc_argsize = sizeof(struct nfsd3_readlinkargs),
  		.pc_ressize = sizeof(struct nfsd3_readlinkres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
  	},
  	[NFS3PROC_READ] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
772
  		.pc_func = nfsd3_proc_read,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
773
  		.pc_decode = nfs3svc_decode_readargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
774
  		.pc_encode = nfs3svc_encode_readres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
775
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
776
777
778
779
780
781
  		.pc_argsize = sizeof(struct nfsd3_readargs),
  		.pc_ressize = sizeof(struct nfsd3_readres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
  	},
  	[NFS3PROC_WRITE] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
782
  		.pc_func = nfsd3_proc_write,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
783
  		.pc_decode = nfs3svc_decode_writeargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
784
  		.pc_encode = nfs3svc_encode_writeres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
785
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
786
787
788
789
790
791
  		.pc_argsize = sizeof(struct nfsd3_writeargs),
  		.pc_ressize = sizeof(struct nfsd3_writeres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+WC+4,
  	},
  	[NFS3PROC_CREATE] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
792
  		.pc_func = nfsd3_proc_create,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
793
  		.pc_decode = nfs3svc_decode_createargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
794
  		.pc_encode = nfs3svc_encode_createres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
795
  		.pc_release = nfs3svc_release_fhandle2,
b9081d90f   Yu Zhiguo   NFS: kill off com...
796
797
798
799
800
801
  		.pc_argsize = sizeof(struct nfsd3_createargs),
  		.pc_ressize = sizeof(struct nfsd3_createres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+(1+FH+pAT)+WC,
  	},
  	[NFS3PROC_MKDIR] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
802
  		.pc_func = nfsd3_proc_mkdir,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
803
  		.pc_decode = nfs3svc_decode_mkdirargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
804
  		.pc_encode = nfs3svc_encode_createres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
805
  		.pc_release = nfs3svc_release_fhandle2,
b9081d90f   Yu Zhiguo   NFS: kill off com...
806
807
808
809
810
811
  		.pc_argsize = sizeof(struct nfsd3_mkdirargs),
  		.pc_ressize = sizeof(struct nfsd3_createres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+(1+FH+pAT)+WC,
  	},
  	[NFS3PROC_SYMLINK] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
812
  		.pc_func = nfsd3_proc_symlink,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
813
  		.pc_decode = nfs3svc_decode_symlinkargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
814
  		.pc_encode = nfs3svc_encode_createres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
815
  		.pc_release = nfs3svc_release_fhandle2,
b9081d90f   Yu Zhiguo   NFS: kill off com...
816
817
818
819
820
821
  		.pc_argsize = sizeof(struct nfsd3_symlinkargs),
  		.pc_ressize = sizeof(struct nfsd3_createres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+(1+FH+pAT)+WC,
  	},
  	[NFS3PROC_MKNOD] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
822
  		.pc_func = nfsd3_proc_mknod,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
823
  		.pc_decode = nfs3svc_decode_mknodargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
824
  		.pc_encode = nfs3svc_encode_createres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
825
  		.pc_release = nfs3svc_release_fhandle2,
b9081d90f   Yu Zhiguo   NFS: kill off com...
826
827
828
829
830
831
  		.pc_argsize = sizeof(struct nfsd3_mknodargs),
  		.pc_ressize = sizeof(struct nfsd3_createres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+(1+FH+pAT)+WC,
  	},
  	[NFS3PROC_REMOVE] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
832
  		.pc_func = nfsd3_proc_remove,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
833
  		.pc_decode = nfs3svc_decode_diropargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
834
  		.pc_encode = nfs3svc_encode_wccstatres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
835
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
836
837
838
839
840
841
  		.pc_argsize = sizeof(struct nfsd3_diropargs),
  		.pc_ressize = sizeof(struct nfsd3_wccstatres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+WC,
  	},
  	[NFS3PROC_RMDIR] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
842
  		.pc_func = nfsd3_proc_rmdir,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
843
  		.pc_decode = nfs3svc_decode_diropargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
844
  		.pc_encode = nfs3svc_encode_wccstatres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
845
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
846
847
848
849
850
851
  		.pc_argsize = sizeof(struct nfsd3_diropargs),
  		.pc_ressize = sizeof(struct nfsd3_wccstatres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+WC,
  	},
  	[NFS3PROC_RENAME] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
852
  		.pc_func = nfsd3_proc_rename,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
853
  		.pc_decode = nfs3svc_decode_renameargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
854
  		.pc_encode = nfs3svc_encode_renameres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
855
  		.pc_release = nfs3svc_release_fhandle2,
b9081d90f   Yu Zhiguo   NFS: kill off com...
856
857
858
859
860
861
  		.pc_argsize = sizeof(struct nfsd3_renameargs),
  		.pc_ressize = sizeof(struct nfsd3_renameres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+WC+WC,
  	},
  	[NFS3PROC_LINK] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
862
  		.pc_func = nfsd3_proc_link,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
863
  		.pc_decode = nfs3svc_decode_linkargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
864
  		.pc_encode = nfs3svc_encode_linkres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
865
  		.pc_release = nfs3svc_release_fhandle2,
b9081d90f   Yu Zhiguo   NFS: kill off com...
866
867
868
869
870
871
  		.pc_argsize = sizeof(struct nfsd3_linkargs),
  		.pc_ressize = sizeof(struct nfsd3_linkres),
  		.pc_cachetype = RC_REPLBUFF,
  		.pc_xdrressize = ST+pAT+WC,
  	},
  	[NFS3PROC_READDIR] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
872
  		.pc_func = nfsd3_proc_readdir,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
873
  		.pc_decode = nfs3svc_decode_readdirargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
874
  		.pc_encode = nfs3svc_encode_readdirres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
875
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
876
877
878
879
880
  		.pc_argsize = sizeof(struct nfsd3_readdirargs),
  		.pc_ressize = sizeof(struct nfsd3_readdirres),
  		.pc_cachetype = RC_NOCACHE,
  	},
  	[NFS3PROC_READDIRPLUS] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
881
  		.pc_func = nfsd3_proc_readdirplus,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
882
  		.pc_decode = nfs3svc_decode_readdirplusargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
883
  		.pc_encode = nfs3svc_encode_readdirres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
884
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
885
886
887
888
889
  		.pc_argsize = sizeof(struct nfsd3_readdirplusargs),
  		.pc_ressize = sizeof(struct nfsd3_readdirres),
  		.pc_cachetype = RC_NOCACHE,
  	},
  	[NFS3PROC_FSSTAT] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
890
  		.pc_func = nfsd3_proc_fsstat,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
891
  		.pc_decode = nfs3svc_decode_fhandleargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
892
  		.pc_encode = nfs3svc_encode_fsstatres,
b9081d90f   Yu Zhiguo   NFS: kill off com...
893
894
895
896
897
898
  		.pc_argsize = sizeof(struct nfsd3_fhandleargs),
  		.pc_ressize = sizeof(struct nfsd3_fsstatres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+pAT+2*6+1,
  	},
  	[NFS3PROC_FSINFO] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
899
  		.pc_func = nfsd3_proc_fsinfo,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
900
  		.pc_decode = nfs3svc_decode_fhandleargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
901
  		.pc_encode = nfs3svc_encode_fsinfores,
b9081d90f   Yu Zhiguo   NFS: kill off com...
902
903
904
905
906
907
  		.pc_argsize = sizeof(struct nfsd3_fhandleargs),
  		.pc_ressize = sizeof(struct nfsd3_fsinfores),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+pAT+12,
  	},
  	[NFS3PROC_PATHCONF] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
908
  		.pc_func = nfsd3_proc_pathconf,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
909
  		.pc_decode = nfs3svc_decode_fhandleargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
910
  		.pc_encode = nfs3svc_encode_pathconfres,
b9081d90f   Yu Zhiguo   NFS: kill off com...
911
912
913
914
915
916
  		.pc_argsize = sizeof(struct nfsd3_fhandleargs),
  		.pc_ressize = sizeof(struct nfsd3_pathconfres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+pAT+6,
  	},
  	[NFS3PROC_COMMIT] = {
a6beb7327   Christoph Hellwig   sunrpc: properly ...
917
  		.pc_func = nfsd3_proc_commit,
026fec7e7   Christoph Hellwig   sunrpc: properly ...
918
  		.pc_decode = nfs3svc_decode_commitargs,
63f8de379   Christoph Hellwig   sunrpc: properly ...
919
  		.pc_encode = nfs3svc_encode_commitres,
8537488b5   Christoph Hellwig   sunrpc: properly ...
920
  		.pc_release = nfs3svc_release_fhandle,
b9081d90f   Yu Zhiguo   NFS: kill off com...
921
922
923
924
925
  		.pc_argsize = sizeof(struct nfsd3_commitargs),
  		.pc_ressize = sizeof(struct nfsd3_commitres),
  		.pc_cachetype = RC_NOCACHE,
  		.pc_xdrressize = ST+WC+2,
  	},
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
926
  };
7fd38af9c   Christoph Hellwig   sunrpc: move pc_c...
927
  static unsigned int nfsd_count3[ARRAY_SIZE(nfsd_procedures3)];
e9679189e   Christoph Hellwig   sunrpc: mark all ...
928
929
930
931
932
933
934
  const struct svc_version nfsd_version3 = {
  	.vs_vers	= 3,
  	.vs_nproc	= 22,
  	.vs_proc	= nfsd_procedures3,
  	.vs_dispatch	= nfsd_dispatch,
  	.vs_count	= nfsd_count3,
  	.vs_xdrsize	= NFS3_SVC_XDRSIZE,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
935
  };