diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c index 549369739d80..dc30b4582234 100644 --- a/drivers/staging/lustre/lustre/llite/dcache.c +++ b/drivers/staging/lustre/lustre/llite/dcache.c @@ -74,6 +74,12 @@ static void ll_release(struct dentry *de) * an AST before calling d_revalidate_it(). The dentry still exists (marked * INVALID) so d_lookup() matches it, but we have no lock on it (so * lock_match() fails) and we spin around real_lookup(). + * + * This race doesn't apply to lookups in d_alloc_parallel(), and for + * those we want to ensure that only one dentry with a given name is + * in ll_lookup_nd() at a time. So allow invalid dentries to match + * while d_in_lookup(). We will be called again when the lookup + * completes, and can give a different answer then. */ static int ll_dcompare(const struct dentry *dentry, unsigned int len, const char *str, @@ -93,6 +99,10 @@ static int ll_dcompare(const struct dentry *dentry, if (d_mountpoint((struct dentry *)dentry)) return 0; + /* ensure exclusion against parallel lookup of the same name */ + if (d_in_lookup((struct dentry*)dentry)) + return 0; + if (d_lustre_invalid(dentry)) return 1;