summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@hammerspace.com>2022-03-22 09:11:44 -0400
committerTrond Myklebust <trond.myklebust@hammerspace.com>2022-03-22 15:52:55 -0400
commite47a62df29a0714cc2d5129516a3618337c84554 (patch)
tree468b8be51d92dda4c8707044bfc5836206f2311c
parent648a4548d622c4ae965058db1a6b5b95c062789a (diff)
NFS: Fix revalidation of empty readdir pages
If the page is empty, we need to check the array->last_cookie instead of the first entry. Add a helper for the cases where we care. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
-rw-r--r--fs/nfs/dir.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 17986c0019d4..bac4cf1a308e 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -252,6 +252,11 @@ static void nfs_readdir_page_array_free(struct page *page)
}
}
+static u64 nfs_readdir_array_index_cookie(struct nfs_cache_array *array)
+{
+ return array->size == 0 ? array->last_cookie : array->array[0].cookie;
+}
+
static void nfs_readdir_array_set_eof(struct nfs_cache_array *array)
{
array->page_is_eof = 1;
@@ -369,7 +374,7 @@ static bool nfs_readdir_page_validate(struct page *page, u64 last_cookie,
if (array->change_attr != change_attr)
ret = false;
- if (array->size > 0 && array->array[0].cookie != last_cookie)
+ if (nfs_readdir_array_index_cookie(array) != last_cookie)
ret = false;
kunmap_atomic(array);
return ret;
@@ -480,7 +485,7 @@ static void nfs_readdir_seek_next_array(struct nfs_cache_array *array,
desc->cache_entry_index = 0;
desc->page_index++;
} else
- desc->last_cookie = array->array[0].cookie;
+ desc->last_cookie = nfs_readdir_array_index_cookie(array);
}
static void nfs_readdir_rewind_search(struct nfs_readdir_descriptor *desc)