projects/linux·blob master · refs

781 lines · 19.9 KiB

1// SPDX-License-Identifier: GPL-2.0
2/*
3 * linux/fs/nfs/proc.c
4 *
5 * Copyright (C) 1992, 1993, 1994 Rick Sladkey
6 *
7 * OS-independent nfs remote procedure call functions
8 *
9 * Tuned by Alan Cox <[email protected]> for >3K buffers
10 * so at last we can have decent(ish) throughput off a
11 * Sun server.
12 *
13 * Coding optimized and cleaned up by Florian La Roche.
14 * Note: Error returns are optimized for NFS_OK, which isn't translated via
15 * nfs_stat_to_errno(), but happens to be already the right return code.
16 *
17 * Also, the code currently doesn't check the size of the packet, when
18 * it decodes the packet.
19 *
20 * Feel free to fix it and mail me the diffs if it worries you.
21 *
22 * Completely rewritten to support the new RPC call interface;
23 * rewrote and moved the entire XDR stuff to xdr.c
24 * --Olaf Kirch June 1996
25 *
26 * The code below initializes all auto variables explicitly, otherwise
27 * it will fail to work as a module (gcc generates a memset call for an
28 * incomplete struct).
29 */
30
31#include <linux/types.h>
32#include <linux/param.h>
33#include <linux/time.h>
34#include <linux/mm.h>
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/filelock.h>
45#include <linux/lockd/bind.h>
46#include <linux/freezer.h>
47#include "internal.h"
48
49#define NFSDBG_FACILITY NFSDBG_PROC
50
51/*
52 * Bare-bones access to getattr: this is for nfs_read_super.
53 */
54static int
55nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
56 struct nfs_fsinfo *info)
57{
58 struct nfs_fattr *fattr = info->fattr;
59 struct nfs2_fsstat fsinfo;
60 struct rpc_message msg = {
61 .rpc_proc = &nfs_procedures[NFSPROC_GETATTR],
62 .rpc_argp = fhandle,
63 .rpc_resp = fattr,
64 };
65 int status;
66
67 dprintk("%s: call getattr\n", __func__);
68 nfs_fattr_init(fattr);
69 status = rpc_call_sync(server->client, &msg, 0);
70 /* Retry with default authentication if different */
71 if (status && server->nfs_client->cl_rpcclient != server->client)
72 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
73 dprintk("%s: reply getattr: %d\n", __func__, status);
74 if (status)
75 return status;
76 dprintk("%s: call statfs\n", __func__);
77 msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS];
78 msg.rpc_resp = &fsinfo;
79 status = rpc_call_sync(server->client, &msg, 0);
80 /* Retry with default authentication if different */
81 if (status && server->nfs_client->cl_rpcclient != server->client)
82 status = rpc_call_sync(server->nfs_client->cl_rpcclient, &msg, 0);
83 dprintk("%s: reply statfs: %d\n", __func__, status);
84 if (status)
85 return status;
86 info->rtmax = NFS_MAXDATA;
87 info->rtpref = fsinfo.tsize;
88 info->rtmult = fsinfo.bsize;
89 info->wtmax = NFS_MAXDATA;
90 info->wtpref = fsinfo.tsize;
91 info->wtmult = fsinfo.bsize;
92 info->dtpref = fsinfo.tsize;
93 info->maxfilesize = 0x7FFFFFFF;
94 info->lease_time = 0;
95 info->change_attr_type = NFS4_CHANGE_TYPE_IS_UNDEFINED;
96 info->xattr_support = 0;
97 return 0;
98}
99
100/*
101 * One function for each procedure in the NFS protocol.
102 */
103static int
104nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
105 struct nfs_fattr *fattr, struct inode *inode)
106{
107 struct rpc_message msg = {
108 .rpc_proc = &nfs_procedures[NFSPROC_GETATTR],
109 .rpc_argp = fhandle,
110 .rpc_resp = fattr,
111 };
112 int status;
113 unsigned short task_flags = 0;
114
115 /* Is this is an attribute revalidation, subject to softreval? */
116 if (inode && (server->flags & NFS_MOUNT_SOFTREVAL))
117 task_flags |= RPC_TASK_TIMEOUT;
118
119 dprintk("NFS call getattr\n");
120 nfs_fattr_init(fattr);
121 status = rpc_call_sync(server->client, &msg, task_flags);
122 dprintk("NFS reply getattr: %d\n", status);
123 return status;
124}
125
126static int
127nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
128 struct iattr *sattr)
129{
130 struct inode *inode = d_inode(dentry);
131 struct nfs_sattrargs arg = {
132 .fh = NFS_FH(inode),
133 .sattr = sattr
134 };
135 struct rpc_message msg = {
136 .rpc_proc = &nfs_procedures[NFSPROC_SETATTR],
137 .rpc_argp = &arg,
138 .rpc_resp = fattr,
139 };
140 int status;
141
142 /* Mask out the non-modebit related stuff from attr->ia_mode */
143 sattr->ia_mode &= S_IALLUGO;
144
145 dprintk("NFS call setattr\n");
146 if (sattr->ia_valid & ATTR_FILE)
147 msg.rpc_cred = nfs_file_cred(sattr->ia_file);
148 nfs_fattr_init(fattr);
149 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
150 if (status == 0)
151 nfs_setattr_update_inode(inode, sattr, fattr);
152 dprintk("NFS reply setattr: %d\n", status);
153 return status;
154}
155
156static int
157nfs_proc_lookup(struct inode *dir, struct dentry *dentry, const struct qstr *name,
158 struct nfs_fh *fhandle, struct nfs_fattr *fattr)
159{
160 struct nfs_diropargs arg = {
161 .fh = NFS_FH(dir),
162 .name = name->name,
163 .len = name->len
164 };
165 struct nfs_diropok res = {
166 .fh = fhandle,
167 .fattr = fattr
168 };
169 struct rpc_message msg = {
170 .rpc_proc = &nfs_procedures[NFSPROC_LOOKUP],
171 .rpc_argp = &arg,
172 .rpc_resp = &res,
173 };
174 int status;
175 unsigned short task_flags = 0;
176
177 /* Is this is an attribute revalidation, subject to softreval? */
178 if (nfs_lookup_is_soft_revalidate(dentry))
179 task_flags |= RPC_TASK_TIMEOUT;
180
181 dprintk("NFS call lookup %pd2\n", dentry);
182 nfs_fattr_init(fattr);
183 status = rpc_call_sync(NFS_CLIENT(dir), &msg, task_flags);
184 dprintk("NFS reply lookup: %d\n", status);
185 return status;
186}
187
188static int nfs_proc_readlink(struct inode *inode, struct page *page,
189 unsigned int pgbase, unsigned int pglen)
190{
191 struct nfs_readlinkargs args = {
192 .fh = NFS_FH(inode),
193 .pgbase = pgbase,
194 .pglen = pglen,
195 .pages = &page
196 };
197 struct rpc_message msg = {
198 .rpc_proc = &nfs_procedures[NFSPROC_READLINK],
199 .rpc_argp = &args,
200 };
201 int status;
202
203 dprintk("NFS call readlink\n");
204 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
205 dprintk("NFS reply readlink: %d\n", status);
206 return status;
207}
208
209struct nfs_createdata {
210 struct nfs_createargs arg;
211 struct nfs_diropok res;
212 struct nfs_fh fhandle;
213 struct nfs_fattr fattr;
214};
215
216static struct nfs_createdata *nfs_alloc_createdata(struct inode *dir,
217 struct dentry *dentry, struct iattr *sattr)
218{
219 struct nfs_createdata *data;
220
221 data = kmalloc_obj(*data);
222
223 if (data != NULL) {
224 data->arg.fh = NFS_FH(dir);
225 data->arg.name = dentry->d_name.name;
226 data->arg.len = dentry->d_name.len;
227 data->arg.sattr = sattr;
228 nfs_fattr_init(&data->fattr);
229 data->fhandle.size = 0;
230 data->res.fh = &data->fhandle;
231 data->res.fattr = &data->fattr;
232 }
233 return data;
234};
235
236static void nfs_free_createdata(const struct nfs_createdata *data)
237{
238 kfree(data);
239}
240
241static int
242nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
243 int flags)
244{
245 struct nfs_createdata *data;
246 struct rpc_message msg = {
247 .rpc_proc = &nfs_procedures[NFSPROC_CREATE],
248 };
249 int status = -ENOMEM;
250
251 dprintk("NFS call create %pd\n", dentry);
252 data = nfs_alloc_createdata(dir, dentry, sattr);
253 if (data == NULL)
254 goto out;
255 msg.rpc_argp = &data->arg;
256 msg.rpc_resp = &data->res;
257 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
258 nfs_mark_for_revalidate(dir);
259 if (status == 0)
260 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr);
261 nfs_free_createdata(data);
262out:
263 dprintk("NFS reply create: %d\n", status);
264 return status;
265}
266
267/*
268 * In NFSv2, mknod is grafted onto the create call.
269 */
270static int
271nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
272 dev_t rdev)
273{
274 struct nfs_createdata *data;
275 struct rpc_message msg = {
276 .rpc_proc = &nfs_procedures[NFSPROC_CREATE],
277 };
278 umode_t mode;
279 int status = -ENOMEM;
280
281 dprintk("NFS call mknod %pd\n", dentry);
282
283 mode = sattr->ia_mode;
284 if (S_ISFIFO(mode)) {
285 sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR;
286 sattr->ia_valid &= ~ATTR_SIZE;
287 } else if (S_ISCHR(mode) || S_ISBLK(mode)) {
288 sattr->ia_valid |= ATTR_SIZE;
289 sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */
290 }
291
292 data = nfs_alloc_createdata(dir, dentry, sattr);
293 if (data == NULL)
294 goto out;
295 msg.rpc_argp = &data->arg;
296 msg.rpc_resp = &data->res;
297
298 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
299 nfs_mark_for_revalidate(dir);
300
301 if (status == -EINVAL && S_ISFIFO(mode)) {
302 sattr->ia_mode = mode;
303 nfs_fattr_init(data->res.fattr);
304 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
305 }
306 if (status == 0)
307 status = nfs_instantiate(dentry, data->res.fh, data->res.fattr);
308 nfs_free_createdata(data);
309out:
310 dprintk("NFS reply mknod: %d\n", status);
311 return status;
312}
313
314static int
315nfs_proc_remove(struct inode *dir, struct dentry *dentry)
316{
317 struct nfs_removeargs arg = {
318 .fh = NFS_FH(dir),
319 .name = dentry->d_name,
320 };
321 struct rpc_message msg = {
322 .rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
323 .rpc_argp = &arg,
324 };
325 int status;
326
327 dprintk("NFS call remove %pd2\n",dentry);
328 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
329 nfs_mark_for_revalidate(dir);
330
331 dprintk("NFS reply remove: %d\n", status);
332 return status;
333}
334
335static void
336nfs_proc_unlink_setup(struct rpc_message *msg,
337 struct dentry *dentry,
338 struct inode *inode)
339{
340 msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
341}
342
343static void nfs_proc_unlink_rpc_prepare(struct rpc_task *task, struct nfs_unlinkdata *data)
344{
345 rpc_call_start(task);
346}
347
348static int nfs_proc_unlink_done(struct rpc_task *task, struct inode *dir)
349{
350 nfs_mark_for_revalidate(dir);
351 return 1;
352}
353
354static void
355nfs_proc_rename_setup(struct rpc_message *msg,
356 struct dentry *old_dentry,
357 struct dentry *new_dentry,
358 struct inode *same_parent)
359{
360 msg->rpc_proc = &nfs_procedures[NFSPROC_RENAME];
361}
362
363static void nfs_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data)
364{
365 rpc_call_start(task);
366}
367
368static int
369nfs_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
370 struct inode *new_dir)
371{
372 nfs_mark_for_revalidate(old_dir);
373 nfs_mark_for_revalidate(new_dir);
374 return 1;
375}
376
377static int
378nfs_proc_link(struct inode *inode, struct inode *dir, const struct qstr *name)
379{
380 struct nfs_linkargs arg = {
381 .fromfh = NFS_FH(inode),
382 .tofh = NFS_FH(dir),
383 .toname = name->name,
384 .tolen = name->len
385 };
386 struct rpc_message msg = {
387 .rpc_proc = &nfs_procedures[NFSPROC_LINK],
388 .rpc_argp = &arg,
389 };
390 int status;
391
392 dprintk("NFS call link %s\n", name->name);
393 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
394 nfs_mark_for_revalidate(inode);
395 nfs_mark_for_revalidate(dir);
396 dprintk("NFS reply link: %d\n", status);
397 return status;
398}
399
400static int
401nfs_proc_symlink(struct inode *dir, struct dentry *dentry, struct folio *folio,
402 unsigned int len, struct iattr *sattr)
403{
404 struct page *page = &folio->page;
405 struct nfs_fh *fh;
406 struct nfs_fattr *fattr;
407 struct nfs_symlinkargs arg = {
408 .fromfh = NFS_FH(dir),
409 .fromname = dentry->d_name.name,
410 .fromlen = dentry->d_name.len,
411 .pages = &page,
412 .pathlen = len,
413 .sattr = sattr
414 };
415 struct rpc_message msg = {
416 .rpc_proc = &nfs_procedures[NFSPROC_SYMLINK],
417 .rpc_argp = &arg,
418 };
419 int status = -ENAMETOOLONG;
420
421 dprintk("NFS call symlink %pd\n", dentry);
422
423 if (len > NFS2_MAXPATHLEN)
424 goto out;
425
426 fh = nfs_alloc_fhandle();
427 fattr = nfs_alloc_fattr();
428 status = -ENOMEM;
429 if (fh == NULL || fattr == NULL)
430 goto out_free;
431
432 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
433 nfs_mark_for_revalidate(dir);
434
435 /*
436 * V2 SYMLINK requests don't return any attributes. Setting the
437 * filehandle size to zero indicates to nfs_instantiate that it
438 * should fill in the data with a LOOKUP call on the wire.
439 */
440 if (status == 0)
441 status = nfs_instantiate(dentry, fh, fattr);
442
443out_free:
444 nfs_free_fattr(fattr);
445 nfs_free_fhandle(fh);
446out:
447 dprintk("NFS reply symlink: %d\n", status);
448 return status;
449}
450
451static struct dentry *
452nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
453{
454 struct nfs_createdata *data;
455 struct rpc_message msg = {
456 .rpc_proc = &nfs_procedures[NFSPROC_MKDIR],
457 };
458 struct dentry *alias = NULL;
459 int status = -ENOMEM;
460
461 dprintk("NFS call mkdir %pd\n", dentry);
462 data = nfs_alloc_createdata(dir, dentry, sattr);
463 if (data == NULL)
464 goto out;
465 msg.rpc_argp = &data->arg;
466 msg.rpc_resp = &data->res;
467
468 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
469 nfs_mark_for_revalidate(dir);
470 if (status == 0) {
471 alias = nfs_add_or_obtain(dentry, data->res.fh, data->res.fattr);
472 status = PTR_ERR_OR_ZERO(alias);
473 } else
474 alias = ERR_PTR(status);
475 nfs_free_createdata(data);
476out:
477 dprintk("NFS reply mkdir: %d\n", status);
478 return alias;
479}
480
481static int
482nfs_proc_rmdir(struct inode *dir, const struct qstr *name)
483{
484 struct nfs_diropargs arg = {
485 .fh = NFS_FH(dir),
486 .name = name->name,
487 .len = name->len
488 };
489 struct rpc_message msg = {
490 .rpc_proc = &nfs_procedures[NFSPROC_RMDIR],
491 .rpc_argp = &arg,
492 };
493 int status;
494
495 dprintk("NFS call rmdir %s\n", name->name);
496 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
497 nfs_mark_for_revalidate(dir);
498 dprintk("NFS reply rmdir: %d\n", status);
499 return status;
500}
501
502/*
503 * The READDIR implementation is somewhat hackish - we pass a temporary
504 * buffer to the encode function, which installs it in the receive
505 * the receive iovec. The decode function just parses the reply to make
506 * sure it is syntactically correct; the entries itself are decoded
507 * from nfs_readdir by calling the decode_entry function directly.
508 */
509static int nfs_proc_readdir(struct nfs_readdir_arg *nr_arg,
510 struct nfs_readdir_res *nr_res)
511{
512 struct inode *dir = d_inode(nr_arg->dentry);
513 struct nfs_readdirargs arg = {
514 .fh = NFS_FH(dir),
515 .cookie = nr_arg->cookie,
516 .count = nr_arg->page_len,
517 .pages = nr_arg->pages,
518 };
519 struct rpc_message msg = {
520 .rpc_proc = &nfs_procedures[NFSPROC_READDIR],
521 .rpc_argp = &arg,
522 .rpc_cred = nr_arg->cred,
523 };
524 int status;
525
526 dprintk("NFS call readdir %llu\n", (unsigned long long)nr_arg->cookie);
527 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
528 nr_res->verf[0] = nr_res->verf[1] = 0;
529
530 nfs_invalidate_atime(dir);
531
532 dprintk("NFS reply readdir: %d\n", status);
533 return status;
534}
535
536static int
537nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
538 struct nfs_fsstat *stat)
539{
540 struct nfs2_fsstat fsinfo;
541 struct rpc_message msg = {
542 .rpc_proc = &nfs_procedures[NFSPROC_STATFS],
543 .rpc_argp = fhandle,
544 .rpc_resp = &fsinfo,
545 };
546 int status;
547
548 dprintk("NFS call statfs\n");
549 nfs_fattr_init(stat->fattr);
550 status = rpc_call_sync(server->client, &msg, 0);
551 dprintk("NFS reply statfs: %d\n", status);
552 if (status)
553 goto out;
554 stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize;
555 stat->fbytes = (u64)fsinfo.bfree * fsinfo.bsize;
556 stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize;
557 stat->tfiles = 0;
558 stat->ffiles = 0;
559 stat->afiles = 0;
560out:
561 return status;
562}
563
564static int
565nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
566 struct nfs_fsinfo *info)
567{
568 struct nfs2_fsstat fsinfo;
569 struct rpc_message msg = {
570 .rpc_proc = &nfs_procedures[NFSPROC_STATFS],
571 .rpc_argp = fhandle,
572 .rpc_resp = &fsinfo,
573 };
574 int status;
575
576 dprintk("NFS call fsinfo\n");
577 nfs_fattr_init(info->fattr);
578 status = rpc_call_sync(server->client, &msg, 0);
579 dprintk("NFS reply fsinfo: %d\n", status);
580 if (status)
581 goto out;
582 info->rtmax = NFS_MAXDATA;
583 info->rtpref = fsinfo.tsize;
584 info->rtmult = fsinfo.bsize;
585 info->wtmax = NFS_MAXDATA;
586 info->wtpref = fsinfo.tsize;
587 info->wtmult = fsinfo.bsize;
588 info->dtpref = fsinfo.tsize;
589 info->maxfilesize = 0x7FFFFFFF;
590 info->lease_time = 0;
591out:
592 return status;
593}
594
595static int
596nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
597 struct nfs_pathconf *info)
598{
599 info->max_link = 0;
600 info->max_namelen = NFS2_MAXNAMLEN;
601 info->case_preserving = true;
602 return 0;
603}
604
605static int nfs_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
606{
607 struct inode *inode = hdr->inode;
608
609 nfs_invalidate_atime(inode);
610 if (task->tk_status >= 0) {
611 nfs_refresh_inode(inode, hdr->res.fattr);
612 /* Emulate the eof flag, which isn't normally needed in NFSv2
613 * as it is guaranteed to always return the file attributes
614 */
615 if ((hdr->res.count == 0 && hdr->args.count > 0) ||
616 hdr->args.offset + hdr->res.count >= hdr->res.fattr->size)
617 hdr->res.eof = 1;
618 }
619 return 0;
620}
621
622static void nfs_proc_read_setup(struct nfs_pgio_header *hdr,
623 struct rpc_message *msg)
624{
625 msg->rpc_proc = &nfs_procedures[NFSPROC_READ];
626}
627
628static int nfs_proc_pgio_rpc_prepare(struct rpc_task *task,
629 struct nfs_pgio_header *hdr)
630{
631 rpc_call_start(task);
632 return 0;
633}
634
635static int nfs_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
636{
637 if (task->tk_status >= 0) {
638 hdr->res.count = hdr->args.count;
639 nfs_writeback_update_inode(hdr);
640 }
641 return 0;
642}
643
644static void nfs_proc_write_setup(struct nfs_pgio_header *hdr,
645 struct rpc_message *msg,
646 struct rpc_clnt **clnt)
647{
648 /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
649 hdr->args.stable = NFS_FILE_SYNC;
650 msg->rpc_proc = &nfs_procedures[NFSPROC_WRITE];
651}
652
653static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
654{
655 BUG();
656}
657
658static void
659nfs_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg,
660 struct rpc_clnt **clnt)
661{
662 BUG();
663}
664
665static int
666nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
667{
668 struct inode *inode = file_inode(filp);
669
670 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl, NULL);
671}
672
673/* Helper functions for NFS lock bounds checking */
674#define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL)
675static int nfs_lock_check_bounds(const struct file_lock *fl)
676{
677 __s32 start, end;
678
679 start = (__s32)fl->fl_start;
680 if ((loff_t)start != fl->fl_start)
681 goto out_einval;
682
683 if (fl->fl_end != OFFSET_MAX) {
684 end = (__s32)fl->fl_end;
685 if ((loff_t)end != fl->fl_end)
686 goto out_einval;
687 } else
688 end = NFS_LOCK32_OFFSET_MAX;
689
690 if (start < 0 || start > end)
691 goto out_einval;
692 return 0;
693out_einval:
694 return -EINVAL;
695}
696
697static int nfs_have_delegation(struct inode *inode, fmode_t type, int flags)
698{
699 return 0;
700}
701
702static void nfs_return_delegation(struct inode *inode)
703{
704 if (S_ISREG(inode->i_mode))
705 nfs_wb_all(inode);
706}
707
708static const struct inode_operations nfs_dir_inode_operations = {
709 .create = nfs_create,
710 .lookup = nfs_lookup,
711 .atomic_open = nfs_atomic_open_v23,
712 .link = nfs_link,
713 .unlink = nfs_unlink,
714 .symlink = nfs_symlink,
715 .mkdir = nfs_mkdir,
716 .rmdir = nfs_rmdir,
717 .mknod = nfs_mknod,
718 .rename = nfs_rename,
719 .permission = nfs_permission,
720 .getattr = nfs_getattr,
721 .setattr = nfs_setattr,
722 .fileattr_get = nfs_fileattr_get,
723};
724
725static const struct inode_operations nfs_file_inode_operations = {
726 .permission = nfs_permission,
727 .getattr = nfs_getattr,
728 .setattr = nfs_setattr,
729 .fileattr_get = nfs_fileattr_get,
730};
731
732const struct nfs_rpc_ops nfs_v2_clientops = {
733 .version = 2, /* protocol version */
734 .dentry_ops = &nfs_dentry_operations,
735 .dir_inode_ops = &nfs_dir_inode_operations,
736 .file_inode_ops = &nfs_file_inode_operations,
737 .file_ops = &nfs_file_operations,
738 .getroot = nfs_proc_get_root,
739 .submount = nfs_submount,
740 .try_get_tree = nfs_try_get_tree,
741 .getattr = nfs_proc_getattr,
742 .setattr = nfs_proc_setattr,
743 .lookup = nfs_proc_lookup,
744 .access = NULL, /* access */
745 .readlink = nfs_proc_readlink,
746 .create = nfs_proc_create,
747 .remove = nfs_proc_remove,
748 .unlink_setup = nfs_proc_unlink_setup,
749 .unlink_rpc_prepare = nfs_proc_unlink_rpc_prepare,
750 .unlink_done = nfs_proc_unlink_done,
751 .rename_setup = nfs_proc_rename_setup,
752 .rename_rpc_prepare = nfs_proc_rename_rpc_prepare,
753 .rename_done = nfs_proc_rename_done,
754 .link = nfs_proc_link,
755 .symlink = nfs_proc_symlink,
756 .mkdir = nfs_proc_mkdir,
757 .rmdir = nfs_proc_rmdir,
758 .readdir = nfs_proc_readdir,
759 .mknod = nfs_proc_mknod,
760 .statfs = nfs_proc_statfs,
761 .fsinfo = nfs_proc_fsinfo,
762 .pathconf = nfs_proc_pathconf,
763 .decode_dirent = nfs2_decode_dirent,
764 .pgio_rpc_prepare = nfs_proc_pgio_rpc_prepare,
765 .read_setup = nfs_proc_read_setup,
766 .read_done = nfs_read_done,
767 .write_setup = nfs_proc_write_setup,
768 .write_done = nfs_write_done,
769 .commit_setup = nfs_proc_commit_setup,
770 .commit_rpc_prepare = nfs_proc_commit_rpc_prepare,
771 .lock = nfs_proc_lock,
772 .lock_check_bounds = nfs_lock_check_bounds,
773 .close_context = nfs_close_context,
774 .have_delegation = nfs_have_delegation,
775 .return_delegation = nfs_return_delegation,
776 .alloc_client = nfs_alloc_client,
777 .init_client = nfs_init_client,
778 .free_client = nfs_free_client,
779 .create_server = nfs_create_server,
780 .clone_server = nfs_clone_server,
781};