Ignore:
Timestamp:
Mar 15, 2017, 2:42:58 AM (7 weeks ago)
Author:
brainslayer
Message:

use new squashfs in all kernels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/linux/universal/linux-4.9/fs/namespace.c

    r31574 r31662  
    642642
    643643/*
    644  * find the last mount at @dentry on vfsmount @mnt.
    645  * mount_lock must be held.
    646  */
    647 struct mount *__lookup_mnt_last(struct vfsmount *mnt, struct dentry *dentry)
    648 {
    649         struct mount *p, *res = NULL;
    650         p = __lookup_mnt(mnt, dentry);
    651         if (!p)
    652                 goto out;
    653         if (!(p->mnt.mnt_flags & MNT_UMOUNT))
    654                 res = p;
    655         hlist_for_each_entry_continue(p, mnt_hash) {
    656                 if (&p->mnt_parent->mnt != mnt || p->mnt_mountpoint != dentry)
    657                         break;
    658                 if (!(p->mnt.mnt_flags & MNT_UMOUNT))
    659                         res = p;
    660         }
    661 out:
    662         return res;
    663 }
    664 
    665 /*
    666644 * lookup_mnt - Return the first child mount mounted at path
    667645 *
     
    883861}
    884862
     863static void __attach_mnt(struct mount *mnt, struct mount *parent)
     864{
     865        hlist_add_head_rcu(&mnt->mnt_hash,
     866                           m_hash(&parent->mnt, mnt->mnt_mountpoint));
     867        list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
     868}
     869
    885870/*
    886871 * vfsmount lock must be held for write
     
    891876{
    892877        mnt_set_mountpoint(parent, mp, mnt);
    893         hlist_add_head_rcu(&mnt->mnt_hash, m_hash(&parent->mnt, mp->m_dentry));
    894         list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
    895 }
    896 
    897 static void attach_shadowed(struct mount *mnt,
    898                         struct mount *parent,
    899                         struct mount *shadows)
    900 {
    901         if (shadows) {
    902                 hlist_add_behind_rcu(&mnt->mnt_hash, &shadows->mnt_hash);
    903                 list_add(&mnt->mnt_child, &shadows->mnt_child);
    904         } else {
    905                 hlist_add_head_rcu(&mnt->mnt_hash,
    906                                 m_hash(&parent->mnt, mnt->mnt_mountpoint));
    907                 list_add_tail(&mnt->mnt_child, &parent->mnt_mounts);
    908         }
     878        __attach_mnt(mnt, parent);
     879}
     880
     881void mnt_change_mountpoint(struct mount *parent, struct mountpoint *mp, struct mount *mnt)
     882{
     883        struct mountpoint *old_mp = mnt->mnt_mp;
     884        struct dentry *old_mountpoint = mnt->mnt_mountpoint;
     885        struct mount *old_parent = mnt->mnt_parent;
     886
     887        list_del_init(&mnt->mnt_child);
     888        hlist_del_init(&mnt->mnt_mp_list);
     889        hlist_del_init_rcu(&mnt->mnt_hash);
     890
     891        attach_mnt(mnt, parent, mp);
     892
     893        put_mountpoint(old_mp);
     894
     895        /*
     896         * Safely avoid even the suggestion this code might sleep or
     897         * lock the mount hash by taking advantage of the knowledge that
     898         * mnt_change_mountpoint will not release the final reference
     899         * to a mountpoint.
     900         *
     901         * During mounting, the mount passed in as the parent mount will
     902         * continue to use the old mountpoint and during unmounting, the
     903         * old mountpoint will continue to exist until namespace_unlock,
     904         * which happens well after mnt_change_mountpoint.
     905         */
     906        spin_lock(&old_mountpoint->d_lock);
     907        old_mountpoint->d_lockref.count--;
     908        spin_unlock(&old_mountpoint->d_lock);
     909
     910        mnt_add_count(old_parent, -1);
    909911}
    910912
     
    912914 * vfsmount lock must be held for write
    913915 */
    914 static void commit_tree(struct mount *mnt, struct mount *shadows)
     916static void commit_tree(struct mount *mnt)
    915917{
    916918        struct mount *parent = mnt->mnt_parent;
     
    930932        n->pending_mounts = 0;
    931933
    932         attach_shadowed(mnt, parent, shadows);
     934        __attach_mnt(mnt, parent);
    933935        touch_mnt_namespace(n);
    934936}
     
    993995}
    994996EXPORT_SYMBOL_GPL(vfs_kern_mount);
     997
     998struct vfsmount *
     999vfs_submount(const struct dentry *mountpoint, struct file_system_type *type,
     1000             const char *name, void *data)
     1001{
     1002        /* Until it is worked out how to pass the user namespace
     1003         * through from the parent mount to the submount don't support
     1004         * unprivileged mounts with submounts.
     1005         */
     1006        if (mountpoint->d_sb->s_user_ns != &init_user_ns)
     1007                return ERR_PTR(-EPERM);
     1008
     1009        return vfs_kern_mount(type, MS_SUBMOUNT, name, data);
     1010}
     1011EXPORT_SYMBOL_GPL(vfs_submount);
    9951012
    9961013static struct mount *clone_mnt(struct mount *old, struct dentry *root,
     
    17381755
    17391756                for (s = r; s; s = next_mnt(s, r)) {
    1740                         struct mount *t = NULL;
    17411757                        if (!(flag & CL_COPY_UNBINDABLE) &&
    17421758                            IS_MNT_UNBINDABLE(s)) {
     
    17601776                        lock_mount_hash();
    17611777                        list_add_tail(&q->mnt_list, &res->mnt_list);
    1762                         mnt_set_mountpoint(parent, p->mnt_mp, q);
    1763                         if (!list_empty(&parent->mnt_mounts)) {
    1764                                 t = list_last_entry(&parent->mnt_mounts,
    1765                                         struct mount, mnt_child);
    1766                                 if (t->mnt_mp != p->mnt_mp)
    1767                                         t = NULL;
    1768                         }
    1769                         attach_shadowed(q, parent, t);
     1778                        attach_mnt(q, parent, p->mnt_mp);
    17701779                        unlock_mount_hash();
    17711780                }
     
    19681977        HLIST_HEAD(tree_list);
    19691978        struct mnt_namespace *ns = dest_mnt->mnt_ns;
     1979        struct mountpoint *smp;
    19701980        struct mount *child, *p;
    19711981        struct hlist_node *n;
    19721982        int err;
     1983
     1984        /* Preallocate a mountpoint in case the new mounts need
     1985         * to be tucked under other mounts.
     1986         */
     1987        smp = get_mountpoint(source_mnt->mnt.mnt_root);
     1988        if (IS_ERR(smp))
     1989                return PTR_ERR(smp);
    19731990
    19741991        /* Is there space to add these mounts to the mount namespace? */
     
    19982015        } else {
    19992016                mnt_set_mountpoint(dest_mnt, dest_mp, source_mnt);
    2000                 commit_tree(source_mnt, NULL);
     2017                commit_tree(source_mnt);
    20012018        }
    20022019
     
    20042021                struct mount *q;
    20052022                hlist_del_init(&child->mnt_hash);
    2006                 q = __lookup_mnt_last(&child->mnt_parent->mnt,
    2007                                       child->mnt_mountpoint);
    2008                 commit_tree(child, q);
    2009         }
     2023                q = __lookup_mnt(&child->mnt_parent->mnt,
     2024                                 child->mnt_mountpoint);
     2025                if (q)
     2026                        mnt_change_mountpoint(child, smp, q);
     2027                commit_tree(child);
     2028        }
     2029        put_mountpoint(smp);
    20102030        unlock_mount_hash();
    20112031
     
    20222042 out:
    20232043        ns->pending_mounts = 0;
     2044
     2045        read_seqlock_excl(&mount_lock);
     2046        put_mountpoint(smp);
     2047        read_sequnlock_excl(&mount_lock);
     2048
    20242049        return err;
    20252050}
     
    27702795        flags &= ~(MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_ACTIVE | MS_BORN |
    27712796                   MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
    2772                    MS_STRICTATIME | MS_NOREMOTELOCK);
     2797                   MS_STRICTATIME | MS_NOREMOTELOCK | MS_SUBMOUNT);
    27732798
    27742799        if (flags & MS_REMOUNT)
Note: See TracChangeset for help on using the changeset viewer.