NFS: Reduce stack footprint of nfs_readdir()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
Родитель
011fff7239
Коммит
aa49b4cf7d
17
fs/nfs/dir.c
17
fs/nfs/dir.c
|
@ -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)
|
||||||
|
|
||||||
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 @@ out:
|
||||||
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,
|
||||||
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,
|
||||||
.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,
|
||||||
.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,
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче