Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] NFS: nfs_prime_dcache() needs fh to be set.
@ 2015-02-20 21:02 NeilBrown
  0 siblings, 0 replies; only message in thread
From: NeilBrown @ 2015-02-20 21:02 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: NFS, Nix, J. Bruce Fields

[-- 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 --]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-20 21:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-20 21:02 [PATCH] NFS: nfs_prime_dcache() needs fh to be set NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox