Commit 0795bf83 authored by Fabian Frederick's avatar Fabian Frederick Committed by Trond Myklebust

nfs: use kmap/kunmap directly

This patch removes useless nfs_readdir_get_array() and
nfs_readdir_release_array() as suggested by Trond Myklebust

nfs_readdir() calls nfs_revalidate_mapping() before
readdir_search_pagecache() , nfs_do_filldir(), uncached_readdir()
so mapping should be correct.

While kmap() can't fail, all subsequent error checks were removed
as well as unused labels.
Signed-off-by: default avatarFabian Frederick <fabf@skynet.be>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 59b86d85
...@@ -169,27 +169,6 @@ typedef struct { ...@@ -169,27 +169,6 @@ typedef struct {
unsigned int eof:1; unsigned int eof:1;
} nfs_readdir_descriptor_t; } nfs_readdir_descriptor_t;
/*
* The caller is responsible for calling nfs_readdir_release_array(page)
*/
static
struct nfs_cache_array *nfs_readdir_get_array(struct page *page)
{
void *ptr;
if (page == NULL)
return ERR_PTR(-EIO);
ptr = kmap(page);
if (ptr == NULL)
return ERR_PTR(-ENOMEM);
return ptr;
}
static
void nfs_readdir_release_array(struct page *page)
{
kunmap(page);
}
/* /*
* we are freeing strings created by nfs_add_to_readdir_array() * we are freeing strings created by nfs_add_to_readdir_array()
*/ */
...@@ -229,13 +208,10 @@ int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int le ...@@ -229,13 +208,10 @@ int nfs_readdir_make_qstr(struct qstr *string, const char *name, unsigned int le
static static
int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page)
{ {
struct nfs_cache_array *array = nfs_readdir_get_array(page); struct nfs_cache_array *array = kmap(page);
struct nfs_cache_array_entry *cache_entry; struct nfs_cache_array_entry *cache_entry;
int ret; int ret;
if (IS_ERR(array))
return PTR_ERR(array);
cache_entry = &array->array[array->size]; cache_entry = &array->array[array->size];
/* Check that this entry lies within the page bounds */ /* Check that this entry lies within the page bounds */
...@@ -254,7 +230,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page) ...@@ -254,7 +230,7 @@ int nfs_readdir_add_to_array(struct nfs_entry *entry, struct page *page)
if (entry->eof != 0) if (entry->eof != 0)
array->eof_index = array->size; array->eof_index = array->size;
out: out:
nfs_readdir_release_array(page); kunmap(page);
return ret; return ret;
} }
...@@ -343,11 +319,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) ...@@ -343,11 +319,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
struct nfs_cache_array *array; struct nfs_cache_array *array;
int status; int status;
array = nfs_readdir_get_array(desc->page); array = kmap(desc->page);
if (IS_ERR(array)) {
status = PTR_ERR(array);
goto out;
}
if (*desc->dir_cookie == 0) if (*desc->dir_cookie == 0)
status = nfs_readdir_search_for_pos(array, desc); status = nfs_readdir_search_for_pos(array, desc);
...@@ -359,8 +331,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc) ...@@ -359,8 +331,7 @@ int nfs_readdir_search_array(nfs_readdir_descriptor_t *desc)
desc->current_index += array->size; desc->current_index += array->size;
desc->page_index++; desc->page_index++;
} }
nfs_readdir_release_array(desc->page); kunmap(desc->page);
out:
return status; return status;
} }
...@@ -596,13 +567,10 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en ...@@ -596,13 +567,10 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en
out_nopages: out_nopages:
if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) { if (count == 0 || (status == -EBADCOOKIE && entry->eof != 0)) {
array = nfs_readdir_get_array(page); array = kmap(page);
if (!IS_ERR(array)) { array->eof_index = array->size;
array->eof_index = array->size; status = 0;
status = 0; kunmap(page);
nfs_readdir_release_array(page);
} else
status = PTR_ERR(array);
} }
put_page(scratch); put_page(scratch);
...@@ -664,11 +632,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, ...@@ -664,11 +632,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
goto out; goto out;
} }
array = nfs_readdir_get_array(page); array = kmap(page);
if (IS_ERR(array)) {
status = PTR_ERR(array);
goto out_label_free;
}
memset(array, 0, sizeof(struct nfs_cache_array)); memset(array, 0, sizeof(struct nfs_cache_array));
array->eof_index = -1; array->eof_index = -1;
...@@ -692,8 +656,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page, ...@@ -692,8 +656,7 @@ int nfs_readdir_xdr_to_array(nfs_readdir_descriptor_t *desc, struct page *page,
nfs_readdir_free_pages(pages, array_size); nfs_readdir_free_pages(pages, array_size);
out_release_array: out_release_array:
nfs_readdir_release_array(page); kunmap(page);
out_label_free:
nfs4_label_free(entry.label); nfs4_label_free(entry.label);
out: out:
nfs_free_fattr(entry.fattr); nfs_free_fattr(entry.fattr);
...@@ -791,12 +754,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) ...@@ -791,12 +754,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc)
struct nfs_cache_array *array = NULL; struct nfs_cache_array *array = NULL;
struct nfs_open_dir_context *ctx = file->private_data; struct nfs_open_dir_context *ctx = file->private_data;
array = nfs_readdir_get_array(desc->page); array = kmap(desc->page);
if (IS_ERR(array)) {
res = PTR_ERR(array);
goto out;
}
for (i = desc->cache_entry_index; i < array->size; i++) { for (i = desc->cache_entry_index; i < array->size; i++) {
struct nfs_cache_array_entry *ent; struct nfs_cache_array_entry *ent;
...@@ -817,8 +775,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc) ...@@ -817,8 +775,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc)
if (array->eof_index >= 0) if (array->eof_index >= 0)
desc->eof = 1; desc->eof = 1;
nfs_readdir_release_array(desc->page); kunmap(desc->page);
out:
cache_page_release(desc); cache_page_release(desc);
dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n", dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @ cookie %Lu; returning = %d\n",
(unsigned long long)*desc->dir_cookie, res); (unsigned long long)*desc->dir_cookie, res);
......
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