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