Skip to contentSkip to conversation

NFS: nfs_prime_dcache() needs fh to be set.

PATCH New NeilBrown 1 participant 1 message Feb 20, 2015

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 NFS: nfs_prime_dcache() needs fh to be set.

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 <[email protected]>
Fixes d39ab9de3b80da5835049b1c3b49da4e84e01c07
Cc [email protected] (v2.6.27+)
fs/nfs/dir.c +1 -1
index 9b0c55cb2a2e..43e29e3e3697 100644
@@ -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);