... thus making it much closer to (now unreachable, BTW) IS_ROOT(dentry) case in __d_move(). A bit more and it'll fold in.
Unified · Split
| @@ -2635,38 +2635,34 @@ out_err: · 2634 unmodified lines | ||
| 2635 | 2635 | * Prepare an anonymous dentry for life in the superblock's dentry tree as a |
| 2636 | 2636 | * named dentry in place of the dentry to be replaced. |
| 2637 | 2637 | */ |
| 2638 | −static void __d_materialise_dentry(struct dentry *dentry, struct dentry *anon) | |
| 2638 | +static void __d_materialise_dentry(struct dentry *dentry, struct dentry *target) | |
| 2639 | 2639 | { |
| 2640 | − struct dentry *dparent; | |
| 2641 | − | |
| 2642 | − dentry_lock_for_move(anon, dentry); | |
| 2640 | + dentry_lock_for_move(dentry, target); | |
| 2643 | 2641 | |
| 2644 | 2642 | write_seqcount_begin(&dentry->d_seq); |
| 2645 | − write_seqcount_begin_nested(&anon->d_seq, DENTRY_D_LOCK_NESTED); | |
| 2646 | − | |
| 2647 | − dparent = dentry->d_parent; | |
| 2643 | + write_seqcount_begin_nested(&target->d_seq, DENTRY_D_LOCK_NESTED); | |
| 2648 | 2644 | |
| 2649 | − switch_names(dentry, anon); | |
| 2650 | − swap(dentry->d_name.hash, anon->d_name.hash); | |
| 2645 | + switch_names(dentry, target); | |
| 2646 | + swap(dentry->d_name.hash, target->d_name.hash); | |
| 2651 | 2647 | |
| 2652 | − dentry->d_parent = dentry; | |
| 2653 | − list_del_init(&dentry->d_u.d_child); | |
| 2654 | − anon->d_parent = dparent; | |
| 2655 | − list_move(&anon->d_u.d_child, &dparent->d_subdirs); | |
| 2656 | − if (likely(!d_unhashed(anon))) { | |
| 2657 | − hlist_bl_lock(&anon->d_sb->s_anon); | |
| 2658 | − __hlist_bl_del(&anon->d_hash); | |
| 2659 | − anon->d_hash.pprev = NULL; | |
| 2660 | − hlist_bl_unlock(&anon->d_sb->s_anon); | |
| 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); | |
| 2661 | 2657 | } |
| 2662 | − __d_rehash(anon, d_hash(anon->d_parent, anon->d_name.hash)); | |
| 2658 | + __d_rehash(dentry, d_hash(dentry->d_parent, dentry->d_name.hash)); | |
| 2663 | 2659 | |
| 2660 | + write_seqcount_end(&target->d_seq); | |
| 2664 | 2661 | write_seqcount_end(&dentry->d_seq); |
| 2665 | − write_seqcount_end(&anon->d_seq); | |
| 2666 | 2662 | |
| 2667 | − dentry_unlock_parents_for_move(anon, dentry); | |
| 2663 | + dentry_unlock_parents_for_move(dentry, target); | |
| 2664 | + spin_unlock(&target->d_lock); | |
| 2668 | 2665 | spin_unlock(&dentry->d_lock); |
| 2669 | − spin_unlock(&anon->d_lock); | |
| 2670 | 2666 | } |
| 2671 | 2667 | |
| 2672 | 2668 | /** |
| @@ -2714,7 +2710,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) · 41 unmodified lines | ||
| 2714 | 2710 | return ERR_PTR(-EIO); |
| 2715 | 2711 | } |
| 2716 | 2712 | write_seqlock(&rename_lock); |
| 2717 | − __d_materialise_dentry(dentry, new); | |
| 2713 | + __d_materialise_dentry(new, dentry); | |
| 2718 | 2714 | write_sequnlock(&rename_lock); |
| 2719 | 2715 | spin_unlock(&inode->i_lock); |
| 2720 | 2716 | security_d_instantiate(new, inode); |
| @@ -2775,7 +2771,7 @@ struct dentry *d_materialise_unique(struct dentry *dentry, struct inode *inode) · 54 unmodified lines | ||
| 2775 | 2771 | } else if (IS_ROOT(alias)) { |
| 2776 | 2772 | /* Is this an anonymous mountpoint that we |
| 2777 | 2773 | * could splice into our tree? */ |
| 2778 | − __d_materialise_dentry(dentry, alias); | |
| 2774 | + __d_materialise_dentry(alias, dentry); | |
| 2779 | 2775 | write_sequnlock(&rename_lock); |
| 2780 | 2776 | goto found; |
| 2781 | 2777 | } else { |