diff options
author | Chuck Lever <cel@netapp.com> | 2006-03-20 13:44:23 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:23 -0500 |
commit | dead28da8e3fb32601d38fb32b7021122e0a3d21 (patch) | |
tree | a1a23e27e08345c86ed0d9812f848470b615eb34 /fs/nfs/proc.c | |
parent | cc0175c1dc1de8f6af0eb0631dcc5b999a6fcc42 (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/proc.c')
-rw-r--r-- | fs/nfs/proc.c | 107 |
1 files changed, 85 insertions, 22 deletions
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index f5150d71c03..2b051ab8bea 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -58,16 +58,23 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle, | |||
58 | { | 58 | { |
59 | struct nfs_fattr *fattr = info->fattr; | 59 | struct nfs_fattr *fattr = info->fattr; |
60 | struct nfs2_fsstat fsinfo; | 60 | struct nfs2_fsstat fsinfo; |
61 | struct rpc_message msg = { | ||
62 | .rpc_proc = &nfs_procedures[NFSPROC_GETATTR], | ||
63 | .rpc_argp = fhandle, | ||
64 | .rpc_resp = fattr, | ||
65 | }; | ||
61 | int status; | 66 | int status; |
62 | 67 | ||
63 | dprintk("%s: call getattr\n", __FUNCTION__); | 68 | dprintk("%s: call getattr\n", __FUNCTION__); |
64 | nfs_fattr_init(fattr); | 69 | nfs_fattr_init(fattr); |
65 | status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0); | 70 | status = rpc_call_sync(server->client_sys, &msg, 0); |
66 | dprintk("%s: reply getattr: %d\n", __FUNCTION__, status); | 71 | dprintk("%s: reply getattr: %d\n", __FUNCTION__, status); |
67 | if (status) | 72 | if (status) |
68 | return status; | 73 | return status; |
69 | dprintk("%s: call statfs\n", __FUNCTION__); | 74 | dprintk("%s: call statfs\n", __FUNCTION__); |
70 | status = rpc_call(server->client_sys, NFSPROC_STATFS, fhandle, &fsinfo, 0); | 75 | msg.rpc_proc = &nfs_procedures[NFSPROC_STATFS]; |
76 | msg.rpc_resp = &fsinfo; | ||
77 | status = rpc_call_sync(server->client_sys, &msg, 0); | ||
71 | dprintk("%s: reply statfs: %d\n", __FUNCTION__, status); | 78 | dprintk("%s: reply statfs: %d\n", __FUNCTION__, status); |
72 | if (status) | 79 | if (status) |
73 | return status; | 80 | return status; |
@@ -90,12 +97,16 @@ static int | |||
90 | nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, | 97 | nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, |
91 | struct nfs_fattr *fattr) | 98 | struct nfs_fattr *fattr) |
92 | { | 99 | { |
100 | struct rpc_message msg = { | ||
101 | .rpc_proc = &nfs_procedures[NFSPROC_GETATTR], | ||
102 | .rpc_argp = fhandle, | ||
103 | .rpc_resp = fattr, | ||
104 | }; | ||
93 | int status; | 105 | int status; |
94 | 106 | ||
95 | dprintk("NFS call getattr\n"); | 107 | dprintk("NFS call getattr\n"); |
96 | nfs_fattr_init(fattr); | 108 | nfs_fattr_init(fattr); |
97 | status = rpc_call(server->client, NFSPROC_GETATTR, | 109 | status = rpc_call_sync(server->client, &msg, 0); |
98 | fhandle, fattr, 0); | ||
99 | dprintk("NFS reply getattr: %d\n", status); | 110 | dprintk("NFS reply getattr: %d\n", status); |
100 | return status; | 111 | return status; |
101 | } | 112 | } |
@@ -109,6 +120,11 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
109 | .fh = NFS_FH(inode), | 120 | .fh = NFS_FH(inode), |
110 | .sattr = sattr | 121 | .sattr = sattr |
111 | }; | 122 | }; |
123 | struct rpc_message msg = { | ||
124 | .rpc_proc = &nfs_procedures[NFSPROC_SETATTR], | ||
125 | .rpc_argp = &arg, | ||
126 | .rpc_resp = fattr, | ||
127 | }; | ||
112 | int status; | 128 | int status; |
113 | 129 | ||
114 | /* Mask out the non-modebit related stuff from attr->ia_mode */ | 130 | /* Mask out the non-modebit related stuff from attr->ia_mode */ |
@@ -116,7 +132,7 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, | |||
116 | 132 | ||
117 | dprintk("NFS call setattr\n"); | 133 | dprintk("NFS call setattr\n"); |
118 | nfs_fattr_init(fattr); | 134 | nfs_fattr_init(fattr); |
119 | status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0); | 135 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
120 | if (status == 0) | 136 | if (status == 0) |
121 | nfs_setattr_update_inode(inode, sattr); | 137 | nfs_setattr_update_inode(inode, sattr); |
122 | dprintk("NFS reply setattr: %d\n", status); | 138 | dprintk("NFS reply setattr: %d\n", status); |
@@ -136,11 +152,16 @@ nfs_proc_lookup(struct inode *dir, struct qstr *name, | |||
136 | .fh = fhandle, | 152 | .fh = fhandle, |
137 | .fattr = fattr | 153 | .fattr = fattr |
138 | }; | 154 | }; |
155 | struct rpc_message msg = { | ||
156 | .rpc_proc = &nfs_procedures[NFSPROC_LOOKUP], | ||
157 | .rpc_argp = &arg, | ||
158 | .rpc_resp = &res, | ||
159 | }; | ||
139 | int status; | 160 | int status; |
140 | 161 | ||
141 | dprintk("NFS call lookup %s\n", name->name); | 162 | dprintk("NFS call lookup %s\n", name->name); |
142 | nfs_fattr_init(fattr); | 163 | nfs_fattr_init(fattr); |
143 | status = rpc_call(NFS_CLIENT(dir), NFSPROC_LOOKUP, &arg, &res, 0); | 164 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
144 | dprintk("NFS reply lookup: %d\n", status); | 165 | dprintk("NFS reply lookup: %d\n", status); |
145 | return status; | 166 | return status; |
146 | } | 167 | } |
@@ -154,10 +175,14 @@ static int nfs_proc_readlink(struct inode *inode, struct page *page, | |||
154 | .pglen = pglen, | 175 | .pglen = pglen, |
155 | .pages = &page | 176 | .pages = &page |
156 | }; | 177 | }; |
178 | struct rpc_message msg = { | ||
179 | .rpc_proc = &nfs_procedures[NFSPROC_READLINK], | ||
180 | .rpc_argp = &args, | ||
181 | }; | ||
157 | int status; | 182 | int status; |
158 | 183 | ||
159 | dprintk("NFS call readlink\n"); | 184 | dprintk("NFS call readlink\n"); |
160 | status = rpc_call(NFS_CLIENT(inode), NFSPROC_READLINK, &args, NULL, 0); | 185 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
161 | dprintk("NFS reply readlink: %d\n", status); | 186 | dprintk("NFS reply readlink: %d\n", status); |
162 | return status; | 187 | return status; |
163 | } | 188 | } |
@@ -233,11 +258,16 @@ nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
233 | .fh = &fhandle, | 258 | .fh = &fhandle, |
234 | .fattr = &fattr | 259 | .fattr = &fattr |
235 | }; | 260 | }; |
261 | struct rpc_message msg = { | ||
262 | .rpc_proc = &nfs_procedures[NFSPROC_CREATE], | ||
263 | .rpc_argp = &arg, | ||
264 | .rpc_resp = &res, | ||
265 | }; | ||
236 | int status; | 266 | int status; |
237 | 267 | ||
238 | nfs_fattr_init(&fattr); | 268 | nfs_fattr_init(&fattr); |
239 | dprintk("NFS call create %s\n", dentry->d_name.name); | 269 | dprintk("NFS call create %s\n", dentry->d_name.name); |
240 | status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0); | 270 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
241 | if (status == 0) | 271 | if (status == 0) |
242 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 272 | status = nfs_instantiate(dentry, &fhandle, &fattr); |
243 | dprintk("NFS reply create: %d\n", status); | 273 | dprintk("NFS reply create: %d\n", status); |
@@ -263,6 +293,11 @@ nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
263 | .fh = &fhandle, | 293 | .fh = &fhandle, |
264 | .fattr = &fattr | 294 | .fattr = &fattr |
265 | }; | 295 | }; |
296 | struct rpc_message msg = { | ||
297 | .rpc_proc = &nfs_procedures[NFSPROC_CREATE], | ||
298 | .rpc_argp = &arg, | ||
299 | .rpc_resp = &res, | ||
300 | }; | ||
266 | int status, mode; | 301 | int status, mode; |
267 | 302 | ||
268 | dprintk("NFS call mknod %s\n", dentry->d_name.name); | 303 | dprintk("NFS call mknod %s\n", dentry->d_name.name); |
@@ -277,13 +312,13 @@ nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
277 | } | 312 | } |
278 | 313 | ||
279 | nfs_fattr_init(&fattr); | 314 | nfs_fattr_init(&fattr); |
280 | status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0); | 315 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
281 | nfs_mark_for_revalidate(dir); | 316 | nfs_mark_for_revalidate(dir); |
282 | 317 | ||
283 | if (status == -EINVAL && S_ISFIFO(mode)) { | 318 | if (status == -EINVAL && S_ISFIFO(mode)) { |
284 | sattr->ia_mode = mode; | 319 | sattr->ia_mode = mode; |
285 | nfs_fattr_init(&fattr); | 320 | nfs_fattr_init(&fattr); |
286 | status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0); | 321 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
287 | } | 322 | } |
288 | if (status == 0) | 323 | if (status == 0) |
289 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 324 | status = nfs_instantiate(dentry, &fhandle, &fattr); |
@@ -302,8 +337,6 @@ nfs_proc_remove(struct inode *dir, struct qstr *name) | |||
302 | struct rpc_message msg = { | 337 | struct rpc_message msg = { |
303 | .rpc_proc = &nfs_procedures[NFSPROC_REMOVE], | 338 | .rpc_proc = &nfs_procedures[NFSPROC_REMOVE], |
304 | .rpc_argp = &arg, | 339 | .rpc_argp = &arg, |
305 | .rpc_resp = NULL, | ||
306 | .rpc_cred = NULL | ||
307 | }; | 340 | }; |
308 | int status; | 341 | int status; |
309 | 342 | ||
@@ -355,10 +388,14 @@ nfs_proc_rename(struct inode *old_dir, struct qstr *old_name, | |||
355 | .toname = new_name->name, | 388 | .toname = new_name->name, |
356 | .tolen = new_name->len | 389 | .tolen = new_name->len |
357 | }; | 390 | }; |
391 | struct rpc_message msg = { | ||
392 | .rpc_proc = &nfs_procedures[NFSPROC_RENAME], | ||
393 | .rpc_argp = &arg, | ||
394 | }; | ||
358 | int status; | 395 | int status; |
359 | 396 | ||
360 | dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); | 397 | dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); |
361 | status = rpc_call(NFS_CLIENT(old_dir), NFSPROC_RENAME, &arg, NULL, 0); | 398 | status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); |
362 | nfs_mark_for_revalidate(old_dir); | 399 | nfs_mark_for_revalidate(old_dir); |
363 | nfs_mark_for_revalidate(new_dir); | 400 | nfs_mark_for_revalidate(new_dir); |
364 | dprintk("NFS reply rename: %d\n", status); | 401 | dprintk("NFS reply rename: %d\n", status); |
@@ -374,10 +411,14 @@ nfs_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) | |||
374 | .toname = name->name, | 411 | .toname = name->name, |
375 | .tolen = name->len | 412 | .tolen = name->len |
376 | }; | 413 | }; |
414 | struct rpc_message msg = { | ||
415 | .rpc_proc = &nfs_procedures[NFSPROC_LINK], | ||
416 | .rpc_argp = &arg, | ||
417 | }; | ||
377 | int status; | 418 | int status; |
378 | 419 | ||
379 | dprintk("NFS call link %s\n", name->name); | 420 | dprintk("NFS call link %s\n", name->name); |
380 | status = rpc_call(NFS_CLIENT(inode), NFSPROC_LINK, &arg, NULL, 0); | 421 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
381 | nfs_mark_for_revalidate(inode); | 422 | nfs_mark_for_revalidate(inode); |
382 | nfs_mark_for_revalidate(dir); | 423 | nfs_mark_for_revalidate(dir); |
383 | dprintk("NFS reply link: %d\n", status); | 424 | dprintk("NFS reply link: %d\n", status); |
@@ -397,6 +438,10 @@ nfs_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path, | |||
397 | .tolen = path->len, | 438 | .tolen = path->len, |
398 | .sattr = sattr | 439 | .sattr = sattr |
399 | }; | 440 | }; |
441 | struct rpc_message msg = { | ||
442 | .rpc_proc = &nfs_procedures[NFSPROC_SYMLINK], | ||
443 | .rpc_argp = &arg, | ||
444 | }; | ||
400 | int status; | 445 | int status; |
401 | 446 | ||
402 | if (path->len > NFS2_MAXPATHLEN) | 447 | if (path->len > NFS2_MAXPATHLEN) |
@@ -404,7 +449,7 @@ nfs_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path, | |||
404 | dprintk("NFS call symlink %s -> %s\n", name->name, path->name); | 449 | dprintk("NFS call symlink %s -> %s\n", name->name, path->name); |
405 | nfs_fattr_init(fattr); | 450 | nfs_fattr_init(fattr); |
406 | fhandle->size = 0; | 451 | fhandle->size = 0; |
407 | status = rpc_call(NFS_CLIENT(dir), NFSPROC_SYMLINK, &arg, NULL, 0); | 452 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
408 | nfs_mark_for_revalidate(dir); | 453 | nfs_mark_for_revalidate(dir); |
409 | dprintk("NFS reply symlink: %d\n", status); | 454 | dprintk("NFS reply symlink: %d\n", status); |
410 | return status; | 455 | return status; |
@@ -425,11 +470,16 @@ nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr) | |||
425 | .fh = &fhandle, | 470 | .fh = &fhandle, |
426 | .fattr = &fattr | 471 | .fattr = &fattr |
427 | }; | 472 | }; |
473 | struct rpc_message msg = { | ||
474 | .rpc_proc = &nfs_procedures[NFSPROC_MKDIR], | ||
475 | .rpc_argp = &arg, | ||
476 | .rpc_resp = &res, | ||
477 | }; | ||
428 | int status; | 478 | int status; |
429 | 479 | ||
430 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); | 480 | dprintk("NFS call mkdir %s\n", dentry->d_name.name); |
431 | nfs_fattr_init(&fattr); | 481 | nfs_fattr_init(&fattr); |
432 | status = rpc_call(NFS_CLIENT(dir), NFSPROC_MKDIR, &arg, &res, 0); | 482 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
433 | nfs_mark_for_revalidate(dir); | 483 | nfs_mark_for_revalidate(dir); |
434 | if (status == 0) | 484 | if (status == 0) |
435 | status = nfs_instantiate(dentry, &fhandle, &fattr); | 485 | status = nfs_instantiate(dentry, &fhandle, &fattr); |
@@ -445,10 +495,14 @@ nfs_proc_rmdir(struct inode *dir, struct qstr *name) | |||
445 | .name = name->name, | 495 | .name = name->name, |
446 | .len = name->len | 496 | .len = name->len |
447 | }; | 497 | }; |
498 | struct rpc_message msg = { | ||
499 | .rpc_proc = &nfs_procedures[NFSPROC_RMDIR], | ||
500 | .rpc_argp = &arg, | ||
501 | }; | ||
448 | int status; | 502 | int status; |
449 | 503 | ||
450 | dprintk("NFS call rmdir %s\n", name->name); | 504 | dprintk("NFS call rmdir %s\n", name->name); |
451 | status = rpc_call(NFS_CLIENT(dir), NFSPROC_RMDIR, &arg, NULL, 0); | 505 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
452 | nfs_mark_for_revalidate(dir); | 506 | nfs_mark_for_revalidate(dir); |
453 | dprintk("NFS reply rmdir: %d\n", status); | 507 | dprintk("NFS reply rmdir: %d\n", status); |
454 | return status; | 508 | return status; |
@@ -470,13 +524,12 @@ nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
470 | .fh = NFS_FH(dir), | 524 | .fh = NFS_FH(dir), |
471 | .cookie = cookie, | 525 | .cookie = cookie, |
472 | .count = count, | 526 | .count = count, |
473 | .pages = &page | 527 | .pages = &page, |
474 | }; | 528 | }; |
475 | struct rpc_message msg = { | 529 | struct rpc_message msg = { |
476 | .rpc_proc = &nfs_procedures[NFSPROC_READDIR], | 530 | .rpc_proc = &nfs_procedures[NFSPROC_READDIR], |
477 | .rpc_argp = &arg, | 531 | .rpc_argp = &arg, |
478 | .rpc_resp = NULL, | 532 | .rpc_cred = cred, |
479 | .rpc_cred = cred | ||
480 | }; | 533 | }; |
481 | int status; | 534 | int status; |
482 | 535 | ||
@@ -495,11 +548,16 @@ nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle, | |||
495 | struct nfs_fsstat *stat) | 548 | struct nfs_fsstat *stat) |
496 | { | 549 | { |
497 | struct nfs2_fsstat fsinfo; | 550 | struct nfs2_fsstat fsinfo; |
551 | struct rpc_message msg = { | ||
552 | .rpc_proc = &nfs_procedures[NFSPROC_STATFS], | ||
553 | .rpc_argp = fhandle, | ||
554 | .rpc_resp = &fsinfo, | ||
555 | }; | ||
498 | int status; | 556 | int status; |
499 | 557 | ||
500 | dprintk("NFS call statfs\n"); | 558 | dprintk("NFS call statfs\n"); |
501 | nfs_fattr_init(stat->fattr); | 559 | nfs_fattr_init(stat->fattr); |
502 | status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0); | 560 | status = rpc_call_sync(server->client, &msg, 0); |
503 | dprintk("NFS reply statfs: %d\n", status); | 561 | dprintk("NFS reply statfs: %d\n", status); |
504 | if (status) | 562 | if (status) |
505 | goto out; | 563 | goto out; |
@@ -518,11 +576,16 @@ nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle, | |||
518 | struct nfs_fsinfo *info) | 576 | struct nfs_fsinfo *info) |
519 | { | 577 | { |
520 | struct nfs2_fsstat fsinfo; | 578 | struct nfs2_fsstat fsinfo; |
579 | struct rpc_message msg = { | ||
580 | .rpc_proc = &nfs_procedures[NFSPROC_STATFS], | ||
581 | .rpc_argp = fhandle, | ||
582 | .rpc_resp = &fsinfo, | ||
583 | }; | ||
521 | int status; | 584 | int status; |
522 | 585 | ||
523 | dprintk("NFS call fsinfo\n"); | 586 | dprintk("NFS call fsinfo\n"); |
524 | nfs_fattr_init(info->fattr); | 587 | nfs_fattr_init(info->fattr); |
525 | status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0); | 588 | status = rpc_call_sync(server->client, &msg, 0); |
526 | dprintk("NFS reply fsinfo: %d\n", status); | 589 | dprintk("NFS reply fsinfo: %d\n", status); |
527 | if (status) | 590 | if (status) |
528 | goto out; | 591 | goto out; |