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);
123 dprintk("NFS reply setattr: %d\n", status
);
128 nfs3_proc_lookup(struct inode
*dir
, struct qstr
*name
,
129 struct nfs_fh
*fhandle
, struct nfs_fattr
*fattr
)
131 struct nfs_fattr dir_attr
;
132 struct nfs3_diropargs arg
= {
137 struct nfs3_diropres res
= {
138 .dir_attr
= &dir_attr
,
144 dprintk("NFS call lookup %s\n", name
->name
);
147 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_LOOKUP
, &arg
, &res
, 0);
148 if (status
>= 0 && !(fattr
->valid
& NFS_ATTR_FATTR
))
149 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_GETATTR
,
151 dprintk("NFS reply lookup: %d\n", status
);
153 status
= nfs_refresh_inode(dir
, &dir_attr
);
157 static int nfs3_proc_access(struct inode
*inode
, struct nfs_access_entry
*entry
)
159 struct nfs_fattr fattr
;
160 struct nfs3_accessargs arg
= {
163 struct nfs3_accessres res
= {
166 struct rpc_message msg
= {
167 .rpc_proc
= &nfs3_procedures
[NFS3PROC_ACCESS
],
170 .rpc_cred
= entry
->cred
172 int mode
= entry
->mask
;
175 dprintk("NFS call access\n");
179 arg
.access
|= NFS3_ACCESS_READ
;
180 if (S_ISDIR(inode
->i_mode
)) {
181 if (mode
& MAY_WRITE
)
182 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
;
184 arg
.access
|= NFS3_ACCESS_LOOKUP
;
186 if (mode
& MAY_WRITE
)
187 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
;
189 arg
.access
|= NFS3_ACCESS_EXECUTE
;
191 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
192 nfs_refresh_inode(inode
, &fattr
);
195 if (res
.access
& NFS3_ACCESS_READ
)
196 entry
->mask
|= MAY_READ
;
197 if (res
.access
& (NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
))
198 entry
->mask
|= MAY_WRITE
;
199 if (res
.access
& (NFS3_ACCESS_LOOKUP
|NFS3_ACCESS_EXECUTE
))
200 entry
->mask
|= MAY_EXEC
;
202 dprintk("NFS reply access: %d\n", status
);
206 static int nfs3_proc_readlink(struct inode
*inode
, struct page
*page
,
207 unsigned int pgbase
, unsigned int pglen
)
209 struct nfs_fattr fattr
;
210 struct nfs3_readlinkargs args
= {
218 dprintk("NFS call readlink\n");
220 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_READLINK
,
222 nfs_refresh_inode(inode
, &fattr
);
223 dprintk("NFS reply readlink: %d\n", status
);
227 static int nfs3_proc_read(struct nfs_read_data
*rdata
)
229 int flags
= rdata
->flags
;
230 struct inode
* inode
= rdata
->inode
;
231 struct nfs_fattr
* fattr
= rdata
->res
.fattr
;
232 struct rpc_message msg
= {
233 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
234 .rpc_argp
= &rdata
->args
,
235 .rpc_resp
= &rdata
->res
,
236 .rpc_cred
= rdata
->cred
,
240 dprintk("NFS call read %d @ %Ld\n", rdata
->args
.count
,
241 (long long) rdata
->args
.offset
);
243 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, flags
);
245 nfs_refresh_inode(inode
, fattr
);
246 dprintk("NFS reply read: %d\n", status
);
250 static int nfs3_proc_write(struct nfs_write_data
*wdata
)
252 int rpcflags
= wdata
->flags
;
253 struct inode
* inode
= wdata
->inode
;
254 struct nfs_fattr
* fattr
= wdata
->res
.fattr
;
255 struct rpc_message msg
= {
256 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
257 .rpc_argp
= &wdata
->args
,
258 .rpc_resp
= &wdata
->res
,
259 .rpc_cred
= wdata
->cred
,
263 dprintk("NFS call write %d @ %Ld\n", wdata
->args
.count
,
264 (long long) wdata
->args
.offset
);
266 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, rpcflags
);
268 nfs_refresh_inode(inode
, fattr
);
269 dprintk("NFS reply write: %d\n", status
);
270 return status
< 0? status
: wdata
->res
.count
;
273 static int nfs3_proc_commit(struct nfs_write_data
*cdata
)
275 struct inode
* inode
= cdata
->inode
;
276 struct nfs_fattr
* fattr
= cdata
->res
.fattr
;
277 struct rpc_message msg
= {
278 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
279 .rpc_argp
= &cdata
->args
,
280 .rpc_resp
= &cdata
->res
,
281 .rpc_cred
= cdata
->cred
,
285 dprintk("NFS call commit %d @ %Ld\n", cdata
->args
.count
,
286 (long long) cdata
->args
.offset
);
288 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
290 nfs_refresh_inode(inode
, fattr
);
291 dprintk("NFS reply commit: %d\n", status
);
296 * Create a regular file.
297 * For now, we don't implement O_EXCL.
300 nfs3_proc_create(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
303 struct nfs_fh fhandle
;
304 struct nfs_fattr fattr
;
305 struct nfs_fattr dir_attr
;
306 struct nfs3_createargs arg
= {
308 .name
= dentry
->d_name
.name
,
309 .len
= dentry
->d_name
.len
,
312 struct nfs3_diropres res
= {
313 .dir_attr
= &dir_attr
,
317 mode_t mode
= sattr
->ia_mode
;
320 dprintk("NFS call create %s\n", dentry
->d_name
.name
);
321 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
322 if (flags
& O_EXCL
) {
323 arg
.createmode
= NFS3_CREATE_EXCLUSIVE
;
324 arg
.verifier
[0] = jiffies
;
325 arg
.verifier
[1] = current
->pid
;
328 sattr
->ia_mode
&= ~current
->fs
->umask
;
333 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_CREATE
, &arg
, &res
, 0);
334 nfs_refresh_inode(dir
, &dir_attr
);
336 /* If the server doesn't support the exclusive creation semantics,
337 * try again with simple 'guarded' mode. */
338 if (status
== NFSERR_NOTSUPP
) {
339 switch (arg
.createmode
) {
340 case NFS3_CREATE_EXCLUSIVE
:
341 arg
.createmode
= NFS3_CREATE_GUARDED
;
344 case NFS3_CREATE_GUARDED
:
345 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
348 case NFS3_CREATE_UNCHECKED
:
355 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
359 /* When we created the file with exclusive semantics, make
360 * sure we set the attributes afterwards. */
361 if (arg
.createmode
== NFS3_CREATE_EXCLUSIVE
) {
362 dprintk("NFS call setattr (post-create)\n");
364 if (!(sattr
->ia_valid
& ATTR_ATIME_SET
))
365 sattr
->ia_valid
|= ATTR_ATIME
;
366 if (!(sattr
->ia_valid
& ATTR_MTIME_SET
))
367 sattr
->ia_valid
|= ATTR_MTIME
;
369 /* Note: we could use a guarded setattr here, but I'm
370 * not sure this buys us anything (and I'd have
371 * to revamp the NFSv3 XDR code) */
372 status
= nfs3_proc_setattr(dentry
, &fattr
, sattr
);
373 nfs_refresh_inode(dentry
->d_inode
, &fattr
);
374 dprintk("NFS reply setattr (post-create): %d\n", status
);
378 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
380 dprintk("NFS reply create: %d\n", status
);
385 nfs3_proc_remove(struct inode
*dir
, struct qstr
*name
)
387 struct nfs_fattr dir_attr
;
388 struct nfs3_diropargs arg
= {
393 struct rpc_message msg
= {
394 .rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
],
396 .rpc_resp
= &dir_attr
,
400 dprintk("NFS call remove %s\n", name
->name
);
402 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
403 nfs_refresh_inode(dir
, &dir_attr
);
404 dprintk("NFS reply remove: %d\n", status
);
409 nfs3_proc_unlink_setup(struct rpc_message
*msg
, struct dentry
*dir
, struct qstr
*name
)
412 struct nfs3_diropargs arg
;
413 struct nfs_fattr res
;
416 ptr
= (struct unlinkxdr
*)kmalloc(sizeof(*ptr
), GFP_KERNEL
);
419 ptr
->arg
.fh
= NFS_FH(dir
->d_inode
);
420 ptr
->arg
.name
= name
->name
;
421 ptr
->arg
.len
= name
->len
;
423 msg
->rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
];
424 msg
->rpc_argp
= &ptr
->arg
;
425 msg
->rpc_resp
= &ptr
->res
;
430 nfs3_proc_unlink_done(struct dentry
*dir
, struct rpc_task
*task
)
432 struct rpc_message
*msg
= &task
->tk_msg
;
433 struct nfs_fattr
*dir_attr
;
435 if (nfs3_async_handle_jukebox(task
))
438 dir_attr
= (struct nfs_fattr
*)msg
->rpc_resp
;
439 nfs_refresh_inode(dir
->d_inode
, dir_attr
);
440 kfree(msg
->rpc_argp
);
446 nfs3_proc_rename(struct inode
*old_dir
, struct qstr
*old_name
,
447 struct inode
*new_dir
, struct qstr
*new_name
)
449 struct nfs_fattr old_dir_attr
, new_dir_attr
;
450 struct nfs3_renameargs arg
= {
451 .fromfh
= NFS_FH(old_dir
),
452 .fromname
= old_name
->name
,
453 .fromlen
= old_name
->len
,
454 .tofh
= NFS_FH(new_dir
),
455 .toname
= new_name
->name
,
456 .tolen
= new_name
->len
458 struct nfs3_renameres res
= {
459 .fromattr
= &old_dir_attr
,
460 .toattr
= &new_dir_attr
464 dprintk("NFS call rename %s -> %s\n", old_name
->name
, new_name
->name
);
465 old_dir_attr
.valid
= 0;
466 new_dir_attr
.valid
= 0;
467 status
= rpc_call(NFS_CLIENT(old_dir
), NFS3PROC_RENAME
, &arg
, &res
, 0);
468 nfs_refresh_inode(old_dir
, &old_dir_attr
);
469 nfs_refresh_inode(new_dir
, &new_dir_attr
);
470 dprintk("NFS reply rename: %d\n", status
);
475 nfs3_proc_link(struct inode
*inode
, struct inode
*dir
, struct qstr
*name
)
477 struct nfs_fattr dir_attr
, fattr
;
478 struct nfs3_linkargs arg
= {
479 .fromfh
= NFS_FH(inode
),
481 .toname
= name
->name
,
484 struct nfs3_linkres res
= {
485 .dir_attr
= &dir_attr
,
490 dprintk("NFS call link %s\n", name
->name
);
493 status
= rpc_call(NFS_CLIENT(inode
), NFS3PROC_LINK
, &arg
, &res
, 0);
494 nfs_refresh_inode(dir
, &dir_attr
);
495 nfs_refresh_inode(inode
, &fattr
);
496 dprintk("NFS reply link: %d\n", status
);
501 nfs3_proc_symlink(struct inode
*dir
, struct qstr
*name
, struct qstr
*path
,
502 struct iattr
*sattr
, struct nfs_fh
*fhandle
,
503 struct nfs_fattr
*fattr
)
505 struct nfs_fattr dir_attr
;
506 struct nfs3_symlinkargs arg
= {
507 .fromfh
= NFS_FH(dir
),
508 .fromname
= name
->name
,
509 .fromlen
= name
->len
,
510 .topath
= path
->name
,
514 struct nfs3_diropres res
= {
515 .dir_attr
= &dir_attr
,
521 if (path
->len
> NFS3_MAXPATHLEN
)
522 return -ENAMETOOLONG
;
523 dprintk("NFS call symlink %s -> %s\n", name
->name
, path
->name
);
526 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_SYMLINK
, &arg
, &res
, 0);
527 nfs_refresh_inode(dir
, &dir_attr
);
528 dprintk("NFS reply symlink: %d\n", status
);
533 nfs3_proc_mkdir(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
)
535 struct nfs_fh fhandle
;
536 struct nfs_fattr fattr
, dir_attr
;
537 struct nfs3_mkdirargs arg
= {
539 .name
= dentry
->d_name
.name
,
540 .len
= dentry
->d_name
.len
,
543 struct nfs3_diropres res
= {
544 .dir_attr
= &dir_attr
,
548 int mode
= sattr
->ia_mode
;
551 dprintk("NFS call mkdir %s\n", dentry
->d_name
.name
);
555 sattr
->ia_mode
&= ~current
->fs
->umask
;
557 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKDIR
, &arg
, &res
, 0);
558 nfs_refresh_inode(dir
, &dir_attr
);
561 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
564 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
566 dprintk("NFS reply mkdir: %d\n", status
);
571 nfs3_proc_rmdir(struct inode
*dir
, struct qstr
*name
)
573 struct nfs_fattr dir_attr
;
574 struct nfs3_diropargs arg
= {
581 dprintk("NFS call rmdir %s\n", name
->name
);
583 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_RMDIR
, &arg
, &dir_attr
, 0);
584 nfs_refresh_inode(dir
, &dir_attr
);
585 dprintk("NFS reply rmdir: %d\n", status
);
590 * The READDIR implementation is somewhat hackish - we pass the user buffer
591 * to the encode function, which installs it in the receive iovec.
592 * The decode function itself doesn't perform any decoding, it just makes
593 * sure the reply is syntactically correct.
595 * Also note that this implementation handles both plain readdir and
599 nfs3_proc_readdir(struct dentry
*dentry
, struct rpc_cred
*cred
,
600 u64 cookie
, struct page
*page
, unsigned int count
, int plus
)
602 struct inode
*dir
= dentry
->d_inode
;
603 struct nfs_fattr dir_attr
;
604 u32
*verf
= NFS_COOKIEVERF(dir
);
605 struct nfs3_readdirargs arg
= {
608 .verf
= {verf
[0], verf
[1]},
613 struct nfs3_readdirres res
= {
614 .dir_attr
= &dir_attr
,
618 struct rpc_message msg
= {
619 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIR
],
629 msg
.rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIRPLUS
];
631 dprintk("NFS call readdir%s %d\n",
632 plus
? "plus" : "", (unsigned int) cookie
);
635 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
636 nfs_refresh_inode(dir
, &dir_attr
);
637 dprintk("NFS reply readdir: %d\n", status
);
643 nfs3_proc_mknod(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
647 struct nfs_fattr fattr
, dir_attr
;
648 struct nfs3_mknodargs arg
= {
650 .name
= dentry
->d_name
.name
,
651 .len
= dentry
->d_name
.len
,
655 struct nfs3_diropres res
= {
656 .dir_attr
= &dir_attr
,
660 mode_t mode
= sattr
->ia_mode
;
663 switch (sattr
->ia_mode
& S_IFMT
) {
664 case S_IFBLK
: arg
.type
= NF3BLK
; break;
665 case S_IFCHR
: arg
.type
= NF3CHR
; break;
666 case S_IFIFO
: arg
.type
= NF3FIFO
; break;
667 case S_IFSOCK
: arg
.type
= NF3SOCK
; break;
668 default: return -EINVAL
;
671 dprintk("NFS call mknod %s %u:%u\n", dentry
->d_name
.name
,
672 MAJOR(rdev
), MINOR(rdev
));
674 sattr
->ia_mode
&= ~current
->fs
->umask
;
678 status
= rpc_call(NFS_CLIENT(dir
), NFS3PROC_MKNOD
, &arg
, &res
, 0);
679 nfs_refresh_inode(dir
, &dir_attr
);
682 status
= nfs_instantiate(dentry
, &fh
, &fattr
);
685 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
687 dprintk("NFS reply mknod: %d\n", status
);
692 nfs3_proc_statfs(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
693 struct nfs_fsstat
*stat
)
697 dprintk("NFS call fsstat\n");
698 stat
->fattr
->valid
= 0;
699 status
= rpc_call(server
->client
, NFS3PROC_FSSTAT
, fhandle
, stat
, 0);
700 dprintk("NFS reply statfs: %d\n", status
);
705 nfs3_proc_fsinfo(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
706 struct nfs_fsinfo
*info
)
710 dprintk("NFS call fsinfo\n");
711 info
->fattr
->valid
= 0;
712 status
= rpc_call(server
->client_sys
, NFS3PROC_FSINFO
, fhandle
, info
, 0);
713 dprintk("NFS reply fsinfo: %d\n", status
);
718 nfs3_proc_pathconf(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
719 struct nfs_pathconf
*info
)
723 dprintk("NFS call pathconf\n");
724 info
->fattr
->valid
= 0;
725 status
= rpc_call(server
->client
, NFS3PROC_PATHCONF
, fhandle
, info
, 0);
726 dprintk("NFS reply pathconf: %d\n", status
);
730 extern u32
*nfs3_decode_dirent(u32
*, struct nfs_entry
*, int);
733 nfs3_read_done(struct rpc_task
*task
)
735 struct nfs_write_data
*data
= (struct nfs_write_data
*) task
->tk_calldata
;
737 if (nfs3_async_handle_jukebox(task
))
739 /* Call back common NFS readpage processing */
740 if (task
->tk_status
>= 0)
741 nfs_refresh_inode(data
->inode
, &data
->fattr
);
742 nfs_readpage_result(task
);
746 nfs3_proc_read_setup(struct nfs_read_data
*data
)
748 struct rpc_task
*task
= &data
->task
;
749 struct inode
*inode
= data
->inode
;
751 struct rpc_message msg
= {
752 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
753 .rpc_argp
= &data
->args
,
754 .rpc_resp
= &data
->res
,
755 .rpc_cred
= data
->cred
,
758 /* N.B. Do we need to test? Never called for swapfile inode */
759 flags
= RPC_TASK_ASYNC
| (IS_SWAPFILE(inode
)? NFS_RPC_SWAPFLAGS
: 0);
761 /* Finalize the task. */
762 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_read_done
, flags
);
763 rpc_call_setup(task
, &msg
, 0);
767 nfs3_write_done(struct rpc_task
*task
)
769 struct nfs_write_data
*data
;
771 if (nfs3_async_handle_jukebox(task
))
773 data
= (struct nfs_write_data
*)task
->tk_calldata
;
774 if (task
->tk_status
>= 0)
775 nfs_refresh_inode(data
->inode
, data
->res
.fattr
);
776 nfs_writeback_done(task
);
780 nfs3_proc_write_setup(struct nfs_write_data
*data
, int how
)
782 struct rpc_task
*task
= &data
->task
;
783 struct inode
*inode
= data
->inode
;
786 struct rpc_message msg
= {
787 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
788 .rpc_argp
= &data
->args
,
789 .rpc_resp
= &data
->res
,
790 .rpc_cred
= data
->cred
,
793 if (how
& FLUSH_STABLE
) {
794 if (!NFS_I(inode
)->ncommit
)
795 stable
= NFS_FILE_SYNC
;
797 stable
= NFS_DATA_SYNC
;
799 stable
= NFS_UNSTABLE
;
800 data
->args
.stable
= stable
;
802 /* Set the initial flags for the task. */
803 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
805 /* Finalize the task. */
806 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_write_done
, flags
);
807 rpc_call_setup(task
, &msg
, 0);
811 nfs3_commit_done(struct rpc_task
*task
)
813 struct nfs_write_data
*data
;
815 if (nfs3_async_handle_jukebox(task
))
817 data
= (struct nfs_write_data
*)task
->tk_calldata
;
818 if (task
->tk_status
>= 0)
819 nfs_refresh_inode(data
->inode
, data
->res
.fattr
);
820 nfs_commit_done(task
);
824 nfs3_proc_commit_setup(struct nfs_write_data
*data
, int how
)
826 struct rpc_task
*task
= &data
->task
;
827 struct inode
*inode
= data
->inode
;
829 struct rpc_message msg
= {
830 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
831 .rpc_argp
= &data
->args
,
832 .rpc_resp
= &data
->res
,
833 .rpc_cred
= data
->cred
,
836 /* Set the initial flags for the task. */
837 flags
= (how
& FLUSH_SYNC
) ? 0 : RPC_TASK_ASYNC
;
839 /* Finalize the task. */
840 rpc_init_task(task
, NFS_CLIENT(inode
), nfs3_commit_done
, flags
);
841 rpc_call_setup(task
, &msg
, 0);
845 nfs3_proc_lock(struct file
*filp
, int cmd
, struct file_lock
*fl
)
847 return nlmclnt_proc(filp
->f_dentry
->d_inode
, cmd
, fl
);
850 struct nfs_rpc_ops nfs_v3_clientops
= {
851 .version
= 3, /* protocol version */
852 .dentry_ops
= &nfs_dentry_operations
,
853 .dir_inode_ops
= &nfs3_dir_inode_operations
,
854 .file_inode_ops
= &nfs3_file_inode_operations
,
855 .getroot
= nfs3_proc_get_root
,
856 .getattr
= nfs3_proc_getattr
,
857 .setattr
= nfs3_proc_setattr
,
858 .lookup
= nfs3_proc_lookup
,
859 .access
= nfs3_proc_access
,
860 .readlink
= nfs3_proc_readlink
,
861 .read
= nfs3_proc_read
,
862 .write
= nfs3_proc_write
,
863 .commit
= nfs3_proc_commit
,
864 .create
= nfs3_proc_create
,
865 .remove
= nfs3_proc_remove
,
866 .unlink_setup
= nfs3_proc_unlink_setup
,
867 .unlink_done
= nfs3_proc_unlink_done
,
868 .rename
= nfs3_proc_rename
,
869 .link
= nfs3_proc_link
,
870 .symlink
= nfs3_proc_symlink
,
871 .mkdir
= nfs3_proc_mkdir
,
872 .rmdir
= nfs3_proc_rmdir
,
873 .readdir
= nfs3_proc_readdir
,
874 .mknod
= nfs3_proc_mknod
,
875 .statfs
= nfs3_proc_statfs
,
876 .fsinfo
= nfs3_proc_fsinfo
,
877 .pathconf
= nfs3_proc_pathconf
,
878 .decode_dirent
= nfs3_decode_dirent
,
879 .read_setup
= nfs3_proc_read_setup
,
880 .write_setup
= nfs3_proc_write_setup
,
881 .commit_setup
= nfs3_proc_commit_setup
,
882 .file_open
= nfs_open
,
883 .file_release
= nfs_release
,
884 .lock
= nfs3_proc_lock
,
885 .clear_acl_cache
= nfs3_forget_cached_acls
,