diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-11-25 00:46:35 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:57:09 -0500 |
commit | 143c8c91cee7efdd732ec5f61b3471fc46192f20 (patch) | |
tree | dd3e9a9b8b88f1876a258fe1bf274532aeb72a62 /fs | |
parent | 900148dcac6bc93ca688d64a7f9a9f8d706e0d1c (diff) |
vfs: mnt_ns moved to struct mount
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 2 | ||||
-rw-r--r-- | fs/mount.h | 1 | ||||
-rw-r--r-- | fs/namespace.c | 45 | ||||
-rw-r--r-- | fs/pnode.c | 10 |
4 files changed, 30 insertions, 28 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 24790041ea76..9791b1e7eee4 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -2503,7 +2503,7 @@ global_root: | |||
2503 | if (!slash) | 2503 | if (!slash) |
2504 | error = prepend(buffer, buflen, "/", 1); | 2504 | error = prepend(buffer, buflen, "/", 1); |
2505 | if (!error) | 2505 | if (!error) |
2506 | error = vfsmnt->mnt_ns ? 1 : 2; | 2506 | error = real_mount(vfsmnt)->mnt_ns ? 1 : 2; |
2507 | goto out; | 2507 | goto out; |
2508 | } | 2508 | } |
2509 | 2509 | ||
diff --git a/fs/mount.h b/fs/mount.h index eb62ad232e4d..4a5f1dca0c2e 100644 --- a/fs/mount.h +++ b/fs/mount.h | |||
@@ -25,6 +25,7 @@ struct mount { | |||
25 | struct list_head mnt_slave_list;/* list of slave mounts */ | 25 | struct list_head mnt_slave_list;/* list of slave mounts */ |
26 | struct list_head mnt_slave; /* slave list entry */ | 26 | struct list_head mnt_slave; /* slave list entry */ |
27 | struct mount *mnt_master; /* slave is on master->mnt_slave_list */ | 27 | struct mount *mnt_master; /* slave is on master->mnt_slave_list */ |
28 | struct mnt_namespace *mnt_ns; /* containing namespace */ | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | static inline struct mount *real_mount(struct vfsmount *mnt) | 31 | static inline struct mount *real_mount(struct vfsmount *mnt) |
diff --git a/fs/namespace.c b/fs/namespace.c index 3e95cc26dda6..4cdb7f698613 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -505,7 +505,7 @@ struct vfsmount *lookup_mnt(struct path *path) | |||
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | static inline int check_mnt(struct vfsmount *mnt) | 508 | static inline int check_mnt(struct mount *mnt) |
509 | { | 509 | { |
510 | return mnt->mnt_ns == current->nsproxy->mnt_ns; | 510 | return mnt->mnt_ns == current->nsproxy->mnt_ns; |
511 | } | 511 | } |
@@ -614,13 +614,13 @@ static void commit_tree(struct mount *mnt) | |||
614 | struct mount *parent = mnt->mnt_parent; | 614 | struct mount *parent = mnt->mnt_parent; |
615 | struct mount *m; | 615 | struct mount *m; |
616 | LIST_HEAD(head); | 616 | LIST_HEAD(head); |
617 | struct mnt_namespace *n = parent->mnt.mnt_ns; | 617 | struct mnt_namespace *n = parent->mnt_ns; |
618 | 618 | ||
619 | BUG_ON(parent == mnt); | 619 | BUG_ON(parent == mnt); |
620 | 620 | ||
621 | list_add_tail(&head, &mnt->mnt.mnt_list); | 621 | list_add_tail(&head, &mnt->mnt.mnt_list); |
622 | list_for_each_entry(m, &head, mnt.mnt_list) { | 622 | list_for_each_entry(m, &head, mnt.mnt_list) { |
623 | m->mnt.mnt_ns = n; | 623 | m->mnt_ns = n; |
624 | __mnt_make_longterm(m); | 624 | __mnt_make_longterm(m); |
625 | } | 625 | } |
626 | 626 | ||
@@ -1234,8 +1234,8 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) | |||
1234 | list_for_each_entry(p, &tmp_list, mnt_hash) { | 1234 | list_for_each_entry(p, &tmp_list, mnt_hash) { |
1235 | list_del_init(&p->mnt_expire); | 1235 | list_del_init(&p->mnt_expire); |
1236 | list_del_init(&p->mnt.mnt_list); | 1236 | list_del_init(&p->mnt.mnt_list); |
1237 | __touch_mnt_namespace(p->mnt.mnt_ns); | 1237 | __touch_mnt_namespace(p->mnt_ns); |
1238 | p->mnt.mnt_ns = NULL; | 1238 | p->mnt_ns = NULL; |
1239 | __mnt_make_shortterm(p); | 1239 | __mnt_make_shortterm(p); |
1240 | list_del_init(&p->mnt_child); | 1240 | list_del_init(&p->mnt_child); |
1241 | if (mnt_has_parent(p)) { | 1241 | if (mnt_has_parent(p)) { |
@@ -1367,7 +1367,7 @@ SYSCALL_DEFINE2(umount, char __user *, name, int, flags) | |||
1367 | retval = -EINVAL; | 1367 | retval = -EINVAL; |
1368 | if (path.dentry != path.mnt->mnt_root) | 1368 | if (path.dentry != path.mnt->mnt_root) |
1369 | goto dput_and_out; | 1369 | goto dput_and_out; |
1370 | if (!check_mnt(path.mnt)) | 1370 | if (!check_mnt(mnt)) |
1371 | goto dput_and_out; | 1371 | goto dput_and_out; |
1372 | 1372 | ||
1373 | retval = -EPERM; | 1373 | retval = -EPERM; |
@@ -1619,7 +1619,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, | |||
1619 | if (parent_path) { | 1619 | if (parent_path) { |
1620 | detach_mnt(source_mnt, parent_path); | 1620 | detach_mnt(source_mnt, parent_path); |
1621 | attach_mnt(source_mnt, path); | 1621 | attach_mnt(source_mnt, path); |
1622 | touch_mnt_namespace(parent_path->mnt->mnt_ns); | 1622 | touch_mnt_namespace(source_mnt->mnt_ns); |
1623 | } else { | 1623 | } else { |
1624 | mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); | 1624 | mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt); |
1625 | commit_tree(source_mnt); | 1625 | commit_tree(source_mnt); |
@@ -1765,7 +1765,7 @@ static int do_loopback(struct path *path, char *old_name, | |||
1765 | if (IS_MNT_UNBINDABLE(old_path.mnt)) | 1765 | if (IS_MNT_UNBINDABLE(old_path.mnt)) |
1766 | goto out2; | 1766 | goto out2; |
1767 | 1767 | ||
1768 | if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) | 1768 | if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old)) |
1769 | goto out2; | 1769 | goto out2; |
1770 | 1770 | ||
1771 | err = -ENOMEM; | 1771 | err = -ENOMEM; |
@@ -1818,11 +1818,12 @@ static int do_remount(struct path *path, int flags, int mnt_flags, | |||
1818 | { | 1818 | { |
1819 | int err; | 1819 | int err; |
1820 | struct super_block *sb = path->mnt->mnt_sb; | 1820 | struct super_block *sb = path->mnt->mnt_sb; |
1821 | struct mount *mnt = real_mount(path->mnt); | ||
1821 | 1822 | ||
1822 | if (!capable(CAP_SYS_ADMIN)) | 1823 | if (!capable(CAP_SYS_ADMIN)) |
1823 | return -EPERM; | 1824 | return -EPERM; |
1824 | 1825 | ||
1825 | if (!check_mnt(path->mnt)) | 1826 | if (!check_mnt(mnt)) |
1826 | return -EINVAL; | 1827 | return -EINVAL; |
1827 | 1828 | ||
1828 | if (path->dentry != path->mnt->mnt_root) | 1829 | if (path->dentry != path->mnt->mnt_root) |
@@ -1839,14 +1840,14 @@ static int do_remount(struct path *path, int flags, int mnt_flags, | |||
1839 | err = do_remount_sb(sb, flags, data, 0); | 1840 | err = do_remount_sb(sb, flags, data, 0); |
1840 | if (!err) { | 1841 | if (!err) { |
1841 | br_write_lock(vfsmount_lock); | 1842 | br_write_lock(vfsmount_lock); |
1842 | mnt_flags |= path->mnt->mnt_flags & MNT_PROPAGATION_MASK; | 1843 | mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK; |
1843 | path->mnt->mnt_flags = mnt_flags; | 1844 | mnt->mnt.mnt_flags = mnt_flags; |
1844 | br_write_unlock(vfsmount_lock); | 1845 | br_write_unlock(vfsmount_lock); |
1845 | } | 1846 | } |
1846 | up_write(&sb->s_umount); | 1847 | up_write(&sb->s_umount); |
1847 | if (!err) { | 1848 | if (!err) { |
1848 | br_write_lock(vfsmount_lock); | 1849 | br_write_lock(vfsmount_lock); |
1849 | touch_mnt_namespace(path->mnt->mnt_ns); | 1850 | touch_mnt_namespace(mnt->mnt_ns); |
1850 | br_write_unlock(vfsmount_lock); | 1851 | br_write_unlock(vfsmount_lock); |
1851 | } | 1852 | } |
1852 | return err; | 1853 | return err; |
@@ -1880,8 +1881,10 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1880 | if (err < 0) | 1881 | if (err < 0) |
1881 | goto out; | 1882 | goto out; |
1882 | 1883 | ||
1884 | old = real_mount(old_path.mnt); | ||
1885 | |||
1883 | err = -EINVAL; | 1886 | err = -EINVAL; |
1884 | if (!check_mnt(path->mnt) || !check_mnt(old_path.mnt)) | 1887 | if (!check_mnt(real_mount(path->mnt)) || !check_mnt(old)) |
1885 | goto out1; | 1888 | goto out1; |
1886 | 1889 | ||
1887 | if (d_unlinked(path->dentry)) | 1890 | if (d_unlinked(path->dentry)) |
@@ -1891,8 +1894,6 @@ static int do_move_mount(struct path *path, char *old_name) | |||
1891 | if (old_path.dentry != old_path.mnt->mnt_root) | 1894 | if (old_path.dentry != old_path.mnt->mnt_root) |
1892 | goto out1; | 1895 | goto out1; |
1893 | 1896 | ||
1894 | old = real_mount(old_path.mnt); | ||
1895 | |||
1896 | if (!mnt_has_parent(old)) | 1897 | if (!mnt_has_parent(old)) |
1897 | goto out1; | 1898 | goto out1; |
1898 | 1899 | ||
@@ -1984,7 +1985,7 @@ static int do_add_mount(struct mount *newmnt, struct path *path, int mnt_flags) | |||
1984 | return err; | 1985 | return err; |
1985 | 1986 | ||
1986 | err = -EINVAL; | 1987 | err = -EINVAL; |
1987 | if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(path->mnt)) | 1988 | if (!(mnt_flags & MNT_SHRINKABLE) && !check_mnt(real_mount(path->mnt))) |
1988 | goto unlock; | 1989 | goto unlock; |
1989 | 1990 | ||
1990 | /* Refuse the same filesystem on the same mount point */ | 1991 | /* Refuse the same filesystem on the same mount point */ |
@@ -2112,7 +2113,7 @@ void mark_mounts_for_expiry(struct list_head *mounts) | |||
2112 | } | 2113 | } |
2113 | while (!list_empty(&graveyard)) { | 2114 | while (!list_empty(&graveyard)) { |
2114 | mnt = list_first_entry(&graveyard, struct mount, mnt_expire); | 2115 | mnt = list_first_entry(&graveyard, struct mount, mnt_expire); |
2115 | touch_mnt_namespace(mnt->mnt.mnt_ns); | 2116 | touch_mnt_namespace(mnt->mnt_ns); |
2116 | umount_tree(mnt, 1, &umounts); | 2117 | umount_tree(mnt, 1, &umounts); |
2117 | } | 2118 | } |
2118 | br_write_unlock(vfsmount_lock); | 2119 | br_write_unlock(vfsmount_lock); |
@@ -2185,7 +2186,7 @@ static void shrink_submounts(struct mount *mnt, struct list_head *umounts) | |||
2185 | while (!list_empty(&graveyard)) { | 2186 | while (!list_empty(&graveyard)) { |
2186 | m = list_first_entry(&graveyard, struct mount, | 2187 | m = list_first_entry(&graveyard, struct mount, |
2187 | mnt_expire); | 2188 | mnt_expire); |
2188 | touch_mnt_namespace(m->mnt.mnt_ns); | 2189 | touch_mnt_namespace(m->mnt_ns); |
2189 | umount_tree(m, 1, umounts); | 2190 | umount_tree(m, 1, umounts); |
2190 | } | 2191 | } |
2191 | } | 2192 | } |
@@ -2423,7 +2424,7 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, | |||
2423 | p = real_mount(mnt_ns->root); | 2424 | p = real_mount(mnt_ns->root); |
2424 | q = new; | 2425 | q = new; |
2425 | while (p) { | 2426 | while (p) { |
2426 | q->mnt.mnt_ns = new_ns; | 2427 | q->mnt_ns = new_ns; |
2427 | __mnt_make_longterm(q); | 2428 | __mnt_make_longterm(q); |
2428 | if (fs) { | 2429 | if (fs) { |
2429 | if (&p->mnt == fs->root.mnt) { | 2430 | if (&p->mnt == fs->root.mnt) { |
@@ -2479,7 +2480,7 @@ static struct mnt_namespace *create_mnt_ns(struct vfsmount *mnt) | |||
2479 | 2480 | ||
2480 | new_ns = alloc_mnt_ns(); | 2481 | new_ns = alloc_mnt_ns(); |
2481 | if (!IS_ERR(new_ns)) { | 2482 | if (!IS_ERR(new_ns)) { |
2482 | mnt->mnt_ns = new_ns; | 2483 | real_mount(mnt)->mnt_ns = new_ns; |
2483 | __mnt_make_longterm(real_mount(mnt)); | 2484 | __mnt_make_longterm(real_mount(mnt)); |
2484 | new_ns->root = mnt; | 2485 | new_ns->root = mnt; |
2485 | list_add(&new_ns->list, &new_ns->root->mnt_list); | 2486 | list_add(&new_ns->list, &new_ns->root->mnt_list); |
@@ -2644,7 +2645,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, | |||
2644 | IS_MNT_SHARED(&new_mnt->mnt_parent->mnt) || | 2645 | IS_MNT_SHARED(&new_mnt->mnt_parent->mnt) || |
2645 | IS_MNT_SHARED(&root_mnt->mnt_parent->mnt)) | 2646 | IS_MNT_SHARED(&root_mnt->mnt_parent->mnt)) |
2646 | goto out4; | 2647 | goto out4; |
2647 | if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) | 2648 | if (!check_mnt(root_mnt) || !check_mnt(new_mnt)) |
2648 | goto out4; | 2649 | goto out4; |
2649 | error = -ENOENT; | 2650 | error = -ENOENT; |
2650 | if (d_unlinked(new.dentry)) | 2651 | if (d_unlinked(new.dentry)) |
@@ -2793,5 +2794,5 @@ EXPORT_SYMBOL(kern_unmount); | |||
2793 | 2794 | ||
2794 | bool our_mnt(struct vfsmount *mnt) | 2795 | bool our_mnt(struct vfsmount *mnt) |
2795 | { | 2796 | { |
2796 | return check_mnt(mnt); | 2797 | return check_mnt(real_mount(mnt)); |
2797 | } | 2798 | } |
diff --git a/fs/pnode.c b/fs/pnode.c index 12cc1518e0cd..cec329822a16 100644 --- a/fs/pnode.c +++ b/fs/pnode.c | |||
@@ -36,7 +36,7 @@ static struct mount *get_peer_under_root(struct mount *mnt, | |||
36 | 36 | ||
37 | do { | 37 | do { |
38 | /* Check the namespace first for optimization */ | 38 | /* Check the namespace first for optimization */ |
39 | if (m->mnt.mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) | 39 | if (m->mnt_ns == ns && is_path_reachable(m, m->mnt.mnt_root, root)) |
40 | return m; | 40 | return m; |
41 | 41 | ||
42 | m = next_peer(m); | 42 | m = next_peer(m); |
@@ -56,7 +56,7 @@ int get_dominating_id(struct mount *mnt, const struct path *root) | |||
56 | struct mount *m; | 56 | struct mount *m; |
57 | 57 | ||
58 | for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { | 58 | for (m = mnt->mnt_master; m != NULL; m = m->mnt_master) { |
59 | struct mount *d = get_peer_under_root(m, mnt->mnt.mnt_ns, root); | 59 | struct mount *d = get_peer_under_root(m, mnt->mnt_ns, root); |
60 | if (d) | 60 | if (d) |
61 | return d->mnt.mnt_group_id; | 61 | return d->mnt.mnt_group_id; |
62 | } | 62 | } |
@@ -145,7 +145,7 @@ static struct mount *propagation_next(struct mount *m, | |||
145 | struct mount *origin) | 145 | struct mount *origin) |
146 | { | 146 | { |
147 | /* are there any slaves of this mount? */ | 147 | /* are there any slaves of this mount? */ |
148 | if (!IS_MNT_NEW(&m->mnt) && !list_empty(&m->mnt_slave_list)) | 148 | if (!IS_MNT_NEW(m) && !list_empty(&m->mnt_slave_list)) |
149 | return first_slave(m); | 149 | return first_slave(m); |
150 | 150 | ||
151 | while (1) { | 151 | while (1) { |
@@ -189,7 +189,7 @@ static struct mount *get_source(struct mount *dest, | |||
189 | if (p_last_dest) { | 189 | if (p_last_dest) { |
190 | do { | 190 | do { |
191 | p_last_dest = next_peer(p_last_dest); | 191 | p_last_dest = next_peer(p_last_dest); |
192 | } while (IS_MNT_NEW(&p_last_dest->mnt)); | 192 | } while (IS_MNT_NEW(p_last_dest)); |
193 | /* is that a peer of the earlier? */ | 193 | /* is that a peer of the earlier? */ |
194 | if (dest == p_last_dest) { | 194 | if (dest == p_last_dest) { |
195 | *type = CL_MAKE_SHARED; | 195 | *type = CL_MAKE_SHARED; |
@@ -232,7 +232,7 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry, | |||
232 | int type; | 232 | int type; |
233 | struct mount *source; | 233 | struct mount *source; |
234 | 234 | ||
235 | if (IS_MNT_NEW(&m->mnt)) | 235 | if (IS_MNT_NEW(m)) |
236 | continue; | 236 | continue; |
237 | 237 | ||
238 | source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); | 238 | source = get_source(m, prev_dest_mnt, prev_src_mnt, &type); |