diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-04-16 16:22:49 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-05-14 15:09:25 -0400 |
commit | 136f2627c932da5835e67e464e191d8c43c3f3fd (patch) | |
tree | 5f6aff24fe7163a260c553f3d4899c4ef51abbf7 | |
parent | aa49b4cf7dbf45438563f0ff6a2d23a68b70a7b9 (diff) |
NFS: Reduce the stack footprint of nfs_link()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | fs/nfs/nfs3proc.c | 22 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 16 |
2 files changed, 21 insertions, 17 deletions
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 1c5bfb3d6f08..982a81bb7257 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -468,30 +468,32 @@ out: | |||
468 | static int | 468 | static int |
469 | nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) | 469 | nfs3_proc_link(struct inode *inode, struct inode *dir, struct qstr *name) |
470 | { | 470 | { |
471 | struct nfs_fattr dir_attr, fattr; | ||
472 | struct nfs3_linkargs arg = { | 471 | struct nfs3_linkargs arg = { |
473 | .fromfh = NFS_FH(inode), | 472 | .fromfh = NFS_FH(inode), |
474 | .tofh = NFS_FH(dir), | 473 | .tofh = NFS_FH(dir), |
475 | .toname = name->name, | 474 | .toname = name->name, |
476 | .tolen = name->len | 475 | .tolen = name->len |
477 | }; | 476 | }; |
478 | struct nfs3_linkres res = { | 477 | struct nfs3_linkres res; |
479 | .dir_attr = &dir_attr, | ||
480 | .fattr = &fattr | ||
481 | }; | ||
482 | struct rpc_message msg = { | 478 | struct rpc_message msg = { |
483 | .rpc_proc = &nfs3_procedures[NFS3PROC_LINK], | 479 | .rpc_proc = &nfs3_procedures[NFS3PROC_LINK], |
484 | .rpc_argp = &arg, | 480 | .rpc_argp = &arg, |
485 | .rpc_resp = &res, | 481 | .rpc_resp = &res, |
486 | }; | 482 | }; |
487 | int status; | 483 | int status = -ENOMEM; |
488 | 484 | ||
489 | dprintk("NFS call link %s\n", name->name); | 485 | dprintk("NFS call link %s\n", name->name); |
490 | nfs_fattr_init(&dir_attr); | 486 | res.fattr = nfs_alloc_fattr(); |
491 | nfs_fattr_init(&fattr); | 487 | res.dir_attr = nfs_alloc_fattr(); |
488 | if (res.fattr == NULL || res.dir_attr == NULL) | ||
489 | goto out; | ||
490 | |||
492 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 491 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
493 | nfs_post_op_update_inode(dir, &dir_attr); | 492 | nfs_post_op_update_inode(dir, res.dir_attr); |
494 | nfs_post_op_update_inode(inode, &fattr); | 493 | nfs_post_op_update_inode(inode, res.fattr); |
494 | out: | ||
495 | nfs_free_fattr(res.dir_attr); | ||
496 | nfs_free_fattr(res.fattr); | ||
495 | dprintk("NFS reply link: %d\n", status); | 497 | dprintk("NFS reply link: %d\n", status); |
496 | return status; | 498 | return status; |
497 | } | 499 | } |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 14cde99d8a60..0ffd4cfd3b1f 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -2707,28 +2707,30 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, struct qstr * | |||
2707 | .name = name, | 2707 | .name = name, |
2708 | .bitmask = server->attr_bitmask, | 2708 | .bitmask = server->attr_bitmask, |
2709 | }; | 2709 | }; |
2710 | struct nfs_fattr fattr, dir_attr; | ||
2711 | struct nfs4_link_res res = { | 2710 | struct nfs4_link_res res = { |
2712 | .server = server, | 2711 | .server = server, |
2713 | .fattr = &fattr, | ||
2714 | .dir_attr = &dir_attr, | ||
2715 | }; | 2712 | }; |
2716 | struct rpc_message msg = { | 2713 | struct rpc_message msg = { |
2717 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK], | 2714 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LINK], |
2718 | .rpc_argp = &arg, | 2715 | .rpc_argp = &arg, |
2719 | .rpc_resp = &res, | 2716 | .rpc_resp = &res, |
2720 | }; | 2717 | }; |
2721 | int status; | 2718 | int status = -ENOMEM; |
2719 | |||
2720 | res.fattr = nfs_alloc_fattr(); | ||
2721 | res.dir_attr = nfs_alloc_fattr(); | ||
2722 | if (res.fattr == NULL || res.dir_attr == NULL) | ||
2723 | goto out; | ||
2722 | 2724 | ||
2723 | nfs_fattr_init(res.fattr); | ||
2724 | nfs_fattr_init(res.dir_attr); | ||
2725 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); | 2725 | status = nfs4_call_sync(server, &msg, &arg, &res, 1); |
2726 | if (!status) { | 2726 | if (!status) { |
2727 | update_changeattr(dir, &res.cinfo); | 2727 | update_changeattr(dir, &res.cinfo); |
2728 | nfs_post_op_update_inode(dir, res.dir_attr); | 2728 | nfs_post_op_update_inode(dir, res.dir_attr); |
2729 | nfs_post_op_update_inode(inode, res.fattr); | 2729 | nfs_post_op_update_inode(inode, res.fattr); |
2730 | } | 2730 | } |
2731 | 2731 | out: | |
2732 | nfs_free_fattr(res.dir_attr); | ||
2733 | nfs_free_fattr(res.fattr); | ||
2732 | return status; | 2734 | return status; |
2733 | } | 2735 | } |
2734 | 2736 | ||