xref: /openbmc/linux/fs/nfs/proc.c (revision cf3fff54)
1 /*
2  *  linux/fs/nfs/proc.c
3  *
4  *  Copyright (C) 1992, 1993, 1994  Rick Sladkey
5  *
6  *  OS-independent nfs remote procedure call functions
7  *
8  *  Tuned by Alan Cox <A.Cox@swansea.ac.uk> for >3K buffers
9  *  so at last we can have decent(ish) throughput off a
10  *  Sun server.
11  *
12  *  Coding optimized and cleaned up by Florian La Roche.
13  *  Note: Error returns are optimized for NFS_OK, which isn't translated via
14  *  nfs_stat_to_errno(), but happens to be already the right return code.
15  *
16  *  Also, the code currently doesn't check the size of the packet, when
17  *  it decodes the packet.
18  *
19  *  Feel free to fix it and mail me the diffs if it worries you.
20  *
21  *  Completely rewritten to support the new RPC call interface;
22  *  rewrote and moved the entire XDR stuff to xdr.c
23  *  --Olaf Kirch June 1996
24  *
25  *  The code below initializes all auto variables explicitly, otherwise
26  *  it will fail to work as a module (gcc generates a memset call for an
27  *  incomplete struct).
28  */
29 
30 #include <linux/types.h>
31 #include <linux/param.h>
32 #include <linux/slab.h>
33 #include <linux/time.h>
34 #include <linux/mm.h>
35 #include <linux/utsname.h>
36 #include <linux/errno.h>
37 #include <linux/string.h>
38 #include <linux/in.h>
39 #include <linux/pagemap.h>
40 #include <linux/sunrpc/clnt.h>
41 #include <linux/nfs.h>
42 #include <linux/nfs2.h>
43 #include <linux/nfs_fs.h>
44 #include <linux/nfs_page.h>
45 #include <linux/lockd/bind.h>
46 #include <linux/smp_lock.h>
47 
48 #define NFSDBG_FACILITY		NFSDBG_PROC
49 
50 extern struct rpc_procinfo nfs_procedures[];
51 
52 /*
53  * Bare-bones access to getattr: this is for nfs_read_super.
54  */
55 static int
56 nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
57 		  struct nfs_fsinfo *info)
58 {
59 	struct nfs_fattr *fattr = info->fattr;
60 	struct nfs2_fsstat fsinfo;
61 	int status;
62 
63 	dprintk("%s: call getattr\n", __FUNCTION__);
64 	nfs_fattr_init(fattr);
65 	status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0);
66 	dprintk("%s: reply getattr: %d\n", __FUNCTION__, status);
67 	if (status)
68 		return status;
69 	dprintk("%s: call statfs\n", __FUNCTION__);
70 	status = rpc_call(server->client_sys, NFSPROC_STATFS, fhandle, &fsinfo, 0);
71 	dprintk("%s: reply statfs: %d\n", __FUNCTION__, status);
72 	if (status)
73 		return status;
74 	info->rtmax  = NFS_MAXDATA;
75 	info->rtpref = fsinfo.tsize;
76 	info->rtmult = fsinfo.bsize;
77 	info->wtmax  = NFS_MAXDATA;
78 	info->wtpref = fsinfo.tsize;
79 	info->wtmult = fsinfo.bsize;
80 	info->dtpref = fsinfo.tsize;
81 	info->maxfilesize = 0x7FFFFFFF;
82 	info->lease_time = 0;
83 	return 0;
84 }
85 
86 /*
87  * One function for each procedure in the NFS protocol.
88  */
89 static int
90 nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
91 		struct nfs_fattr *fattr)
92 {
93 	int	status;
94 
95 	dprintk("NFS call  getattr\n");
96 	nfs_fattr_init(fattr);
97 	status = rpc_call(server->client, NFSPROC_GETATTR,
98 				fhandle, fattr, 0);
99 	dprintk("NFS reply getattr: %d\n", status);
100 	return status;
101 }
102 
103 static int
104 nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
105 		 struct iattr *sattr)
106 {
107 	struct inode *inode = dentry->d_inode;
108 	struct nfs_sattrargs	arg = {
109 		.fh	= NFS_FH(inode),
110 		.sattr	= sattr
111 	};
112 	int	status;
113 
114 	/* Mask out the non-modebit related stuff from attr->ia_mode */
115 	sattr->ia_mode &= S_IALLUGO;
116 
117 	dprintk("NFS call  setattr\n");
118 	nfs_fattr_init(fattr);
119 	status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0);
120 	if (status == 0)
121 		nfs_setattr_update_inode(inode, sattr);
122 	dprintk("NFS reply setattr: %d\n", status);
123 	return status;
124 }
125 
126 static int
127 nfs_proc_lookup(struct inode *dir, struct qstr *name,
128 		struct nfs_fh *fhandle, struct nfs_fattr *fattr)
129 {
130 	struct nfs_diropargs	arg = {
131 		.fh		= NFS_FH(dir),
132 		.name		= name->name,
133 		.len		= name->len
134 	};
135 	struct nfs_diropok	res = {
136 		.fh		= fhandle,
137 		.fattr		= fattr
138 	};
139 	int			status;
140 
141 	dprintk("NFS call  lookup %s\n", name->name);
142 	nfs_fattr_init(fattr);
143 	status = rpc_call(NFS_CLIENT(dir), NFSPROC_LOOKUP, &arg, &res, 0);
144 	dprintk("NFS reply lookup: %d\n", status);
145 	return status;
146 }
147 
148 static int nfs_proc_readlink(struct inode *inode, struct page *page,
149 		unsigned int pgbase, unsigned int pglen)
150 {
151 	struct nfs_readlinkargs	args = {
152 		.fh		= NFS_FH(inode),
153 		.pgbase		= pgbase,
154 		.pglen		= pglen,
155 		.pages		= &page
156 	};
157 	int			status;
158 
159 	dprintk("NFS call  readlink\n");
160 	status = rpc_call(NFS_CLIENT(inode), NFSPROC_READLINK, &args, NULL, 0);
161 	dprintk("NFS reply readlink: %d\n", status);
162 	return status;
163 }
164 
165 static int nfs_proc_read(struct nfs_read_data *rdata)
166 {
167 	int			flags = rdata->flags;
168 	struct inode *		inode = rdata->inode;
169 	struct nfs_fattr *	fattr = rdata->res.fattr;
170 	struct rpc_message	msg = {
171 		.rpc_proc	= &nfs_procedures[NFSPROC_READ],
172 		.rpc_argp	= &rdata->args,
173 		.rpc_resp	= &rdata->res,
174 		.rpc_cred	= rdata->cred,
175 	};
176 	int			status;
177 
178 	dprintk("NFS call  read %d @ %Ld\n", rdata->args.count,
179 			(long long) rdata->args.offset);
180 	nfs_fattr_init(fattr);
181 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
182 	if (status >= 0) {
183 		nfs_refresh_inode(inode, fattr);
184 		/* Emulate the eof flag, which isn't normally needed in NFSv2
185 		 * as it is guaranteed to always return the file attributes
186 		 */
187 		if (rdata->args.offset + rdata->args.count >= fattr->size)
188 			rdata->res.eof = 1;
189 	}
190 	dprintk("NFS reply read: %d\n", status);
191 	return status;
192 }
193 
194 static int nfs_proc_write(struct nfs_write_data *wdata)
195 {
196 	int			flags = wdata->flags;
197 	struct inode *		inode = wdata->inode;
198 	struct nfs_fattr *	fattr = wdata->res.fattr;
199 	struct rpc_message	msg = {
200 		.rpc_proc	= &nfs_procedures[NFSPROC_WRITE],
201 		.rpc_argp	= &wdata->args,
202 		.rpc_resp	= &wdata->res,
203 		.rpc_cred	= wdata->cred,
204 	};
205 	int			status;
206 
207 	dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
208 			(long long) wdata->args.offset);
209 	nfs_fattr_init(fattr);
210 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
211 	if (status >= 0) {
212 		nfs_post_op_update_inode(inode, fattr);
213 		wdata->res.count = wdata->args.count;
214 		wdata->verf.committed = NFS_FILE_SYNC;
215 	}
216 	dprintk("NFS reply write: %d\n", status);
217 	return status < 0? status : wdata->res.count;
218 }
219 
220 static int
221 nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
222 		int flags, struct nameidata *nd)
223 {
224 	struct nfs_fh		fhandle;
225 	struct nfs_fattr	fattr;
226 	struct nfs_createargs	arg = {
227 		.fh		= NFS_FH(dir),
228 		.name		= dentry->d_name.name,
229 		.len		= dentry->d_name.len,
230 		.sattr		= sattr
231 	};
232 	struct nfs_diropok	res = {
233 		.fh		= &fhandle,
234 		.fattr		= &fattr
235 	};
236 	int			status;
237 
238 	nfs_fattr_init(&fattr);
239 	dprintk("NFS call  create %s\n", dentry->d_name.name);
240 	status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
241 	if (status == 0)
242 		status = nfs_instantiate(dentry, &fhandle, &fattr);
243 	dprintk("NFS reply create: %d\n", status);
244 	return status;
245 }
246 
247 /*
248  * In NFSv2, mknod is grafted onto the create call.
249  */
250 static int
251 nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
252 	       dev_t rdev)
253 {
254 	struct nfs_fh fhandle;
255 	struct nfs_fattr fattr;
256 	struct nfs_createargs	arg = {
257 		.fh		= NFS_FH(dir),
258 		.name		= dentry->d_name.name,
259 		.len		= dentry->d_name.len,
260 		.sattr		= sattr
261 	};
262 	struct nfs_diropok	res = {
263 		.fh		= &fhandle,
264 		.fattr		= &fattr
265 	};
266 	int status, mode;
267 
268 	dprintk("NFS call  mknod %s\n", dentry->d_name.name);
269 
270 	mode = sattr->ia_mode;
271 	if (S_ISFIFO(mode)) {
272 		sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR;
273 		sattr->ia_valid &= ~ATTR_SIZE;
274 	} else if (S_ISCHR(mode) || S_ISBLK(mode)) {
275 		sattr->ia_valid |= ATTR_SIZE;
276 		sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */
277 	}
278 
279 	nfs_fattr_init(&fattr);
280 	status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
281 	nfs_mark_for_revalidate(dir);
282 
283 	if (status == -EINVAL && S_ISFIFO(mode)) {
284 		sattr->ia_mode = mode;
285 		nfs_fattr_init(&fattr);
286 		status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
287 	}
288 	if (status == 0)
289 		status = nfs_instantiate(dentry, &fhandle, &fattr);
290 	dprintk("NFS reply mknod: %d\n", status);
291 	return status;
292 }
293 
294 static int
295 nfs_proc_remove(struct inode *dir, struct qstr *name)
296 {
297 	struct nfs_diropargs	arg = {
298 		.fh		= NFS_FH(dir),
299 		.name		= name->name,
300 		.len		= name->len
301 	};
302 	struct rpc_message	msg = {
303 		.rpc_proc	= &nfs_procedures[NFSPROC_REMOVE],
304 		.rpc_argp	= &arg,
305 		.rpc_resp	= NULL,
306 		.rpc_cred	= NULL
307 	};
308 	int			status;
309 
310 	dprintk("NFS call  remove %s\n", name->name);
311 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
312 	nfs_mark_for_revalidate(dir);
313 
314 	dprintk("NFS reply remove: %d\n", status);
315 	return status;
316 }
317 
318 static int
319 nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name)
320 {
321 	struct nfs_diropargs	*arg;
322 
323 	arg = (struct nfs_diropargs *)kmalloc(sizeof(*arg), GFP_KERNEL);
324 	if (!arg)
325 		return -ENOMEM;
326 	arg->fh = NFS_FH(dir->d_inode);
327 	arg->name = name->name;
328 	arg->len = name->len;
329 	msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
330 	msg->rpc_argp = arg;
331 	return 0;
332 }
333 
334 static int
335 nfs_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
336 {
337 	struct rpc_message *msg = &task->tk_msg;
338 
339 	if (msg->rpc_argp) {
340 		nfs_mark_for_revalidate(dir->d_inode);
341 		kfree(msg->rpc_argp);
342 	}
343 	return 0;
344 }
345 
346 static int
347 nfs_proc_rename(struct inode *old_dir, struct qstr *old_name,
348 		struct inode *new_dir, struct qstr *new_name)
349 {
350 	struct nfs_renameargs	arg = {
351 		.fromfh		= NFS_FH(old_dir),
352 		.fromname	= old_name->name,
353 		.fromlen	= old_name->len,
354 		.tofh		= NFS_FH(new_dir),
355 		.toname		= new_name->name,
356 		.tolen		= new_name->len
357 	};
358 	int			status;
359 
360 	dprintk("NFS call  rename %s -> %s\n", old_name->name, new_name->name);
361 	status = rpc_call(NFS_CLIENT(old_dir), NFSPROC_RENAME, &arg, NULL, 0);
362 	nfs_mark_for_revalidate(old_dir);
363 	nfs_mark_for_revalidate(new_dir);
364 	dprintk("NFS reply rename: %d\n", status);
365 	return status;
366 }
367 
368 static int
369 nfs_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
370 {
371 	struct nfs_linkargs	arg = {
372 		.fromfh		= NFS_FH(inode),
373 		.tofh		= NFS_FH(dir),
374 		.toname		= name->name,
375 		.tolen		= name->len
376 	};
377 	int			status;
378 
379 	dprintk("NFS call  link %s\n", name->name);
380 	status = rpc_call(NFS_CLIENT(inode), NFSPROC_LINK, &arg, NULL, 0);
381 	nfs_mark_for_revalidate(inode);
382 	nfs_mark_for_revalidate(dir);
383 	dprintk("NFS reply link: %d\n", status);
384 	return status;
385 }
386 
387 static int
388 nfs_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path,
389 		 struct iattr *sattr, struct nfs_fh *fhandle,
390 		 struct nfs_fattr *fattr)
391 {
392 	struct nfs_symlinkargs	arg = {
393 		.fromfh		= NFS_FH(dir),
394 		.fromname	= name->name,
395 		.fromlen	= name->len,
396 		.topath		= path->name,
397 		.tolen		= path->len,
398 		.sattr		= sattr
399 	};
400 	int			status;
401 
402 	if (path->len > NFS2_MAXPATHLEN)
403 		return -ENAMETOOLONG;
404 	dprintk("NFS call  symlink %s -> %s\n", name->name, path->name);
405 	nfs_fattr_init(fattr);
406 	fhandle->size = 0;
407 	status = rpc_call(NFS_CLIENT(dir), NFSPROC_SYMLINK, &arg, NULL, 0);
408 	nfs_mark_for_revalidate(dir);
409 	dprintk("NFS reply symlink: %d\n", status);
410 	return status;
411 }
412 
413 static int
414 nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
415 {
416 	struct nfs_fh fhandle;
417 	struct nfs_fattr fattr;
418 	struct nfs_createargs	arg = {
419 		.fh		= NFS_FH(dir),
420 		.name		= dentry->d_name.name,
421 		.len		= dentry->d_name.len,
422 		.sattr		= sattr
423 	};
424 	struct nfs_diropok	res = {
425 		.fh		= &fhandle,
426 		.fattr		= &fattr
427 	};
428 	int			status;
429 
430 	dprintk("NFS call  mkdir %s\n", dentry->d_name.name);
431 	nfs_fattr_init(&fattr);
432 	status = rpc_call(NFS_CLIENT(dir), NFSPROC_MKDIR, &arg, &res, 0);
433 	nfs_mark_for_revalidate(dir);
434 	if (status == 0)
435 		status = nfs_instantiate(dentry, &fhandle, &fattr);
436 	dprintk("NFS reply mkdir: %d\n", status);
437 	return status;
438 }
439 
440 static int
441 nfs_proc_rmdir(struct inode *dir, struct qstr *name)
442 {
443 	struct nfs_diropargs	arg = {
444 		.fh		= NFS_FH(dir),
445 		.name		= name->name,
446 		.len		= name->len
447 	};
448 	int			status;
449 
450 	dprintk("NFS call  rmdir %s\n", name->name);
451 	status = rpc_call(NFS_CLIENT(dir), NFSPROC_RMDIR, &arg, NULL, 0);
452 	nfs_mark_for_revalidate(dir);
453 	dprintk("NFS reply rmdir: %d\n", status);
454 	return status;
455 }
456 
457 /*
458  * The READDIR implementation is somewhat hackish - we pass a temporary
459  * buffer to the encode function, which installs it in the receive
460  * the receive iovec. The decode function just parses the reply to make
461  * sure it is syntactically correct; the entries itself are decoded
462  * from nfs_readdir by calling the decode_entry function directly.
463  */
464 static int
465 nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
466 		 u64 cookie, struct page *page, unsigned int count, int plus)
467 {
468 	struct inode		*dir = dentry->d_inode;
469 	struct nfs_readdirargs	arg = {
470 		.fh		= NFS_FH(dir),
471 		.cookie		= cookie,
472 		.count		= count,
473 		.pages		= &page
474 	};
475 	struct rpc_message	msg = {
476 		.rpc_proc	= &nfs_procedures[NFSPROC_READDIR],
477 		.rpc_argp	= &arg,
478 		.rpc_resp	= NULL,
479 		.rpc_cred	= cred
480 	};
481 	int			status;
482 
483 	lock_kernel();
484 
485 	dprintk("NFS call  readdir %d\n", (unsigned int)cookie);
486 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
487 
488 	dprintk("NFS reply readdir: %d\n", status);
489 	unlock_kernel();
490 	return status;
491 }
492 
493 static int
494 nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
495 			struct nfs_fsstat *stat)
496 {
497 	struct nfs2_fsstat fsinfo;
498 	int	status;
499 
500 	dprintk("NFS call  statfs\n");
501 	nfs_fattr_init(stat->fattr);
502 	status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0);
503 	dprintk("NFS reply statfs: %d\n", status);
504 	if (status)
505 		goto out;
506 	stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize;
507 	stat->fbytes = (u64)fsinfo.bfree  * fsinfo.bsize;
508 	stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize;
509 	stat->tfiles = 0;
510 	stat->ffiles = 0;
511 	stat->afiles = 0;
512 out:
513 	return status;
514 }
515 
516 static int
517 nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
518 			struct nfs_fsinfo *info)
519 {
520 	struct nfs2_fsstat fsinfo;
521 	int	status;
522 
523 	dprintk("NFS call  fsinfo\n");
524 	nfs_fattr_init(info->fattr);
525 	status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0);
526 	dprintk("NFS reply fsinfo: %d\n", status);
527 	if (status)
528 		goto out;
529 	info->rtmax  = NFS_MAXDATA;
530 	info->rtpref = fsinfo.tsize;
531 	info->rtmult = fsinfo.bsize;
532 	info->wtmax  = NFS_MAXDATA;
533 	info->wtpref = fsinfo.tsize;
534 	info->wtmult = fsinfo.bsize;
535 	info->dtpref = fsinfo.tsize;
536 	info->maxfilesize = 0x7FFFFFFF;
537 	info->lease_time = 0;
538 out:
539 	return status;
540 }
541 
542 static int
543 nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
544 		  struct nfs_pathconf *info)
545 {
546 	info->max_link = 0;
547 	info->max_namelen = NFS2_MAXNAMLEN;
548 	return 0;
549 }
550 
551 extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int);
552 
553 static void nfs_read_done(struct rpc_task *task, void *calldata)
554 {
555 	struct nfs_read_data *data = calldata;
556 
557 	if (task->tk_status >= 0) {
558 		nfs_refresh_inode(data->inode, data->res.fattr);
559 		/* Emulate the eof flag, which isn't normally needed in NFSv2
560 		 * as it is guaranteed to always return the file attributes
561 		 */
562 		if (data->args.offset + data->args.count >= data->res.fattr->size)
563 			data->res.eof = 1;
564 	}
565 	nfs_readpage_result(task, calldata);
566 }
567 
568 static const struct rpc_call_ops nfs_read_ops = {
569 	.rpc_call_done = nfs_read_done,
570 	.rpc_release = nfs_readdata_release,
571 };
572 
573 static void
574 nfs_proc_read_setup(struct nfs_read_data *data)
575 {
576 	struct rpc_task		*task = &data->task;
577 	struct inode		*inode = data->inode;
578 	int			flags;
579 	struct rpc_message	msg = {
580 		.rpc_proc	= &nfs_procedures[NFSPROC_READ],
581 		.rpc_argp	= &data->args,
582 		.rpc_resp	= &data->res,
583 		.rpc_cred	= data->cred,
584 	};
585 
586 	/* N.B. Do we need to test? Never called for swapfile inode */
587 	flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
588 
589 	/* Finalize the task. */
590 	rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs_read_ops, data);
591 	rpc_call_setup(task, &msg, 0);
592 }
593 
594 static void nfs_write_done(struct rpc_task *task, void *calldata)
595 {
596 	struct nfs_write_data *data = calldata;
597 
598 	if (task->tk_status >= 0)
599 		nfs_post_op_update_inode(data->inode, data->res.fattr);
600 	nfs_writeback_done(task, calldata);
601 }
602 
603 static const struct rpc_call_ops nfs_write_ops = {
604 	.rpc_call_done = nfs_write_done,
605 	.rpc_release = nfs_writedata_release,
606 };
607 
608 static void
609 nfs_proc_write_setup(struct nfs_write_data *data, int how)
610 {
611 	struct rpc_task		*task = &data->task;
612 	struct inode		*inode = data->inode;
613 	int			flags;
614 	struct rpc_message	msg = {
615 		.rpc_proc	= &nfs_procedures[NFSPROC_WRITE],
616 		.rpc_argp	= &data->args,
617 		.rpc_resp	= &data->res,
618 		.rpc_cred	= data->cred,
619 	};
620 
621 	/* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
622 	data->args.stable = NFS_FILE_SYNC;
623 
624 	/* Set the initial flags for the task.  */
625 	flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
626 
627 	/* Finalize the task. */
628 	rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs_write_ops, data);
629 	rpc_call_setup(task, &msg, 0);
630 }
631 
632 static void
633 nfs_proc_commit_setup(struct nfs_write_data *data, int how)
634 {
635 	BUG();
636 }
637 
638 static int
639 nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
640 {
641 	return nlmclnt_proc(filp->f_dentry->d_inode, cmd, fl);
642 }
643 
644 
645 struct nfs_rpc_ops	nfs_v2_clientops = {
646 	.version	= 2,		       /* protocol version */
647 	.dentry_ops	= &nfs_dentry_operations,
648 	.dir_inode_ops	= &nfs_dir_inode_operations,
649 	.file_inode_ops	= &nfs_file_inode_operations,
650 	.getroot	= nfs_proc_get_root,
651 	.getattr	= nfs_proc_getattr,
652 	.setattr	= nfs_proc_setattr,
653 	.lookup		= nfs_proc_lookup,
654 	.access		= NULL,		       /* access */
655 	.readlink	= nfs_proc_readlink,
656 	.read		= nfs_proc_read,
657 	.write		= nfs_proc_write,
658 	.commit		= NULL,		       /* commit */
659 	.create		= nfs_proc_create,
660 	.remove		= nfs_proc_remove,
661 	.unlink_setup	= nfs_proc_unlink_setup,
662 	.unlink_done	= nfs_proc_unlink_done,
663 	.rename		= nfs_proc_rename,
664 	.link		= nfs_proc_link,
665 	.symlink	= nfs_proc_symlink,
666 	.mkdir		= nfs_proc_mkdir,
667 	.rmdir		= nfs_proc_rmdir,
668 	.readdir	= nfs_proc_readdir,
669 	.mknod		= nfs_proc_mknod,
670 	.statfs		= nfs_proc_statfs,
671 	.fsinfo		= nfs_proc_fsinfo,
672 	.pathconf	= nfs_proc_pathconf,
673 	.decode_dirent	= nfs_decode_dirent,
674 	.read_setup	= nfs_proc_read_setup,
675 	.write_setup	= nfs_proc_write_setup,
676 	.commit_setup	= nfs_proc_commit_setup,
677 	.file_open	= nfs_open,
678 	.file_release	= nfs_release,
679 	.lock		= nfs_proc_lock,
680 };
681