Linux NFS development
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: NFS <linux-nfs@vger.kernel.org>, Nix <nix@esperi.org.uk>,
	"J. Bruce Fields" <bfields@fieldses.org>
Subject: [PATCH] NFS: nfs_prime_dcache() needs fh to be set.
Date: Sat, 21 Feb 2015 08:02:48 +1100	[thread overview]
Message-ID: <20150221080248.0a487903@notabene.brown> (raw)

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


In some circumstances, READDIRPLUS does not return a filehandle.
A particular example is that the Linux NFSv3 server does not return a
filehandle for directories that are mounted on.

When that happens, we mustn't call nfs_prime_cache, as it will assume
that the filehandle has changed and will invalidate the dentry.  This
will unmount any filesystem mounted at or below that point.

This bug has been present since 2.6.37 when commit d39ab9de3b80da
introduced nfs_prime_dcache.
It has become easier to trigger since commit 311324ad17136
in Linux 3.15 increased the usage of READDIRPLUS on directories that
were already largely in cache.

Note that if the server actually returns a different file handle
for a mounted-on directory, that will still force an unmount.
Possibly Linux should refuse to mount anything on a directory which
has a 'FH_VOLATILE_ANY' file handle.

Reported-and-tested-by: Nix <nix@esperi.org.uk>
Signed-off-by: NeilBrown <neilb@suse.de>
Fixes: d39ab9de3b80da5835049b1c3b49da4e84e01c07
Cc: stable@vger.kernel.org (v2.6.27+)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 9b0c55cb2a2e..43e29e3e3697 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -541,7 +541,7 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en
 
 		count++;
 
-		if (desc->plus != 0)
+		if (desc->plus != 0 && entry->fh->size)
 			nfs_prime_dcache(desc->file->f_path.dentry, entry);
 
 		status = nfs_readdir_add_to_array(entry, page);

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

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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150221080248.0a487903@notabene.brown \
    --to=neilb@suse.de \
    --cc=bfields@fieldses.org \
    --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