Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223049
b: refs/heads/master
c: 47c716c
h: refs/heads/master
i:
  223047: fd156af
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Dec 7, 2010
1 parent 5a04e85 commit cdae237
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 18fb5fe40ce7f789b5cfc3aa81ff1e6175b0a5be
refs/heads/master: 47c716cbf638a16583441d78be3fc24345eab636
47 changes: 17 additions & 30 deletions trunk/fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page)
goto out;
array->last_cookie = entry->cookie;
array->size++;
if (entry->eof == 1)
if (entry->eof != 0)
array->eof_index = array->size;
out:
nfs_readdir_release_array(page);
Expand Down Expand Up @@ -311,27 +311,22 @@ int nfs_readdir_search_for_cookie(struct nfs_cache_array *array, nfs_readdir_des
for (i = 0; i < array->size; i++) {
if (array->array[i].cookie == *desc->dir_cookie) {
desc->cache_entry_index = i;
status = 0;
goto out;
return 0;
}
}
if (i == array->eof_index) {
if (array->eof_index >= 0) {
status = -EBADCOOKIE;
if (*desc->dir_cookie == array->last_cookie)
desc->eof = 1;
}
out:
return status;
}

static
int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
{
struct nfs_cache_array *array;
int status = -EBADCOOKIE;

if (desc->dir_cookie == NULL)
goto out;
int status;

array = nfs_readdir_get_array(desc->page);
if (IS_ERR(array)) {
Expand All @@ -344,8 +339,10 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
else
status = nfs_readdir_search_for_cookie(array, desc);

if (status == -EAGAIN)
if (status == -EAGAIN) {
desc->last_cookie = array->last_cookie;
desc->page_index++;
}
nfs_readdir_release_array(desc->page);
out:
return status;
Expand Down Expand Up @@ -492,15 +489,15 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en

count++;

if (desc->plus == 1)
if (desc->plus != 0)
nfs_prime_dcache(desc->file->f_path.dentry, entry);

status = nfs_readdir_add_to_array(entry, page);
if (status != 0)
break;
} while (!entry->eof);

if (count == 0 || (status == -EBADCOOKIE && entry->eof == 1)) {
if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) {
array = nfs_readdir_get_array(page);
if (!IS_ERR(array)) {
array->eof_index = array->size;
Expand Down Expand Up @@ -664,9 +661,8 @@ int find_cache_page(nfs_readdir_descriptor_t *desc)
return PTR_ERR(desc->page);

res = nfs_readdir_search_array(desc);
if (res == 0)
return 0;
cache_page_release(desc);
if (res != 0)
cache_page_release(desc);
return res;
}

Expand All @@ -680,20 +676,12 @@ int readdir_search_pagecache(nfs_readdir_descriptor_t *desc)
desc->current_index = 0;
desc->last_cookie = 0;
}
while (1) {
do {
res = find_cache_page(desc);
if (res != -EAGAIN)
break;
desc->page_index++;
}
} while (res == -EAGAIN);
return res;
}

static inline unsigned int dt_type(struct inode *inode)
{
return (inode->i_mode >> 12) & 15;
}

/*
* Once we've found the start of the dirent within a page: fill 'er up...
*/
Expand Down Expand Up @@ -723,13 +711,12 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent,
break;
}
file->f_pos++;
desc->cache_entry_index = i;
if (i < (array->size-1))
*desc->dir_cookie = array->array[i+1].cookie;
else
*desc->dir_cookie = array->last_cookie;
}
if (i == array->eof_index)
if (array->eof_index >= 0)
desc->eof = 1;

nfs_readdir_release_array(desc->page);
Expand Down Expand Up @@ -798,7 +785,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
struct inode *inode = dentry->d_inode;
nfs_readdir_descriptor_t my_desc,
*desc = &my_desc;
int res = -ENOMEM;
int res;

dfprintk(FILE, "NFS: readdir(%s/%s) starting at cookie %llu\n",
dentry->d_parent->d_name.name, dentry->d_name.name,
Expand All @@ -823,7 +810,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (res < 0)
goto out;

while (desc->eof != 1) {
do {
res = readdir_search_pagecache(desc);

if (res == -EBADCOOKIE) {
Expand Down Expand Up @@ -851,7 +838,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
res = nfs_do_filldir(desc, dirent, filldir);
if (res < 0)
break;
}
} while (!desc->eof);
out:
nfs_unblock_sillyrename(dentry);
if (res > 0)
Expand Down

0 comments on commit cdae237

Please sign in to comment.