aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-07-29 17:45:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2016-07-29 17:45:21 -0400
commit15d3c589f6305c50a705572dbb33620c5cba416c (patch)
tree77388e7718be7a81d9e83983b535768df552986f /fs
parentd614146d18159e54d4dfc289e4c1534ccc485cf2 (diff)
fold _d_rehash() and __d_rehash() together
The only place where we feed to __d_rehash() something other than d_hash(dentry->d_name.hash) is __d_move(), where we give it d_hash of another dentry. Postpone rehashing until we'd switched the names and we are rid of that exception, along with the need to keep _d_rehash() and __d_rehash() separate. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/dcache.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 6a629f50c3cf..d9450bd496ac 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2339,19 +2339,15 @@ again:
2339} 2339}
2340EXPORT_SYMBOL(d_delete); 2340EXPORT_SYMBOL(d_delete);
2341 2341
2342static void __d_rehash(struct dentry * entry, struct hlist_bl_head *b) 2342static void __d_rehash(struct dentry *entry)
2343{ 2343{
2344 struct hlist_bl_head *b = d_hash(entry->d_name.hash);
2344 BUG_ON(!d_unhashed(entry)); 2345 BUG_ON(!d_unhashed(entry));
2345 hlist_bl_lock(b); 2346 hlist_bl_lock(b);
2346 hlist_bl_add_head_rcu(&entry->d_hash, b); 2347 hlist_bl_add_head_rcu(&entry->d_hash, b);
2347 hlist_bl_unlock(b); 2348 hlist_bl_unlock(b);
2348} 2349}
2349 2350
2350static void _d_rehash(struct dentry * entry)
2351{
2352 __d_rehash(entry, d_hash(entry->d_name.hash));
2353}
2354
2355/** 2351/**
2356 * d_rehash - add an entry back to the hash 2352 * d_rehash - add an entry back to the hash
2357 * @entry: dentry to add to the hash 2353 * @entry: dentry to add to the hash
@@ -2362,7 +2358,7 @@ static void _d_rehash(struct dentry * entry)
2362void d_rehash(struct dentry * entry) 2358void d_rehash(struct dentry * entry)
2363{ 2359{
2364 spin_lock(&entry->d_lock); 2360 spin_lock(&entry->d_lock);
2365 _d_rehash(entry); 2361 __d_rehash(entry);
2366 spin_unlock(&entry->d_lock); 2362 spin_unlock(&entry->d_lock);
2367} 2363}
2368EXPORT_SYMBOL(d_rehash); 2364EXPORT_SYMBOL(d_rehash);
@@ -2536,7 +2532,7 @@ static inline void __d_add(struct dentry *dentry, struct inode *inode)
2536 raw_write_seqcount_end(&dentry->d_seq); 2532 raw_write_seqcount_end(&dentry->d_seq);
2537 fsnotify_update_flags(dentry); 2533 fsnotify_update_flags(dentry);
2538 } 2534 }
2539 _d_rehash(dentry); 2535 __d_rehash(dentry);
2540 if (dir) 2536 if (dir)
2541 end_dir_add(dir, n); 2537 end_dir_add(dir, n);
2542 spin_unlock(&dentry->d_lock); 2538 spin_unlock(&dentry->d_lock);
@@ -2598,7 +2594,7 @@ struct dentry *d_exact_alias(struct dentry *entry, struct inode *inode)
2598 alias = NULL; 2594 alias = NULL;
2599 } else { 2595 } else {
2600 __dget_dlock(alias); 2596 __dget_dlock(alias);
2601 _d_rehash(alias); 2597 __d_rehash(alias);
2602 spin_unlock(&alias->d_lock); 2598 spin_unlock(&alias->d_lock);
2603 } 2599 }
2604 spin_unlock(&inode->i_lock); 2600 spin_unlock(&inode->i_lock);
@@ -2782,23 +2778,10 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
2782 write_seqcount_begin(&dentry->d_seq); 2778 write_seqcount_begin(&dentry->d_seq);
2783 write_seqcount_begin_nested(&target->d_seq, DENTRY_D_LOCK_NESTED); 2779 write_seqcount_begin_nested(&target->d_seq, DENTRY_D_LOCK_NESTED);
2784 2780
2781 /* unhash both */
2785 /* __d_drop does write_seqcount_barrier, but they're OK to nest. */ 2782 /* __d_drop does write_seqcount_barrier, but they're OK to nest. */
2786
2787 /*
2788 * Move the dentry to the target hash queue. Don't bother checking
2789 * for the same hash queue because of how unlikely it is.
2790 */
2791 __d_drop(dentry); 2783 __d_drop(dentry);
2792 __d_rehash(dentry, d_hash(target->d_name.hash));
2793
2794 /*
2795 * Unhash the target (d_delete() is not usable here). If exchanging
2796 * the two dentries, then rehash onto the other's hash queue.
2797 */
2798 __d_drop(target); 2784 __d_drop(target);
2799 if (exchange) {
2800 __d_rehash(target, d_hash(dentry->d_name.hash));
2801 }
2802 2785
2803 /* Switch the names.. */ 2786 /* Switch the names.. */
2804 if (exchange) 2787 if (exchange)
@@ -2806,6 +2789,11 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
2806 else 2789 else
2807 copy_name(dentry, target); 2790 copy_name(dentry, target);
2808 2791
2792 /* rehash in new place(s) */
2793 __d_rehash(dentry);
2794 if (exchange)
2795 __d_rehash(target);
2796
2809 /* ... and switch them in the tree */ 2797 /* ... and switch them in the tree */
2810 if (IS_ROOT(dentry)) { 2798 if (IS_ROOT(dentry)) {
2811 /* splicing a tree */ 2799 /* splicing a tree */