From: Bobi Jam Date: Wed, 28 Sep 2011 10:24:12 +0000 (+0800) Subject: LU-645 Avoid unnecessary dentry rehashing X-Git-Tag: v1_8_7_81_WC1~45 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=fa111106572c8206fb8b6477617bea4fc483a37d;p=fs%2Flustre-release.git LU-645 Avoid unnecessary dentry rehashing In patchless case the sequence __d_drop() then d_rehash_cond() creates race window if dentry is already hashed, in this case rehashing should be avoided. Change-Id: Ib891e7d2e5ae7efe19ef2ac0abb111e9f9681b7b Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/1435 Tested-by: Hudson Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Johann Lombardi --- diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 916b0ed..782047e 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -533,10 +533,8 @@ revalidate_finish: * dentry */ spin_lock(&ll_lookup_lock); spin_lock(&dcache_lock); - lock_dentry(de); - __d_drop(de); - unlock_dentry(de); - d_rehash_cond(de, 0); + if (d_unhashed(de)) + d_rehash_cond(de, 0); spin_unlock(&dcache_lock); spin_unlock(&ll_lookup_lock); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 87849b3..7f0c7e3 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -450,11 +450,9 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de) continue; dget_locked(dentry); - lock_dentry(dentry); - __d_drop(dentry); - unlock_dentry(dentry); ll_dops_init(dentry, 0, 1); - d_rehash_cond(dentry, 0); /* avoid taking dcache_lock inside */ + if (d_unhashed(dentry)) + d_rehash_cond(dentry, 0); /* avoid taking dcache_lock inside */ spin_unlock(&dcache_lock); spin_unlock(&ll_lookup_lock); iput(inode); diff --git a/lustre/llite/statahead.c b/lustre/llite/statahead.c index b415dc9..d874286 100644 --- a/lustre/llite/statahead.c +++ b/lustre/llite/statahead.c @@ -452,10 +452,10 @@ static int do_statahead_interpret(struct ll_statahead_info *sai) spin_lock(&ll_lookup_lock); spin_lock(&dcache_lock); lock_dentry(dentry); - __d_drop(dentry); dentry->d_flags &= ~DCACHE_LUSTRE_INVALID; unlock_dentry(dentry); - d_rehash_cond(dentry, 0); + if (d_unhashed(dentry)) + d_rehash_cond(dentry, 0); spin_unlock(&dcache_lock); spin_unlock(&ll_lookup_lock);