Skip to content

Commit e47a62d

Browse files
author
Trond Myklebust
committed
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 <[email protected]>
1 parent 648a454 commit e47a62d

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
@@ -252,6 +252,11 @@ static void nfs_readdir_page_array_free(struct page *page)
252252
}
253253
}
254254

255+
static u64 nfs_readdir_array_index_cookie(struct nfs_cache_array *array)
256+
{
257+
return array->size == 0 ? array->last_cookie : array->array[0].cookie;
258+
}
259+
255260
static void nfs_readdir_array_set_eof(struct nfs_cache_array *array)
256261
{
257262
array->page_is_eof = 1;
@@ -369,7 +374,7 @@ static bool nfs_readdir_page_validate(struct page *page, u64 last_cookie,
369374

370375
if (array->change_attr != change_attr)
371376
ret = false;
372-
if (array->size > 0 && array->array[0].cookie != last_cookie)
377+
if (nfs_readdir_array_index_cookie(array) != last_cookie)
373378
ret = false;
374379
kunmap_atomic(array);
375380
return ret;
@@ -480,7 +485,7 @@ static void nfs_readdir_seek_next_array(struct nfs_cache_array *array,
480485
desc->cache_entry_index = 0;
481486
desc->page_index++;
482487
} else
483-
desc->last_cookie = array->array[0].cookie;
488+
desc->last_cookie = nfs_readdir_array_index_cookie(array);
484489
}
485490

486491
static void nfs_readdir_rewind_search(struct nfs_readdir_descriptor *desc)

0 commit comments

Comments
 (0)