@@ -2511,28 +2511,28 @@ static void __d_move(struct dentry *dentry, struct dentry *target,
2511
2511
switch_names (dentry , target );
2512
2512
swap (dentry -> d_name .hash , target -> d_name .hash );
2513
2513
2514
- /* ... and switch the parents */
2514
+ /* ... and switch them in the tree */
2515
2515
if (IS_ROOT (dentry )) {
2516
+ /* splicing a tree */
2516
2517
dentry -> d_parent = target -> d_parent ;
2517
2518
target -> d_parent = target ;
2518
2519
list_del_init (& target -> d_u .d_child );
2520
+ list_move (& dentry -> d_u .d_child , & dentry -> d_parent -> d_subdirs );
2519
2521
} else {
2522
+ /* swapping two dentries */
2520
2523
swap (dentry -> d_parent , target -> d_parent );
2521
-
2522
- /* And add them back to the (new) parent lists */
2523
2524
list_move (& target -> d_u .d_child , & target -> d_parent -> d_subdirs );
2525
+ list_move (& dentry -> d_u .d_child , & dentry -> d_parent -> d_subdirs );
2526
+ if (exchange )
2527
+ fsnotify_d_move (target );
2528
+ fsnotify_d_move (dentry );
2524
2529
}
2525
2530
2526
- list_move (& dentry -> d_u .d_child , & dentry -> d_parent -> d_subdirs );
2527
-
2528
2531
write_seqcount_end (& target -> d_seq );
2529
2532
write_seqcount_end (& dentry -> d_seq );
2530
2533
2531
2534
dentry_unlock_parents_for_move (dentry , target );
2532
- if (exchange )
2533
- fsnotify_d_move (target );
2534
2535
spin_unlock (& target -> d_lock );
2535
- fsnotify_d_move (dentry );
2536
2536
spin_unlock (& dentry -> d_lock );
2537
2537
}
2538
2538
@@ -2631,40 +2631,6 @@ static struct dentry *__d_unalias(struct inode *inode,
2631
2631
return ret ;
2632
2632
}
2633
2633
2634
- /*
2635
- * Prepare an anonymous dentry for life in the superblock's dentry tree as a
2636
- * named dentry in place of the dentry to be replaced.
2637
- */
2638
- static void __d_materialise_dentry (struct dentry * dentry , struct dentry * target )
2639
- {
2640
- dentry_lock_for_move (dentry , target );
2641
-
2642
- write_seqcount_begin (& dentry -> d_seq );
2643
- write_seqcount_begin_nested (& target -> d_seq , DENTRY_D_LOCK_NESTED );
2644
-
2645
- switch_names (dentry , target );
2646
- swap (dentry -> d_name .hash , target -> d_name .hash );
2647
-
2648
- dentry -> d_parent = target -> d_parent ;
2649
- target -> d_parent = target ;
2650
- list_del_init (& target -> d_u .d_child );
2651
- list_move (& dentry -> d_u .d_child , & dentry -> d_parent -> d_subdirs );
2652
- if (likely (!d_unhashed (dentry ))) {
2653
- hlist_bl_lock (& dentry -> d_sb -> s_anon );
2654
- __hlist_bl_del (& dentry -> d_hash );
2655
- dentry -> d_hash .pprev = NULL ;
2656
- hlist_bl_unlock (& dentry -> d_sb -> s_anon );
2657
- }
2658
- __d_rehash (dentry , d_hash (dentry -> d_parent , dentry -> d_name .hash ));
2659
-
2660
- write_seqcount_end (& target -> d_seq );
2661
- write_seqcount_end (& dentry -> d_seq );
2662
-
2663
- dentry_unlock_parents_for_move (dentry , target );
2664
- spin_unlock (& target -> d_lock );
2665
- spin_unlock (& dentry -> d_lock );
2666
- }
2667
-
2668
2634
/**
2669
2635
* d_splice_alias - splice a disconnected dentry into the tree if one exists
2670
2636
* @inode: the inode which may have a disconnected dentry
@@ -2710,7 +2676,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
2710
2676
return ERR_PTR (- EIO );
2711
2677
}
2712
2678
write_seqlock (& rename_lock );
2713
- __d_materialise_dentry (new , dentry );
2679
+ __d_move (new , dentry , false );
2714
2680
write_sequnlock (& rename_lock );
2715
2681
spin_unlock (& inode -> i_lock );
2716
2682
security_d_instantiate (new , inode );
@@ -2771,7 +2737,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode)
2771
2737
} else if (IS_ROOT (alias )) {
2772
2738
/* Is this an anonymous mountpoint that we
2773
2739
* could splice into our tree? */
2774
- __d_materialise_dentry (alias , dentry );
2740
+ __d_move (alias , dentry , false );
2775
2741
write_sequnlock (& rename_lock );
2776
2742
goto found ;
2777
2743
} else {
0 commit comments