diff mbox

NFS: nfs_prime_dcache() needs fh to be set.

Message ID 20150221080248.0a487903@notabene.brown (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Feb. 20, 2015, 9:02 p.m. UTC
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 mbox

Patch

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);