Merge branch 'writeback' of git://git.kernel.dk/linux-2.6-block
[linux-block.git] / fs / nfs / proc.c
CommitLineData
1da177e4
LT
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>
1da177e4
LT
35#include <linux/errno.h>
36#include <linux/string.h>
37#include <linux/in.h>
38#include <linux/pagemap.h>
39#include <linux/sunrpc/clnt.h>
40#include <linux/nfs.h>
41#include <linux/nfs2.h>
42#include <linux/nfs_fs.h>
43#include <linux/nfs_page.h>
44#include <linux/lockd/bind.h>
f7b422b1 45#include "internal.h"
1da177e4
LT
46
47#define NFSDBG_FACILITY NFSDBG_PROC
48
1da177e4
LT
49/*
50 * Bare-bones access to getattr: this is for nfs_read_super.
51 */
52static int
53nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
54 struct nfs_fsinfo *info)
55{
56 struct nfs_fattr *fattr = info->fattr;
57 struct nfs2_fsstat fsinfo;
dead28da
CL
58 struct rpc_message msg = {
59 .rpc_proc = &nfs_procedures[NFSPROC_GETATTR],
60 .rpc_argp = fhandle,
61 .rpc_resp = fattr,
62 };
1da177e4
LT
63 int status;
64
3110ff80 65 dprintk("%s: call getattr\n", __func__);
0e574af1 66 nfs_fattr_init(fattr);
37ca8f5c
EK
67 status = rpc_call_sync(server->client, &msg, 0);
68 /* Retry with default authentication if different */
69 if (status && server->nfs_client->cl_rpcclient != server->client)
70 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
3110ff80 71 dprintk("%s: reply getattr: %d\n", __func__, status);
1da177e4
LT
72 if (status)
73 return status;
3110ff80 74 dprintk("%s: call statfs\n", __func__);
dead28da
CL
75 msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS];
76 msg.rpc_resp = &fsinfo;
37ca8f5c
EK
77 status = rpc_call_sync(server->client, &msg, 0);
78 /* Retry with default authentication if different */
79 if (status && server->nfs_client->cl_rpcclient != server->client)
80 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
3110ff80 81 dprintk("%s: reply statfs: %d\n", __func__, status);
1da177e4
LT
82 if (status)
83 return status;
84 info->rtmax = NFS_MAXDATA;
85 info->rtpref = fsinfo.tsize;
86 info->rtmult = fsinfo.bsize;
87 info->wtmax = NFS_MAXDATA;
88 info->wtpref = fsinfo.tsize;
89 info->wtmult = fsinfo.bsize;
90 info->dtpref = fsinfo.tsize;
91 info->maxfilesize = 0x7FFFFFFF;
92 info->lease_time = 0;
93 return 0;
94}
95
96/*
97 * One function for each procedure in the NFS protocol.
98 */
99static int
100nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
101 struct nfs_fattr *fattr)
102{
dead28da
CL
103 struct rpc_message msg = {
104 .rpc_proc = &nfs_procedures[NFSPROC_GETATTR],
105 .rpc_argp = fhandle,
106 .rpc_resp = fattr,
107 };
1da177e4
LT
108 int status;
109
110 dprintk("NFS call getattr\n");
0e574af1 111 nfs_fattr_init(fattr);
dead28da 112 status = rpc_call_sync(server->client, &msg, 0);
1da177e4
LT
113 dprintk("NFS reply getattr: %d\n", status);
114 return status;
115}
116
117static int
118nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
119 struct iattr *sattr)
120{
121 struct inode *inode = dentry->d_inode;
122 struct nfs_sattrargs arg = {
123 .fh = NFS_FH(inode),
124 .sattr = sattr
125 };
dead28da
CL
126 struct rpc_message msg = {
127 .rpc_proc = &nfs_procedures[NFSPROC_SETATTR],
128 .rpc_argp = &arg,
129 .rpc_resp = fattr,
130 };
1da177e4
LT
131 int status;
132
cf3fff54
TM
133 /* Mask out the non-modebit related stuff from attr->ia_mode */
134 sattr->ia_mode &= S_IALLUGO;
135
1da177e4 136 dprintk("NFS call setattr\n");
659bfcd6
TM
137 if (sattr->ia_valid & ATTR_FILE)
138 msg.rpc_cred = nfs_file_cred(sattr->ia_file);
0e574af1 139 nfs_fattr_init(fattr);
dead28da 140 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
65e4308d
TM
141 if (status == 0)
142 nfs_setattr_update_inode(inode, sattr);
1da177e4
LT
143 dprintk("NFS reply setattr: %d\n", status);
144 return status;
145}
146
147static int
148nfs_proc_lookup(struct inode *dir, struct qstr *name,
149 struct nfs_fh *fhandle, struct nfs_fattr *fattr)
150{
151 struct nfs_diropargs arg = {
152 .fh = NFS_FH(dir),
153 .name = name->name,
154 .len = name->len
155 };
156 struct nfs_diropok res = {
157 .fh = fhandle,
158 .fattr = fattr
159 };
dead28da
CL
160 struct rpc_message msg = {
161 .rpc_proc = &nfs_procedures[NFSPROC_LOOKUP],
162 .rpc_argp = &arg,
163 .rpc_resp = &res,
164 };
1da177e4
LT
165 int status;
166
167 dprintk("NFS call lookup %s\n", name->name);
0e574af1 168 nfs_fattr_init(fattr);
dead28da 169 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
1da177e4
LT
170 dprintk("NFS reply lookup: %d\n", status);
171 return status;
172}
173
174static int nfs_proc_readlink(struct inode *inode, struct page *page,
175 unsigned int pgbase, unsigned int pglen)
176{
177 struct nfs_readlinkargs args = {
178 .fh = NFS_FH(inode),
179 .pgbase = pgbase,
180 .pglen = pglen,
181 .pages = &page
182 };
dead28da
CL
183 struct rpc_message msg = {
184 .rpc_proc = &nfs_procedures[NFSPROC_READLINK],
185 .rpc_argp = &args,
186 };
1da177e4
LT
187 int status;
188
189 dprintk("NFS call readlink\n");
dead28da 190 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
1da177e4
LT
191 dprintk("NFS reply readlink: %d\n", status);
192 return status;
193}
194
1da177e4
LT
195static int
196nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
02a913a7 197 int flags, struct nameidata *nd)
1da177e4
LT
198{
199 struct nfs_fh fhandle;
200 struct nfs_fattr fattr;
201 struct nfs_createargs arg = {
202 .fh = NFS_FH(dir),
203 .name = dentry->d_name.name,
204 .len = dentry->d_name.len,
205 .sattr = sattr
206 };
207 struct nfs_diropok res = {
208 .fh = &fhandle,
209 .fattr = &fattr
210 };
dead28da
CL
211 struct rpc_message msg = {
212 .rpc_proc = &nfs_procedures[NFSPROC_CREATE],
213 .rpc_argp = &arg,
214 .rpc_resp = &res,
215 };
1da177e4
LT
216 int status;
217
0e574af1 218 nfs_fattr_init(&fattr);
1da177e4 219 dprintk("NFS call create %s\n", dentry->d_name.name);
dead28da 220 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
bad2a524 221 nfs_mark_for_revalidate(dir);
1da177e4
LT
222 if (status == 0)
223 status = nfs_instantiate(dentry, &fhandle, &fattr);
224 dprintk("NFS reply create: %d\n", status);
225 return status;
226}
227
228/*
229 * In NFSv2, mknod is grafted onto the create call.
230 */
231static int
232nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
233 dev_t rdev)
234{
235 struct nfs_fh fhandle;
236 struct nfs_fattr fattr;
237 struct nfs_createargs arg = {
238 .fh = NFS_FH(dir),
239 .name = dentry->d_name.name,
240 .len = dentry->d_name.len,
241 .sattr = sattr
242 };
243 struct nfs_diropok res = {
244 .fh = &fhandle,
245 .fattr = &fattr
246 };
dead28da
CL
247 struct rpc_message msg = {
248 .rpc_proc = &nfs_procedures[NFSPROC_CREATE],
249 .rpc_argp = &arg,
250 .rpc_resp = &res,
251 };
1da177e4
LT
252 int status, mode;
253
254 dprintk("NFS call mknod %s\n", dentry->d_name.name);
255
256 mode = sattr->ia_mode;
257 if (S_ISFIFO(mode)) {
258 sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR;
259 sattr->ia_valid &= ~ATTR_SIZE;
260 } else if (S_ISCHR(mode) || S_ISBLK(mode)) {
261 sattr->ia_valid |= ATTR_SIZE;
262 sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */
263 }
264
0e574af1 265 nfs_fattr_init(&fattr);
dead28da 266 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
decf491f 267 nfs_mark_for_revalidate(dir);
1da177e4
LT
268
269 if (status == -EINVAL && S_ISFIFO(mode)) {
270 sattr->ia_mode = mode;
0e574af1 271 nfs_fattr_init(&fattr);
dead28da 272 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
1da177e4
LT
273 }
274 if (status == 0)
275 status = nfs_instantiate(dentry, &fhandle, &fattr);
276 dprintk("NFS reply mknod: %d\n", status);
277 return status;
278}
279
280static int
281nfs_proc_remove(struct inode *dir, struct qstr *name)
282{
4fdc17b2
TM
283 struct nfs_removeargs arg = {
284 .fh = NFS_FH(dir),
285 .name.len = name->len,
286 .name.name = name->name,
1da177e4 287 };
4fdc17b2
TM
288 struct rpc_message msg = {
289 .rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
290 .rpc_argp = &arg,
1da177e4
LT
291 };
292 int status;
293
294 dprintk("NFS call remove %s\n", name->name);
295 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
decf491f 296 nfs_mark_for_revalidate(dir);
1da177e4
LT
297
298 dprintk("NFS reply remove: %d\n", status);
299 return status;
300}
301
e4eff1a6
TM
302static void
303nfs_proc_unlink_setup(struct rpc_message *msg, struct inode *dir)
1da177e4 304{
1da177e4 305 msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
1da177e4
LT
306}
307
e4eff1a6 308static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir)
1da177e4 309{
e4eff1a6
TM
310 nfs_mark_for_revalidate(dir);
311 return 1;
1da177e4
LT
312}
313
314static int
315nfs_proc_rename(struct inode *old_dir, struct qstr *old_name,
316 struct inode *new_dir, struct qstr *new_name)
317{
318 struct nfs_renameargs arg = {
319 .fromfh = NFS_FH(old_dir),
320 .fromname = old_name->name,
321 .fromlen = old_name->len,
322 .tofh = NFS_FH(new_dir),
323 .toname = new_name->name,
324 .tolen = new_name->len
325 };
dead28da
CL
326 struct rpc_message msg = {
327 .rpc_proc = &nfs_procedures[NFSPROC_RENAME],
328 .rpc_argp = &arg,
329 };
1da177e4
LT
330 int status;
331
332 dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name);
dead28da 333 status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0);
decf491f
TM
334 nfs_mark_for_revalidate(old_dir);
335 nfs_mark_for_revalidate(new_dir);
1da177e4
LT
336 dprintk("NFS reply rename: %d\n", status);
337 return status;
338}
339
340static int
341nfs_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
342{
343 struct nfs_linkargs arg = {
344 .fromfh = NFS_FH(inode),
345 .tofh = NFS_FH(dir),
346 .toname = name->name,
347 .tolen = name->len
348 };
dead28da
CL
349 struct rpc_message msg = {
350 .rpc_proc = &nfs_procedures[NFSPROC_LINK],
351 .rpc_argp = &arg,
352 };
1da177e4
LT
353 int status;
354
355 dprintk("NFS call link %s\n", name->name);
dead28da 356 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
5ba7cc48 357 nfs_mark_for_revalidate(inode);
decf491f 358 nfs_mark_for_revalidate(dir);
1da177e4
LT
359 dprintk("NFS reply link: %d\n", status);
360 return status;
361}
362
363static int
94a6d753
CL
364nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct page *page,
365 unsigned int len, struct iattr *sattr)
1da177e4 366{
4f390c15
CL
367 struct nfs_fh fhandle;
368 struct nfs_fattr fattr;
1da177e4
LT
369 struct nfs_symlinkargs arg = {
370 .fromfh = NFS_FH(dir),
4f390c15
CL
371 .fromname = dentry->d_name.name,
372 .fromlen = dentry->d_name.len,
94a6d753
CL
373 .pages = &page,
374 .pathlen = len,
1da177e4
LT
375 .sattr = sattr
376 };
dead28da
CL
377 struct rpc_message msg = {
378 .rpc_proc = &nfs_procedures[NFSPROC_SYMLINK],
379 .rpc_argp = &arg,
380 };
1da177e4
LT
381 int status;
382
94a6d753 383 if (len > NFS2_MAXPATHLEN)
1da177e4 384 return -ENAMETOOLONG;
4f390c15 385
94a6d753
CL
386 dprintk("NFS call symlink %s\n", dentry->d_name.name);
387
dead28da 388 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
decf491f 389 nfs_mark_for_revalidate(dir);
4f390c15
CL
390
391 /*
392 * V2 SYMLINK requests don't return any attributes. Setting the
393 * filehandle size to zero indicates to nfs_instantiate that it
394 * should fill in the data with a LOOKUP call on the wire.
395 */
396 if (status == 0) {
397 nfs_fattr_init(&fattr);
398 fhandle.size = 0;
399 status = nfs_instantiate(dentry, &fhandle, &fattr);
400 }
401
1da177e4
LT
402 dprintk("NFS reply symlink: %d\n", status);
403 return status;
404}
405
406static int
407nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
408{
409 struct nfs_fh fhandle;
410 struct nfs_fattr fattr;
411 struct nfs_createargs arg = {
412 .fh = NFS_FH(dir),
413 .name = dentry->d_name.name,
414 .len = dentry->d_name.len,
415 .sattr = sattr
416 };
417 struct nfs_diropok res = {
418 .fh = &fhandle,
419 .fattr = &fattr
420 };
dead28da
CL
421 struct rpc_message msg = {
422 .rpc_proc = &nfs_procedures[NFSPROC_MKDIR],
423 .rpc_argp = &arg,
424 .rpc_resp = &res,
425 };
1da177e4
LT
426 int status;
427
428 dprintk("NFS call mkdir %s\n", dentry->d_name.name);
0e574af1 429 nfs_fattr_init(&fattr);
dead28da 430 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
decf491f 431 nfs_mark_for_revalidate(dir);
1da177e4
LT
432 if (status == 0)
433 status = nfs_instantiate(dentry, &fhandle, &fattr);
434 dprintk("NFS reply mkdir: %d\n", status);
435 return status;
436}
437
438static int
439nfs_proc_rmdir(struct inode *dir, struct qstr *name)
440{
441 struct nfs_diropargs arg = {
442 .fh = NFS_FH(dir),
443 .name = name->name,
444 .len = name->len
445 };
dead28da
CL
446 struct rpc_message msg = {
447 .rpc_proc = &nfs_procedures[NFSPROC_RMDIR],
448 .rpc_argp = &arg,
449 };
1da177e4
LT
450 int status;
451
452 dprintk("NFS call rmdir %s\n", name->name);
dead28da 453 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
decf491f 454 nfs_mark_for_revalidate(dir);
1da177e4
LT
455 dprintk("NFS reply rmdir: %d\n", status);
456 return status;
457}
458
459/*
460 * The READDIR implementation is somewhat hackish - we pass a temporary
461 * buffer to the encode function, which installs it in the receive
462 * the receive iovec. The decode function just parses the reply to make
463 * sure it is syntactically correct; the entries itself are decoded
464 * from nfs_readdir by calling the decode_entry function directly.
465 */
466static int
467nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
468 u64 cookie, struct page *page, unsigned int count, int plus)
469{
470 struct inode *dir = dentry->d_inode;
471 struct nfs_readdirargs arg = {
472 .fh = NFS_FH(dir),
473 .cookie = cookie,
474 .count = count,
dead28da 475 .pages = &page,
1da177e4
LT
476 };
477 struct rpc_message msg = {
478 .rpc_proc = &nfs_procedures[NFSPROC_READDIR],
479 .rpc_argp = &arg,
dead28da 480 .rpc_cred = cred,
1da177e4
LT
481 };
482 int status;
483
1da177e4
LT
484 dprintk("NFS call readdir %d\n", (unsigned int)cookie);
485 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
486
c4812998
TM
487 nfs_invalidate_atime(dir);
488
1da177e4 489 dprintk("NFS reply readdir: %d\n", status);
1da177e4
LT
490 return status;
491}
492
493static int
494nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
495 struct nfs_fsstat *stat)
496{
497 struct nfs2_fsstat fsinfo;
dead28da
CL
498 struct rpc_message msg = {
499 .rpc_proc = &nfs_procedures[NFSPROC_STATFS],
500 .rpc_argp = fhandle,
501 .rpc_resp = &fsinfo,
502 };
1da177e4
LT
503 int status;
504
505 dprintk("NFS call statfs\n");
0e574af1 506 nfs_fattr_init(stat->fattr);
dead28da 507 status = rpc_call_sync(server->client, &msg, 0);
1da177e4
LT
508 dprintk("NFS reply statfs: %d\n", status);
509 if (status)
510 goto out;
511 stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize;
512 stat->fbytes = (u64)fsinfo.bfree * fsinfo.bsize;
513 stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize;
514 stat->tfiles = 0;
515 stat->ffiles = 0;
516 stat->afiles = 0;
517out:
518 return status;
519}
520
521static int
522nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
523 struct nfs_fsinfo *info)
524{
525 struct nfs2_fsstat fsinfo;
dead28da
CL
526 struct rpc_message msg = {
527 .rpc_proc = &nfs_procedures[NFSPROC_STATFS],
528 .rpc_argp = fhandle,
529 .rpc_resp = &fsinfo,
530 };
1da177e4
LT
531 int status;
532
533 dprintk("NFS call fsinfo\n");
0e574af1 534 nfs_fattr_init(info->fattr);
dead28da 535 status = rpc_call_sync(server->client, &msg, 0);
1da177e4
LT
536 dprintk("NFS reply fsinfo: %d\n", status);
537 if (status)
538 goto out;
539 info->rtmax = NFS_MAXDATA;
540 info->rtpref = fsinfo.tsize;
541 info->rtmult = fsinfo.bsize;
542 info->wtmax = NFS_MAXDATA;
543 info->wtpref = fsinfo.tsize;
544 info->wtmult = fsinfo.bsize;
545 info->dtpref = fsinfo.tsize;
546 info->maxfilesize = 0x7FFFFFFF;
547 info->lease_time = 0;
548out:
549 return status;
550}
551
552static int
553nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
554 struct nfs_pathconf *info)
555{
556 info->max_link = 0;
557 info->max_namelen = NFS2_MAXNAMLEN;
558 return 0;
559}
560
ec06c096 561static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data)
1da177e4 562{
8850df99 563 nfs_invalidate_atime(data->inode);
1da177e4
LT
564 if (task->tk_status >= 0) {
565 nfs_refresh_inode(data->inode, data->res.fattr);
566 /* Emulate the eof flag, which isn't normally needed in NFSv2
567 * as it is guaranteed to always return the file attributes
568 */
569 if (data->args.offset + data->args.count >= data->res.fattr->size)
570 data->res.eof = 1;
571 }
ec06c096 572 return 0;
1da177e4
LT
573}
574
bdc7f021 575static void nfs_proc_read_setup(struct nfs_read_data *data, struct rpc_message *msg)
1da177e4 576{
bdc7f021 577 msg->rpc_proc = &nfs_procedures[NFSPROC_READ];
1da177e4
LT
578}
579
788e7a89 580static int nfs_write_done(struct rpc_task *task, struct nfs_write_data *data)
1da177e4 581{
1da177e4 582 if (task->tk_status >= 0)
70ca8852 583 nfs_post_op_update_inode_force_wcc(data->inode, data->res.fattr);
788e7a89 584 return 0;
1da177e4
LT
585}
586
bdc7f021 587static void nfs_proc_write_setup(struct nfs_write_data *data, struct rpc_message *msg)
1da177e4 588{
1da177e4
LT
589 /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
590 data->args.stable = NFS_FILE_SYNC;
bdc7f021 591 msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE];
1da177e4
LT
592}
593
594static void
bdc7f021 595nfs_proc_commit_setup(struct nfs_write_data *data, struct rpc_message *msg)
1da177e4
LT
596{
597 BUG();
598}
599
600static int
601nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
602{
1093a60e
CL
603 struct inode *inode = filp->f_path.dentry->d_inode;
604
605 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl);
1da177e4
LT
606}
607
2116271a
TM
608/* Helper functions for NFS lock bounds checking */
609#define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL)
610static int nfs_lock_check_bounds(const struct file_lock *fl)
611{
612 __s32 start, end;
613
614 start = (__s32)fl->fl_start;
615 if ((loff_t)start != fl->fl_start)
616 goto out_einval;
617
618 if (fl->fl_end != OFFSET_MAX) {
619 end = (__s32)fl->fl_end;
620 if ((loff_t)end != fl->fl_end)
621 goto out_einval;
622 } else
623 end = NFS_LOCK32_OFFSET_MAX;
624
625 if (start < 0 || start > end)
626 goto out_einval;
627 return 0;
628out_einval:
629 return -EINVAL;
630}
1da177e4 631
509de811 632const struct nfs_rpc_ops nfs_v2_clientops = {
1da177e4
LT
633 .version = 2, /* protocol version */
634 .dentry_ops = &nfs_dentry_operations,
635 .dir_inode_ops = &nfs_dir_inode_operations,
92cfc62c 636 .file_inode_ops = &nfs_file_inode_operations,
1da177e4
LT
637 .getroot = nfs_proc_get_root,
638 .getattr = nfs_proc_getattr,
639 .setattr = nfs_proc_setattr,
640 .lookup = nfs_proc_lookup,
641 .access = NULL, /* access */
642 .readlink = nfs_proc_readlink,
1da177e4
LT
643 .create = nfs_proc_create,
644 .remove = nfs_proc_remove,
645 .unlink_setup = nfs_proc_unlink_setup,
646 .unlink_done = nfs_proc_unlink_done,
647 .rename = nfs_proc_rename,
648 .link = nfs_proc_link,
649 .symlink = nfs_proc_symlink,
650 .mkdir = nfs_proc_mkdir,
651 .rmdir = nfs_proc_rmdir,
652 .readdir = nfs_proc_readdir,
653 .mknod = nfs_proc_mknod,
654 .statfs = nfs_proc_statfs,
655 .fsinfo = nfs_proc_fsinfo,
656 .pathconf = nfs_proc_pathconf,
657 .decode_dirent = nfs_decode_dirent,
658 .read_setup = nfs_proc_read_setup,
ec06c096 659 .read_done = nfs_read_done,
1da177e4 660 .write_setup = nfs_proc_write_setup,
788e7a89 661 .write_done = nfs_write_done,
1da177e4 662 .commit_setup = nfs_proc_commit_setup,
1da177e4 663 .lock = nfs_proc_lock,
2116271a 664 .lock_check_bounds = nfs_lock_check_bounds,
7fe5c398 665 .close_context = nfs_close_context,
1da177e4 666};