Skip to content

Commit ed782b5

Browse files
author
Al Viro
committed
dcache.c: new helper: __d_add()
d_add() with inode->i_lock already held; common to d_add() and d_splice_alias(). All ->lookup() instances that end up hashing the dentry they are given will hash it here. This almost completes the preparations to parallel lookups proper - the only remaining bit is taking security_d_instantiate() past d_rehash() and doing rehashing without dropping ->d_lock. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent de689f5 commit ed782b5

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

fs/dcache.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,19 @@ void d_rehash(struct dentry * entry)
23602360
}
23612361
EXPORT_SYMBOL(d_rehash);
23622362

2363+
2364+
/* inode->i_lock held if inode is non-NULL */
2365+
2366+
static inline void __d_add(struct dentry *dentry, struct inode *inode)
2367+
{
2368+
if (inode) {
2369+
__d_instantiate(dentry, inode);
2370+
spin_unlock(&inode->i_lock);
2371+
}
2372+
security_d_instantiate(dentry, inode);
2373+
d_rehash(dentry);
2374+
}
2375+
23632376
/**
23642377
* d_add - add dentry to hash queues
23652378
* @entry: dentry to add
@@ -2371,8 +2384,9 @@ EXPORT_SYMBOL(d_rehash);
23712384

23722385
void d_add(struct dentry *entry, struct inode *inode)
23732386
{
2374-
d_instantiate(entry, inode);
2375-
d_rehash(entry);
2387+
if (inode)
2388+
spin_lock(&inode->i_lock);
2389+
__d_add(entry, inode);
23762390
}
23772391
EXPORT_SYMBOL(d_add);
23782392

@@ -2798,12 +2812,8 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
27982812
return new;
27992813
}
28002814
}
2801-
/* already taking inode->i_lock, so d_add() by hand */
2802-
__d_instantiate(dentry, inode);
2803-
spin_unlock(&inode->i_lock);
28042815
out:
2805-
security_d_instantiate(dentry, inode);
2806-
d_rehash(dentry);
2816+
__d_add(dentry, inode);
28072817
return NULL;
28082818
}
28092819
EXPORT_SYMBOL(d_splice_alias);

0 commit comments

Comments
 (0)