dect
/
linux-2.6
Archived
13
0
Fork 0

NFS: Reduce stack footprint of nfs3_proc_rename() and nfs4_proc_rename()

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Trond Myklebust 2010-04-16 16:22:49 -04:00
parent a3cba2aad9
commit 011fff7239
2 changed files with 22 additions and 17 deletions

View File

@ -432,7 +432,6 @@ static int
nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name, nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name,
struct inode *new_dir, struct qstr *new_name) struct inode *new_dir, struct qstr *new_name)
{ {
struct nfs_fattr old_dir_attr, new_dir_attr;
struct nfs3_renameargs arg = { struct nfs3_renameargs arg = {
.fromfh = NFS_FH(old_dir), .fromfh = NFS_FH(old_dir),
.fromname = old_name->name, .fromname = old_name->name,
@ -441,23 +440,27 @@ nfs3_proc_rename(struct inode *old_dir, struct qstr *old_name,
.toname = new_name->name, .toname = new_name->name,
.tolen = new_name->len .tolen = new_name->len
}; };
struct nfs3_renameres res = { struct nfs3_renameres res;
.fromattr = &old_dir_attr,
.toattr = &new_dir_attr
};
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs3_procedures[NFS3PROC_RENAME], .rpc_proc = &nfs3_procedures[NFS3PROC_RENAME],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
}; };
int status; int status = -ENOMEM;
dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name); dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name);
nfs_fattr_init(&old_dir_attr);
nfs_fattr_init(&new_dir_attr); res.fromattr = nfs_alloc_fattr();
res.toattr = nfs_alloc_fattr();
if (res.fromattr == NULL || res.toattr == NULL)
goto out;
status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0); status = rpc_call_sync(NFS_CLIENT(old_dir), &msg, 0);
nfs_post_op_update_inode(old_dir, &old_dir_attr); nfs_post_op_update_inode(old_dir, res.fromattr);
nfs_post_op_update_inode(new_dir, &new_dir_attr); nfs_post_op_update_inode(new_dir, res.toattr);
out:
nfs_free_fattr(res.toattr);
nfs_free_fattr(res.fromattr);
dprintk("NFS reply rename: %d\n", status); dprintk("NFS reply rename: %d\n", status);
return status; return status;
} }

View File

@ -2656,29 +2656,31 @@ static int _nfs4_proc_rename(struct inode *old_dir, struct qstr *old_name,
.new_name = new_name, .new_name = new_name,
.bitmask = server->attr_bitmask, .bitmask = server->attr_bitmask,
}; };
struct nfs_fattr old_fattr, new_fattr;
struct nfs4_rename_res res = { struct nfs4_rename_res res = {
.server = server, .server = server,
.old_fattr = &old_fattr,
.new_fattr = &new_fattr,
}; };
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME], .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME],
.rpc_argp = &arg, .rpc_argp = &arg,
.rpc_resp = &res, .rpc_resp = &res,
}; };
int status; int status = -ENOMEM;
nfs_fattr_init(res.old_fattr); res.old_fattr = nfs_alloc_fattr();
nfs_fattr_init(res.new_fattr); res.new_fattr = nfs_alloc_fattr();
status = nfs4_call_sync(server, &msg, &arg, &res, 1); if (res.old_fattr == NULL || res.new_fattr == NULL)
goto out;
status = nfs4_call_sync(server, &msg, &arg, &res, 1);
if (!status) { if (!status) {
update_changeattr(old_dir, &res.old_cinfo); update_changeattr(old_dir, &res.old_cinfo);
nfs_post_op_update_inode(old_dir, res.old_fattr); nfs_post_op_update_inode(old_dir, res.old_fattr);
update_changeattr(new_dir, &res.new_cinfo); update_changeattr(new_dir, &res.new_cinfo);
nfs_post_op_update_inode(new_dir, res.new_fattr); nfs_post_op_update_inode(new_dir, res.new_fattr);
} }
out:
nfs_free_fattr(res.new_fattr);
nfs_free_fattr(res.old_fattr);
return status; return status;
} }