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 nfs_fattr_init(info->fattr);
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");
101 nfs_fattr_init(fattr);
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");
120 nfs_fattr_init(fattr);
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);
146 nfs_fattr_init(&dir_attr);
147 nfs_fattr_init(fattr);
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");
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 nfs_fattr_init(&fattr);
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");
220 nfs_fattr_init(&fattr);
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);
243 nfs_fattr_init(fattr);
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);
266 nfs_fattr_init(fattr);
267 status = rpc_call_sync(NFS_CLIENT(inode), &msg, rpcflags);
269 nfs_post_op_update_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);
288 nfs_fattr_init(fattr);
289 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
291 nfs_post_op_update_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;
332 nfs_fattr_init(&dir_attr);
333 nfs_fattr_init(&fattr);
334 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_CREATE, &arg, &res, 0);
335 nfs_post_op_update_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);
404 nfs_fattr_init(&dir_attr);
405 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
406 nfs_post_op_update_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;
425 nfs_fattr_init(&ptr->res);
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_post_op_update_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 nfs_fattr_init(&old_dir_attr);
469 nfs_fattr_init(&new_dir_attr);
470 status = rpc_call(NFS_CLIENT(old_dir), NFS3PROC_RENAME, &arg, &res, 0);
471 nfs_post_op_update_inode(old_dir, &old_dir_attr);
472 nfs_post_op_update_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);
494 nfs_fattr_init(&dir_attr);
495 nfs_fattr_init(&fattr);
496 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_LINK, &arg, &res, 0);
497 nfs_post_op_update_inode(dir, &dir_attr);
498 nfs_post_op_update_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);
527 nfs_fattr_init(&dir_attr);
528 nfs_fattr_init(fattr);
529 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_SYMLINK, &arg, &res, 0);
530 nfs_post_op_update_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);
556 sattr->ia_mode &= ~current->fs->umask;
558 nfs_fattr_init(&dir_attr);
559 nfs_fattr_init(&fattr);
560 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKDIR, &arg, &res, 0);
561 nfs_post_op_update_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);
585 nfs_fattr_init(&dir_attr);
586 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_RMDIR, &arg, &dir_attr, 0);
587 nfs_post_op_update_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);
637 nfs_fattr_init(&dir_attr);
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;
679 nfs_fattr_init(&dir_attr);
680 nfs_fattr_init(&fattr);
681 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKNOD, &arg, &res, 0);
682 nfs_post_op_update_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 nfs_fattr_init(stat->fattr);
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 nfs_fattr_init(info->fattr);
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 nfs_fattr_init(info->fattr);
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);
735 static void nfs3_read_done(struct rpc_task *task, void *calldata)
737 struct nfs_read_data *data = calldata;
739 if (nfs3_async_handle_jukebox(task))
741 /* Call back common NFS readpage processing */
742 if (task->tk_status >= 0)
743 nfs_refresh_inode(data->inode, &data->fattr);
744 nfs_readpage_result(task, calldata);
747 static const struct rpc_call_ops nfs3_read_ops = {
748 .rpc_call_done = nfs3_read_done,
749 .rpc_release = nfs_readdata_release,
753 nfs3_proc_read_setup(struct nfs_read_data *data)
755 struct rpc_task *task = &data->task;
756 struct inode *inode = data->inode;
758 struct rpc_message msg = {
759 .rpc_proc = &nfs3_procedures[NFS3PROC_READ],
760 .rpc_argp = &data->args,
761 .rpc_resp = &data->res,
762 .rpc_cred = data->cred,
765 /* N.B. Do we need to test? Never called for swapfile inode */
766 flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
768 /* Finalize the task. */
769 rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_read_ops, data);
770 rpc_call_setup(task, &msg, 0);
773 static void nfs3_write_done(struct rpc_task *task, void *calldata)
775 struct nfs_write_data *data = calldata;
777 if (nfs3_async_handle_jukebox(task))
779 if (task->tk_status >= 0)
780 nfs_post_op_update_inode(data->inode, data->res.fattr);
781 nfs_writeback_done(task, calldata);
784 static const struct rpc_call_ops nfs3_write_ops = {
785 .rpc_call_done = nfs3_write_done,
786 .rpc_release = nfs_writedata_release,
790 nfs3_proc_write_setup(struct nfs_write_data *data, int how)
792 struct rpc_task *task = &data->task;
793 struct inode *inode = data->inode;
796 struct rpc_message msg = {
797 .rpc_proc = &nfs3_procedures[NFS3PROC_WRITE],
798 .rpc_argp = &data->args,
799 .rpc_resp = &data->res,
800 .rpc_cred = data->cred,
803 if (how & FLUSH_STABLE) {
804 if (!NFS_I(inode)->ncommit)
805 stable = NFS_FILE_SYNC;
807 stable = NFS_DATA_SYNC;
809 stable = NFS_UNSTABLE;
810 data->args.stable = stable;
812 /* Set the initial flags for the task. */
813 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
815 /* Finalize the task. */
816 rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_write_ops, data);
817 rpc_call_setup(task, &msg, 0);
820 static void nfs3_commit_done(struct rpc_task *task, void *calldata)
822 struct nfs_write_data *data = calldata;
824 if (nfs3_async_handle_jukebox(task))
826 if (task->tk_status >= 0)
827 nfs_post_op_update_inode(data->inode, data->res.fattr);
828 nfs_commit_done(task, calldata);
831 static const struct rpc_call_ops nfs3_commit_ops = {
832 .rpc_call_done = nfs3_commit_done,
833 .rpc_release = nfs_commit_release,
837 nfs3_proc_commit_setup(struct nfs_write_data *data, int how)
839 struct rpc_task *task = &data->task;
840 struct inode *inode = data->inode;
842 struct rpc_message msg = {
843 .rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT],
844 .rpc_argp = &data->args,
845 .rpc_resp = &data->res,
846 .rpc_cred = data->cred,
849 /* Set the initial flags for the task. */
850 flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
852 /* Finalize the task. */
853 rpc_init_task(task, NFS_CLIENT(inode), flags, &nfs3_commit_ops, data);
854 rpc_call_setup(task, &msg, 0);
858 nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
860 return nlmclnt_proc(filp->f_dentry->d_inode, cmd, fl);
863 struct nfs_rpc_ops nfs_v3_clientops = {
864 .version = 3, /* protocol version */
865 .dentry_ops = &nfs_dentry_operations,
866 .dir_inode_ops = &nfs3_dir_inode_operations,
867 .file_inode_ops = &nfs3_file_inode_operations,
868 .getroot = nfs3_proc_get_root,
869 .getattr = nfs3_proc_getattr,
870 .setattr = nfs3_proc_setattr,
871 .lookup = nfs3_proc_lookup,
872 .access = nfs3_proc_access,
873 .readlink = nfs3_proc_readlink,
874 .read = nfs3_proc_read,
875 .write = nfs3_proc_write,
876 .commit = nfs3_proc_commit,
877 .create = nfs3_proc_create,
878 .remove = nfs3_proc_remove,
879 .unlink_setup = nfs3_proc_unlink_setup,
880 .unlink_done = nfs3_proc_unlink_done,
881 .rename = nfs3_proc_rename,
882 .link = nfs3_proc_link,
883 .symlink = nfs3_proc_symlink,
884 .mkdir = nfs3_proc_mkdir,
885 .rmdir = nfs3_proc_rmdir,
886 .readdir = nfs3_proc_readdir,
887 .mknod = nfs3_proc_mknod,
888 .statfs = nfs3_proc_statfs,
889 .fsinfo = nfs3_proc_fsinfo,
890 .pathconf = nfs3_proc_pathconf,
891 .decode_dirent = nfs3_decode_dirent,
892 .read_setup = nfs3_proc_read_setup,
893 .write_setup = nfs3_proc_write_setup,
894 .commit_setup = nfs3_proc_commit_setup,
895 .file_open = nfs_open,
896 .file_release = nfs_release,
897 .lock = nfs3_proc_lock,
898 .clear_acl_cache = nfs3_forget_cached_acls,