2 * linux/fs/nfs/nfs3proc.c
4 * Client-side NFSv3 procedures stubs.
6 * Copyright (C) 1997, Olaf Kirch
10 #include <linux/utsname.h>
11 #include <linux/errno.h>
12 #include <linux/string.h>
13 #include <linux/sunrpc/clnt.h>
14 #include <linux/nfs.h>
15 #include <linux/nfs3.h>
16 #include <linux/nfs_fs.h>
17 #include <linux/nfs_page.h>
18 #include <linux/lockd/bind.h>
19 #include <linux/smp_lock.h>
20 #include <linux/nfs_mount.h>
22 #define NFSDBG_FACILITY NFSDBG_PROC
24 extern struct rpc_procinfo nfs3_procedures
[];
26 /* A wrapper to handle the EJUKEBOX error message */
28 nfs3_rpc_wrapper(struct rpc_clnt
*clnt
, struct rpc_message
*msg
, int flags
)
32 rpc_clnt_sigmask(clnt
, &oldset
);
34 res
= rpc_call_sync(clnt
, msg
, flags
);
37 schedule_timeout_interruptible(NFS_JUKEBOX_RETRY_TIME
);
39 } while (!signalled());
40 rpc_clnt_sigunmask(clnt
, &oldset
);
45 nfs3_rpc_call_wrapper(struct rpc_clnt
*clnt
, u32 proc
, void *argp
, void *resp
, int flags
)
47 struct rpc_message msg
= {
48 .rpc_proc
= &clnt
->cl_procinfo
[proc
],
52 return nfs3_rpc_wrapper(clnt
, &msg
, flags
);
55 #define rpc_call(clnt, proc, argp, resp, flags) \
56 nfs3_rpc_call_wrapper(clnt, proc, argp, resp, flags)
57 #define rpc_call_sync(clnt, msg, flags) \
58 nfs3_rpc_wrapper(clnt, msg, flags)
61 nfs3_async_handle_jukebox(struct rpc_task
*task
)
63 if (task
->tk_status
!= -EJUKEBOX
)
66 rpc_restart_call(task
);
67 rpc_delay(task
, NFS_JUKEBOX_RETRY_TIME
);
72 do_proc_get_root(struct rpc_clnt
*client
, struct nfs_fh
*fhandle
,
73 struct nfs_fsinfo
*info
)
77 dprintk("%s: call fsinfo\n", __FUNCTION__
);
78 nfs_fattr_init(info
->fattr
);
79 status
= rpc_call(client
, NFS3PROC_FSINFO
, fhandle
, info
, 0);
80 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__
, status
);
81 if (!(info
->fattr
->valid
& NFS_ATTR_FATTR
)) {
82 status
= rpc_call(client
, NFS3PROC_GETATTR
, fhandle
, info
->fattr
, 0);
83 dprintk("%s: reply getattr: %d\n", __FUNCTION__
, status
);
89 * Bare-bones access to getattr: this is for nfs_read_super.
92 nfs3_proc_get_root(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
93 struct nfs_fsinfo
*info
)
97 status
= do_proc_get_root(server
->client
, fhandle
, info
);
98 if (status
&& server
->client_sys
!= server
->client
)
99 status
= do_proc_get_root(server
->client_sys
, fhandle
, info
);
104 * One function for each procedure in the NFS protocol.
107 nfs3_proc_getattr(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
108 struct nfs_fattr
*fattr
)
112 dprintk("NFS call getattr\n");
113 nfs_fattr_init(fattr
);
114 status
= rpc_call(server
->client
, NFS3PROC_GETATTR
,
116 dprintk("NFS reply getattr: %d\n", status
);
121 nfs3_proc_setattr(struct dentry
*dentry
, struct nfs_fattr
*fattr
,
124 struct inode
*inode
= dentry
->d_inode
;
125 struct nfs3_sattrargs arg
= {
131 dprintk("NFS call setattr\n");
132 nfs_fattr_init(fattr
);
133 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_SETATTR
, &arg
, fattr
, 0);
135 nfs_setattr_update_inode(inode
, sattr
);
136 dprintk("NFS reply setattr: %d\n", status
);
141 nfs3_proc_lookup(struct inode
*dir
, struct qstr
*name
,
142 struct nfs_fh
*fhandle
, struct nfs_fattr
*fattr
)
144 struct nfs_fattr dir_attr
;
145 struct nfs3_diropargs arg
= {
150 struct nfs3_diropres res
= {
151 .dir_attr
= &dir_attr
,
157 dprintk("NFS call lookup %s\n", name
->name
);
158 nfs_fattr_init(&dir_attr
);
159 nfs_fattr_init(fattr
);
160 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_LOOKUP
, &arg
, &res
, 0);
161 if (status
>= 0 && !(fattr
->valid
& NFS_ATTR_FATTR
))
162 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_GETATTR
,
164 dprintk("NFS reply lookup: %d\n", status
);
166 status
= nfs_refresh_inode(dir
, &dir_attr
);
170 static int nfs3_proc_access(struct inode
*inode
, struct nfs_access_entry
*entry
)
172 struct nfs_fattr fattr
;
173 struct nfs3_accessargs arg
= {
176 struct nfs3_accessres res
= {
179 struct rpc_message msg
= {
180 .rpc_proc
= &nfs3_procedures
[NFS3PROC_ACCESS
],
183 .rpc_cred
= entry
->cred
185 int mode
= entry
->mask
;
188 dprintk("NFS call access\n");
191 arg
.access
|= NFS3_ACCESS_READ
;
192 if (S_ISDIR(inode
->i_mode
)) {
193 if (mode
& MAY_WRITE
)
194 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
;
196 arg
.access
|= NFS3_ACCESS_LOOKUP
;
198 if (mode
& MAY_WRITE
)
199 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
;
201 arg
.access
|= NFS3_ACCESS_EXECUTE
;
203 nfs_fattr_init(&fattr
);
204 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
205 nfs_refresh_inode(inode
, &fattr
);
208 if (res
.access
& NFS3_ACCESS_READ
)
209 entry
->mask
|= MAY_READ
;
210 if (res
.access
& (NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
))
211 entry
->mask
|= MAY_WRITE
;
212 if (res
.access
& (NFS3_ACCESS_LOOKUP
|NFS3_ACCESS_EXECUTE
))
213 entry
->mask
|= MAY_EXEC
;
215 dprintk("NFS reply access: %d\n", status
);
219 static int nfs3_proc_readlink(struct inode
*inode
, struct page
*page
,
220 unsigned int pgbase
, unsigned int pglen
)
222 struct nfs_fattr fattr
;
223 struct nfs3_readlinkargs args
= {
231 dprintk("NFS call readlink\n");
232 nfs_fattr_init(&fattr
);
233 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_READLINK
,
235 nfs_refresh_inode(inode
, &fattr
);
236 dprintk("NFS reply readlink: %d\n", status
);
240 static int nfs3_proc_read(struct nfs_read_data
*rdata
)
242 int flags
= rdata
->flags
;
243 struct inode
* inode
= rdata
->inode
;
244 struct nfs_fattr
* fattr
= rdata
->res
.fattr
;
245 struct rpc_message msg
= {
246 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
247 .rpc_argp
= &rdata
->args
,
248 .rpc_resp
= &rdata
->res
,
249 .rpc_cred
= rdata
->cred
,
253 dprintk("NFS call read %d @ %Ld\n", rdata
->args
.count
,
254 (long long) rdata
->args
.offset
);
255 nfs_fattr_init(fattr
);
256 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, flags
);
258 nfs_refresh_inode(inode
, fattr
);
259 dprintk("NFS reply read: %d\n", status
);
263 static int nfs3_proc_write(struct nfs_write_data
*wdata
)
265 int rpcflags
= wdata
->flags
;
266 struct inode
* inode
= wdata
->inode
;
267 struct nfs_fattr
* fattr
= wdata
->res
.fattr
;
268 struct rpc_message msg
= {
269 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
270 .rpc_argp
= &wdata
->args
,
271 .rpc_resp
= &wdata
->res
,
272 .rpc_cred
= wdata
->cred
,
276 dprintk("NFS call write %d @ %Ld\n", wdata
->args
.count
,
277 (long long) wdata
->args
.offset
);
278 nfs_fattr_init(fattr
);
279 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, rpcflags
);
281 nfs_post_op_update_inode(inode
, fattr
);
282 dprintk("NFS reply write: %d\n", status
);
283 return status
< 0? status
: wdata
->res
.count
;
286 static int nfs3_proc_commit(struct nfs_write_data
*cdata
)
288 struct inode
* inode
= cdata
->inode
;
289 struct nfs_fattr
* fattr
= cdata
->res
.fattr
;
290 struct rpc_message msg
= {
291 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
292 .rpc_argp
= &cdata
->args
,
293 .rpc_resp
= &cdata
->res
,
294 .rpc_cred
= cdata
->cred
,
298 dprintk("NFS call commit %d @ %Ld\n", cdata
->args
.count
,
299 (long long) cdata
->args
.offset
);
300 nfs_fattr_init(fattr
);
301 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
303 nfs_post_op_update_inode(inode
, fattr
);
304 dprintk("NFS reply commit: %d\n", status
);
309 * Create a regular file.
310 * For now, we don't implement O_EXCL.
313 nfs3_proc_create(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
314 int flags
, struct nameidata
*nd
)
316 struct nfs_fh fhandle
;
317 struct nfs_fattr fattr
;
318 struct nfs_fattr dir_attr
;
319 struct nfs3_createargs arg
= {
321 .name
= dentry
->d_name
.name
,
322 .len
= dentry
->d_name
.len
,
325 struct nfs3_diropres res
= {
326 .dir_attr
= &dir_attr
,
330 mode_t mode
= sattr
->ia_mode
;
333 dprintk("NFS call create %s\n", dentry
->d_name
.name
);
334 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
335 if (flags
& O_EXCL
) {
336 arg
.createmode
= NFS3_CREATE_EXCLUSIVE
;
337 arg
.verifier
[0] = jiffies
;
338 arg
.verifier
[1] = current
->pid
;
341 sattr
->ia_mode
&= ~current
->fs
->umask
;
344 nfs_fattr_init(&dir_attr
);
345 nfs_fattr_init(&fattr
);
346 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_CREATE
, &arg
, &res
, 0);
347 nfs_post_op_update_inode(dir
, &dir_attr
);
349 /* If the server doesn't support the exclusive creation semantics,
350 * try again with simple 'guarded' mode. */
351 if (status
== NFSERR_NOTSUPP
) {
352 switch (arg
.createmode
) {
353 case NFS3_CREATE_EXCLUSIVE
:
354 arg
.createmode
= NFS3_CREATE_GUARDED
;
357 case NFS3_CREATE_GUARDED
:
358 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
361 case NFS3_CREATE_UNCHECKED
:
368 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
372 /* When we created the file with exclusive semantics, make
373 * sure we set the attributes afterwards. */
374 if (arg
.createmode
== NFS3_CREATE_EXCLUSIVE
) {
375 dprintk("NFS call setattr (post-create)\n");
377 if (!(sattr
->ia_valid
& ATTR_ATIME_SET
))
378 sattr
->ia_valid
|= ATTR_ATIME
;
379 if (!(sattr
->ia_valid
& ATTR_MTIME_SET
))
380 sattr
->ia_valid
|= ATTR_MTIME
;
382 /* Note: we could use a guarded setattr here, but I'm
383 * not sure this buys us anything (and I'd have
384 * to revamp the NFSv3 XDR code) */
385 status
= nfs3_proc_setattr(dentry
, &fattr
, sattr
);
387 nfs_setattr_update_inode(dentry
->d_inode
, sattr
);
388 nfs_refresh_inode(dentry
->d_inode
, &fattr
);
389 dprintk("NFS reply setattr (post-create): %d\n", status
);
393 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
395 dprintk("NFS reply create: %d\n", status
);
400 nfs3_proc_remove(struct inode
*dir
, struct qstr
*name
)
402 struct nfs_fattr dir_attr
;
403 struct nfs3_diropargs arg
= {
408 struct rpc_message msg
= {
409 .rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
],
411 .rpc_resp
= &dir_attr
,
415 dprintk("NFS call remove %s\n", name
->name
);
416 nfs_fattr_init(&dir_attr
);
417 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
418 nfs_post_op_update_inode(dir
, &dir_attr
);
419 dprintk("NFS reply remove: %d\n", status
);
424 nfs3_proc_unlink_setup(struct rpc_message
*msg
, struct dentry
*dir
, struct qstr
*name
)
427 struct nfs3_diropargs arg
;
428 struct nfs_fattr res
;
431 ptr
= (struct unlinkxdr
*)kmalloc(sizeof(*ptr
), GFP_KERNEL
);
434 ptr
->arg
.fh
= NFS_FH(dir
->d_inode
);
435 ptr
->arg
.name
= name
->name
;
436 ptr
->arg
.len
= name
->len
;
437 nfs_fattr_init(&ptr
->res
);
438 msg
->rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
];
439 msg
->rpc_argp
= &ptr
->arg
;
440 msg
->rpc_resp
= &ptr
->res
;
445 nfs3_proc_unlink_done(struct dentry
*dir
, struct rpc_task
*task
)
447 struct rpc_message
*msg
= &task
->tk_msg
;
448 struct nfs_fattr
*dir_attr
;
450 if (nfs3_async_handle_jukebox(task
))
453 dir_attr
= (struct nfs_fattr
*)msg
->rpc_resp
;
454 nfs_post_op_update_inode(dir
->d_inode
, dir_attr
);
455 kfree(msg
->rpc_argp
);
461 nfs3_proc_rename(struct inode
*old_dir
, struct qstr
*old_name
,
462 struct inode
*new_dir
, struct qstr
*new_name
)
464 struct nfs_fattr old_dir_attr
, new_dir_attr
;
465 struct nfs3_renameargs arg
= {
466 .fromfh
= NFS_FH(old_dir
),
467 .fromname
= old_name
->name
,
468 .fromlen
= old_name
->len
,
469 .tofh
= NFS_FH(new_dir
),
470 .toname
= new_name
->name
,
471 .tolen
= new_name
->len
473 struct nfs3_renameres res
= {
474 .fromattr
= &old_dir_attr
,
475 .toattr
= &new_dir_attr
479 dprintk("NFS call rename %s -> %s\n", old_name
->name
, new_name
->name
);
480 nfs_fattr_init(&old_dir_attr
);
481 nfs_fattr_init(&new_dir_attr
);
482 status
= rpc_call(NFS_CLIENT(old_dir
), NFS3PROC_RENAME
, &arg
, &res
, 0);
483 nfs_post_op_update_inode(old_dir
, &old_dir_attr
);
484 nfs_post_op_update_inode(new_dir
, &new_dir_attr
);
485 dprintk("NFS reply rename: %d\n", status
);
490 nfs3_proc_link(struct inode
*inode
, struct inode
*dir
, struct qstr
*name
)
492 struct nfs_fattr dir_attr
, fattr
;
493 struct nfs3_linkargs arg
= {
494 .fromfh
= NFS_FH(inode
),
496 .toname
= name
->name
,
499 struct nfs3_linkres res
= {
500 .dir_attr
= &dir_attr
,
505 dprintk("NFS call link %s\n", name
->name
);
506 nfs_fattr_init(&dir_attr
);
507 nfs_fattr_init(&fattr
);
508 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_LINK
, &arg
, &res
, 0);
509 nfs_post_op_update_inode(dir
, &dir_attr
);
510 nfs_post_op_update_inode(inode
, &fattr
);
511 dprintk("NFS reply link: %d\n", status
);
516 nfs3_proc_symlink(struct inode
*dir
, struct qstr
*name
, struct qstr
*path
,
517 struct iattr
*sattr
, struct nfs_fh
*fhandle
,
518 struct nfs_fattr
*fattr
)
520 struct nfs_fattr dir_attr
;
521 struct nfs3_symlinkargs arg
= {
522 .fromfh
= NFS_FH(dir
),
523 .fromname
= name
->name
,
524 .fromlen
= name
->len
,
525 .topath
= path
->name
,
529 struct nfs3_diropres res
= {
530 .dir_attr
= &dir_attr
,
536 if (path
->len
> NFS3_MAXPATHLEN
)
537 return -ENAMETOOLONG
;
538 dprintk("NFS call symlink %s -> %s\n", name
->name
, path
->name
);
539 nfs_fattr_init(&dir_attr
);
540 nfs_fattr_init(fattr
);
541 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_SYMLINK
, &arg
, &res
, 0);
542 nfs_post_op_update_inode(dir
, &dir_attr
);
543 dprintk("NFS reply symlink: %d\n", status
);
548 nfs3_proc_mkdir(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
)
550 struct nfs_fh fhandle
;
551 struct nfs_fattr fattr
, dir_attr
;
552 struct nfs3_mkdirargs arg
= {
554 .name
= dentry
->d_name
.name
,
555 .len
= dentry
->d_name
.len
,
558 struct nfs3_diropres res
= {
559 .dir_attr
= &dir_attr
,
563 int mode
= sattr
->ia_mode
;
566 dprintk("NFS call mkdir %s\n", dentry
->d_name
.name
);
568 sattr
->ia_mode
&= ~current
->fs
->umask
;
570 nfs_fattr_init(&dir_attr
);
571 nfs_fattr_init(&fattr
);
572 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKDIR
, &arg
, &res
, 0);
573 nfs_post_op_update_inode(dir
, &dir_attr
);
576 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
579 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
581 dprintk("NFS reply mkdir: %d\n", status
);
586 nfs3_proc_rmdir(struct inode
*dir
, struct qstr
*name
)
588 struct nfs_fattr dir_attr
;
589 struct nfs3_diropargs arg
= {
596 dprintk("NFS call rmdir %s\n", name
->name
);
597 nfs_fattr_init(&dir_attr
);
598 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_RMDIR
, &arg
, &dir_attr
, 0);
599 nfs_post_op_update_inode(dir
, &dir_attr
);
600 dprintk("NFS reply rmdir: %d\n", status
);
605 * The READDIR implementation is somewhat hackish - we pass the user buffer
606 * to the encode function, which installs it in the receive iovec.
607 * The decode function itself doesn't perform any decoding, it just makes
608 * sure the reply is syntactically correct.
610 * Also note that this implementation handles both plain readdir and
614 nfs3_proc_readdir(struct dentry
*dentry
, struct rpc_cred
*cred
,
615 u64 cookie
, struct page
*page
, unsigned int count
, int plus
)
617 struct inode
*dir
= dentry
->d_inode
;
618 struct nfs_fattr dir_attr
;
619 u32
*verf
= NFS_COOKIEVERF(dir
);
620 struct nfs3_readdirargs arg
= {
623 .verf
= {verf
[0], verf
[1]},
628 struct nfs3_readdirres res
= {
629 .dir_attr
= &dir_attr
,
633 struct rpc_message msg
= {
634 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIR
],
644 msg
.rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIRPLUS
];
646 dprintk("NFS call readdir%s %d\n",
647 plus
? "plus" : "", (unsigned int) cookie
);
649 nfs_fattr_init(&dir_attr
);
650 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
651 nfs_refresh_inode(dir
, &dir_attr
);
652 dprintk("NFS reply readdir: %d\n", status
);
658 nfs3_proc_mknod(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
662 struct nfs_fattr fattr
, dir_attr
;
663 struct nfs3_mknodargs arg
= {
665 .name
= dentry
->d_name
.name
,
666 .len
= dentry
->d_name
.len
,
670 struct nfs3_diropres res
= {
671 .dir_attr
= &dir_attr
,
675 mode_t mode
= sattr
->ia_mode
;
678 switch (sattr
->ia_mode
& S_IFMT
) {
679 case S_IFBLK
: arg
.type
= NF3BLK
; break;
680 case S_IFCHR
: arg
.type
= NF3CHR
; break;
681 case S_IFIFO
: arg
.type
= NF3FIFO
; break;
682 case S_IFSOCK
: arg
.type
= NF3SOCK
; break;
683 default: return -EINVAL
;
686 dprintk("NFS call mknod %s %u:%u\n", dentry
->d_name
.name
,
687 MAJOR(rdev
), MINOR(rdev
));
689 sattr
->ia_mode
&= ~current
->fs
->umask
;
691 nfs_fattr_init(&dir_attr
);
692 nfs_fattr_init(&fattr
);
693 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKNOD
, &arg
, &res
, 0);
694 nfs_post_op_update_inode(dir
, &dir_attr
);
697 status
= nfs_instantiate(dentry
, &fh
, &fattr
);
700 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
702 dprintk("NFS reply mknod: %d\n", status
);
707 nfs3_proc_statfs(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
708 struct nfs_fsstat
*stat
)
712 dprintk("NFS call fsstat\n");
713 nfs_fattr_init(stat
->fattr
);
714 status
= rpc_call(server
->client
, NFS3PROC_FSSTAT
, fhandle
, stat
, 0);
715 dprintk("NFS reply statfs: %d\n", status
);
720 nfs3_proc_fsinfo(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
721 struct nfs_fsinfo
*info
)
725 dprintk("NFS call fsinfo\n");
726 nfs_fattr_init(info
->fattr
);
727 status
= rpc_call(server
->client_sys
, NFS3PROC_FSINFO
, fhandle
, info
, 0);
728 dprintk("NFS reply fsinfo: %d\n", status
);
733 nfs3_proc_pathconf(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
734 struct nfs_pathconf
*info
)
738 dprintk("NFS call pathconf\n");
739 nfs_fattr_init(info
->fattr
);
740 status
= rpc_call(server
->client
, NFS3PROC_PATHCONF
, fhandle
, info
, 0);
741 dprintk("NFS reply pathconf: %d\n", status
);
745 extern u32
*nfs3_decode_dirent(u32
*, struct nfs_entry
*, int);
747 static void nfs3_read_done(struct rpc_task
*task
, void *calldata
)
749 struct nfs_read_data
*data
= calldata
;
751 if (nfs3_async_handle_jukebox(task
))
753 /* Call back common NFS readpage processing */
754 if (task
->tk_status
>= 0)
755 nfs_refresh_inode(data
->inode
, &data
->fattr
);
756 nfs_readpage_result(task
, calldata
);
759 static const struct rpc_call_ops nfs3_read_ops
= {
760 .rpc_call_done
= nfs3_read_done
,
761 .rpc_release
= nfs_readdata_release
,
765 nfs3_proc_read_setup(struct nfs_read_data
*data
)
767 struct rpc_task
*task
= &data
->task
;
768 struct inode
*inode
= data
->inode
;
770 struct rpc_message msg
= {
771 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
772 .rpc_argp
= &data
->args
,
773 .rpc_resp
= &data
->res
,
774 .rpc_cred
= data
->cred
,
777 /* N.B. Do we need to test? Never called for swapfile inode */
778 flags
= RPC_TASK_ASYNC
| (IS_SWAPFILE(inode
)? NFS_RPC_SWAPFLAGS
: 0);
780 /* Finalize the task. */
781 rpc_init_task(task
, NFS_CLIENT(inode
), flags
, &nfs3_read_ops
, data
);
782 rpc_call_setup(task
, &msg
, 0);
785 static void nfs3_write_done(struct rpc_task
*task
, void *calldata
)
787 struct nfs_write_data
*data
= calldata
;
789 if (nfs3_async_handle_jukebox(task
))
791 if (task
->tk_status
>= 0)
792 nfs_post_op_update_inode(data
->inode
, data
->res
.fattr
);
793 nfs_writeback_done(task
, calldata
);
796 static const struct rpc_call_ops nfs3_write_ops
= {
797 .rpc_call_done
= nfs3_write_done
,
798 .rpc_release
= nfs_writedata_release
,
802 nfs3_proc_write_setup(struct nfs_write_data
*data
, int how
)
804 struct rpc_task
*task
= &data
->task
;
805 struct inode
*inode
= data
->inode
;
808 struct rpc_message msg
= {
809 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
810 .rpc_argp
= &data
->args
,
811 .rpc_resp
= &data
->res
,
812 .rpc_cred
= data
->cred
,
815 if (how
& FLUSH_STABLE
) {
816 if (!NFS_I(inode
)->ncommit
)
817 stable
= NFS_FILE_SYNC
;
819 stable
= NFS_DATA_SYNC
;
821 stable
= NFS_UNSTABLE
;
822 data
->args
.stable
= stable
;
824 /* Set the initial flags for the task. */
825 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
827 /* Finalize the task. */
828 rpc_init_task(task
, NFS_CLIENT(inode
), flags
, &nfs3_write_ops
, data
);
829 rpc_call_setup(task
, &msg
, 0);
832 static void nfs3_commit_done(struct rpc_task
*task
, void *calldata
)
834 struct nfs_write_data
*data
= calldata
;
836 if (nfs3_async_handle_jukebox(task
))
838 if (task
->tk_status
>= 0)
839 nfs_post_op_update_inode(data
->inode
, data
->res
.fattr
);
840 nfs_commit_done(task
, calldata
);
843 static const struct rpc_call_ops nfs3_commit_ops
= {
844 .rpc_call_done
= nfs3_commit_done
,
845 .rpc_release
= nfs_commit_release
,
849 nfs3_proc_commit_setup(struct nfs_write_data
*data
, int how
)
851 struct rpc_task
*task
= &data
->task
;
852 struct inode
*inode
= data
->inode
;
854 struct rpc_message msg
= {
855 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
856 .rpc_argp
= &data
->args
,
857 .rpc_resp
= &data
->res
,
858 .rpc_cred
= data
->cred
,
861 /* Set the initial flags for the task. */
862 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
864 /* Finalize the task. */
865 rpc_init_task(task
, NFS_CLIENT(inode
), flags
, &nfs3_commit_ops
, data
);
866 rpc_call_setup(task
, &msg
, 0);
870 nfs3_proc_lock(struct file
*filp
, int cmd
, struct file_lock
*fl
)
872 return nlmclnt_proc(filp
->f_dentry
->d_inode
, cmd
, fl
);
875 struct nfs_rpc_ops nfs_v3_clientops
= {
876 .version
= 3, /* protocol version */
877 .dentry_ops
= &nfs_dentry_operations
,
878 .dir_inode_ops
= &nfs3_dir_inode_operations
,
879 .file_inode_ops
= &nfs3_file_inode_operations
,
880 .getroot
= nfs3_proc_get_root
,
881 .getattr
= nfs3_proc_getattr
,
882 .setattr
= nfs3_proc_setattr
,
883 .lookup
= nfs3_proc_lookup
,
884 .access
= nfs3_proc_access
,
885 .readlink
= nfs3_proc_readlink
,
886 .read
= nfs3_proc_read
,
887 .write
= nfs3_proc_write
,
888 .commit
= nfs3_proc_commit
,
889 .create
= nfs3_proc_create
,
890 .remove
= nfs3_proc_remove
,
891 .unlink_setup
= nfs3_proc_unlink_setup
,
892 .unlink_done
= nfs3_proc_unlink_done
,
893 .rename
= nfs3_proc_rename
,
894 .link
= nfs3_proc_link
,
895 .symlink
= nfs3_proc_symlink
,
896 .mkdir
= nfs3_proc_mkdir
,
897 .rmdir
= nfs3_proc_rmdir
,
898 .readdir
= nfs3_proc_readdir
,
899 .mknod
= nfs3_proc_mknod
,
900 .statfs
= nfs3_proc_statfs
,
901 .fsinfo
= nfs3_proc_fsinfo
,
902 .pathconf
= nfs3_proc_pathconf
,
903 .decode_dirent
= nfs3_decode_dirent
,
904 .read_setup
= nfs3_proc_read_setup
,
905 .write_setup
= nfs3_proc_write_setup
,
906 .commit_setup
= nfs3_proc_commit_setup
,
907 .file_open
= nfs_open
,
908 .file_release
= nfs_release
,
909 .lock
= nfs3_proc_lock
,
910 .clear_acl_cache
= nfs3_forget_cached_acls
,