From: Trond Myklebust <trondmy@hammerspace.com>
To: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"bcodding@redhat.com" <bcodding@redhat.com>
Subject: Re: [PATCH v1 04/10] NFS: Keep the readdir pagecache cursor updated
Date: Thu, 21 Jan 2021 20:00:53 +0000 [thread overview]
Message-ID: <76fd114e0f4018cf7e00f565759e10acd1f0ba92.camel@hammerspace.com> (raw)
In-Reply-To: <f803021382040dba38ce8414ed1db8e400c0cc49.1611160121.git.bcodding@redhat.com>
On Wed, 2021-01-20 at 11:59 -0500, Benjamin Coddington wrote:
> Whenever we successfully locate our dir_cookie within the pagecache,
> or
> finish emitting entries to userspace, update the pagecache cursor.
> These
> updates provide marker points to validate pagecache pages in a future
> patch.
How isn't this going to end up subject to the exact same problem that
Dave Wysochanski's patchset had?
>
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
> fs/nfs/dir.c | 29 +++++++++++++++++++++++++----
> 1 file changed, 25 insertions(+), 4 deletions(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 6626aff9f54d..7f6c84c8a412 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -150,6 +150,10 @@ struct nfs_cache_array {
> struct nfs_cache_array_entry array[];
> };
>
> +static const int cache_entries_per_page =
> + (PAGE_SIZE - sizeof(struct nfs_cache_array)) /
> + sizeof(struct nfs_cache_array_entry);
> +
> struct nfs_readdir_descriptor {
> struct file *file;
> struct page *page;
> @@ -251,6 +255,21 @@ static bool nfs_readdir_array_is_full(struct
> nfs_cache_array *array)
> return array->page_full;
> }
>
> +static void nfs_readdir_set_cursor(struct nfs_readdir_descriptor
> *desc, int index)
> +{
> + desc->pgc.entry_index = index;
> + desc->pgc.index_cookie = desc->dir_cookie;
> +}
> +
> +static void nfs_readdir_cursor_next(struct nfs_dir_page_cursor *pgc,
> u64 cookie)
> +{
> + pgc->index_cookie = cookie;
> + if (++pgc->entry_index == cache_entries_per_page) {
> + pgc->entry_index = 0;
> + pgc->page_index++;
> + }
> +}
> +
> /*
> * the caller is responsible for freeing qstr.name
> * when called by nfs_readdir_add_to_array, the strings will be
> freed in
> @@ -424,7 +443,7 @@ static int nfs_readdir_search_for_pos(struct
> nfs_cache_array *array,
>
> index = (unsigned int)diff;
> desc->dir_cookie = array->array[index].cookie;
> - desc->pgc.entry_index = index;
> + nfs_readdir_set_cursor(desc, index);
> return 0;
> out_eof:
> desc->eof = true;
> @@ -492,7 +511,7 @@ static int nfs_readdir_search_for_cookie(struct
> nfs_cache_array *array,
> else
> desc->ctx->pos = new_pos;
> desc->prev_index = new_pos;
> - desc->pgc.entry_index = i;
> + nfs_readdir_set_cursor(desc, i);
> return 0;
> }
> }
> @@ -519,9 +538,9 @@ static int nfs_readdir_search_array(struct
> nfs_readdir_descriptor *desc)
> status = nfs_readdir_search_for_cookie(array, desc);
>
> if (status == -EAGAIN) {
> - desc->pgc.index_cookie = array->last_cookie;
> + desc->pgc.entry_index = array->size - 1;
> + nfs_readdir_cursor_next(&desc->pgc, array-
> >last_cookie);
> desc->current_index += array->size;
> - desc->pgc.page_index++;
> }
> kunmap_atomic(array);
> return status;
> @@ -1035,6 +1054,8 @@ static void nfs_do_filldir(struct
> nfs_readdir_descriptor *desc)
> desc->eof = true;
>
> kunmap(desc->page);
> + desc->pgc.entry_index = i-1;
> + nfs_readdir_cursor_next(&desc->pgc, desc->dir_cookie);
> dfprintk(DIRCACHE, "NFS: nfs_do_filldir() filling ended @
> cookie %llu\n",
> (unsigned long long)desc->dir_cookie);
> }
--
Trond Myklebust
CTO, Hammerspace Inc
4984 El Camino Real, Suite 208
Los Altos, CA 94022
www.hammer.space
next prev parent reply other threads:[~2021-01-21 20:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 16:59 [PATCH v1 00/10] NFS client readdir per-page validation Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 01/10] NFS: save the directory's change attribute on pagecache pages Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 02/10] NFSv4: Send GETATTR with READDIR Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 03/10] NFS: Add a struct to track readdir pagecache location Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 04/10] NFS: Keep the readdir pagecache cursor updated Benjamin Coddington
2021-01-21 20:00 ` Trond Myklebust [this message]
2021-01-21 20:11 ` Trond Myklebust
2021-01-22 0:21 ` Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 05/10] NFS: readdir per-page cache validation Benjamin Coddington
2021-01-20 20:08 ` kernel test robot
2021-01-20 16:59 ` [PATCH v1 06/10] NFS: stash the readdir pagecache cursor on the open directory context Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 07/10] NFS: Support headless readdir pagecache pages Benjamin Coddington
2021-01-21 17:24 ` Anna Schumaker
2021-01-21 17:57 ` Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 08/10] NFS: Reset pagecache cursor on llseek Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 09/10] NFS: Remove nfs_readdir_dont_search_cache() Benjamin Coddington
2021-01-20 16:59 ` [PATCH v1 10/10] NFS: Revalidate the directory pagecache on every nfs_readdir() Benjamin Coddington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=76fd114e0f4018cf7e00f565759e10acd1f0ba92.camel@hammerspace.com \
--to=trondmy@hammerspace.com \
--cc=bcodding@redhat.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox