Linux NFS development
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: linux-nfs@vger.kernel.org, Nix <nix@esperi.org.uk>
Subject: Re: [PATCH 3/3] NFS: Don't require a filehandle to refresh the inode in nfs_prime_dcache()
Date: Wed, 25 Feb 2015 08:53:18 +1100	[thread overview]
Message-ID: <20150225085318.2a714592@notabene.brown> (raw)
In-Reply-To: <1424736897-95767-3-git-send-email-trond.myklebust@primarydata.com>

[-- Attachment #1: Type: text/plain, Size: 2337 bytes --]

On Mon, 23 Feb 2015 19:14:57 -0500 Trond Myklebust
<trond.myklebust@primarydata.com> wrote:

> If the server does not return a valid set of attributes that we can
> use to either create a file or refresh the inode, then there is no
> value in calling nfs_prime_dcache().
> 
> However if we're just refreshing the inode using the attributes that
> the server returned, then it shouldn't matter whether or not we have
> a filehandle, as long as we check the fsid+fileid combination.
> 
> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> ---
>  fs/nfs/dir.c | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 0da617a61c0b..c19e16f0b2d0 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -408,14 +408,22 @@ static int xdr_decode(nfs_readdir_descriptor_t *desc,
>  	return 0;
>  }
>  
> +/* Match file and dirent using either filehandle or fileid
> + * Note: caller is responsible for checking the fsid
> + */
>  static
>  int nfs_same_file(struct dentry *dentry, struct nfs_entry *entry)
>  {
> +	struct nfs_inode *nfsi;
> +
>  	if (dentry->d_inode == NULL)
>  		goto different;
> -	if (nfs_compare_fh(entry->fh, NFS_FH(dentry->d_inode)) != 0)
> -		goto different;
> -	return 1;
> +
> +	nfsi = NFS_I(dentry->d_inode);
> +	if (entry->fattr->fileid == nfsi->fileid)
> +		return 1;
> +	if (nfs_compare_fh(entry->fh, &nfsi->fh) == 0)
> +		return 1;
>  different:
>  	return 0;
>  }
> @@ -469,6 +477,10 @@ void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry)
>  	struct inode *inode;
>  	int status;
>  
> +	if (!(entry->fattr->valid & NFS_ATTR_FATTR_FILEID))
> +		return;
> +	if (!(entry->fattr->valid & NFS_ATTR_FATTR_FSID))
> +		return;
>  	if (filename.name[0] == '.') {
>  		if (filename.len == 1)
>  			return;


I believe this will fix the observed problem.  This is partly because the
Linux NFSv3 server either returns both a filehandle and attributes, or
neither.

If a server happened to return postop attributes, but no filehandle, then the
"nfs_compare_fh()" would be a meaningless test.

I think you should abort nfs_prime_dcache if entry->fh->size is zero for
exactly the same reason that you abort if NFS_ATTR_FATTR_FSID is not set.

NeilBrown

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  reply	other threads:[~2015-02-24 21:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-24  0:14 [PATCH 1/3] NFS: Don't invalidate a submounted dentry in nfs_prime_dcache() Trond Myklebust
2015-02-24  0:14 ` [PATCH 2/3] NFSv3: Use the readdir fileid as the mounted-on-fileid Trond Myklebust
2015-02-24  0:14   ` [PATCH 3/3] NFS: Don't require a filehandle to refresh the inode in nfs_prime_dcache() Trond Myklebust
2015-02-24 21:53     ` NeilBrown [this message]
2015-02-24 21:46   ` [PATCH 2/3] NFSv3: Use the readdir fileid as the mounted-on-fileid NeilBrown
2015-02-24  3:09 ` [PATCH 1/3] NFS: Don't invalidate a submounted dentry in nfs_prime_dcache() Trond Myklebust
2015-02-24 21:49   ` NeilBrown
2015-02-25  0:17     ` Trond Myklebust
2015-02-24 21:44 ` NeilBrown
2015-03-12 23:15 ` Nix

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=20150225085318.2a714592@notabene.brown \
    --to=neilb@suse.de \
    --cc=linux-nfs@vger.kernel.org \
    --cc=nix@esperi.org.uk \
    --cc=trond.myklebust@primarydata.com \
    /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