Skip to content

Commit 03414c3

Browse files
committed
NFS: Trigger the "ls -l" readdir heuristic sooner
jira LE-1907 Rebuild_History Non-Buildable kernel-rt-5.14.0-284.30.1.rt14.315.el9_2 commit-author Benjamin Coddington <[email protected]> commit 85aa8dd Since commit 1a34c8c ("NFS: Support larger readdir buffers") has updated dtsize, and with recent improvements to the READDIRPLUS helper heuristic, the heuristic may not trigger until many dentries are emitted to userspace. This will cause many thousands of GETATTR calls for "ls -l" when the directory's pagecache has already been populated. This manifests as poor performance for long directory listings after an initially fast "ls -l". Fix this by emitting only 17 entries for any first pass through the NFS directory's ->iterate_shared(), which allows userpace to prime the counters for the heuristic. Signed-off-by: Benjamin Coddington <[email protected]> Signed-off-by: Trond Myklebust <[email protected]> (cherry picked from commit 85aa8dd) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 4129cb6 commit 03414c3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/nfs/dir.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,8 @@ static int readdir_search_pagecache(struct nfs_readdir_descriptor *desc)
10691069
return res;
10701070
}
10711071

1072+
#define NFS_READDIR_CACHE_MISS_THRESHOLD (16UL)
1073+
10721074
/*
10731075
* Once we've found the start of the dirent within a page: fill 'er up...
10741076
*/
@@ -1078,6 +1080,7 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc,
10781080
struct file *file = desc->file;
10791081
struct nfs_cache_array *array;
10801082
unsigned int i;
1083+
bool first_emit = !desc->dir_cookie;
10811084

10821085
array = kmap(desc->page);
10831086
for (i = desc->cache_entry_index; i < array->size; i++) {
@@ -1101,6 +1104,10 @@ static void nfs_do_filldir(struct nfs_readdir_descriptor *desc,
11011104
desc->ctx->pos = desc->dir_cookie;
11021105
else
11031106
desc->ctx->pos++;
1107+
if (first_emit && i > NFS_READDIR_CACHE_MISS_THRESHOLD + 1) {
1108+
desc->eob = true;
1109+
break;
1110+
}
11041111
}
11051112
if (array->page_is_eof)
11061113
desc->eof = !desc->eob;
@@ -1182,8 +1189,6 @@ static int uncached_readdir(struct nfs_readdir_descriptor *desc)
11821189
return status;
11831190
}
11841191

1185-
#define NFS_READDIR_CACHE_MISS_THRESHOLD (16UL)
1186-
11871192
static bool nfs_readdir_handle_cache_misses(struct inode *inode,
11881193
struct nfs_readdir_descriptor *desc,
11891194
unsigned int cache_misses,

0 commit comments

Comments
 (0)