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 <bobijam@whamcloud.com>
Reviewed-on: http://review.whamcloud.com/1435
Tested-by: Hudson
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
* 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);
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);
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);