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>
24 #define NFSDBG_FACILITY NFSDBG_PROC
26 extern struct rpc_procinfo nfs3_procedures
[];
28 /* A wrapper to handle the EJUKEBOX error message */
30 nfs3_rpc_wrapper(struct rpc_clnt
*clnt
, struct rpc_message
*msg
, int flags
)
34 rpc_clnt_sigmask(clnt
, &oldset
);
36 res
= rpc_call_sync(clnt
, msg
, flags
);
39 schedule_timeout_interruptible(NFS_JUKEBOX_RETRY_TIME
);
41 } while (!signalled());
42 rpc_clnt_sigunmask(clnt
, &oldset
);
46 #define rpc_call_sync(clnt, msg, flags) nfs3_rpc_wrapper(clnt, msg, flags)
49 nfs3_async_handle_jukebox(struct rpc_task
*task
, struct inode
*inode
)
51 if (task
->tk_status
!= -EJUKEBOX
)
53 nfs_inc_stats(inode
, NFSIOS_DELAY
);
55 rpc_restart_call(task
);
56 rpc_delay(task
, NFS_JUKEBOX_RETRY_TIME
);
61 do_proc_get_root(struct rpc_clnt
*client
, struct nfs_fh
*fhandle
,
62 struct nfs_fsinfo
*info
)
64 struct rpc_message msg
= {
65 .rpc_proc
= &nfs3_procedures
[NFS3PROC_FSINFO
],
71 dprintk("%s: call fsinfo\n", __FUNCTION__
);
72 nfs_fattr_init(info
->fattr
);
73 status
= rpc_call_sync(client
, &msg
, 0);
74 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__
, status
);
75 if (!(info
->fattr
->valid
& NFS_ATTR_FATTR
)) {
76 msg
.rpc_proc
= &nfs3_procedures
[NFS3PROC_GETATTR
];
77 msg
.rpc_resp
= info
->fattr
;
78 status
= rpc_call_sync(client
, &msg
, 0);
79 dprintk("%s: reply getattr: %d\n", __FUNCTION__
, status
);
85 * Bare-bones access to getattr: this is for nfs_read_super.
88 nfs3_proc_get_root(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
89 struct nfs_fsinfo
*info
)
93 status
= do_proc_get_root(server
->client
, fhandle
, info
);
94 if (status
&& server
->client_sys
!= server
->client
)
95 status
= do_proc_get_root(server
->client_sys
, fhandle
, info
);
100 * One function for each procedure in the NFS protocol.
103 nfs3_proc_getattr(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
104 struct nfs_fattr
*fattr
)
106 struct rpc_message msg
= {
107 .rpc_proc
= &nfs3_procedures
[NFS3PROC_GETATTR
],
113 dprintk("NFS call getattr\n");
114 nfs_fattr_init(fattr
);
115 status
= rpc_call_sync(server
->client
, &msg
, 0);
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
= {
129 struct rpc_message msg
= {
130 .rpc_proc
= &nfs3_procedures
[NFS3PROC_SETATTR
],
136 dprintk("NFS call setattr\n");
137 nfs_fattr_init(fattr
);
138 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
140 nfs_setattr_update_inode(inode
, sattr
);
141 dprintk("NFS reply setattr: %d\n", status
);
146 nfs3_proc_lookup(struct inode
*dir
, struct qstr
*name
,
147 struct nfs_fh
*fhandle
, struct nfs_fattr
*fattr
)
149 struct nfs_fattr dir_attr
;
150 struct nfs3_diropargs arg
= {
155 struct nfs3_diropres res
= {
156 .dir_attr
= &dir_attr
,
160 struct rpc_message msg
= {
161 .rpc_proc
= &nfs3_procedures
[NFS3PROC_LOOKUP
],
167 dprintk("NFS call lookup %s\n", name
->name
);
168 nfs_fattr_init(&dir_attr
);
169 nfs_fattr_init(fattr
);
170 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
171 if (status
>= 0 && !(fattr
->valid
& NFS_ATTR_FATTR
)) {
172 msg
.rpc_proc
= &nfs3_procedures
[NFS3PROC_GETATTR
];
173 msg
.rpc_argp
= fhandle
;
174 msg
.rpc_resp
= fattr
;
175 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
177 dprintk("NFS reply lookup: %d\n", status
);
179 status
= nfs_refresh_inode(dir
, &dir_attr
);
183 static int nfs3_proc_access(struct inode
*inode
, struct nfs_access_entry
*entry
)
185 struct nfs_fattr fattr
;
186 struct nfs3_accessargs arg
= {
189 struct nfs3_accessres res
= {
192 struct rpc_message msg
= {
193 .rpc_proc
= &nfs3_procedures
[NFS3PROC_ACCESS
],
196 .rpc_cred
= entry
->cred
,
198 int mode
= entry
->mask
;
201 dprintk("NFS call access\n");
204 arg
.access
|= NFS3_ACCESS_READ
;
205 if (S_ISDIR(inode
->i_mode
)) {
206 if (mode
& MAY_WRITE
)
207 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
;
209 arg
.access
|= NFS3_ACCESS_LOOKUP
;
211 if (mode
& MAY_WRITE
)
212 arg
.access
|= NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
;
214 arg
.access
|= NFS3_ACCESS_EXECUTE
;
216 nfs_fattr_init(&fattr
);
217 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
218 nfs_refresh_inode(inode
, &fattr
);
221 if (res
.access
& NFS3_ACCESS_READ
)
222 entry
->mask
|= MAY_READ
;
223 if (res
.access
& (NFS3_ACCESS_MODIFY
| NFS3_ACCESS_EXTEND
| NFS3_ACCESS_DELETE
))
224 entry
->mask
|= MAY_WRITE
;
225 if (res
.access
& (NFS3_ACCESS_LOOKUP
|NFS3_ACCESS_EXECUTE
))
226 entry
->mask
|= MAY_EXEC
;
228 dprintk("NFS reply access: %d\n", status
);
232 static int nfs3_proc_readlink(struct inode
*inode
, struct page
*page
,
233 unsigned int pgbase
, unsigned int pglen
)
235 struct nfs_fattr fattr
;
236 struct nfs3_readlinkargs args
= {
242 struct rpc_message msg
= {
243 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READLINK
],
249 dprintk("NFS call readlink\n");
250 nfs_fattr_init(&fattr
);
251 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
252 nfs_refresh_inode(inode
, &fattr
);
253 dprintk("NFS reply readlink: %d\n", status
);
257 static int nfs3_proc_read(struct nfs_read_data
*rdata
)
259 int flags
= rdata
->flags
;
260 struct inode
* inode
= rdata
->inode
;
261 struct nfs_fattr
* fattr
= rdata
->res
.fattr
;
262 struct rpc_message msg
= {
263 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
264 .rpc_argp
= &rdata
->args
,
265 .rpc_resp
= &rdata
->res
,
266 .rpc_cred
= rdata
->cred
,
270 dprintk("NFS call read %d @ %Ld\n", rdata
->args
.count
,
271 (long long) rdata
->args
.offset
);
272 nfs_fattr_init(fattr
);
273 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, flags
);
275 nfs_refresh_inode(inode
, fattr
);
276 dprintk("NFS reply read: %d\n", status
);
280 static int nfs3_proc_write(struct nfs_write_data
*wdata
)
282 int rpcflags
= wdata
->flags
;
283 struct inode
* inode
= wdata
->inode
;
284 struct nfs_fattr
* fattr
= wdata
->res
.fattr
;
285 struct rpc_message msg
= {
286 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
287 .rpc_argp
= &wdata
->args
,
288 .rpc_resp
= &wdata
->res
,
289 .rpc_cred
= wdata
->cred
,
293 dprintk("NFS call write %d @ %Ld\n", wdata
->args
.count
,
294 (long long) wdata
->args
.offset
);
295 nfs_fattr_init(fattr
);
296 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, rpcflags
);
298 nfs_post_op_update_inode(inode
, fattr
);
299 dprintk("NFS reply write: %d\n", status
);
300 return status
< 0? status
: wdata
->res
.count
;
303 static int nfs3_proc_commit(struct nfs_write_data
*cdata
)
305 struct inode
* inode
= cdata
->inode
;
306 struct nfs_fattr
* fattr
= cdata
->res
.fattr
;
307 struct rpc_message msg
= {
308 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
309 .rpc_argp
= &cdata
->args
,
310 .rpc_resp
= &cdata
->res
,
311 .rpc_cred
= cdata
->cred
,
315 dprintk("NFS call commit %d @ %Ld\n", cdata
->args
.count
,
316 (long long) cdata
->args
.offset
);
317 nfs_fattr_init(fattr
);
318 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
320 nfs_post_op_update_inode(inode
, fattr
);
321 dprintk("NFS reply commit: %d\n", status
);
326 * Create a regular file.
327 * For now, we don't implement O_EXCL.
330 nfs3_proc_create(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
331 int flags
, struct nameidata
*nd
)
333 struct nfs_fh fhandle
;
334 struct nfs_fattr fattr
;
335 struct nfs_fattr dir_attr
;
336 struct nfs3_createargs arg
= {
338 .name
= dentry
->d_name
.name
,
339 .len
= dentry
->d_name
.len
,
342 struct nfs3_diropres res
= {
343 .dir_attr
= &dir_attr
,
347 struct rpc_message msg
= {
348 .rpc_proc
= &nfs3_procedures
[NFS3PROC_CREATE
],
352 mode_t mode
= sattr
->ia_mode
;
355 dprintk("NFS call create %s\n", dentry
->d_name
.name
);
356 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
357 if (flags
& O_EXCL
) {
358 arg
.createmode
= NFS3_CREATE_EXCLUSIVE
;
359 arg
.verifier
[0] = jiffies
;
360 arg
.verifier
[1] = current
->pid
;
363 sattr
->ia_mode
&= ~current
->fs
->umask
;
366 nfs_fattr_init(&dir_attr
);
367 nfs_fattr_init(&fattr
);
368 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
369 nfs_refresh_inode(dir
, &dir_attr
);
371 /* If the server doesn't support the exclusive creation semantics,
372 * try again with simple 'guarded' mode. */
373 if (status
== NFSERR_NOTSUPP
) {
374 switch (arg
.createmode
) {
375 case NFS3_CREATE_EXCLUSIVE
:
376 arg
.createmode
= NFS3_CREATE_GUARDED
;
379 case NFS3_CREATE_GUARDED
:
380 arg
.createmode
= NFS3_CREATE_UNCHECKED
;
383 case NFS3_CREATE_UNCHECKED
:
390 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
394 /* When we created the file with exclusive semantics, make
395 * sure we set the attributes afterwards. */
396 if (arg
.createmode
== NFS3_CREATE_EXCLUSIVE
) {
397 dprintk("NFS call setattr (post-create)\n");
399 if (!(sattr
->ia_valid
& ATTR_ATIME_SET
))
400 sattr
->ia_valid
|= ATTR_ATIME
;
401 if (!(sattr
->ia_valid
& ATTR_MTIME_SET
))
402 sattr
->ia_valid
|= ATTR_MTIME
;
404 /* Note: we could use a guarded setattr here, but I'm
405 * not sure this buys us anything (and I'd have
406 * to revamp the NFSv3 XDR code) */
407 status
= nfs3_proc_setattr(dentry
, &fattr
, sattr
);
409 nfs_setattr_update_inode(dentry
->d_inode
, sattr
);
410 nfs_refresh_inode(dentry
->d_inode
, &fattr
);
411 dprintk("NFS reply setattr (post-create): %d\n", status
);
415 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
417 dprintk("NFS reply create: %d\n", status
);
422 nfs3_proc_remove(struct inode
*dir
, struct qstr
*name
)
424 struct nfs_fattr dir_attr
;
425 struct nfs3_diropargs arg
= {
430 struct rpc_message msg
= {
431 .rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
],
433 .rpc_resp
= &dir_attr
,
437 dprintk("NFS call remove %s\n", name
->name
);
438 nfs_fattr_init(&dir_attr
);
439 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
440 nfs_post_op_update_inode(dir
, &dir_attr
);
441 dprintk("NFS reply remove: %d\n", status
);
446 nfs3_proc_unlink_setup(struct rpc_message
*msg
, struct dentry
*dir
, struct qstr
*name
)
449 struct nfs3_diropargs arg
;
450 struct nfs_fattr res
;
453 ptr
= (struct unlinkxdr
*)kmalloc(sizeof(*ptr
), GFP_KERNEL
);
456 ptr
->arg
.fh
= NFS_FH(dir
->d_inode
);
457 ptr
->arg
.name
= name
->name
;
458 ptr
->arg
.len
= name
->len
;
459 nfs_fattr_init(&ptr
->res
);
460 msg
->rpc_proc
= &nfs3_procedures
[NFS3PROC_REMOVE
];
461 msg
->rpc_argp
= &ptr
->arg
;
462 msg
->rpc_resp
= &ptr
->res
;
467 nfs3_proc_unlink_done(struct dentry
*dir
, struct rpc_task
*task
)
469 struct rpc_message
*msg
= &task
->tk_msg
;
470 struct nfs_fattr
*dir_attr
;
472 if (nfs3_async_handle_jukebox(task
, dir
->d_inode
))
475 dir_attr
= (struct nfs_fattr
*)msg
->rpc_resp
;
476 nfs_post_op_update_inode(dir
->d_inode
, dir_attr
);
477 kfree(msg
->rpc_argp
);
483 nfs3_proc_rename(struct inode
*old_dir
, struct qstr
*old_name
,
484 struct inode
*new_dir
, struct qstr
*new_name
)
486 struct nfs_fattr old_dir_attr
, new_dir_attr
;
487 struct nfs3_renameargs arg
= {
488 .fromfh
= NFS_FH(old_dir
),
489 .fromname
= old_name
->name
,
490 .fromlen
= old_name
->len
,
491 .tofh
= NFS_FH(new_dir
),
492 .toname
= new_name
->name
,
493 .tolen
= new_name
->len
495 struct nfs3_renameres res
= {
496 .fromattr
= &old_dir_attr
,
497 .toattr
= &new_dir_attr
499 struct rpc_message msg
= {
500 .rpc_proc
= &nfs3_procedures
[NFS3PROC_RENAME
],
506 dprintk("NFS call rename %s -> %s\n", old_name
->name
, new_name
->name
);
507 nfs_fattr_init(&old_dir_attr
);
508 nfs_fattr_init(&new_dir_attr
);
509 status
= rpc_call_sync(NFS_CLIENT(old_dir
), &msg
, 0);
510 nfs_post_op_update_inode(old_dir
, &old_dir_attr
);
511 nfs_post_op_update_inode(new_dir
, &new_dir_attr
);
512 dprintk("NFS reply rename: %d\n", status
);
517 nfs3_proc_link(struct inode
*inode
, struct inode
*dir
, struct qstr
*name
)
519 struct nfs_fattr dir_attr
, fattr
;
520 struct nfs3_linkargs arg
= {
521 .fromfh
= NFS_FH(inode
),
523 .toname
= name
->name
,
526 struct nfs3_linkres res
= {
527 .dir_attr
= &dir_attr
,
530 struct rpc_message msg
= {
531 .rpc_proc
= &nfs3_procedures
[NFS3PROC_LINK
],
537 dprintk("NFS call link %s\n", name
->name
);
538 nfs_fattr_init(&dir_attr
);
539 nfs_fattr_init(&fattr
);
540 status
= rpc_call_sync(NFS_CLIENT(inode
), &msg
, 0);
541 nfs_post_op_update_inode(dir
, &dir_attr
);
542 nfs_post_op_update_inode(inode
, &fattr
);
543 dprintk("NFS reply link: %d\n", status
);
548 nfs3_proc_symlink(struct inode
*dir
, struct qstr
*name
, struct qstr
*path
,
549 struct iattr
*sattr
, struct nfs_fh
*fhandle
,
550 struct nfs_fattr
*fattr
)
552 struct nfs_fattr dir_attr
;
553 struct nfs3_symlinkargs arg
= {
554 .fromfh
= NFS_FH(dir
),
555 .fromname
= name
->name
,
556 .fromlen
= name
->len
,
557 .topath
= path
->name
,
561 struct nfs3_diropres res
= {
562 .dir_attr
= &dir_attr
,
566 struct rpc_message msg
= {
567 .rpc_proc
= &nfs3_procedures
[NFS3PROC_SYMLINK
],
573 if (path
->len
> NFS3_MAXPATHLEN
)
574 return -ENAMETOOLONG
;
575 dprintk("NFS call symlink %s -> %s\n", name
->name
, path
->name
);
576 nfs_fattr_init(&dir_attr
);
577 nfs_fattr_init(fattr
);
578 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
579 nfs_post_op_update_inode(dir
, &dir_attr
);
580 dprintk("NFS reply symlink: %d\n", status
);
585 nfs3_proc_mkdir(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
)
587 struct nfs_fh fhandle
;
588 struct nfs_fattr fattr
, dir_attr
;
589 struct nfs3_mkdirargs arg
= {
591 .name
= dentry
->d_name
.name
,
592 .len
= dentry
->d_name
.len
,
595 struct nfs3_diropres res
= {
596 .dir_attr
= &dir_attr
,
600 struct rpc_message msg
= {
601 .rpc_proc
= &nfs3_procedures
[NFS3PROC_MKDIR
],
605 int mode
= sattr
->ia_mode
;
608 dprintk("NFS call mkdir %s\n", dentry
->d_name
.name
);
610 sattr
->ia_mode
&= ~current
->fs
->umask
;
612 nfs_fattr_init(&dir_attr
);
613 nfs_fattr_init(&fattr
);
614 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
615 nfs_post_op_update_inode(dir
, &dir_attr
);
618 status
= nfs_instantiate(dentry
, &fhandle
, &fattr
);
621 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
623 dprintk("NFS reply mkdir: %d\n", status
);
628 nfs3_proc_rmdir(struct inode
*dir
, struct qstr
*name
)
630 struct nfs_fattr dir_attr
;
631 struct nfs3_diropargs arg
= {
636 struct rpc_message msg
= {
637 .rpc_proc
= &nfs3_procedures
[NFS3PROC_RMDIR
],
639 .rpc_resp
= &dir_attr
,
643 dprintk("NFS call rmdir %s\n", name
->name
);
644 nfs_fattr_init(&dir_attr
);
645 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
646 nfs_post_op_update_inode(dir
, &dir_attr
);
647 dprintk("NFS reply rmdir: %d\n", status
);
652 * The READDIR implementation is somewhat hackish - we pass the user buffer
653 * to the encode function, which installs it in the receive iovec.
654 * The decode function itself doesn't perform any decoding, it just makes
655 * sure the reply is syntactically correct.
657 * Also note that this implementation handles both plain readdir and
661 nfs3_proc_readdir(struct dentry
*dentry
, struct rpc_cred
*cred
,
662 u64 cookie
, struct page
*page
, unsigned int count
, int plus
)
664 struct inode
*dir
= dentry
->d_inode
;
665 struct nfs_fattr dir_attr
;
666 u32
*verf
= NFS_COOKIEVERF(dir
);
667 struct nfs3_readdirargs arg
= {
670 .verf
= {verf
[0], verf
[1]},
675 struct nfs3_readdirres res
= {
676 .dir_attr
= &dir_attr
,
680 struct rpc_message msg
= {
681 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIR
],
691 msg
.rpc_proc
= &nfs3_procedures
[NFS3PROC_READDIRPLUS
];
693 dprintk("NFS call readdir%s %d\n",
694 plus
? "plus" : "", (unsigned int) cookie
);
696 nfs_fattr_init(&dir_attr
);
697 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
698 nfs_refresh_inode(dir
, &dir_attr
);
699 dprintk("NFS reply readdir: %d\n", status
);
705 nfs3_proc_mknod(struct inode
*dir
, struct dentry
*dentry
, struct iattr
*sattr
,
709 struct nfs_fattr fattr
, dir_attr
;
710 struct nfs3_mknodargs arg
= {
712 .name
= dentry
->d_name
.name
,
713 .len
= dentry
->d_name
.len
,
717 struct nfs3_diropres res
= {
718 .dir_attr
= &dir_attr
,
722 struct rpc_message msg
= {
723 .rpc_proc
= &nfs3_procedures
[NFS3PROC_MKNOD
],
727 mode_t mode
= sattr
->ia_mode
;
730 switch (sattr
->ia_mode
& S_IFMT
) {
731 case S_IFBLK
: arg
.type
= NF3BLK
; break;
732 case S_IFCHR
: arg
.type
= NF3CHR
; break;
733 case S_IFIFO
: arg
.type
= NF3FIFO
; break;
734 case S_IFSOCK
: arg
.type
= NF3SOCK
; break;
735 default: return -EINVAL
;
738 dprintk("NFS call mknod %s %u:%u\n", dentry
->d_name
.name
,
739 MAJOR(rdev
), MINOR(rdev
));
741 sattr
->ia_mode
&= ~current
->fs
->umask
;
743 nfs_fattr_init(&dir_attr
);
744 nfs_fattr_init(&fattr
);
745 status
= rpc_call_sync(NFS_CLIENT(dir
), &msg
, 0);
746 nfs_post_op_update_inode(dir
, &dir_attr
);
749 status
= nfs_instantiate(dentry
, &fh
, &fattr
);
752 status
= nfs3_proc_set_default_acl(dir
, dentry
->d_inode
, mode
);
754 dprintk("NFS reply mknod: %d\n", status
);
759 nfs3_proc_statfs(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
760 struct nfs_fsstat
*stat
)
762 struct rpc_message msg
= {
763 .rpc_proc
= &nfs3_procedures
[NFS3PROC_FSSTAT
],
769 dprintk("NFS call fsstat\n");
770 nfs_fattr_init(stat
->fattr
);
771 status
= rpc_call_sync(server
->client
, &msg
, 0);
772 dprintk("NFS reply statfs: %d\n", status
);
777 nfs3_proc_fsinfo(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
778 struct nfs_fsinfo
*info
)
780 struct rpc_message msg
= {
781 .rpc_proc
= &nfs3_procedures
[NFS3PROC_FSINFO
],
787 dprintk("NFS call fsinfo\n");
788 nfs_fattr_init(info
->fattr
);
789 status
= rpc_call_sync(server
->client_sys
, &msg
, 0);
790 dprintk("NFS reply fsinfo: %d\n", status
);
795 nfs3_proc_pathconf(struct nfs_server
*server
, struct nfs_fh
*fhandle
,
796 struct nfs_pathconf
*info
)
798 struct rpc_message msg
= {
799 .rpc_proc
= &nfs3_procedures
[NFS3PROC_PATHCONF
],
805 dprintk("NFS call pathconf\n");
806 nfs_fattr_init(info
->fattr
);
807 status
= rpc_call_sync(server
->client
, &msg
, 0);
808 dprintk("NFS reply pathconf: %d\n", status
);
812 extern u32
*nfs3_decode_dirent(u32
*, struct nfs_entry
*, int);
814 static int nfs3_read_done(struct rpc_task
*task
, struct nfs_read_data
*data
)
816 if (nfs3_async_handle_jukebox(task
, data
->inode
))
818 /* Call back common NFS readpage processing */
819 if (task
->tk_status
>= 0)
820 nfs_refresh_inode(data
->inode
, &data
->fattr
);
824 static void nfs3_proc_read_setup(struct nfs_read_data
*data
)
826 struct rpc_message msg
= {
827 .rpc_proc
= &nfs3_procedures
[NFS3PROC_READ
],
828 .rpc_argp
= &data
->args
,
829 .rpc_resp
= &data
->res
,
830 .rpc_cred
= data
->cred
,
833 rpc_call_setup(&data
->task
, &msg
, 0);
836 static int nfs3_write_done(struct rpc_task
*task
, struct nfs_write_data
*data
)
838 if (nfs3_async_handle_jukebox(task
, data
->inode
))
840 if (task
->tk_status
>= 0)
841 nfs_post_op_update_inode(data
->inode
, data
->res
.fattr
);
845 static void nfs3_proc_write_setup(struct nfs_write_data
*data
, int how
)
847 struct rpc_message msg
= {
848 .rpc_proc
= &nfs3_procedures
[NFS3PROC_WRITE
],
849 .rpc_argp
= &data
->args
,
850 .rpc_resp
= &data
->res
,
851 .rpc_cred
= data
->cred
,
854 data
->args
.stable
= NFS_UNSTABLE
;
855 if (how
& FLUSH_STABLE
) {
856 data
->args
.stable
= NFS_FILE_SYNC
;
857 if (NFS_I(data
->inode
)->ncommit
)
858 data
->args
.stable
= NFS_DATA_SYNC
;
861 /* Finalize the task. */
862 rpc_call_setup(&data
->task
, &msg
, 0);
865 static int nfs3_commit_done(struct rpc_task
*task
, struct nfs_write_data
*data
)
867 if (nfs3_async_handle_jukebox(task
, data
->inode
))
869 if (task
->tk_status
>= 0)
870 nfs_post_op_update_inode(data
->inode
, data
->res
.fattr
);
874 static void nfs3_proc_commit_setup(struct nfs_write_data
*data
, int how
)
876 struct rpc_message msg
= {
877 .rpc_proc
= &nfs3_procedures
[NFS3PROC_COMMIT
],
878 .rpc_argp
= &data
->args
,
879 .rpc_resp
= &data
->res
,
880 .rpc_cred
= data
->cred
,
883 rpc_call_setup(&data
->task
, &msg
, 0);
887 nfs3_proc_lock(struct file
*filp
, int cmd
, struct file_lock
*fl
)
889 return nlmclnt_proc(filp
->f_dentry
->d_inode
, cmd
, fl
);
892 struct nfs_rpc_ops nfs_v3_clientops
= {
893 .version
= 3, /* protocol version */
894 .dentry_ops
= &nfs_dentry_operations
,
895 .dir_inode_ops
= &nfs3_dir_inode_operations
,
896 .file_inode_ops
= &nfs3_file_inode_operations
,
897 .getroot
= nfs3_proc_get_root
,
898 .getattr
= nfs3_proc_getattr
,
899 .setattr
= nfs3_proc_setattr
,
900 .lookup
= nfs3_proc_lookup
,
901 .access
= nfs3_proc_access
,
902 .readlink
= nfs3_proc_readlink
,
903 .read
= nfs3_proc_read
,
904 .write
= nfs3_proc_write
,
905 .commit
= nfs3_proc_commit
,
906 .create
= nfs3_proc_create
,
907 .remove
= nfs3_proc_remove
,
908 .unlink_setup
= nfs3_proc_unlink_setup
,
909 .unlink_done
= nfs3_proc_unlink_done
,
910 .rename
= nfs3_proc_rename
,
911 .link
= nfs3_proc_link
,
912 .symlink
= nfs3_proc_symlink
,
913 .mkdir
= nfs3_proc_mkdir
,
914 .rmdir
= nfs3_proc_rmdir
,
915 .readdir
= nfs3_proc_readdir
,
916 .mknod
= nfs3_proc_mknod
,
917 .statfs
= nfs3_proc_statfs
,
918 .fsinfo
= nfs3_proc_fsinfo
,
919 .pathconf
= nfs3_proc_pathconf
,
920 .decode_dirent
= nfs3_decode_dirent
,
921 .read_setup
= nfs3_proc_read_setup
,
922 .read_done
= nfs3_read_done
,
923 .write_setup
= nfs3_proc_write_setup
,
924 .write_done
= nfs3_write_done
,
925 .commit_setup
= nfs3_proc_commit_setup
,
926 .commit_done
= nfs3_commit_done
,
927 .file_open
= nfs_open
,
928 .file_release
= nfs_release
,
929 .lock
= nfs3_proc_lock
,
930 .clear_acl_cache
= nfs3_forget_cached_acls
,