aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dcache.c
diff options
context:
space:
mode:
authorOGAWA Hirofumi <hirofumi@mail.parknet.co.jp>2008-10-15 18:50:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2008-10-23 05:13:17 -0400
commit360da90029196c9449bc61e5a07ce8404e4cba57 (patch)
tree7bca57f11b2022633f5c49ec9a1bca9d2d4d1b1a /fs/dcache.c
parente2761a1167633ed943fea29002f990194923d060 (diff)
[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: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Diffstat (limited to 'fs/dcache.c')
-rw-r--r--fs/dcache.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 64024005da43..5a24cee6b76a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -981,6 +981,15 @@ struct dentry *d_alloc_name(struct dentry *parent, const char *name)
981 return d_alloc(parent, &q); 981 return d_alloc(parent, &q);
982} 982}
983 983
984/* the caller must hold dcache_lock */
985static void __d_instantiate(struct dentry *dentry, struct inode *inode)
986{
987 if (inode)
988 list_add(&dentry->d_alias, &inode->i_dentry);
989 dentry->d_inode = inode;
990 fsnotify_d_instantiate(dentry, inode);
991}
992
984/** 993/**
985 * d_instantiate - fill in inode information for a dentry 994 * d_instantiate - fill in inode information for a dentry
986 * @entry: dentry to complete 995 * @entry: dentry to complete
@@ -1000,10 +1009,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode)
1000{ 1009{
1001 BUG_ON(!list_empty(&entry->d_alias)); 1010 BUG_ON(!list_empty(&entry->d_alias));
1002 spin_lock(&dcache_lock); 1011 spin_lock(&dcache_lock);
1003 if (inode) 1012 __d_instantiate(entry, inode);
1004 list_add(&entry->d_alias, &inode->i_dentry);
1005 entry->d_inode = inode;
1006 fsnotify_d_instantiate(entry, inode);
1007 spin_unlock(&dcache_lock); 1013 spin_unlock(&dcache_lock);
1008 security_d_instantiate(entry, inode); 1014 security_d_instantiate(entry, inode);
1009} 1015}
@@ -1033,7 +1039,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
1033 unsigned int hash = entry->d_name.hash; 1039 unsigned int hash = entry->d_name.hash;
1034 1040
1035 if (!inode) { 1041 if (!inode) {
1036 entry->d_inode = NULL; 1042 __d_instantiate(entry, NULL);
1037 return NULL; 1043 return NULL;
1038 } 1044 }
1039 1045
@@ -1052,9 +1058,7 @@ static struct dentry *__d_instantiate_unique(struct dentry *entry,
1052 return alias; 1058 return alias;
1053 } 1059 }
1054 1060
1055 list_add(&entry->d_alias, &inode->i_dentry); 1061 __d_instantiate(entry, inode);
1056 entry->d_inode = inode;
1057 fsnotify_d_instantiate(entry, inode);
1058 return NULL; 1062 return NULL;
1059} 1063}
1060 1064
@@ -1213,10 +1217,8 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
1213 d_move(new, dentry); 1217 d_move(new, dentry);
1214 iput(inode); 1218 iput(inode);
1215 } else { 1219 } else {
1216 /* d_instantiate takes dcache_lock, so we do it by hand */ 1220 /* already taking dcache_lock, so d_add() by hand */
1217 list_add(&dentry->d_alias, &inode->i_dentry); 1221 __d_instantiate(dentry, inode);
1218 dentry->d_inode = inode;
1219 fsnotify_d_instantiate(dentry, inode);
1220 spin_unlock(&dcache_lock); 1222 spin_unlock(&dcache_lock);
1221 security_d_instantiate(dentry, inode); 1223 security_d_instantiate(dentry, inode);
1222 d_rehash(dentry); 1224 d_rehash(dentry);
@@ -1299,8 +1301,7 @@ struct dentry *d_add_ci(struct dentry *dentry, struct inode *inode,
1299 * d_instantiate() by hand because it takes dcache_lock which 1301 * d_instantiate() by hand because it takes dcache_lock which
1300 * we already hold. 1302 * we already hold.
1301 */ 1303 */
1302 list_add(&found->d_alias, &inode->i_dentry); 1304 __d_instantiate(found, inode);
1303 found->d_inode = inode;
1304 spin_unlock(&dcache_lock); 1305 spin_unlock(&dcache_lock);
1305 security_d_instantiate(found, inode); 1306 security_d_instantiate(found, inode);
1306 return found; 1307 return found;
@@ -1833,7 +1834,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
1833 1834
1834 if (!inode) { 1835 if (!inode) {
1835 actual = dentry; 1836 actual = dentry;
1836 dentry->d_inode = NULL; 1837 __d_instantiate(dentry, NULL);
1837 goto found_lock; 1838 goto found_lock;
1838 } 1839 }
1839 1840