提交 aa49b4cf 编写于 作者: T Trond Myklebust

NFS: Reduce stack footprint of nfs_readdir()

Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 011fff72
...@@ -530,9 +530,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -530,9 +530,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
nfs_readdir_descriptor_t my_desc, nfs_readdir_descriptor_t my_desc,
*desc = &my_desc; *desc = &my_desc;
struct nfs_entry my_entry; struct nfs_entry my_entry;
struct nfs_fh fh; int res = -ENOMEM;
struct nfs_fattr fattr;
long res;
dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n", dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n",
dentry->d_parent->d_name.name, dentry->d_name.name, dentry->d_parent->d_name.name, dentry->d_name.name,
...@@ -554,9 +552,11 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -554,9 +552,11 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
my_entry.cookie = my_entry.prev_cookie = 0; my_entry.cookie = my_entry.prev_cookie = 0;
my_entry.eof = 0; my_entry.eof = 0;
my_entry.fh = &fh; my_entry.fh = nfs_alloc_fhandle();
my_entry.fattr = &fattr; my_entry.fattr = nfs_alloc_fattr();
nfs_fattr_init(&fattr); if (my_entry.fh == NULL || my_entry.fattr == NULL)
goto out_alloc_failed;
desc->entry = &my_entry; desc->entry = &my_entry;
nfs_block_sillyrename(dentry); nfs_block_sillyrename(dentry);
...@@ -598,7 +598,10 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -598,7 +598,10 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
nfs_unblock_sillyrename(dentry); nfs_unblock_sillyrename(dentry);
if (res > 0) if (res > 0)
res = 0; res = 0;
dfprintk(FILE, "NFS: readdir(%s/%s) returns %ld\n", out_alloc_failed:
nfs_free_fattr(my_entry.fattr);
nfs_free_fhandle(my_entry.fh);
dfprintk(FILE, "NFS: readdir(%s/%s) returns %d\n",
dentry->d_parent->d_name.name, dentry->d_name.name, dentry->d_parent->d_name.name, dentry->d_name.name,
res); res);
return res; return res;
......
...@@ -597,7 +597,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, ...@@ -597,7 +597,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
u64 cookie, struct page *page, unsigned int count, int plus) u64 cookie, struct page *page, unsigned int count, int plus)
{ {
struct inode *dir = dentry->d_inode; struct inode *dir = dentry->d_inode;
struct nfs_fattr dir_attr;
__be32 *verf = NFS_COOKIEVERF(dir); __be32 *verf = NFS_COOKIEVERF(dir);
struct nfs3_readdirargs arg = { struct nfs3_readdirargs arg = {
.fh = NFS_FH(dir), .fh = NFS_FH(dir),
...@@ -608,7 +607,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, ...@@ -608,7 +607,6 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
.pages = &page .pages = &page
}; };
struct nfs3_readdirres res = { struct nfs3_readdirres res = {
.dir_attr = &dir_attr,
.verf = verf, .verf = verf,
.plus = plus .plus = plus
}; };
...@@ -618,7 +616,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, ...@@ -618,7 +616,7 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred .rpc_cred = cred
}; };
int status; int status = -ENOMEM;
if (plus) if (plus)
msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS]; msg.rpc_proc = &nfs3_procedures[NFS3PROC_READDIRPLUS];
...@@ -626,12 +624,17 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, ...@@ -626,12 +624,17 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
dprintk("NFS call readdir%s %d\n", dprintk("NFS call readdir%s %d\n",
plus? "plus" : "", (unsigned int) cookie); plus? "plus" : "", (unsigned int) cookie);
nfs_fattr_init(&dir_attr); res.dir_attr = nfs_alloc_fattr();
if (res.dir_attr == NULL)
goto out;
status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
nfs_invalidate_atime(dir); nfs_invalidate_atime(dir);
nfs_refresh_inode(dir, res.dir_attr);
nfs_refresh_inode(dir, &dir_attr); nfs_free_fattr(res.dir_attr);
out:
dprintk("NFS reply readdir: %d\n", status); dprintk("NFS reply readdir: %d\n", status);
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册