lkml.org 
[lkml]   [2018]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/4] fs/dcache: Avoid the try_lock loop in d_delete()
On Fri, Feb 16, 2018 at 04:09:32PM +0100, John Ogness wrote:
> +static bool dentry_lock_inode(struct dentry *dentry)
> +{
> + struct inode *inode = dentry->d_inode;
> +
> + lockdep_assert_held(&dentry->d_lock);
> +
> + if (unlikely(!spin_trylock(&inode->i_lock))) {

if (likely(spin_trylock(&inode->i_lock)))
return true;

and then unindent by 1 stop the below code:

> + rcu_read_lock();
> + spin_unlock(&dentry->d_lock);
> + spin_lock(&inode->i_lock);
> + spin_lock(&dentry->d_lock);
> + rcu_read_unlock();
> +
> + /*
> + * @dentry->d_inode might have changed after dropping
> + * @dentry->d_lock. If so, release @inode->i_lock and
> + * signal the caller to restart the operation.
> + */
> + if (unlikely(inode != dentry->d_inode)) {
> + spin_unlock(&inode->i_lock);
> + return false;
> + }
> + }
> + return true;
> +}

\
 
 \ /
  Last update: 2018-02-16 18:10    [W:0.033 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site