Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1380441 > unrolled thread

[PATCH 10/15] __d_add(): don't drop/regain ->d_lock

Started byAl Viro <viro@ZenIV.linux.org.uk>
First post2016-04-16 03:00 +0200
Last post2016-04-24 21:30 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 10/15] __d_add(): don't drop/regain ->d_lock Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-16 03:00 +0200
    Re: [PATCH 10/15] __d_add(): don't drop/regain ->d_lock Jeff Layton <jlayton@poochiereds.net> - 2016-04-24 20:10 +0200
      Re: [PATCH 10/15] __d_add(): don't drop/regain ->d_lock Al Viro <viro@ZenIV.linux.org.uk> - 2016-04-24 21:30 +0200

#1380441 — [PATCH 10/15] __d_add(): don't drop/regain ->d_lock

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-04-16 03:00 +0200
Subject[PATCH 10/15] __d_add(): don't drop/regain ->d_lock
Message-ID<romKC-3oC-5@gated-at.bofh.it>
From: Al Viro <viro@zeniv.linux.org.uk>

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/dcache.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/dcache.c b/fs/dcache.c
index e9de4d9..33cad8a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2363,11 +2363,19 @@ EXPORT_SYMBOL(d_rehash);
 
 static inline void __d_add(struct dentry *dentry, struct inode *inode)
 {
+	spin_lock(&dentry->d_lock);
 	if (inode) {
-		__d_instantiate(dentry, inode);
+		unsigned add_flags = d_flags_for_inode(inode);
+		hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
+		raw_write_seqcount_begin(&dentry->d_seq);
+		__d_set_inode_and_type(dentry, inode, add_flags);
+		raw_write_seqcount_end(&dentry->d_seq);
+		__fsnotify_d_instantiate(dentry);
+	}
+	_d_rehash(dentry);
+	spin_unlock(&dentry->d_lock);
+	if (inode)
 		spin_unlock(&inode->i_lock);
-	}
-	d_rehash(dentry);
 }
 
 /**
-- 
2.8.0.rc3

[toc] | [next] | [standalone]


#1385854

FromJeff Layton <jlayton@poochiereds.net>
Date2016-04-24 20:10 +0200
Message-ID<rrwDL-oW-1@gated-at.bofh.it>
In reply to#1380441
On Sat, 2016-04-16 at 01:55 +0100, Al Viro wrote:
> From: Al Viro <viro@zeniv.linux.org.uk>
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
>  fs/dcache.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/dcache.c b/fs/dcache.c
> index e9de4d9..33cad8a 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -2363,11 +2363,19 @@ EXPORT_SYMBOL(d_rehash);
>  
>  static inline void __d_add(struct dentry *dentry, struct inode *inode)
>  {
> +	spin_lock(&dentry->d_lock);
>  	if (inode) {
> -		__d_instantiate(dentry, inode);
> +		unsigned add_flags = d_flags_for_inode(inode);
> +		hlist_add_head(&dentry->d_u.d_alias, &inode->i_dentry);
> +		raw_write_seqcount_begin(&dentry->d_seq);
> +		__d_set_inode_and_type(dentry, inode, add_flags);
> +		raw_write_seqcount_end(&dentry->d_seq);
> +		__fsnotify_d_instantiate(dentry);

Should the above be a new __d_instantiate_locked instead of open-coding 
it?

> +	}
> +	_d_rehash(dentry);
> +	spin_unlock(&dentry->d_lock);
> +	if (inode)
>  		spin_unlock(&inode->i_lock);
> -	}
> -	d_rehash(dentry);
>  }
>  
>  /**
-- 
Jeff Layton <jlayton@poochiereds.net>

[toc] | [prev] | [next] | [standalone]


#1385874

FromAl Viro <viro@ZenIV.linux.org.uk>
Date2016-04-24 21:30 +0200
Message-ID<rrxTc-1ep-23@gated-at.bofh.it>
In reply to#1385854
On Sun, Apr 24, 2016 at 02:09:09PM -0400, Jeff Layton wrote:

> Should the above be a new __d_instantiate_locked instead of open-coding 
> it?

Nope - it gets rehash mashed into it a few commits later.  In principle
we could try to fish the common helper out of it and __d_instantiate()
once the dust settles, but IMO there's not much point.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web