Commit 0adf85b4 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Optimise away the previous cookie field

Replace the 'previous cookie' field in struct nfs_entry with the
array->last_cookie.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent b0365ccb
...@@ -301,19 +301,20 @@ static int nfs_readdir_array_can_expand(struct nfs_cache_array *array) ...@@ -301,19 +301,20 @@ static int nfs_readdir_array_can_expand(struct nfs_cache_array *array)
return 0; return 0;
} }
static static int nfs_readdir_page_array_append(struct page *page,
int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) const struct nfs_entry *entry,
u64 *cookie)
{ {
struct nfs_cache_array *array; struct nfs_cache_array *array;
struct nfs_cache_array_entry *cache_entry; struct nfs_cache_array_entry *cache_entry;
const char *name; const char *name;
int ret; int ret = -ENOMEM;
name = nfs_readdir_copy_name(entry->name, entry->len); name = nfs_readdir_copy_name(entry->name, entry->len);
if (!name)
return -ENOMEM;
array = kmap_atomic(page); array = kmap_atomic(page);
if (!name)
goto out;
ret = nfs_readdir_array_can_expand(array); ret = nfs_readdir_array_can_expand(array);
if (ret) { if (ret) {
kfree(name); kfree(name);
...@@ -321,7 +322,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) ...@@ -321,7 +322,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page)
} }
cache_entry = &array->array[array->size]; cache_entry = &array->array[array->size];
cache_entry->cookie = entry->prev_cookie; cache_entry->cookie = array->last_cookie;
cache_entry->ino = entry->ino; cache_entry->ino = entry->ino;
cache_entry->d_type = entry->d_type; cache_entry->d_type = entry->d_type;
cache_entry->name_len = entry->len; cache_entry->name_len = entry->len;
...@@ -333,6 +334,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) ...@@ -333,6 +334,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page)
if (entry->eof != 0) if (entry->eof != 0)
nfs_readdir_array_set_eof(array); nfs_readdir_array_set_eof(array);
out: out:
*cookie = array->last_cookie;
kunmap_atomic(array); kunmap_atomic(array);
return ret; return ret;
} }
...@@ -798,6 +800,7 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc, ...@@ -798,6 +800,7 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc,
struct xdr_stream stream; struct xdr_stream stream;
struct xdr_buf buf; struct xdr_buf buf;
struct page *scratch, *new, *page = *arrays; struct page *scratch, *new, *page = *arrays;
u64 cookie;
int status; int status;
scratch = alloc_page(GFP_KERNEL); scratch = alloc_page(GFP_KERNEL);
...@@ -819,22 +822,21 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc, ...@@ -819,22 +822,21 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc,
nfs_prime_dcache(file_dentry(desc->file), entry, nfs_prime_dcache(file_dentry(desc->file), entry,
desc->dir_verifier); desc->dir_verifier);
status = nfs_readdir_add_to_array(entry, page); status = nfs_readdir_page_array_append(page, entry, &cookie);
if (status != -ENOSPC) if (status != -ENOSPC)
continue; continue;
if (page->mapping != mapping) { if (page->mapping != mapping) {
if (!--narrays) if (!--narrays)
break; break;
new = nfs_readdir_page_array_alloc(entry->prev_cookie, new = nfs_readdir_page_array_alloc(cookie, GFP_KERNEL);
GFP_KERNEL);
if (!new) if (!new)
break; break;
arrays++; arrays++;
*arrays = page = new; *arrays = page = new;
} else { } else {
new = nfs_readdir_page_get_next( new = nfs_readdir_page_get_next(mapping, cookie,
mapping, entry->prev_cookie, change_attr); change_attr);
if (!new) if (!new)
break; break;
if (page != *arrays) if (page != *arrays)
...@@ -842,7 +844,7 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc, ...@@ -842,7 +844,7 @@ static int nfs_readdir_page_filler(struct nfs_readdir_descriptor *desc,
page = new; page = new;
} }
desc->page_index_max++; desc->page_index_max++;
status = nfs_readdir_add_to_array(entry, page); status = nfs_readdir_page_array_append(page, entry, &cookie);
} while (!status && !entry->eof); } while (!status && !entry->eof);
switch (status) { switch (status) {
......
...@@ -955,7 +955,6 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, ...@@ -955,7 +955,6 @@ int nfs2_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
* The type (size and byte order) of nfscookie isn't defined in * The type (size and byte order) of nfscookie isn't defined in
* RFC 1094. This implementation assumes that it's an XDR uint32. * RFC 1094. This implementation assumes that it's an XDR uint32.
*/ */
entry->prev_cookie = entry->cookie;
p = xdr_inline_decode(xdr, 4); p = xdr_inline_decode(xdr, 4);
if (unlikely(!p)) if (unlikely(!p))
return -EAGAIN; return -EAGAIN;
......
...@@ -2024,7 +2024,6 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, ...@@ -2024,7 +2024,6 @@ int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
zero_nfs_fh3(entry->fh); zero_nfs_fh3(entry->fh);
} }
entry->prev_cookie = entry->cookie;
entry->cookie = new_cookie; entry->cookie = new_cookie;
return 0; return 0;
......
...@@ -7508,7 +7508,6 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, ...@@ -7508,7 +7508,6 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE) if (entry->fattr->valid & NFS_ATTR_FATTR_TYPE)
entry->d_type = nfs_umode_to_dtype(entry->fattr->mode); entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
entry->prev_cookie = entry->cookie;
entry->cookie = new_cookie; entry->cookie = new_cookie;
return 0; return 0;
......
...@@ -745,8 +745,7 @@ struct nfs_auth_info { ...@@ -745,8 +745,7 @@ struct nfs_auth_info {
*/ */
struct nfs_entry { struct nfs_entry {
__u64 ino; __u64 ino;
__u64 cookie, __u64 cookie;
prev_cookie;
const char * name; const char * name;
unsigned int len; unsigned int len;
int eof; int eof;
......
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