| @@ -1649,17 +1649,15 @@ again: · 1648 unmodified lines |
| 1649 | 1649 | if (IS_ERR(dentry)) |
| 1650 | 1650 | return dentry; |
| 1651 | 1651 | if (unlikely(!d_in_lookup(dentry))) { |
| 1652 | | − if (!(flags & LOOKUP_NO_REVAL)) { |
| 1653 | | − int error = d_revalidate(dentry, flags); |
| 1654 | | − if (unlikely(error <= 0)) { |
| 1655 | | − if (!error) { |
| 1656 | | − d_invalidate(dentry); |
| 1657 | | − dput(dentry); |
| 1658 | | − goto again; |
| 1659 | | − } |
| 1652 | + int error = d_revalidate(dentry, flags); |
| 1653 | + if (unlikely(error <= 0)) { |
| 1654 | + if (!error) { |
| 1655 | + d_invalidate(dentry); |
| 1660 | 1656 | dput(dentry); |
| 1661 | | − dentry = ERR_PTR(error); |
| 1657 | + goto again; |
| 1662 | 1658 | } |
| 1659 | + dput(dentry); |
| 1660 | + dentry = ERR_PTR(error); |
| 1663 | 1661 | } |
| 1664 | 1662 | } else { |
| 1665 | 1663 | old = inode->i_op->lookup(inode, dentry, flags); |
| @@ -2617,72 +2615,6 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags, · 951 unmodified lines |
| 2617 | 2615 | } |
| 2618 | 2616 | EXPORT_SYMBOL(user_path_at_empty); |
| 2619 | 2617 | |
| 2620 | | −/** |
| 2621 | | − * mountpoint_last - look up last component for umount |
| 2622 | | − * @nd: pathwalk nameidata - currently pointing at parent directory of "last" |
| 2623 | | − * |
| 2624 | | − * This is a special lookup_last function just for umount. In this case, we |
| 2625 | | − * need to resolve the path without doing any revalidation. |
| 2626 | | − * |
| 2627 | | − * The nameidata should be the result of doing a LOOKUP_PARENT pathwalk. Since |
| 2628 | | − * mountpoints are always pinned in the dcache, their ancestors are too. Thus, |
| 2629 | | − * in almost all cases, this lookup will be served out of the dcache. The only |
| 2630 | | − * cases where it won't are if nd->last refers to a symlink or the path is |
| 2631 | | − * bogus and it doesn't exist. |
| 2632 | | − * |
| 2633 | | − * Returns: |
| 2634 | | − * -error: if there was an error during lookup. This includes -ENOENT if the |
| 2635 | | − * lookup found a negative dentry. |
| 2636 | | − * |
| 2637 | | − * 0: if we successfully resolved nd->last and found it to not to be a |
| 2638 | | − * symlink that needs to be followed. |
| 2639 | | − * |
| 2640 | | − * 1: if we successfully resolved nd->last and found it to be a symlink |
| 2641 | | − * that needs to be followed. |
| 2642 | | − */ |
| 2643 | | −static int |
| 2644 | | −mountpoint_last(struct nameidata *nd) |
| 2645 | | −{ |
| 2646 | | − int error = 0; |
| 2647 | | − struct dentry *dir = nd->path.dentry; |
| 2648 | | − struct path path; |
| 2649 | | − |
| 2650 | | − /* If we're in rcuwalk, drop out of it to handle last component */ |
| 2651 | | − if (nd->flags & LOOKUP_RCU) { |
| 2652 | | − if (unlazy_walk(nd)) |
| 2653 | | − return -ECHILD; |
| 2654 | | − } |
| 2655 | | − |
| 2656 | | − nd->flags &= ~LOOKUP_PARENT; |
| 2657 | | − |
| 2658 | | − if (unlikely(nd->last_type != LAST_NORM)) { |
| 2659 | | − error = handle_dots(nd, nd->last_type); |
| 2660 | | − if (error) |
| 2661 | | − return error; |
| 2662 | | − path.dentry = dget(nd->path.dentry); |
| 2663 | | − } else { |
| 2664 | | − path.dentry = d_lookup(dir, &nd->last); |
| 2665 | | − if (!path.dentry) { |
| 2666 | | − /* |
| 2667 | | − * No cached dentry. Mounted dentries are pinned in the |
| 2668 | | − * cache, so that means that this dentry is probably |
| 2669 | | − * a symlink or the path doesn't actually point |
| 2670 | | − * to a mounted dentry. |
| 2671 | | − */ |
| 2672 | | − path.dentry = lookup_slow(&nd->last, dir, |
| 2673 | | − nd->flags | LOOKUP_NO_REVAL); |
| 2674 | | − if (IS_ERR(path.dentry)) |
| 2675 | | − return PTR_ERR(path.dentry); |
| 2676 | | − } |
| 2677 | | − } |
| 2678 | | − if (d_flags_negative(smp_load_acquire(&path.dentry->d_flags))) { |
| 2679 | | − dput(path.dentry); |
| 2680 | | − return -ENOENT; |
| 2681 | | − } |
| 2682 | | − path.mnt = nd->path.mnt; |
| 2683 | | − return step_into(nd, &path, 0, d_backing_inode(path.dentry), 0); |
| 2684 | | −} |
| 2685 | | − |
| 2686 | 2618 | /** |
| 2687 | 2619 | * path_mountpoint - look up a path to be umounted |
| 2688 | 2620 | * @nd: lookup context |
| @@ -2699,14 +2631,17 @@ path_mountpoint(struct nameidata *nd, unsigned flags, struct path *path) · 10 unmodified lines |
| 2699 | 2631 | int err; |
| 2700 | 2632 | |
| 2701 | 2633 | while (!(err = link_path_walk(s, nd)) && |
| 2702 | | − (err = mountpoint_last(nd)) > 0) { |
| 2634 | + (err = lookup_last(nd)) > 0) { |
| 2703 | 2635 | s = trailing_symlink(nd); |
| 2704 | 2636 | } |
| 2637 | + if (!err && (nd->flags & LOOKUP_RCU)) |
| 2638 | + err = unlazy_walk(nd); |
| 2639 | + if (!err) |
| 2640 | + err = handle_lookup_down(nd); |
| 2705 | 2641 | if (!err) { |
| 2706 | 2642 | *path = nd->path; |
| 2707 | 2643 | nd->path.mnt = NULL; |
| 2708 | 2644 | nd->path.dentry = NULL; |
| 2709 | | − follow_mount(path); |
| 2710 | 2645 | } |
| 2711 | 2646 | terminate_walk(nd); |
| 2712 | 2647 | return err; |