Commit 9c3f4d98 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Reduce use of uncached readdir

When reading a very large directory, we want to try to keep the page
cache up to date if doing so is inexpensive. With the change to allow
readdir to continue reading even when the cache is incomplete, we no
longer need to fall back to uncached readdir in order to scale to large
directories.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 9ff89c25
......@@ -999,28 +999,11 @@ static int find_and_lock_cache_page(struct nfs_readdir_descriptor *desc)
return res;
}
static bool nfs_readdir_dont_search_cache(struct nfs_readdir_descriptor *desc)
{
struct address_space *mapping = desc->file->f_mapping;
struct inode *dir = file_inode(desc->file);
unsigned int dtsize = NFS_SERVER(dir)->dtsize;
loff_t size = i_size_read(dir);
/*
* Default to uncached readdir if the page cache is empty, and
* we're looking for a non-zero cookie in a large directory.
*/
return desc->dir_cookie != 0 && mapping->nrpages == 0 && size > dtsize;
}
/* Search for desc->dir_cookie from the beginning of the page cache */
static int readdir_search_pagecache(struct nfs_readdir_descriptor *desc)
{
int res;
if (nfs_readdir_dont_search_cache(desc))
return -EBADCOOKIE;
do {
if (desc->page_index == 0) {
desc->current_index = 0;
......@@ -1273,10 +1256,10 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int whence)
}
if (offset != filp->f_pos) {
filp->f_pos = offset;
if (!nfs_readdir_use_cookie(filp)) {
dir_ctx->page_index = 0;
if (!nfs_readdir_use_cookie(filp))
dir_ctx->dir_cookie = 0;
dir_ctx->page_index = 0;
} else
else
dir_ctx->dir_cookie = offset;
if (offset == 0)
memset(dir_ctx->verf, 0, sizeof(dir_ctx->verf));
......
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