Skip to content

Commit

Permalink
NFS: Ensure we use the correct cookie in nfs_readdir_xdr_filler
Browse files Browse the repository at this point in the history
We need to use the cookie from the previous array entry, not the
actual cookie that we are searching for (except for the case of
uncached_readdir).

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Dec 1, 2010
1 parent 22a5b56 commit 0aded70
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ typedef struct {
struct page *page;
unsigned long page_index;
u64 *dir_cookie;
u64 last_cookie;
loff_t current_index;
decode_dirent_t decode;

Expand Down Expand Up @@ -344,6 +345,8 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
else
status = nfs_readdir_search_for_cookie(array, desc);

if (status == -EAGAIN)
desc->last_cookie = array->last_cookie;
nfs_readdir_release_array(desc->page);
out:
return status;
Expand Down Expand Up @@ -563,7 +566,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
unsigned int array_size = ARRAY_SIZE(pages);

entry.prev_cookie = 0;
entry.cookie = *desc->dir_cookie;
entry.cookie = desc->last_cookie;
entry.eof = 0;
entry.fh = nfs_alloc_fhandle();
entry.fattr = nfs_alloc_fattr();
Expand Down Expand Up @@ -672,8 +675,10 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
{
int res;

if (desc->page_index == 0)
if (desc->page_index == 0) {
desc->current_index = 0;
desc->last_cookie = 0;
}
while (1) {
res = find_cache_page(desc);
if (res != -EAGAIN)
Expand Down Expand Up @@ -764,6 +769,7 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
}

desc->page_index = 0;
desc->last_cookie = *desc->dir_cookie;
desc->page = page;

status = nfs_readdir_xdr_to_array(desc, page, inode);
Expand Down

0 comments on commit 0aded70

Please sign in to comment.