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 * Bare-bones access to getattr: this is for nfs_read_super.
75 nfs3_proc_get_root(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
76 struct nfs_fsinfo
*info
)
80 dprintk("%s: call fsinfo\n", __FUNCTION__
);
81 info
->fattr
->valid
= 0;
82 status
= rpc_call(server
->client_sys
, NFS3PROC_FSINFO
, fhandle
, info
, 0);
83 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__
, status
);
84 if (!(info
->fattr
->valid
& NFS_ATTR_FATTR
)) {
85 status
= rpc_call(server
->client_sys
, NFS3PROC_GETATTR
, fhandle
, info
->fattr
, 0);
86 dprintk("%s: reply getattr: %d\n", __FUNCTION__
, status
);
92 * One function for each procedure in the NFS protocol.
95 nfs3_proc_getattr(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
96 struct nfs_fattr
*fattr
)
100 dprintk("NFS call getattr\n");
102 status
= rpc_call(server
->client
, NFS3PROC_GETATTR
,
104 dprintk("NFS reply getattr: %d\n", status
);
109 nfs3_proc_setattr(struct dentry
*dentry
, struct nfs_fattr
*fattr
,
112 struct inode
*inode
= dentry
->d_inode
;
113 struct nfs3_sattrargs arg
= {
119 dprintk("NFS call setattr\n");
121 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_SETATTR
, &arg
, fattr
, 0);
123 nfs_setattr_update_inode(inode
, sattr
);
124 dprintk("NFS reply setattr: %d\n", status
);
129 nfs3_proc_lookup(struct inode
*dir
, struct qstr
*name
,
130 struct nfs_fh
*fhandle
, struct nfs_fattr
*fattr
)
132 struct nfs_fattr dir_attr
;
133 struct nfs3_diropargs arg
= {
138 struct nfs3_diropres res
= {
139 .dir_attr
= &dir_attr
,
145 dprintk("NFS call lookup %s\n", name
->name
);
148 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_LOOKUP
, &arg
, &res
, 0);
149 if (status
>= 0 && !(fattr
->valid
& NFS_ATTR_FATTR
))
150 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_GETATTR
,
152 dprintk("NFS reply lookup: %d\n", status
);
154 status
= nfs_refresh_inode(dir
, &dir_attr
);
158 static int nfs3_proc_access(struct inode
*inode
, struct nfs_access_entry
*entry
)
160 struct nfs_fattr fattr
;
161 struct nfs3_accessargs arg
= {
164 struct nfs3_accessres res
= {
167 struct rpc_message msg
= {
168 .rpc_proc
= &nfs3_procedures
[NFS3PROC_ACCESS
],
171 .rpc_cred
= entry
->cred
173 int mode
= entry
->mask
;
176 dprintk("NFS call access\n");
180 arg
.access
|= NFS3_ACCESS_READ
;
181 if (S_ISDIR(inode
->i_mode
)) {
182 if (mode
& MAY_WRITE
)
183 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
;
185 arg
.access
|= NFS3_ACCESS_LOOKUP
;
187 if (mode
& MAY_WRITE
)
188 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
;
190 arg
.access
|= NFS3_ACCESS_EXECUTE
;
192 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
193 nfs_refresh_inode(inode
, &fattr
);
196 if (res
.access
& NFS3_ACCESS_READ
)
197 entry
->mask
|= MAY_READ
;
198 if (res
.access
& (NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
))
199 entry
->mask
|= MAY_WRITE
;
200 if (res
.access
& (NFS3_ACCESS_LOOKUP
|NFS3_ACCESS_EXECUTE
))
201 entry
->mask
|= MAY_EXEC
;
203 dprintk("NFS reply access: %d\n", status
);
207 static int nfs3_proc_readlink(struct inode
*inode
, struct page
*page
,
208 unsigned int pgbase
, unsigned int pglen
)
210 struct nfs_fattr fattr
;
211 struct nfs3_readlinkargs args
= {
219 dprintk("NFS call readlink\n");
221 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_READLINK
,
223 nfs_refresh_inode(inode
, &fattr
);
224 dprintk("NFS reply readlink: %d\n", status
);
228 static int nfs3_proc_read(struct nfs_read_data
*rdata
)
230 int flags
= rdata
->flags
;
231 struct inode
* inode
= rdata
->inode
;
232 struct nfs_fattr
* fattr
= rdata
->res
.fattr
;
233 struct rpc_message msg
= {
234 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
235 .rpc_argp
= &rdata
->args
,
236 .rpc_resp
= &rdata
->res
,
237 .rpc_cred
= rdata
->cred
,
241 dprintk("NFS call read %d @ %Ld\n", rdata
->args
.count
,
242 (long long) rdata
->args
.offset
);
244 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, flags
);
246 nfs_refresh_inode(inode
, fattr
);
247 dprintk("NFS reply read: %d\n", status
);
251 static int nfs3_proc_write(struct nfs_write_data
*wdata
)
253 int rpcflags
= wdata
->flags
;
254 struct inode
* inode
= wdata
->inode
;
255 struct nfs_fattr
* fattr
= wdata
->res
.fattr
;
256 struct rpc_message msg
= {
257 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
258 .rpc_argp
= &wdata
->args
,
259 .rpc_resp
= &wdata
->res
,
260 .rpc_cred
= wdata
->cred
,
264 dprintk("NFS call write %d @ %Ld\n", wdata
->args
.count
,
265 (long long) wdata
->args
.offset
);
267 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, rpcflags
);
269 nfs_refresh_inode(inode
, fattr
);
270 dprintk("NFS reply write: %d\n", status
);
271 return status
< 0? status
: wdata
->res
.count
;
274 static int nfs3_proc_commit(struct nfs_write_data
*cdata
)
276 struct inode
* inode
= cdata
->inode
;
277 struct nfs_fattr
* fattr
= cdata
->res
.fattr
;
278 struct rpc_message msg
= {
279 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
280 .rpc_argp
= &cdata
->args
,
281 .rpc_resp
= &cdata
->res
,
282 .rpc_cred
= cdata
->cred
,
286 dprintk("NFS call commit %d @ %Ld\n", cdata
->args
.count
,
287 (long long) cdata
->args
.offset
);
289 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
291 nfs_refresh_inode(inode
, fattr
);
292 dprintk("NFS reply commit: %d\n", status
);
297 * Create a regular file.
298 * For now, we don't implement O_EXCL.
301 nfs3_proc_create(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
302 int flags
, struct nameidata
*nd
)
304 struct nfs_fh fhandle
;
305 struct nfs_fattr fattr
;
306 struct nfs_fattr dir_attr
;
307 struct nfs3_createargs arg
= {
309 .name
= dentry
->d_name
.name
,
310 .len
= dentry
->d_name
.len
,
313 struct nfs3_diropres res
= {
314 .dir_attr
= &dir_attr
,
318 mode_t mode
= sattr
->ia_mode
;
321 dprintk("NFS call create %s\n", dentry
->d_name
.name
);
322 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
323 if (flags
& O_EXCL
) {
324 arg
.createmode
= NFS3_CREATE_EXCLUSIVE
;
325 arg
.verifier
[0] = jiffies
;
326 arg
.verifier
[1] = current
->pid
;
329 sattr
->ia_mode
&= ~current
->fs
->umask
;
334 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_CREATE
, &arg
, &res
, 0);
335 nfs_refresh_inode(dir
, &dir_attr
);
337 /* If the server doesn't support the exclusive creation semantics,
338 * try again with simple 'guarded' mode. */
339 if (status
== NFSERR_NOTSUPP
) {
340 switch (arg
.createmode
) {
341 case NFS3_CREATE_EXCLUSIVE
:
342 arg
.createmode
= NFS3_CREATE_GUARDED
;
345 case NFS3_CREATE_GUARDED
:
346 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
349 case NFS3_CREATE_UNCHECKED
:
356 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
360 /* When we created the file with exclusive semantics, make
361 * sure we set the attributes afterwards. */
362 if (arg
.createmode
== NFS3_CREATE_EXCLUSIVE
) {
363 dprintk("NFS call setattr (post-create)\n");
365 if (!(sattr
->ia_valid
& ATTR_ATIME_SET
))
366 sattr
->ia_valid
|= ATTR_ATIME
;
367 if (!(sattr
->ia_valid
& ATTR_MTIME_SET
))
368 sattr
->ia_valid
|= ATTR_MTIME
;
370 /* Note: we could use a guarded setattr here, but I'm
371 * not sure this buys us anything (and I'd have
372 * to revamp the NFSv3 XDR code) */
373 status
= nfs3_proc_setattr(dentry
, &fattr
, sattr
);
375 nfs_setattr_update_inode(dentry
->d_inode
, sattr
);
376 nfs_refresh_inode(dentry
->d_inode
, &fattr
);
377 dprintk("NFS reply setattr (post-create): %d\n", status
);
381 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
383 dprintk("NFS reply create: %d\n", status
);
388 nfs3_proc_remove(struct inode
*dir
, struct qstr
*name
)
390 struct nfs_fattr dir_attr
;
391 struct nfs3_diropargs arg
= {
396 struct rpc_message msg
= {
397 .rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
],
399 .rpc_resp
= &dir_attr
,
403 dprintk("NFS call remove %s\n", name
->name
);
405 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
406 nfs_refresh_inode(dir
, &dir_attr
);
407 dprintk("NFS reply remove: %d\n", status
);
412 nfs3_proc_unlink_setup(struct rpc_message
*msg
, struct dentry
*dir
, struct qstr
*name
)
415 struct nfs3_diropargs arg
;
416 struct nfs_fattr res
;
419 ptr
= (struct unlinkxdr
*)kmalloc(sizeof(*ptr
), GFP_KERNEL
);
422 ptr
->arg
.fh
= NFS_FH(dir
->d_inode
);
423 ptr
->arg
.name
= name
->name
;
424 ptr
->arg
.len
= name
->len
;
426 msg
->rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
];
427 msg
->rpc_argp
= &ptr
->arg
;
428 msg
->rpc_resp
= &ptr
->res
;
433 nfs3_proc_unlink_done(struct dentry
*dir
, struct rpc_task
*task
)
435 struct rpc_message
*msg
= &task
->tk_msg
;
436 struct nfs_fattr
*dir_attr
;
438 if (nfs3_async_handle_jukebox(task
))
441 dir_attr
= (struct nfs_fattr
*)msg
->rpc_resp
;
442 nfs_refresh_inode(dir
->d_inode
, dir_attr
);
443 kfree(msg
->rpc_argp
);
449 nfs3_proc_rename(struct inode
*old_dir
, struct qstr
*old_name
,
450 struct inode
*new_dir
, struct qstr
*new_name
)
452 struct nfs_fattr old_dir_attr
, new_dir_attr
;
453 struct nfs3_renameargs arg
= {
454 .fromfh
= NFS_FH(old_dir
),
455 .fromname
= old_name
->name
,
456 .fromlen
= old_name
->len
,
457 .tofh
= NFS_FH(new_dir
),
458 .toname
= new_name
->name
,
459 .tolen
= new_name
->len
461 struct nfs3_renameres res
= {
462 .fromattr
= &old_dir_attr
,
463 .toattr
= &new_dir_attr
467 dprintk("NFS call rename %s -> %s\n", old_name
->name
, new_name
->name
);
468 old_dir_attr
.valid
= 0;
469 new_dir_attr
.valid
= 0;
470 status
= rpc_call(NFS_CLIENT(old_dir
), NFS3PROC_RENAME
, &arg
, &res
, 0);
471 nfs_refresh_inode(old_dir
, &old_dir_attr
);
472 nfs_refresh_inode(new_dir
, &new_dir_attr
);
473 dprintk("NFS reply rename: %d\n", status
);
478 nfs3_proc_link(struct inode
*inode
, struct inode
*dir
, struct qstr
*name
)
480 struct nfs_fattr dir_attr
, fattr
;
481 struct nfs3_linkargs arg
= {
482 .fromfh
= NFS_FH(inode
),
484 .toname
= name
->name
,
487 struct nfs3_linkres res
= {
488 .dir_attr
= &dir_attr
,
493 dprintk("NFS call link %s\n", name
->name
);
496 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_LINK
, &arg
, &res
, 0);
497 nfs_refresh_inode(dir
, &dir_attr
);
498 nfs_refresh_inode(inode
, &fattr
);
499 dprintk("NFS reply link: %d\n", status
);
504 nfs3_proc_symlink(struct inode
*dir
, struct qstr
*name
, struct qstr
*path
,
505 struct iattr
*sattr
, struct nfs_fh
*fhandle
,
506 struct nfs_fattr
*fattr
)
508 struct nfs_fattr dir_attr
;
509 struct nfs3_symlinkargs arg
= {
510 .fromfh
= NFS_FH(dir
),
511 .fromname
= name
->name
,
512 .fromlen
= name
->len
,
513 .topath
= path
->name
,
517 struct nfs3_diropres res
= {
518 .dir_attr
= &dir_attr
,
524 if (path
->len
> NFS3_MAXPATHLEN
)
525 return -ENAMETOOLONG
;
526 dprintk("NFS call symlink %s -> %s\n", name
->name
, path
->name
);
529 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_SYMLINK
, &arg
, &res
, 0);
530 nfs_refresh_inode(dir
, &dir_attr
);
531 dprintk("NFS reply symlink: %d\n", status
);
536 nfs3_proc_mkdir(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
)
538 struct nfs_fh fhandle
;
539 struct nfs_fattr fattr
, dir_attr
;
540 struct nfs3_mkdirargs arg
= {
542 .name
= dentry
->d_name
.name
,
543 .len
= dentry
->d_name
.len
,
546 struct nfs3_diropres res
= {
547 .dir_attr
= &dir_attr
,
551 int mode
= sattr
->ia_mode
;
554 dprintk("NFS call mkdir %s\n", dentry
->d_name
.name
);
558 sattr
->ia_mode
&= ~current
->fs
->umask
;
560 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKDIR
, &arg
, &res
, 0);
561 nfs_refresh_inode(dir
, &dir_attr
);
564 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
567 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
569 dprintk("NFS reply mkdir: %d\n", status
);
574 nfs3_proc_rmdir(struct inode
*dir
, struct qstr
*name
)
576 struct nfs_fattr dir_attr
;
577 struct nfs3_diropargs arg
= {
584 dprintk("NFS call rmdir %s\n", name
->name
);
586 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_RMDIR
, &arg
, &dir_attr
, 0);
587 nfs_refresh_inode(dir
, &dir_attr
);
588 dprintk("NFS reply rmdir: %d\n", status
);
593 * The READDIR implementation is somewhat hackish - we pass the user buffer
594 * to the encode function, which installs it in the receive iovec.
595 * The decode function itself doesn't perform any decoding, it just makes
596 * sure the reply is syntactically correct.
598 * Also note that this implementation handles both plain readdir and
602 nfs3_proc_readdir(struct dentry
*dentry
, struct rpc_cred
*cred
,
603 u64 cookie
, struct page
*page
, unsigned int count
, int plus
)
605 struct inode
*dir
= dentry
->d_inode
;
606 struct nfs_fattr dir_attr
;
607 u32
*verf
= NFS_COOKIEVERF(dir
);
608 struct nfs3_readdirargs arg
= {
611 .verf
= {verf
[0], verf
[1]},
616 struct nfs3_readdirres res
= {
617 .dir_attr
= &dir_attr
,
621 struct rpc_message msg
= {
622 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIR
],
632 msg
.rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIRPLUS
];
634 dprintk("NFS call readdir%s %d\n",
635 plus
? "plus" : "", (unsigned int) cookie
);
638 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
639 nfs_refresh_inode(dir
, &dir_attr
);
640 dprintk("NFS reply readdir: %d\n", status
);
646 nfs3_proc_mknod(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
650 struct nfs_fattr fattr
, dir_attr
;
651 struct nfs3_mknodargs arg
= {
653 .name
= dentry
->d_name
.name
,
654 .len
= dentry
->d_name
.len
,
658 struct nfs3_diropres res
= {
659 .dir_attr
= &dir_attr
,
663 mode_t mode
= sattr
->ia_mode
;
666 switch (sattr
->ia_mode
& S_IFMT
) {
667 case S_IFBLK
: arg
.type
= NF3BLK
; break;
668 case S_IFCHR
: arg
.type
= NF3CHR
; break;
669 case S_IFIFO
: arg
.type
= NF3FIFO
; break;
670 case S_IFSOCK
: arg
.type
= NF3SOCK
; break;
671 default: return -EINVAL
;
674 dprintk("NFS call mknod %s %u:%u\n", dentry
->d_name
.name
,
675 MAJOR(rdev
), MINOR(rdev
));
677 sattr
->ia_mode
&= ~current
->fs
->umask
;
681 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKNOD
, &arg
, &res
, 0);
682 nfs_refresh_inode(dir
, &dir_attr
);
685 status
= nfs_instantiate(dentry
, &fh
, &fattr
);
688 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
690 dprintk("NFS reply mknod: %d\n", status
);
695 nfs3_proc_statfs(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
696 struct nfs_fsstat
*stat
)
700 dprintk("NFS call fsstat\n");
701 stat
->fattr
->valid
= 0;
702 status
= rpc_call(server
->client
, NFS3PROC_FSSTAT
, fhandle
, stat
, 0);
703 dprintk("NFS reply statfs: %d\n", status
);
708 nfs3_proc_fsinfo(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
709 struct nfs_fsinfo
*info
)
713 dprintk("NFS call fsinfo\n");
714 info
->fattr
->valid
= 0;
715 status
= rpc_call(server
->client_sys
, NFS3PROC_FSINFO
, fhandle
, info
, 0);
716 dprintk("NFS reply fsinfo: %d\n", status
);
721 nfs3_proc_pathconf(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
722 struct nfs_pathconf
*info
)
726 dprintk("NFS call pathconf\n");
727 info
->fattr
->valid
= 0;
728 status
= rpc_call(server
->client
, NFS3PROC_PATHCONF
, fhandle
, info
, 0);
729 dprintk("NFS reply pathconf: %d\n", status
);
733 extern u32
*nfs3_decode_dirent(u32
*, struct nfs_entry
*, int);
736 nfs3_read_done(struct rpc_task
*task
)
738 struct nfs_write_data
*data
= (struct nfs_write_data
*) task
->tk_calldata
;
740 if (nfs3_async_handle_jukebox(task
))
742 /* Call back common NFS readpage processing */
743 if (task
->tk_status
>= 0)
744 nfs_refresh_inode(data
->inode
, &data
->fattr
);
745 nfs_readpage_result(task
);
749 nfs3_proc_read_setup(struct nfs_read_data
*data
)
751 struct rpc_task
*task
= &data
->task
;
752 struct inode
*inode
= data
->inode
;
754 struct rpc_message msg
= {
755 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
756 .rpc_argp
= &data
->args
,
757 .rpc_resp
= &data
->res
,
758 .rpc_cred
= data
->cred
,
761 /* N.B. Do we need to test? Never called for swapfile inode */
762 flags
= RPC_TASK_ASYNC
| (IS_SWAPFILE(inode
)? NFS_RPC_SWAPFLAGS
: 0);
764 /* Finalize the task. */
765 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_read_done
, flags
);
766 rpc_call_setup(task
, &msg
, 0);
770 nfs3_write_done(struct rpc_task
*task
)
772 struct nfs_write_data
*data
;
774 if (nfs3_async_handle_jukebox(task
))
776 data
= (struct nfs_write_data
*)task
->tk_calldata
;
777 if (task
->tk_status
>= 0)
778 nfs_refresh_inode(data
->inode
, data
->res
.fattr
);
779 nfs_writeback_done(task
);
783 nfs3_proc_write_setup(struct nfs_write_data
*data
, int how
)
785 struct rpc_task
*task
= &data
->task
;
786 struct inode
*inode
= data
->inode
;
789 struct rpc_message msg
= {
790 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
791 .rpc_argp
= &data
->args
,
792 .rpc_resp
= &data
->res
,
793 .rpc_cred
= data
->cred
,
796 if (how
& FLUSH_STABLE
) {
797 if (!NFS_I(inode
)->ncommit
)
798 stable
= NFS_FILE_SYNC
;
800 stable
= NFS_DATA_SYNC
;
802 stable
= NFS_UNSTABLE
;
803 data
->args
.stable
= stable
;
805 /* Set the initial flags for the task. */
806 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
808 /* Finalize the task. */
809 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_write_done
, flags
);
810 rpc_call_setup(task
, &msg
, 0);
814 nfs3_commit_done(struct rpc_task
*task
)
816 struct nfs_write_data
*data
;
818 if (nfs3_async_handle_jukebox(task
))
820 data
= (struct nfs_write_data
*)task
->tk_calldata
;
821 if (task
->tk_status
>= 0)
822 nfs_refresh_inode(data
->inode
, data
->res
.fattr
);
823 nfs_commit_done(task
);
827 nfs3_proc_commit_setup(struct nfs_write_data
*data
, int how
)
829 struct rpc_task
*task
= &data
->task
;
830 struct inode
*inode
= data
->inode
;
832 struct rpc_message msg
= {
833 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
834 .rpc_argp
= &data
->args
,
835 .rpc_resp
= &data
->res
,
836 .rpc_cred
= data
->cred
,
839 /* Set the initial flags for the task. */
840 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
842 /* Finalize the task. */
843 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_commit_done
, flags
);
844 rpc_call_setup(task
, &msg
, 0);
848 nfs3_proc_lock(struct file
*filp
, int cmd
, struct file_lock
*fl
)
850 return nlmclnt_proc(filp
->f_dentry
->d_inode
, cmd
, fl
);
853 struct nfs_rpc_ops nfs_v3_clientops
= {
854 .version
= 3, /* protocol version */
855 .dentry_ops
= &nfs_dentry_operations
,
856 .dir_inode_ops
= &nfs3_dir_inode_operations
,
857 .file_inode_ops
= &nfs3_file_inode_operations
,
858 .getroot
= nfs3_proc_get_root
,
859 .getattr
= nfs3_proc_getattr
,
860 .setattr
= nfs3_proc_setattr
,
861 .lookup
= nfs3_proc_lookup
,
862 .access
= nfs3_proc_access
,
863 .readlink
= nfs3_proc_readlink
,
864 .read
= nfs3_proc_read
,
865 .write
= nfs3_proc_write
,
866 .commit
= nfs3_proc_commit
,
867 .create
= nfs3_proc_create
,
868 .remove
= nfs3_proc_remove
,
869 .unlink_setup
= nfs3_proc_unlink_setup
,
870 .unlink_done
= nfs3_proc_unlink_done
,
871 .rename
= nfs3_proc_rename
,
872 .link
= nfs3_proc_link
,
873 .symlink
= nfs3_proc_symlink
,
874 .mkdir
= nfs3_proc_mkdir
,
875 .rmdir
= nfs3_proc_rmdir
,
876 .readdir
= nfs3_proc_readdir
,
877 .mknod
= nfs3_proc_mknod
,
878 .statfs
= nfs3_proc_statfs
,
879 .fsinfo
= nfs3_proc_fsinfo
,
880 .pathconf
= nfs3_proc_pathconf
,
881 .decode_dirent
= nfs3_decode_dirent
,
882 .read_setup
= nfs3_proc_read_setup
,
883 .write_setup
= nfs3_proc_write_setup
,
884 .commit_setup
= nfs3_proc_commit_setup
,
885 .file_open
= nfs_open
,
886 .file_release
= nfs_release
,
887 .lock
= nfs3_proc_lock
,
888 .clear_acl_cache
= nfs3_forget_cached_acls
,