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 set_current_state(TASK_INTERRUPTIBLE
);
38 schedule_timeout(NFS_JUKEBOX_RETRY_TIME
);
40 } while (!signalled());
41 rpc_clnt_sigunmask(clnt
, &oldset
);
46 nfs3_rpc_call_wrapper(struct rpc_clnt
*clnt
, u32 proc
, void *argp
, void *resp
, int flags
)
48 struct rpc_message msg
= {
49 .rpc_proc
= &clnt
->cl_procinfo
[proc
],
53 return nfs3_rpc_wrapper(clnt
, &msg
, flags
);
56 #define rpc_call(clnt, proc, argp, resp, flags) \
57 nfs3_rpc_call_wrapper(clnt, proc, argp, resp, flags)
58 #define rpc_call_sync(clnt, msg, flags) \
59 nfs3_rpc_wrapper(clnt, msg, flags)
62 nfs3_async_handle_jukebox(struct rpc_task
*task
)
64 if (task
->tk_status
!= -EJUKEBOX
)
67 rpc_restart_call(task
);
68 rpc_delay(task
, NFS_JUKEBOX_RETRY_TIME
);
73 * Bare-bones access to getattr: this is for nfs_read_super.
76 nfs3_proc_get_root(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
77 struct nfs_fsinfo
*info
)
81 dprintk("%s: call fsinfo\n", __FUNCTION__
);
82 info
->fattr
->valid
= 0;
83 status
= rpc_call(server
->client_sys
, NFS3PROC_FSINFO
, fhandle
, info
, 0);
84 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__
, status
);
85 if (!(info
->fattr
->valid
& NFS_ATTR_FATTR
)) {
86 status
= rpc_call(server
->client_sys
, NFS3PROC_GETATTR
, fhandle
, info
->fattr
, 0);
87 dprintk("%s: reply getattr: %d\n", __FUNCTION__
, status
);
93 * One function for each procedure in the NFS protocol.
96 nfs3_proc_getattr(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
97 struct nfs_fattr
*fattr
)
101 dprintk("NFS call getattr\n");
103 status
= rpc_call(server
->client
, NFS3PROC_GETATTR
,
105 dprintk("NFS reply getattr: %d\n", status
);
110 nfs3_proc_setattr(struct dentry
*dentry
, struct nfs_fattr
*fattr
,
113 struct inode
*inode
= dentry
->d_inode
;
114 struct nfs3_sattrargs arg
= {
120 dprintk("NFS call setattr\n");
122 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_SETATTR
, &arg
, fattr
, 0);
124 nfs_setattr_update_inode(inode
, sattr
);
125 dprintk("NFS reply setattr: %d\n", status
);
130 nfs3_proc_lookup(struct inode
*dir
, struct qstr
*name
,
131 struct nfs_fh
*fhandle
, struct nfs_fattr
*fattr
)
133 struct nfs_fattr dir_attr
;
134 struct nfs3_diropargs arg
= {
139 struct nfs3_diropres res
= {
140 .dir_attr
= &dir_attr
,
146 dprintk("NFS call lookup %s\n", name
->name
);
149 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_LOOKUP
, &arg
, &res
, 0);
150 if (status
>= 0 && !(fattr
->valid
& NFS_ATTR_FATTR
))
151 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_GETATTR
,
153 dprintk("NFS reply lookup: %d\n", status
);
155 status
= nfs_refresh_inode(dir
, &dir_attr
);
159 static int nfs3_proc_access(struct inode
*inode
, struct nfs_access_entry
*entry
)
161 struct nfs_fattr fattr
;
162 struct nfs3_accessargs arg
= {
165 struct nfs3_accessres res
= {
168 struct rpc_message msg
= {
169 .rpc_proc
= &nfs3_procedures
[NFS3PROC_ACCESS
],
172 .rpc_cred
= entry
->cred
174 int mode
= entry
->mask
;
177 dprintk("NFS call access\n");
181 arg
.access
|= NFS3_ACCESS_READ
;
182 if (S_ISDIR(inode
->i_mode
)) {
183 if (mode
& MAY_WRITE
)
184 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
;
186 arg
.access
|= NFS3_ACCESS_LOOKUP
;
188 if (mode
& MAY_WRITE
)
189 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
;
191 arg
.access
|= NFS3_ACCESS_EXECUTE
;
193 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
194 nfs_refresh_inode(inode
, &fattr
);
197 if (res
.access
& NFS3_ACCESS_READ
)
198 entry
->mask
|= MAY_READ
;
199 if (res
.access
& (NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
))
200 entry
->mask
|= MAY_WRITE
;
201 if (res
.access
& (NFS3_ACCESS_LOOKUP
|NFS3_ACCESS_EXECUTE
))
202 entry
->mask
|= MAY_EXEC
;
204 dprintk("NFS reply access: %d\n", status
);
208 static int nfs3_proc_readlink(struct inode
*inode
, struct page
*page
,
209 unsigned int pgbase
, unsigned int pglen
)
211 struct nfs_fattr fattr
;
212 struct nfs3_readlinkargs args
= {
220 dprintk("NFS call readlink\n");
222 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_READLINK
,
224 nfs_refresh_inode(inode
, &fattr
);
225 dprintk("NFS reply readlink: %d\n", status
);
229 static int nfs3_proc_read(struct nfs_read_data
*rdata
)
231 int flags
= rdata
->flags
;
232 struct inode
* inode
= rdata
->inode
;
233 struct nfs_fattr
* fattr
= rdata
->res
.fattr
;
234 struct rpc_message msg
= {
235 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
236 .rpc_argp
= &rdata
->args
,
237 .rpc_resp
= &rdata
->res
,
238 .rpc_cred
= rdata
->cred
,
242 dprintk("NFS call read %d @ %Ld\n", rdata
->args
.count
,
243 (long long) rdata
->args
.offset
);
245 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, flags
);
247 nfs_refresh_inode(inode
, fattr
);
248 dprintk("NFS reply read: %d\n", status
);
252 static int nfs3_proc_write(struct nfs_write_data
*wdata
)
254 int rpcflags
= wdata
->flags
;
255 struct inode
* inode
= wdata
->inode
;
256 struct nfs_fattr
* fattr
= wdata
->res
.fattr
;
257 struct rpc_message msg
= {
258 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
259 .rpc_argp
= &wdata
->args
,
260 .rpc_resp
= &wdata
->res
,
261 .rpc_cred
= wdata
->cred
,
265 dprintk("NFS call write %d @ %Ld\n", wdata
->args
.count
,
266 (long long) wdata
->args
.offset
);
268 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, rpcflags
);
270 nfs_refresh_inode(inode
, fattr
);
271 dprintk("NFS reply write: %d\n", status
);
272 return status
< 0? status
: wdata
->res
.count
;
275 static int nfs3_proc_commit(struct nfs_write_data
*cdata
)
277 struct inode
* inode
= cdata
->inode
;
278 struct nfs_fattr
* fattr
= cdata
->res
.fattr
;
279 struct rpc_message msg
= {
280 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
281 .rpc_argp
= &cdata
->args
,
282 .rpc_resp
= &cdata
->res
,
283 .rpc_cred
= cdata
->cred
,
287 dprintk("NFS call commit %d @ %Ld\n", cdata
->args
.count
,
288 (long long) cdata
->args
.offset
);
290 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
292 nfs_refresh_inode(inode
, fattr
);
293 dprintk("NFS reply commit: %d\n", status
);
298 * Create a regular file.
299 * For now, we don't implement O_EXCL.
302 nfs3_proc_create(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
305 struct nfs_fh fhandle
;
306 struct nfs_fattr fattr
;
307 struct nfs_fattr dir_attr
;
308 struct nfs3_createargs arg
= {
310 .name
= dentry
->d_name
.name
,
311 .len
= dentry
->d_name
.len
,
314 struct nfs3_diropres res
= {
315 .dir_attr
= &dir_attr
,
319 mode_t mode
= sattr
->ia_mode
;
322 dprintk("NFS call create %s\n", dentry
->d_name
.name
);
323 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
324 if (flags
& O_EXCL
) {
325 arg
.createmode
= NFS3_CREATE_EXCLUSIVE
;
326 arg
.verifier
[0] = jiffies
;
327 arg
.verifier
[1] = current
->pid
;
330 sattr
->ia_mode
&= ~current
->fs
->umask
;
335 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_CREATE
, &arg
, &res
, 0);
336 nfs_refresh_inode(dir
, &dir_attr
);
338 /* If the server doesn't support the exclusive creation semantics,
339 * try again with simple 'guarded' mode. */
340 if (status
== NFSERR_NOTSUPP
) {
341 switch (arg
.createmode
) {
342 case NFS3_CREATE_EXCLUSIVE
:
343 arg
.createmode
= NFS3_CREATE_GUARDED
;
346 case NFS3_CREATE_GUARDED
:
347 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
350 case NFS3_CREATE_UNCHECKED
:
357 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
361 /* When we created the file with exclusive semantics, make
362 * sure we set the attributes afterwards. */
363 if (arg
.createmode
== NFS3_CREATE_EXCLUSIVE
) {
364 dprintk("NFS call setattr (post-create)\n");
366 if (!(sattr
->ia_valid
& ATTR_ATIME_SET
))
367 sattr
->ia_valid
|= ATTR_ATIME
;
368 if (!(sattr
->ia_valid
& ATTR_MTIME_SET
))
369 sattr
->ia_valid
|= ATTR_MTIME
;
371 /* Note: we could use a guarded setattr here, but I'm
372 * not sure this buys us anything (and I'd have
373 * to revamp the NFSv3 XDR code) */
374 status
= nfs3_proc_setattr(dentry
, &fattr
, sattr
);
376 nfs_setattr_update_inode(dentry
->d_inode
, sattr
);
377 nfs_refresh_inode(dentry
->d_inode
, &fattr
);
378 dprintk("NFS reply setattr (post-create): %d\n", status
);
382 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
384 dprintk("NFS reply create: %d\n", status
);
389 nfs3_proc_remove(struct inode
*dir
, struct qstr
*name
)
391 struct nfs_fattr dir_attr
;
392 struct nfs3_diropargs arg
= {
397 struct rpc_message msg
= {
398 .rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
],
400 .rpc_resp
= &dir_attr
,
404 dprintk("NFS call remove %s\n", name
->name
);
406 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
407 nfs_refresh_inode(dir
, &dir_attr
);
408 dprintk("NFS reply remove: %d\n", status
);
413 nfs3_proc_unlink_setup(struct rpc_message
*msg
, struct dentry
*dir
, struct qstr
*name
)
416 struct nfs3_diropargs arg
;
417 struct nfs_fattr res
;
420 ptr
= (struct unlinkxdr
*)kmalloc(sizeof(*ptr
), GFP_KERNEL
);
423 ptr
->arg
.fh
= NFS_FH(dir
->d_inode
);
424 ptr
->arg
.name
= name
->name
;
425 ptr
->arg
.len
= name
->len
;
427 msg
->rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
];
428 msg
->rpc_argp
= &ptr
->arg
;
429 msg
->rpc_resp
= &ptr
->res
;
434 nfs3_proc_unlink_done(struct dentry
*dir
, struct rpc_task
*task
)
436 struct rpc_message
*msg
= &task
->tk_msg
;
437 struct nfs_fattr
*dir_attr
;
439 if (nfs3_async_handle_jukebox(task
))
442 dir_attr
= (struct nfs_fattr
*)msg
->rpc_resp
;
443 nfs_refresh_inode(dir
->d_inode
, dir_attr
);
444 kfree(msg
->rpc_argp
);
450 nfs3_proc_rename(struct inode
*old_dir
, struct qstr
*old_name
,
451 struct inode
*new_dir
, struct qstr
*new_name
)
453 struct nfs_fattr old_dir_attr
, new_dir_attr
;
454 struct nfs3_renameargs arg
= {
455 .fromfh
= NFS_FH(old_dir
),
456 .fromname
= old_name
->name
,
457 .fromlen
= old_name
->len
,
458 .tofh
= NFS_FH(new_dir
),
459 .toname
= new_name
->name
,
460 .tolen
= new_name
->len
462 struct nfs3_renameres res
= {
463 .fromattr
= &old_dir_attr
,
464 .toattr
= &new_dir_attr
468 dprintk("NFS call rename %s -> %s\n", old_name
->name
, new_name
->name
);
469 old_dir_attr
.valid
= 0;
470 new_dir_attr
.valid
= 0;
471 status
= rpc_call(NFS_CLIENT(old_dir
), NFS3PROC_RENAME
, &arg
, &res
, 0);
472 nfs_refresh_inode(old_dir
, &old_dir_attr
);
473 nfs_refresh_inode(new_dir
, &new_dir_attr
);
474 dprintk("NFS reply rename: %d\n", status
);
479 nfs3_proc_link(struct inode
*inode
, struct inode
*dir
, struct qstr
*name
)
481 struct nfs_fattr dir_attr
, fattr
;
482 struct nfs3_linkargs arg
= {
483 .fromfh
= NFS_FH(inode
),
485 .toname
= name
->name
,
488 struct nfs3_linkres res
= {
489 .dir_attr
= &dir_attr
,
494 dprintk("NFS call link %s\n", name
->name
);
497 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_LINK
, &arg
, &res
, 0);
498 nfs_refresh_inode(dir
, &dir_attr
);
499 nfs_refresh_inode(inode
, &fattr
);
500 dprintk("NFS reply link: %d\n", status
);
505 nfs3_proc_symlink(struct inode
*dir
, struct qstr
*name
, struct qstr
*path
,
506 struct iattr
*sattr
, struct nfs_fh
*fhandle
,
507 struct nfs_fattr
*fattr
)
509 struct nfs_fattr dir_attr
;
510 struct nfs3_symlinkargs arg
= {
511 .fromfh
= NFS_FH(dir
),
512 .fromname
= name
->name
,
513 .fromlen
= name
->len
,
514 .topath
= path
->name
,
518 struct nfs3_diropres res
= {
519 .dir_attr
= &dir_attr
,
525 if (path
->len
> NFS3_MAXPATHLEN
)
526 return -ENAMETOOLONG
;
527 dprintk("NFS call symlink %s -> %s\n", name
->name
, path
->name
);
530 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_SYMLINK
, &arg
, &res
, 0);
531 nfs_refresh_inode(dir
, &dir_attr
);
532 dprintk("NFS reply symlink: %d\n", status
);
537 nfs3_proc_mkdir(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
)
539 struct nfs_fh fhandle
;
540 struct nfs_fattr fattr
, dir_attr
;
541 struct nfs3_mkdirargs arg
= {
543 .name
= dentry
->d_name
.name
,
544 .len
= dentry
->d_name
.len
,
547 struct nfs3_diropres res
= {
548 .dir_attr
= &dir_attr
,
552 int mode
= sattr
->ia_mode
;
555 dprintk("NFS call mkdir %s\n", dentry
->d_name
.name
);
559 sattr
->ia_mode
&= ~current
->fs
->umask
;
561 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKDIR
, &arg
, &res
, 0);
562 nfs_refresh_inode(dir
, &dir_attr
);
565 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
568 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
570 dprintk("NFS reply mkdir: %d\n", status
);
575 nfs3_proc_rmdir(struct inode
*dir
, struct qstr
*name
)
577 struct nfs_fattr dir_attr
;
578 struct nfs3_diropargs arg
= {
585 dprintk("NFS call rmdir %s\n", name
->name
);
587 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_RMDIR
, &arg
, &dir_attr
, 0);
588 nfs_refresh_inode(dir
, &dir_attr
);
589 dprintk("NFS reply rmdir: %d\n", status
);
594 * The READDIR implementation is somewhat hackish - we pass the user buffer
595 * to the encode function, which installs it in the receive iovec.
596 * The decode function itself doesn't perform any decoding, it just makes
597 * sure the reply is syntactically correct.
599 * Also note that this implementation handles both plain readdir and
603 nfs3_proc_readdir(struct dentry
*dentry
, struct rpc_cred
*cred
,
604 u64 cookie
, struct page
*page
, unsigned int count
, int plus
)
606 struct inode
*dir
= dentry
->d_inode
;
607 struct nfs_fattr dir_attr
;
608 u32
*verf
= NFS_COOKIEVERF(dir
);
609 struct nfs3_readdirargs arg
= {
612 .verf
= {verf
[0], verf
[1]},
617 struct nfs3_readdirres res
= {
618 .dir_attr
= &dir_attr
,
622 struct rpc_message msg
= {
623 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIR
],
633 msg
.rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIRPLUS
];
635 dprintk("NFS call readdir%s %d\n",
636 plus
? "plus" : "", (unsigned int) cookie
);
639 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
640 nfs_refresh_inode(dir
, &dir_attr
);
641 dprintk("NFS reply readdir: %d\n", status
);
647 nfs3_proc_mknod(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
651 struct nfs_fattr fattr
, dir_attr
;
652 struct nfs3_mknodargs arg
= {
654 .name
= dentry
->d_name
.name
,
655 .len
= dentry
->d_name
.len
,
659 struct nfs3_diropres res
= {
660 .dir_attr
= &dir_attr
,
664 mode_t mode
= sattr
->ia_mode
;
667 switch (sattr
->ia_mode
& S_IFMT
) {
668 case S_IFBLK
: arg
.type
= NF3BLK
; break;
669 case S_IFCHR
: arg
.type
= NF3CHR
; break;
670 case S_IFIFO
: arg
.type
= NF3FIFO
; break;
671 case S_IFSOCK
: arg
.type
= NF3SOCK
; break;
672 default: return -EINVAL
;
675 dprintk("NFS call mknod %s %u:%u\n", dentry
->d_name
.name
,
676 MAJOR(rdev
), MINOR(rdev
));
678 sattr
->ia_mode
&= ~current
->fs
->umask
;
682 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKNOD
, &arg
, &res
, 0);
683 nfs_refresh_inode(dir
, &dir_attr
);
686 status
= nfs_instantiate(dentry
, &fh
, &fattr
);
689 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
691 dprintk("NFS reply mknod: %d\n", status
);
696 nfs3_proc_statfs(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
697 struct nfs_fsstat
*stat
)
701 dprintk("NFS call fsstat\n");
702 stat
->fattr
->valid
= 0;
703 status
= rpc_call(server
->client
, NFS3PROC_FSSTAT
, fhandle
, stat
, 0);
704 dprintk("NFS reply statfs: %d\n", status
);
709 nfs3_proc_fsinfo(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
710 struct nfs_fsinfo
*info
)
714 dprintk("NFS call fsinfo\n");
715 info
->fattr
->valid
= 0;
716 status
= rpc_call(server
->client_sys
, NFS3PROC_FSINFO
, fhandle
, info
, 0);
717 dprintk("NFS reply fsinfo: %d\n", status
);
722 nfs3_proc_pathconf(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
723 struct nfs_pathconf
*info
)
727 dprintk("NFS call pathconf\n");
728 info
->fattr
->valid
= 0;
729 status
= rpc_call(server
->client
, NFS3PROC_PATHCONF
, fhandle
, info
, 0);
730 dprintk("NFS reply pathconf: %d\n", status
);
734 extern u32
*nfs3_decode_dirent(u32
*, struct nfs_entry
*, int);
737 nfs3_read_done(struct rpc_task
*task
)
739 struct nfs_write_data
*data
= (struct nfs_write_data
*) task
->tk_calldata
;
741 if (nfs3_async_handle_jukebox(task
))
743 /* Call back common NFS readpage processing */
744 if (task
->tk_status
>= 0)
745 nfs_refresh_inode(data
->inode
, &data
->fattr
);
746 nfs_readpage_result(task
);
750 nfs3_proc_read_setup(struct nfs_read_data
*data
)
752 struct rpc_task
*task
= &data
->task
;
753 struct inode
*inode
= data
->inode
;
755 struct rpc_message msg
= {
756 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
757 .rpc_argp
= &data
->args
,
758 .rpc_resp
= &data
->res
,
759 .rpc_cred
= data
->cred
,
762 /* N.B. Do we need to test? Never called for swapfile inode */
763 flags
= RPC_TASK_ASYNC
| (IS_SWAPFILE(inode
)? NFS_RPC_SWAPFLAGS
: 0);
765 /* Finalize the task. */
766 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_read_done
, flags
);
767 rpc_call_setup(task
, &msg
, 0);
771 nfs3_write_done(struct rpc_task
*task
)
773 struct nfs_write_data
*data
;
775 if (nfs3_async_handle_jukebox(task
))
777 data
= (struct nfs_write_data
*)task
->tk_calldata
;
778 if (task
->tk_status
>= 0)
779 nfs_refresh_inode(data
->inode
, data
->res
.fattr
);
780 nfs_writeback_done(task
);
784 nfs3_proc_write_setup(struct nfs_write_data
*data
, int how
)
786 struct rpc_task
*task
= &data
->task
;
787 struct inode
*inode
= data
->inode
;
790 struct rpc_message msg
= {
791 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
792 .rpc_argp
= &data
->args
,
793 .rpc_resp
= &data
->res
,
794 .rpc_cred
= data
->cred
,
797 if (how
& FLUSH_STABLE
) {
798 if (!NFS_I(inode
)->ncommit
)
799 stable
= NFS_FILE_SYNC
;
801 stable
= NFS_DATA_SYNC
;
803 stable
= NFS_UNSTABLE
;
804 data
->args
.stable
= stable
;
806 /* Set the initial flags for the task. */
807 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
809 /* Finalize the task. */
810 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_write_done
, flags
);
811 rpc_call_setup(task
, &msg
, 0);
815 nfs3_commit_done(struct rpc_task
*task
)
817 struct nfs_write_data
*data
;
819 if (nfs3_async_handle_jukebox(task
))
821 data
= (struct nfs_write_data
*)task
->tk_calldata
;
822 if (task
->tk_status
>= 0)
823 nfs_refresh_inode(data
->inode
, data
->res
.fattr
);
824 nfs_commit_done(task
);
828 nfs3_proc_commit_setup(struct nfs_write_data
*data
, int how
)
830 struct rpc_task
*task
= &data
->task
;
831 struct inode
*inode
= data
->inode
;
833 struct rpc_message msg
= {
834 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
835 .rpc_argp
= &data
->args
,
836 .rpc_resp
= &data
->res
,
837 .rpc_cred
= data
->cred
,
840 /* Set the initial flags for the task. */
841 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
843 /* Finalize the task. */
844 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_commit_done
, flags
);
845 rpc_call_setup(task
, &msg
, 0);
849 nfs3_proc_lock(struct file
*filp
, int cmd
, struct file_lock
*fl
)
851 return nlmclnt_proc(filp
->f_dentry
->d_inode
, cmd
, fl
);
854 struct nfs_rpc_ops nfs_v3_clientops
= {
855 .version
= 3, /* protocol version */
856 .dentry_ops
= &nfs_dentry_operations
,
857 .dir_inode_ops
= &nfs3_dir_inode_operations
,
858 .file_inode_ops
= &nfs3_file_inode_operations
,
859 .getroot
= nfs3_proc_get_root
,
860 .getattr
= nfs3_proc_getattr
,
861 .setattr
= nfs3_proc_setattr
,
862 .lookup
= nfs3_proc_lookup
,
863 .access
= nfs3_proc_access
,
864 .readlink
= nfs3_proc_readlink
,
865 .read
= nfs3_proc_read
,
866 .write
= nfs3_proc_write
,
867 .commit
= nfs3_proc_commit
,
868 .create
= nfs3_proc_create
,
869 .remove
= nfs3_proc_remove
,
870 .unlink_setup
= nfs3_proc_unlink_setup
,
871 .unlink_done
= nfs3_proc_unlink_done
,
872 .rename
= nfs3_proc_rename
,
873 .link
= nfs3_proc_link
,
874 .symlink
= nfs3_proc_symlink
,
875 .mkdir
= nfs3_proc_mkdir
,
876 .rmdir
= nfs3_proc_rmdir
,
877 .readdir
= nfs3_proc_readdir
,
878 .mknod
= nfs3_proc_mknod
,
879 .statfs
= nfs3_proc_statfs
,
880 .fsinfo
= nfs3_proc_fsinfo
,
881 .pathconf
= nfs3_proc_pathconf
,
882 .decode_dirent
= nfs3_decode_dirent
,
883 .read_setup
= nfs3_proc_read_setup
,
884 .write_setup
= nfs3_proc_write_setup
,
885 .commit_setup
= nfs3_proc_commit_setup
,
886 .file_open
= nfs_open
,
887 .file_release
= nfs_release
,
888 .lock
= nfs3_proc_lock
,
889 .clear_acl_cache
= nfs3_forget_cached_acls
,