* [PATCH] vfs: use the predefined d_unhashed inline function instead
@ 2007-09-23 11:14 Denis Cheng
2007-09-25 20:04 ` [PATCH] fs/dcache.c: revamped to use a more straightforward and efficient way to operate Denis Cheng
0 siblings, 1 reply; 3+ messages in thread
From: Denis Cheng @ 2007-09-23 11:14 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-kernel, cr_quan
Signed-off-by: Denis Cheng <crquan@gmail.com>
---
fs/dcache.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 678d39d..62e1800 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1546,7 +1546,7 @@ static void d_move_locked(struct dentry * dentry, struct dentry * target)
}
/* Move the dentry to the target hash queue, if on different bucket */
- if (dentry->d_flags & DCACHE_UNHASHED)
+ if (d_unhashed(dentry))
goto already_unhashed;
hlist_del_rcu(&dentry->d_hash);
--
1.5.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] fs/dcache.c: revamped to use a more straightforward and efficient way to operate
2007-09-23 11:14 [PATCH] vfs: use the predefined d_unhashed inline function instead Denis Cheng
@ 2007-09-25 20:04 ` Denis Cheng
2007-10-01 17:25 ` Jan Kara
0 siblings, 1 reply; 3+ messages in thread
From: Denis Cheng @ 2007-09-25 20:04 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-kernel, cr_quan
Signed-off-by: Denis Cheng <crquan@gmail.com>
---
fs/dcache.c | 39 ++++++++++++++++++---------------------
1 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index 678d39d..05ed44a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -1138,29 +1138,26 @@ struct dentry * d_alloc_anon(struct inode *inode)
spin_lock(&dcache_lock);
res = __d_find_alias(inode, 0);
- if (!res) {
- /* attach a disconnected dentry */
- res = tmp;
- tmp = NULL;
- spin_lock(&res->d_lock);
- res->d_sb = inode->i_sb;
- res->d_parent = res;
- res->d_inode = inode;
- res->d_flags |= DCACHE_DISCONNECTED;
- res->d_flags &= ~DCACHE_UNHASHED;
- list_add(&res->d_alias, &inode->i_dentry);
- hlist_add_head(&res->d_hash, &inode->i_sb->s_anon);
- spin_unlock(&res->d_lock);
-
- inode = NULL; /* don't drop reference */
- }
- spin_unlock(&dcache_lock);
-
- if (inode)
+ if (unlikely(res)) {
+ spin_unlock(&dcache_lock);
iput(inode);
- if (tmp)
dput(tmp);
- return res;
+ return res;
+ } else {
+ /* attach a disconnected dentry */
+ spin_lock(&tmp->d_lock);
+ tmp->d_sb = inode->i_sb;
+ tmp->d_parent = tmp;
+ tmp->d_inode = inode;
+ tmp->d_flags |= DCACHE_DISCONNECTED;
+ tmp->d_flags &= ~DCACHE_UNHASHED;
+ list_add(&tmp->d_alias, &inode->i_dentry);
+ hlist_add_head(&tmp->d_hash, &inode->i_sb->s_anon);
+ spin_unlock(&tmp->d_lock);
+
+ spin_unlock(&dcache_lock);
+ return tmp;
+ }
}
--
1.5.3.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/dcache.c: revamped to use a more straightforward and efficient way to operate
2007-09-25 20:04 ` [PATCH] fs/dcache.c: revamped to use a more straightforward and efficient way to operate Denis Cheng
@ 2007-10-01 17:25 ` Jan Kara
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2007-10-01 17:25 UTC (permalink / raw)
To: Denis Cheng; +Cc: Alexander Viro, linux-kernel, cr_quan
Hello,
thanks for the patch. I have a few comments to it:
1) the patch should have a description in it, not only an email subject
2) usually, if an 'if' branch ends with return, as is the case in your
patch, we don't use 'else' for the other branch...
BTW: I'm not convinced your code would be faster (or slower) than the
original one but you're right it will be easier to read...
Honza
> Signed-off-by: Denis Cheng <crquan@gmail.com>
> ---
> fs/dcache.c | 39 ++++++++++++++++++---------------------
> 1 files changed, 18 insertions(+), 21 deletions(-)
>
> diff --git a/fs/dcache.c b/fs/dcache.c
> index 678d39d..05ed44a 100644
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -1138,29 +1138,26 @@ struct dentry * d_alloc_anon(struct inode *inode)
>
> spin_lock(&dcache_lock);
> res = __d_find_alias(inode, 0);
> - if (!res) {
> - /* attach a disconnected dentry */
> - res = tmp;
> - tmp = NULL;
> - spin_lock(&res->d_lock);
> - res->d_sb = inode->i_sb;
> - res->d_parent = res;
> - res->d_inode = inode;
> - res->d_flags |= DCACHE_DISCONNECTED;
> - res->d_flags &= ~DCACHE_UNHASHED;
> - list_add(&res->d_alias, &inode->i_dentry);
> - hlist_add_head(&res->d_hash, &inode->i_sb->s_anon);
> - spin_unlock(&res->d_lock);
> -
> - inode = NULL; /* don't drop reference */
> - }
> - spin_unlock(&dcache_lock);
> -
> - if (inode)
> + if (unlikely(res)) {
> + spin_unlock(&dcache_lock);
> iput(inode);
> - if (tmp)
> dput(tmp);
> - return res;
> + return res;
> + } else {
> + /* attach a disconnected dentry */
> + spin_lock(&tmp->d_lock);
> + tmp->d_sb = inode->i_sb;
> + tmp->d_parent = tmp;
> + tmp->d_inode = inode;
> + tmp->d_flags |= DCACHE_DISCONNECTED;
> + tmp->d_flags &= ~DCACHE_UNHASHED;
> + list_add(&tmp->d_alias, &inode->i_dentry);
> + hlist_add_head(&tmp->d_hash, &inode->i_sb->s_anon);
> + spin_unlock(&tmp->d_lock);
> +
> + spin_unlock(&dcache_lock);
> + return tmp;
> + }
> }
>
>
> --
> 1.5.3.2
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
--
Jan Kara <jack@suse.cz>
SuSE CR Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-01 17:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-23 11:14 [PATCH] vfs: use the predefined d_unhashed inline function instead Denis Cheng
2007-09-25 20:04 ` [PATCH] fs/dcache.c: revamped to use a more straightforward and efficient way to operate Denis Cheng
2007-10-01 17:25 ` Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®