aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs3proc.c
diff options
context:
space:
mode:
authorChuck Lever <cel@netapp.com>2006-03-20 13:44:23 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 13:44:23 -0500
commitdead28da8e3fb32601d38fb32b7021122e0a3d21 (patch)
treea1a23e27e08345c86ed0d9812f848470b615eb34 /fs/nfs/nfs3proc.c
parentcc0175c1dc1de8f6af0eb0631dcc5b999a6fcc42 (diff)
SUNRPC: eliminate rpc_call()
Clean-up: replace rpc_call() helper with direct call to rpc_call_sync. This makes NFSv2 and NFSv3 synchronous calls more computationally efficient, and reduces stack consumption in functions that used to invoke rpc_call more than once. Test plan: Compile kernel with CONFIG_NFS enabled. Connectathon on NFS version 2, version 3, and version 4 mount points. Signed-off-by: Chuck Lever <cel@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs3proc.c')
-rw-r--r--fs/nfs/nfs3proc.c140
1 files changed, 102 insertions, 38 deletions
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 7204ba5b2bf8..740f8b1ab04d 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -43,21 +43,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
43 return res; 43 return res;
44} 44}
45 45
46static inline int 46#define rpc_call_sync(clnt, msg, flags) nfs3_rpc_wrapper(clnt, msg, flags)
47nfs3_rpc_call_wrapper(struct rpc_clnt *clnt, u32 proc, void *argp, void *resp, int flags)
48{
49 struct rpc_message msg = {
50 .rpc_proc = &clnt->cl_procinfo[proc],
51 .rpc_argp = argp,
52 .rpc_resp = resp,
53 };
54 return nfs3_rpc_wrapper(clnt, &msg, flags);
55}
56
57#define rpc_call(clnt, proc, argp, resp, flags) \
58 nfs3_rpc_call_wrapper(clnt, proc, argp, resp, flags)
59#define rpc_call_sync(clnt, msg, flags) \
60 nfs3_rpc_wrapper(clnt, msg, flags)
61 47
62static int 48static int
63nfs3_async_handle_jukebox(struct rpc_task *task, struct inode *inode) 49nfs3_async_handle_jukebox(struct rpc_task *task, struct inode *inode)
@@ -75,14 +61,21 @@ static int
75do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle, 61do_proc_get_root(struct rpc_clnt *client, struct nfs_fh *fhandle,
76 struct nfs_fsinfo *info) 62 struct nfs_fsinfo *info)
77{ 63{
64 struct rpc_message msg = {
65 .rpc_proc = &nfs3_procedures[NFS3PROC_FSINFO],
66 .rpc_argp = fhandle,
67 .rpc_resp = info,
68 };
78 int status; 69 int status;
79 70
80 dprintk("%s: call fsinfo\n", __FUNCTION__); 71 dprintk("%s: call fsinfo\n", __FUNCTION__);
81 nfs_fattr_init(info->fattr); 72 nfs_fattr_init(info->fattr);
82 status = rpc_call(client, NFS3PROC_FSINFO, fhandle, info, 0); 73 status = rpc_call_sync(client, &msg, 0);
83 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status); 74 dprintk("%s: reply fsinfo: %d\n", __FUNCTION__, status);
84 if (!(info->fattr->valid & NFS_ATTR_FATTR)) { 75 if (!(info->fattr->valid & NFS_ATTR_FATTR)) {
85 status = rpc_call(client, NFS3PROC_GETATTR, fhandle, info->fattr, 0); 76 msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
77 msg.rpc_resp = info->fattr;
78 status = rpc_call_sync(client, &msg, 0);
86 dprintk("%s: reply getattr: %d\n", __FUNCTION__, status); 79 dprintk("%s: reply getattr: %d\n", __FUNCTION__, status);
87 } 80 }
88 return status; 81 return status;
@@ -110,12 +103,16 @@ static int
110nfs3_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, 103nfs3_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
111 struct nfs_fattr *fattr) 104 struct nfs_fattr *fattr)
112{ 105{
106 struct rpc_message msg = {
107 .rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR],
108 .rpc_argp = fhandle,
109 .rpc_resp = fattr,
110 };
113 int status; 111 int status;
114 112
115 dprintk("NFS call getattr\n"); 113 dprintk("NFS call getattr\n");
116 nfs_fattr_init(fattr); 114 nfs_fattr_init(fattr);
117 status = rpc_call(server->client, NFS3PROC_GETATTR, 115 status = rpc_call_sync(server->client, &msg, 0);
118 fhandle, fattr, 0);
119 dprintk("NFS reply getattr: %d\n", status); 116 dprintk("NFS reply getattr: %d\n", status);
120 return status; 117 return status;
121} 118}
@@ -129,11 +126,16 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
129 .fh = NFS_FH(inode), 126 .fh = NFS_FH(inode),
130 .sattr = sattr, 127 .sattr = sattr,
131 }; 128 };
129 struct rpc_message msg = {
130 .rpc_proc = &nfs3_procedures[NFS3PROC_SETATTR],
131 .rpc_argp = &arg,
132 .rpc_resp = fattr,
133 };
132 int status; 134 int status;
133 135
134 dprintk("NFS call setattr\n"); 136 dprintk("NFS call setattr\n");
135 nfs_fattr_init(fattr); 137 nfs_fattr_init(fattr);
136 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_SETATTR, &arg, fattr, 0); 138 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
137 if (status == 0) 139 if (status == 0)
138 nfs_setattr_update_inode(inode, sattr); 140 nfs_setattr_update_inode(inode, sattr);
139 dprintk("NFS reply setattr: %d\n", status); 141 dprintk("NFS reply setattr: %d\n", status);
@@ -155,15 +157,23 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name,
155 .fh = fhandle, 157 .fh = fhandle,
156 .fattr = fattr 158 .fattr = fattr
157 }; 159 };
160 struct rpc_message msg = {
161 .rpc_proc = &nfs3_procedures[NFS3PROC_LOOKUP],
162 .rpc_argp = &arg,
163 .rpc_resp = &res,
164 };
158 int status; 165 int status;
159 166
160 dprintk("NFS call lookup %s\n", name->name); 167 dprintk("NFS call lookup %s\n", name->name);
161 nfs_fattr_init(&dir_attr); 168 nfs_fattr_init(&dir_attr);
162 nfs_fattr_init(fattr); 169 nfs_fattr_init(fattr);
163 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_LOOKUP, &arg, &res, 0); 170 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
164 if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) 171 if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) {
165 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_GETATTR, 172 msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
166 fhandle, fattr, 0); 173 msg.rpc_argp = fhandle;
174 msg.rpc_resp = fattr;
175 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
176 }
167 dprintk("NFS reply lookup: %d\n", status); 177 dprintk("NFS reply lookup: %d\n", status);
168 if (status >= 0) 178 if (status >= 0)
169 status = nfs_refresh_inode(dir, &dir_attr); 179 status = nfs_refresh_inode(dir, &dir_attr);
@@ -183,7 +193,7 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
183 .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS], 193 .rpc_proc = &nfs3_procedures[NFS3PROC_ACCESS],
184 .rpc_argp = &arg, 194 .rpc_argp = &arg,
185 .rpc_resp = &res, 195 .rpc_resp = &res,
186 .rpc_cred = entry->cred 196 .rpc_cred = entry->cred,
187 }; 197 };
188 int mode = entry->mask; 198 int mode = entry->mask;
189 int status; 199 int status;
@@ -229,12 +239,16 @@ static int nfs3_proc_readlink(struct inode *inode, struct page *page,
229 .pglen = pglen, 239 .pglen = pglen,
230 .pages = &page 240 .pages = &page
231 }; 241 };
242 struct rpc_message msg = {
243 .rpc_proc = &nfs3_procedures[NFS3PROC_READLINK],
244 .rpc_argp = &args,
245 .rpc_resp = &fattr,
246 };
232 int status; 247 int status;
233 248
234 dprintk("NFS call readlink\n"); 249 dprintk("NFS call readlink\n");
235 nfs_fattr_init(&fattr); 250 nfs_fattr_init(&fattr);
236 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_READLINK, 251 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
237 &args, &fattr, 0);
238 nfs_refresh_inode(inode, &fattr); 252 nfs_refresh_inode(inode, &fattr);
239 dprintk("NFS reply readlink: %d\n", status); 253 dprintk("NFS reply readlink: %d\n", status);
240 return status; 254 return status;
@@ -330,6 +344,11 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
330 .fh = &fhandle, 344 .fh = &fhandle,
331 .fattr = &fattr 345 .fattr = &fattr
332 }; 346 };
347 struct rpc_message msg = {
348 .rpc_proc = &nfs3_procedures[NFS3PROC_CREATE],
349 .rpc_argp = &arg,
350 .rpc_resp = &res,
351 };
333 mode_t mode = sattr->ia_mode; 352 mode_t mode = sattr->ia_mode;
334 int status; 353 int status;
335 354
@@ -346,8 +365,8 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
346again: 365again:
347 nfs_fattr_init(&dir_attr); 366 nfs_fattr_init(&dir_attr);
348 nfs_fattr_init(&fattr); 367 nfs_fattr_init(&fattr);
349 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_CREATE, &arg, &res, 0); 368 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
350 nfs_post_op_update_inode(dir, &dir_attr); 369 nfs_refresh_inode(dir, &dir_attr);
351 370
352 /* If the server doesn't support the exclusive creation semantics, 371 /* If the server doesn't support the exclusive creation semantics,
353 * try again with simple 'guarded' mode. */ 372 * try again with simple 'guarded' mode. */
@@ -477,12 +496,17 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name,
477 .fromattr = &old_dir_attr, 496 .fromattr = &old_dir_attr,
478 .toattr = &new_dir_attr 497 .toattr = &new_dir_attr
479 }; 498 };
499 struct rpc_message msg = {
500 .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME],
501 .rpc_argp = &arg,
502 .rpc_resp = &res,
503 };
480 int status; 504 int status;
481 505
482 dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); 506 dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name);
483 nfs_fattr_init(&old_dir_attr); 507 nfs_fattr_init(&old_dir_attr);
484 nfs_fattr_init(&new_dir_attr); 508 nfs_fattr_init(&new_dir_attr);
485 status = rpc_call(NFS_CLIENT(old_dir), NFS3PROC_RENAME, &arg, &res, 0); 509 status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0);
486 nfs_post_op_update_inode(old_dir, &old_dir_attr); 510 nfs_post_op_update_inode(old_dir, &old_dir_attr);
487 nfs_post_op_update_inode(new_dir, &new_dir_attr); 511 nfs_post_op_update_inode(new_dir, &new_dir_attr);
488 dprintk("NFS reply rename: %d\n", status); 512 dprintk("NFS reply rename: %d\n", status);
@@ -503,12 +527,17 @@ nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
503 .dir_attr = &dir_attr, 527 .dir_attr = &dir_attr,
504 .fattr = &fattr 528 .fattr = &fattr
505 }; 529 };
530 struct rpc_message msg = {
531 .rpc_proc = &nfs3_procedures[NFS3PROC_LINK],
532 .rpc_argp = &arg,
533 .rpc_resp = &res,
534 };
506 int status; 535 int status;
507 536
508 dprintk("NFS call link %s\n", name->name); 537 dprintk("NFS call link %s\n", name->name);
509 nfs_fattr_init(&dir_attr); 538 nfs_fattr_init(&dir_attr);
510 nfs_fattr_init(&fattr); 539 nfs_fattr_init(&fattr);
511 status = rpc_call(NFS_CLIENT(inode), NFS3PROC_LINK, &arg, &res, 0); 540 status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
512 nfs_post_op_update_inode(dir, &dir_attr); 541 nfs_post_op_update_inode(dir, &dir_attr);
513 nfs_post_op_update_inode(inode, &fattr); 542 nfs_post_op_update_inode(inode, &fattr);
514 dprintk("NFS reply link: %d\n", status); 543 dprintk("NFS reply link: %d\n", status);
@@ -534,6 +563,11 @@ nfs3_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path,
534 .fh = fhandle, 563 .fh = fhandle,
535 .fattr = fattr 564 .fattr = fattr
536 }; 565 };
566 struct rpc_message msg = {
567 .rpc_proc = &nfs3_procedures[NFS3PROC_SYMLINK],
568 .rpc_argp = &arg,
569 .rpc_resp = &res,
570 };
537 int status; 571 int status;
538 572
539 if (path->len > NFS3_MAXPATHLEN) 573 if (path->len > NFS3_MAXPATHLEN)
@@ -541,7 +575,7 @@ nfs3_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path,
541 dprintk("NFS call symlink %s -> %s\n", name->name, path->name); 575 dprintk("NFS call symlink %s -> %s\n", name->name, path->name);
542 nfs_fattr_init(&dir_attr); 576 nfs_fattr_init(&dir_attr);
543 nfs_fattr_init(fattr); 577 nfs_fattr_init(fattr);
544 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_SYMLINK, &arg, &res, 0); 578 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
545 nfs_post_op_update_inode(dir, &dir_attr); 579 nfs_post_op_update_inode(dir, &dir_attr);
546 dprintk("NFS reply symlink: %d\n", status); 580 dprintk("NFS reply symlink: %d\n", status);
547 return status; 581 return status;
@@ -563,6 +597,11 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
563 .fh = &fhandle, 597 .fh = &fhandle,
564 .fattr = &fattr 598 .fattr = &fattr
565 }; 599 };
600 struct rpc_message msg = {
601 .rpc_proc = &nfs3_procedures[NFS3PROC_MKDIR],
602 .rpc_argp = &arg,
603 .rpc_resp = &res,
604 };
566 int mode = sattr->ia_mode; 605 int mode = sattr->ia_mode;
567 int status; 606 int status;
568 607
@@ -572,7 +611,7 @@ nfs3_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
572 611
573 nfs_fattr_init(&dir_attr); 612 nfs_fattr_init(&dir_attr);
574 nfs_fattr_init(&fattr); 613 nfs_fattr_init(&fattr);
575 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKDIR, &arg, &res, 0); 614 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
576 nfs_post_op_update_inode(dir, &dir_attr); 615 nfs_post_op_update_inode(dir, &dir_attr);
577 if (status != 0) 616 if (status != 0)
578 goto out; 617 goto out;
@@ -594,11 +633,16 @@ nfs3_proc_rmdir(struct inode *dir, struct qstr *name)
594 .name = name->name, 633 .name = name->name,
595 .len = name->len 634 .len = name->len
596 }; 635 };
636 struct rpc_message msg = {
637 .rpc_proc = &nfs3_procedures[NFS3PROC_RMDIR],
638 .rpc_argp = &arg,
639 .rpc_resp = &dir_attr,
640 };
597 int status; 641 int status;
598 642
599 dprintk("NFS call rmdir %s\n", name->name); 643 dprintk("NFS call rmdir %s\n", name->name);
600 nfs_fattr_init(&dir_attr); 644 nfs_fattr_init(&dir_attr);
601 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_RMDIR, &arg, &dir_attr, 0); 645 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
602 nfs_post_op_update_inode(dir, &dir_attr); 646 nfs_post_op_update_inode(dir, &dir_attr);
603 dprintk("NFS reply rmdir: %d\n", status); 647 dprintk("NFS reply rmdir: %d\n", status);
604 return status; 648 return status;
@@ -675,6 +719,11 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
675 .fh = &fh, 719 .fh = &fh,
676 .fattr = &fattr 720 .fattr = &fattr
677 }; 721 };
722 struct rpc_message msg = {
723 .rpc_proc = &nfs3_procedures[NFS3PROC_MKNOD],
724 .rpc_argp = &arg,
725 .rpc_resp = &res,
726 };
678 mode_t mode = sattr->ia_mode; 727 mode_t mode = sattr->ia_mode;
679 int status; 728 int status;
680 729
@@ -693,7 +742,7 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
693 742
694 nfs_fattr_init(&dir_attr); 743 nfs_fattr_init(&dir_attr);
695 nfs_fattr_init(&fattr); 744 nfs_fattr_init(&fattr);
696 status = rpc_call(NFS_CLIENT(dir), NFS3PROC_MKNOD, &arg, &res, 0); 745 status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
697 nfs_post_op_update_inode(dir, &dir_attr); 746 nfs_post_op_update_inode(dir, &dir_attr);
698 if (status != 0) 747 if (status != 0)
699 goto out; 748 goto out;
@@ -710,11 +759,16 @@ static int
710nfs3_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle, 759nfs3_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
711 struct nfs_fsstat *stat) 760 struct nfs_fsstat *stat)
712{ 761{
762 struct rpc_message msg = {
763 .rpc_proc = &nfs3_procedures[NFS3PROC_FSSTAT],
764 .rpc_argp = fhandle,
765 .rpc_resp = stat,
766 };
713 int status; 767 int status;
714 768
715 dprintk("NFS call fsstat\n"); 769 dprintk("NFS call fsstat\n");
716 nfs_fattr_init(stat->fattr); 770 nfs_fattr_init(stat->fattr);
717 status = rpc_call(server->client, NFS3PROC_FSSTAT, fhandle, stat, 0); 771 status = rpc_call_sync(server->client, &msg, 0);
718 dprintk("NFS reply statfs: %d\n", status); 772 dprintk("NFS reply statfs: %d\n", status);
719 return status; 773 return status;
720} 774}
@@ -723,11 +777,16 @@ static int
723nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, 777nfs3_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
724 struct nfs_fsinfo *info) 778 struct nfs_fsinfo *info)
725{ 779{
780 struct rpc_message msg = {
781 .rpc_proc = &nfs3_procedures[NFS3PROC_FSINFO],
782 .rpc_argp = fhandle,
783 .rpc_resp = info,
784 };
726 int status; 785 int status;
727 786
728 dprintk("NFS call fsinfo\n"); 787 dprintk("NFS call fsinfo\n");
729 nfs_fattr_init(info->fattr); 788 nfs_fattr_init(info->fattr);
730 status = rpc_call(server->client_sys, NFS3PROC_FSINFO, fhandle, info, 0); 789 status = rpc_call_sync(server->client_sys, &msg, 0);
731 dprintk("NFS reply fsinfo: %d\n", status); 790 dprintk("NFS reply fsinfo: %d\n", status);
732 return status; 791 return status;
733} 792}
@@ -736,11 +795,16 @@ static int
736nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, 795nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
737 struct nfs_pathconf *info) 796 struct nfs_pathconf *info)
738{ 797{
798 struct rpc_message msg = {
799 .rpc_proc = &nfs3_procedures[NFS3PROC_PATHCONF],
800 .rpc_argp = fhandle,
801 .rpc_resp = info,
802 };
739 int status; 803 int status;
740 804
741 dprintk("NFS call pathconf\n"); 805 dprintk("NFS call pathconf\n");
742 nfs_fattr_init(info->fattr); 806 nfs_fattr_init(info->fattr);
743 status = rpc_call(server->client, NFS3PROC_PATHCONF, fhandle, info, 0); 807 status = rpc_call_sync(server->client, &msg, 0);
744 dprintk("NFS reply pathconf: %d\n", status); 808 dprintk("NFS reply pathconf: %d\n", status);
745 return status; 809 return status;
746} 810}