From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: viro@zeniv.linux.org.uk
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
hirofumi@mail.parknet.co.jp
Subject: [PATCH 3/6] vfs: add __d_instantiate() helper
Date: Wed, 15 Oct 2008 22:58:10 +0900 [thread overview]
Message-ID: <7754d3f83e848f5f6f2326623.ps@mail.parknet.co.jp> (raw)
In-Reply-To: <e015bca83e848f5f6f2226623.ps@mail.parknet.co.jp>
This adds __d_instantiate() for users which is already taking
dcache_lock, and replace with it.
The part of d_add_ci() isn't equivalent. But it should be needed
fsnotify_d_instantiate() actually, because the path is to add the
inode to negative dentry. fsnotify_d_instantiate() should be called
after change from negative to positive.
__d_instantiate_unique() and d_materialise_unique() does opencoded
optimized version. From history, it seems a intent, so just add comment.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---
fs/dcache.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff -puN fs/dcache.c~dcache-cleanup-3 fs/dcache.c
--- linux-2.6/fs/dcache.c~dcache-cleanup-3 2008-09-30 05:24:37.000000000 +0900
+++ linux-2.6-hirofumi/fs/dcache.c 2008-09-30 05:24:37.000000000 +0900
@@ -981,6 +981,15 @@ struct dentry *d_alloc_name(struct dentr
return d_alloc(parent, &q);
}
+/* the caller must hold dcache_lock */
+static void __d_instantiate(struct dentry *dentry, struct inode *inode)
+{
+ if (inode)
+ list_add(&dentry->d_alias, &inode->i_dentry);
+ dentry->d_inode = inode;
+ fsnotify_d_instantiate(dentry, inode);
+}
+
/**
* d_instantiate - fill in inode information for a dentry
* @entry: dentry to complete
@@ -1000,10 +1009,7 @@ void d_instantiate(struct dentry *entry,
{
BUG_ON(!list_empty(&entry->d_alias));
spin_lock(&dcache_lock);
- if (inode)
- list_add(&entry->d_alias, &inode->i_dentry);
- entry->d_inode = inode;
- fsnotify_d_instantiate(entry, inode);
+ __d_instantiate(entry, inode);
spin_unlock(&dcache_lock);
security_d_instantiate(entry, inode);
}
@@ -1033,6 +1039,7 @@ static struct dentry *__d_instantiate_un
unsigned int hash = entry->d_name.hash;
if (!inode) {
+ /* __d_instantiate() by hand */
entry->d_inode = NULL;
return NULL;
}
@@ -1052,9 +1059,7 @@ static struct dentry *__d_instantiate_un
return alias;
}
- list_add(&entry->d_alias, &inode->i_dentry);
- entry->d_inode = inode;
- fsnotify_d_instantiate(entry, inode);
+ __d_instantiate(entry, inode);
return NULL;
}
@@ -1211,10 +1216,8 @@ struct dentry *d_splice_alias(struct ino
d_move(new, dentry);
iput(inode);
} else {
- /* d_instantiate takes dcache_lock, so we do it by hand */
- list_add(&dentry->d_alias, &inode->i_dentry);
- dentry->d_inode = inode;
- fsnotify_d_instantiate(dentry, inode);
+ /* already taking dcache_lock, so d_add() by hand */
+ __d_instantiate(dentry, inode);
spin_unlock(&dcache_lock);
security_d_instantiate(dentry, inode);
d_rehash(dentry);
@@ -1297,8 +1300,7 @@ struct dentry *d_add_ci(struct dentry *d
* d_instantiate() by hand because it takes dcache_lock which
* we already hold.
*/
- list_add(&found->d_alias, &inode->i_dentry);
- found->d_inode = inode;
+ __d_instantiate(found, inode);
spin_unlock(&dcache_lock);
security_d_instantiate(found, inode);
return found;
@@ -1827,6 +1829,7 @@ struct dentry *d_materialise_unique(stru
if (!inode) {
actual = dentry;
+ /* __d_instantiate() by hand */
dentry->d_inode = NULL;
goto found_lock;
}
_
next prev parent reply other threads:[~2008-10-15 14:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-15 13:58 [PATCH 1/6] vfs: replace parent == dentry->d_parent by IS_ROOT() OGAWA Hirofumi
2008-10-15 13:58 ` [PATCH 2/6] vfs: add d_ancestor() OGAWA Hirofumi
2008-10-15 13:58 ` OGAWA Hirofumi [this message]
2008-10-15 13:58 ` [PATCH 4/6] vfs: remove unnecessary fsnotify_d_instantiate() OGAWA Hirofumi
2008-10-15 13:58 ` [PATCH 5/6] vfs: remove LOOKUP_PARENT from non LOOKUP_PARENT lookup OGAWA Hirofumi
2008-10-15 13:58 ` [PATCH 6/6] vfs: add LOOKUP_RENAME_NEW intent OGAWA Hirofumi
2008-10-15 19:37 ` Christoph Hellwig
2008-10-15 20:13 ` OGAWA Hirofumi
2008-10-15 19:44 ` [PATCH 5/6] vfs: remove LOOKUP_PARENT from non LOOKUP_PARENT lookup Christoph Hellwig
2008-10-15 21:43 ` OGAWA Hirofumi
2008-10-15 19:43 ` [PATCH 4/6] vfs: remove unnecessary fsnotify_d_instantiate() Christoph Hellwig
2008-10-15 20:16 ` OGAWA Hirofumi
2008-10-15 20:20 ` Christoph Hellwig
2008-10-15 19:41 ` [PATCH 3/6] vfs: add __d_instantiate() helper Christoph Hellwig
2008-10-15 20:39 ` OGAWA Hirofumi
2008-10-15 20:47 ` Trond Myklebust
2008-10-15 21:31 ` OGAWA Hirofumi
2008-10-15 19:53 ` [PATCH 2/6] vfs: add d_ancestor() Christoph Hellwig
2008-10-15 21:42 ` OGAWA Hirofumi
2008-10-15 19:45 ` [PATCH 1/6] vfs: replace parent == dentry->d_parent by IS_ROOT() Christoph Hellwig
2008-10-15 20:24 ` OGAWA Hirofumi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7754d3f83e848f5f6f2326623.ps@mail.parknet.co.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®