Commit 4fe70049 authored by Trond Myklebust's avatar Trond Myklebust Committed by Linus Torvalds

[PATCH] Support for cached lookups via readdirplus [1/6]

Cleanup for the readdirplus code. Make struct nfs_entry take pointers
to the filehandle and file attributes.
parent 4102986d
...@@ -333,7 +333,8 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent, ...@@ -333,7 +333,8 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
/* Reset read descriptor so it searches the page cache from /* Reset read descriptor so it searches the page cache from
* the start upon the next call to readdir_search_pagecache() */ * the start upon the next call to readdir_search_pagecache() */
desc->page_index = 0; desc->page_index = 0;
memset(desc->entry, 0, sizeof(*desc->entry)); desc->entry->cookie = desc->entry->prev_cookie = 0;
desc->entry->eof = 0;
out: out:
dfprintk(VFS, "NFS: uncached_readdir() returns %d\n", status); dfprintk(VFS, "NFS: uncached_readdir() returns %d\n", status);
return status; return status;
...@@ -352,6 +353,8 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -352,6 +353,8 @@ 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;
struct nfs_fattr fattr;
long res; long res;
lock_kernel(); lock_kernel();
...@@ -369,13 +372,17 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -369,13 +372,17 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
* itself. * itself.
*/ */
memset(desc, 0, sizeof(*desc)); memset(desc, 0, sizeof(*desc));
memset(&my_entry, 0, sizeof(my_entry));
desc->file = filp; desc->file = filp;
desc->target = filp->f_pos; desc->target = filp->f_pos;
desc->entry = &my_entry;
desc->decode = NFS_PROTO(inode)->decode_dirent; desc->decode = NFS_PROTO(inode)->decode_dirent;
my_entry.cookie = my_entry.prev_cookie = 0;
my_entry.eof = 0;
my_entry.fh = &fh;
my_entry.fattr = &fattr;
desc->entry = &my_entry;
while(!desc->entry->eof) { while(!desc->entry->eof) {
res = readdir_search_pagecache(desc); res = readdir_search_pagecache(desc);
if (res == -EBADCOOKIE) { if (res == -EBADCOOKIE) {
......
...@@ -603,21 +603,19 @@ nfs3_decode_dirent(u32 *p, struct nfs_entry *entry, int plus) ...@@ -603,21 +603,19 @@ nfs3_decode_dirent(u32 *p, struct nfs_entry *entry, int plus)
p = xdr_decode_hyper(p, &entry->cookie); p = xdr_decode_hyper(p, &entry->cookie);
if (plus) { if (plus) {
p = xdr_decode_post_op_attr(p, &entry->fattr); entry->fattr->valid = 0;
p = xdr_decode_post_op_attr(p, entry->fattr);
/* In fact, a post_op_fh3: */ /* In fact, a post_op_fh3: */
if (*p++) { if (*p++) {
p = xdr_decode_fhandle(p, &entry->fh); p = xdr_decode_fhandle(p, entry->fh);
/* Ugh -- server reply was truncated */ /* Ugh -- server reply was truncated */
if (p == NULL) { if (p == NULL) {
dprintk("NFS: FH truncated\n"); dprintk("NFS: FH truncated\n");
*entry = old; *entry = old;
return ERR_PTR(-EAGAIN); return ERR_PTR(-EAGAIN);
} }
} else { } else
/* If we don't get a file handle, the attrs memset((u8*)(entry->fh), 0, sizeof(*entry->fh));
* aren't worth a lot. */
entry->fattr.valid = 0;
}
} }
entry->eof = !p[0] && p[1]; entry->eof = !p[0] && p[1];
......
...@@ -109,8 +109,8 @@ struct nfs_entry { ...@@ -109,8 +109,8 @@ struct nfs_entry {
const char * name; const char * name;
unsigned int len; unsigned int len;
int eof; int eof;
struct nfs_fh fh; struct nfs_fh * fh;
struct nfs_fattr fattr; struct nfs_fattr * fattr;
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment