提交 360da900 编写于 作者: O OGAWA Hirofumi 提交者: Al Viro

[PATCH vfs-2.6 3/6] vfs: add __d_instantiate() helper

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.
Signed-off-by: NOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
上级 e2761a11
...@@ -981,6 +981,15 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name) ...@@ -981,6 +981,15 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name)
return d_alloc(parent, &q); 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 * d_instantiate - fill in inode information for a dentry
* @entry: dentry to complete * @entry: dentry to complete
...@@ -1000,10 +1009,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode) ...@@ -1000,10 +1009,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode)
{ {
BUG_ON(!list_empty(&entry->d_alias)); BUG_ON(!list_empty(&entry->d_alias));
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
if (inode) __d_instantiate(entry, inode);
list_add(&entry->d_alias, &inode->i_dentry);
entry->d_inode = inode;
fsnotify_d_instantiate(entry, inode);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
security_d_instantiate(entry, inode); security_d_instantiate(entry, inode);
} }
...@@ -1033,7 +1039,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry, ...@@ -1033,7 +1039,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
unsigned int hash = entry->d_name.hash; unsigned int hash = entry->d_name.hash;
if (!inode) { if (!inode) {
entry->d_inode = NULL; __d_instantiate(entry, NULL);
return NULL; return NULL;
} }
...@@ -1052,9 +1058,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry, ...@@ -1052,9 +1058,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
return alias; return alias;
} }
list_add(&entry->d_alias, &inode->i_dentry); __d_instantiate(entry, inode);
entry->d_inode = inode;
fsnotify_d_instantiate(entry, inode);
return NULL; return NULL;
} }
...@@ -1213,10 +1217,8 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) ...@@ -1213,10 +1217,8 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
d_move(new, dentry); d_move(new, dentry);
iput(inode); iput(inode);
} else { } else {
/* d_instantiate takes dcache_lock, so we do it by hand */ /* already taking dcache_lock, so d_add() by hand */
list_add(&dentry->d_alias, &inode->i_dentry); __d_instantiate(dentry, inode);
dentry->d_inode = inode;
fsnotify_d_instantiate(dentry, inode);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
security_d_instantiate(dentry, inode); security_d_instantiate(dentry, inode);
d_rehash(dentry); d_rehash(dentry);
...@@ -1299,8 +1301,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode, ...@@ -1299,8 +1301,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
* d_instantiate() by hand because it takes dcache_lock which * d_instantiate() by hand because it takes dcache_lock which
* we already hold. * we already hold.
*/ */
list_add(&found->d_alias, &inode->i_dentry); __d_instantiate(found, inode);
found->d_inode = inode;
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
security_d_instantiate(found, inode); security_d_instantiate(found, inode);
return found; return found;
...@@ -1833,7 +1834,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) ...@@ -1833,7 +1834,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
if (!inode) { if (!inode) {
actual = dentry; actual = dentry;
dentry->d_inode = NULL; __d_instantiate(dentry, NULL);
goto found_lock; goto found_lock;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册