提交 3376f34f 编写于 作者: A Al Viro

vfs: mnt_parent moved to struct mount

the second victim...
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 643822b4
...@@ -2465,7 +2465,7 @@ static int prepend_path(const struct path *path, ...@@ -2465,7 +2465,7 @@ static int prepend_path(const struct path *path,
if (!mnt_has_parent(mnt)) if (!mnt_has_parent(mnt))
goto global_root; goto global_root;
dentry = vfsmnt->mnt_mountpoint; dentry = vfsmnt->mnt_mountpoint;
vfsmnt = vfsmnt->mnt_parent; vfsmnt = mnt->mnt_parent;
continue; continue;
} }
parent = dentry->d_parent; parent = dentry->d_parent;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
struct mount { struct mount {
struct list_head mnt_hash; struct list_head mnt_hash;
struct vfsmount *mnt_parent;
struct vfsmount mnt; struct vfsmount mnt;
}; };
...@@ -12,7 +13,7 @@ static inline struct mount *real_mount(struct vfsmount *mnt) ...@@ -12,7 +13,7 @@ static inline struct mount *real_mount(struct vfsmount *mnt)
static inline int mnt_has_parent(struct mount *mnt) static inline int mnt_has_parent(struct mount *mnt)
{ {
return &mnt->mnt != mnt->mnt.mnt_parent; return &mnt->mnt != mnt->mnt_parent;
} }
extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int); extern struct mount *__lookup_mnt(struct vfsmount *, struct dentry *, int);
...@@ -680,7 +680,7 @@ static int follow_up_rcu(struct path *path) ...@@ -680,7 +680,7 @@ static int follow_up_rcu(struct path *path)
struct vfsmount *parent; struct vfsmount *parent;
struct dentry *mountpoint; struct dentry *mountpoint;
parent = path->mnt->mnt_parent; parent = real_mount(path->mnt)->mnt_parent;
if (parent == path->mnt) if (parent == path->mnt)
return 0; return 0;
mountpoint = path->mnt->mnt_mountpoint; mountpoint = path->mnt->mnt_mountpoint;
...@@ -695,7 +695,7 @@ int follow_up(struct path *path) ...@@ -695,7 +695,7 @@ int follow_up(struct path *path)
struct dentry *mountpoint; struct dentry *mountpoint;
br_read_lock(vfsmount_lock); br_read_lock(vfsmount_lock);
parent = path->mnt->mnt_parent; parent = real_mount(path->mnt)->mnt_parent;
if (parent == path->mnt) { if (parent == path->mnt) {
br_read_unlock(vfsmount_lock); br_read_unlock(vfsmount_lock);
return 0; return 0;
......
...@@ -476,7 +476,7 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry, ...@@ -476,7 +476,7 @@ struct mount *__lookup_mnt(struct vfsmount *mnt, struct dentry *dentry,
if (tmp == head) if (tmp == head)
break; break;
p = list_entry(tmp, struct mount, mnt_hash); p = list_entry(tmp, struct mount, mnt_hash);
if (p->mnt.mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) { if (p->mnt_parent == mnt && p->mnt.mnt_mountpoint == dentry) {
found = p; found = p;
break; break;
} }
...@@ -558,8 +558,8 @@ static void dentry_reset_mounted(struct dentry *dentry) ...@@ -558,8 +558,8 @@ static void dentry_reset_mounted(struct dentry *dentry)
static void detach_mnt(struct mount *mnt, struct path *old_path) static void detach_mnt(struct mount *mnt, struct path *old_path)
{ {
old_path->dentry = mnt->mnt.mnt_mountpoint; old_path->dentry = mnt->mnt.mnt_mountpoint;
old_path->mnt = mnt->mnt.mnt_parent; old_path->mnt = mnt->mnt_parent;
mnt->mnt.mnt_parent = &mnt->mnt; mnt->mnt_parent = &mnt->mnt;
mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root;
list_del_init(&mnt->mnt.mnt_child); list_del_init(&mnt->mnt.mnt_child);
list_del_init(&mnt->mnt_hash); list_del_init(&mnt->mnt_hash);
...@@ -572,7 +572,7 @@ static void detach_mnt(struct mount *mnt, struct path *old_path) ...@@ -572,7 +572,7 @@ static void detach_mnt(struct mount *mnt, struct path *old_path)
void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
struct mount *child_mnt) struct mount *child_mnt)
{ {
child_mnt->mnt.mnt_parent = mntget(mnt); child_mnt->mnt_parent = mntget(mnt);
child_mnt->mnt.mnt_mountpoint = dget(dentry); child_mnt->mnt.mnt_mountpoint = dget(dentry);
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
dentry->d_flags |= DCACHE_MOUNTED; dentry->d_flags |= DCACHE_MOUNTED;
...@@ -610,7 +610,7 @@ static inline void __mnt_make_shortterm(struct vfsmount *mnt) ...@@ -610,7 +610,7 @@ static inline void __mnt_make_shortterm(struct vfsmount *mnt)
*/ */
static void commit_tree(struct mount *mnt) static void commit_tree(struct mount *mnt)
{ {
struct vfsmount *parent = mnt->mnt.mnt_parent; struct vfsmount *parent = mnt->mnt_parent;
struct vfsmount *m; struct vfsmount *m;
LIST_HEAD(head); LIST_HEAD(head);
struct mnt_namespace *n = parent->mnt_ns; struct mnt_namespace *n = parent->mnt_ns;
...@@ -639,9 +639,9 @@ static struct mount *next_mnt(struct mount *p, struct vfsmount *root) ...@@ -639,9 +639,9 @@ static struct mount *next_mnt(struct mount *p, struct vfsmount *root)
if (&p->mnt == root) if (&p->mnt == root)
return NULL; return NULL;
next = p->mnt.mnt_child.next; next = p->mnt.mnt_child.next;
if (next != &p->mnt.mnt_parent->mnt_mounts) if (next != &p->mnt_parent->mnt_mounts)
break; break;
p = real_mount(p->mnt.mnt_parent); p = real_mount(p->mnt_parent);
} }
} }
return list_entry(next, struct mount, mnt.mnt_child); return list_entry(next, struct mount, mnt.mnt_child);
...@@ -682,7 +682,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void ...@@ -682,7 +682,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
mnt->mnt.mnt_root = root; mnt->mnt.mnt_root = root;
mnt->mnt.mnt_sb = root->d_sb; mnt->mnt.mnt_sb = root->d_sb;
mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt.mnt_parent = &mnt->mnt; mnt->mnt_parent = &mnt->mnt;
return &mnt->mnt; return &mnt->mnt;
} }
EXPORT_SYMBOL_GPL(vfs_kern_mount); EXPORT_SYMBOL_GPL(vfs_kern_mount);
...@@ -710,7 +710,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, ...@@ -710,7 +710,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
mnt->mnt.mnt_sb = sb; mnt->mnt.mnt_sb = sb;
mnt->mnt.mnt_root = dget(root); mnt->mnt.mnt_root = dget(root);
mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt.mnt_parent = &mnt->mnt; mnt->mnt_parent = &mnt->mnt;
if (flag & CL_SLAVE) { if (flag & CL_SLAVE) {
list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list); list_add(&mnt->mnt.mnt_slave, &old->mnt.mnt_slave_list);
...@@ -1021,12 +1021,13 @@ static int show_mountinfo(struct seq_file *m, void *v) ...@@ -1021,12 +1021,13 @@ static int show_mountinfo(struct seq_file *m, void *v)
{ {
struct proc_mounts *p = m->private; struct proc_mounts *p = m->private;
struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
struct mount *r = real_mount(mnt);
struct super_block *sb = mnt->mnt_sb; struct super_block *sb = mnt->mnt_sb;
struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
struct path root = p->root; struct path root = p->root;
int err = 0; int err = 0;
seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, mnt->mnt_parent->mnt_id, seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, r->mnt_parent->mnt_id,
MAJOR(sb->s_dev), MINOR(sb->s_dev)); MAJOR(sb->s_dev), MINOR(sb->s_dev));
if (sb->s_op->show_path) if (sb->s_op->show_path)
err = sb->s_op->show_path(m, mnt); err = sb->s_op->show_path(m, mnt);
...@@ -1201,9 +1202,9 @@ void release_mounts(struct list_head *head) ...@@ -1201,9 +1202,9 @@ void release_mounts(struct list_head *head)
br_write_lock(vfsmount_lock); br_write_lock(vfsmount_lock);
dentry = mnt->mnt.mnt_mountpoint; dentry = mnt->mnt.mnt_mountpoint;
m = mnt->mnt.mnt_parent; m = mnt->mnt_parent;
mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt.mnt_parent = &mnt->mnt; mnt->mnt_parent = &mnt->mnt;
m->mnt_ghosts--; m->mnt_ghosts--;
br_write_unlock(vfsmount_lock); br_write_unlock(vfsmount_lock);
dput(dentry); dput(dentry);
...@@ -1236,7 +1237,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill) ...@@ -1236,7 +1237,7 @@ void umount_tree(struct mount *mnt, int propagate, struct list_head *kill)
__mnt_make_shortterm(&p->mnt); __mnt_make_shortterm(&p->mnt);
list_del_init(&p->mnt.mnt_child); list_del_init(&p->mnt.mnt_child);
if (mnt_has_parent(p)) { if (mnt_has_parent(p)) {
p->mnt.mnt_parent->mnt_ghosts++; p->mnt_parent->mnt_ghosts++;
dentry_reset_mounted(p->mnt.mnt_mountpoint); dentry_reset_mounted(p->mnt.mnt_mountpoint);
} }
change_mnt_propagation(p, MS_PRIVATE); change_mnt_propagation(p, MS_PRIVATE);
...@@ -1434,9 +1435,9 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, ...@@ -1434,9 +1435,9 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
s = skip_mnt_tree(s); s = skip_mnt_tree(s);
continue; continue;
} }
while (p != real_mount(s->mnt.mnt_parent)) { while (p != real_mount(s->mnt_parent)) {
p = real_mount(p->mnt.mnt_parent); p = real_mount(p->mnt_parent);
q = real_mount(q->mnt.mnt_parent); q = real_mount(q->mnt_parent);
} }
p = s; p = s;
path.mnt = &q->mnt; path.mnt = &q->mnt;
...@@ -1898,7 +1899,7 @@ static int do_move_mount(struct path *path, char *old_name) ...@@ -1898,7 +1899,7 @@ static int do_move_mount(struct path *path, char *old_name)
/* /*
* Don't move a mount residing in a shared parent. * Don't move a mount residing in a shared parent.
*/ */
if (IS_MNT_SHARED(old_path.mnt->mnt_parent)) if (IS_MNT_SHARED(old->mnt_parent))
goto out1; goto out1;
/* /*
* Don't move a mount tree containing unbindable mounts to a destination * Don't move a mount tree containing unbindable mounts to a destination
...@@ -1908,7 +1909,7 @@ static int do_move_mount(struct path *path, char *old_name) ...@@ -1908,7 +1909,7 @@ static int do_move_mount(struct path *path, char *old_name)
tree_contains_unbindable(old)) tree_contains_unbindable(old))
goto out1; goto out1;
err = -ELOOP; err = -ELOOP;
for (p = real_mount(path->mnt); mnt_has_parent(p); p = real_mount(p->mnt.mnt_parent)) for (p = real_mount(path->mnt); mnt_has_parent(p); p = real_mount(p->mnt_parent))
if (p == old) if (p == old)
goto out1; goto out1;
...@@ -2158,7 +2159,7 @@ static int select_submounts(struct mount *parent, struct list_head *graveyard) ...@@ -2158,7 +2159,7 @@ static int select_submounts(struct mount *parent, struct list_head *graveyard)
*/ */
if (this_parent != parent) { if (this_parent != parent) {
next = this_parent->mnt.mnt_child.next; next = this_parent->mnt.mnt_child.next;
this_parent = real_mount(this_parent->mnt.mnt_parent); this_parent = real_mount(this_parent->mnt_parent);
goto resume; goto resume;
} }
return found; return found;
...@@ -2564,7 +2565,7 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry, ...@@ -2564,7 +2565,7 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry,
{ {
while (&mnt->mnt != root->mnt && mnt_has_parent(mnt)) { while (&mnt->mnt != root->mnt && mnt_has_parent(mnt)) {
dentry = mnt->mnt.mnt_mountpoint; dentry = mnt->mnt.mnt_mountpoint;
mnt = real_mount(mnt->mnt.mnt_parent); mnt = real_mount(mnt->mnt_parent);
} }
return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry); return &mnt->mnt == root->mnt && is_subdir(dentry, root->dentry);
} }
...@@ -2635,8 +2636,8 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, ...@@ -2635,8 +2636,8 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
new_mnt = real_mount(new.mnt); new_mnt = real_mount(new.mnt);
root_mnt = real_mount(root.mnt); root_mnt = real_mount(root.mnt);
if (IS_MNT_SHARED(old.mnt) || if (IS_MNT_SHARED(old.mnt) ||
IS_MNT_SHARED(new.mnt->mnt_parent) || IS_MNT_SHARED(new_mnt->mnt_parent) ||
IS_MNT_SHARED(root.mnt->mnt_parent)) IS_MNT_SHARED(root_mnt->mnt_parent))
goto out4; goto out4;
if (!check_mnt(root.mnt) || !check_mnt(new.mnt)) if (!check_mnt(root.mnt) || !check_mnt(new.mnt))
goto out4; goto out4;
......
...@@ -292,7 +292,7 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) ...@@ -292,7 +292,7 @@ int propagate_mount_busy(struct mount *mnt, int refcnt)
{ {
struct vfsmount *m; struct vfsmount *m;
struct mount *child; struct mount *child;
struct vfsmount *parent = mnt->mnt.mnt_parent; struct vfsmount *parent = mnt->mnt_parent;
int ret = 0; int ret = 0;
if (&mnt->mnt == parent) if (&mnt->mnt == parent)
...@@ -322,7 +322,7 @@ int propagate_mount_busy(struct mount *mnt, int refcnt) ...@@ -322,7 +322,7 @@ int propagate_mount_busy(struct mount *mnt, int refcnt)
*/ */
static void __propagate_umount(struct mount *mnt) static void __propagate_umount(struct mount *mnt)
{ {
struct vfsmount *parent = mnt->mnt.mnt_parent; struct vfsmount *parent = mnt->mnt_parent;
struct vfsmount *m; struct vfsmount *m;
BUG_ON(parent == &mnt->mnt); BUG_ON(parent == &mnt->mnt);
......
...@@ -53,7 +53,6 @@ struct mnt_pcp { ...@@ -53,7 +53,6 @@ struct mnt_pcp {
}; };
struct vfsmount { struct vfsmount {
struct vfsmount *mnt_parent; /* fs we are mounted on */
struct dentry *mnt_mountpoint; /* dentry of mountpoint */ struct dentry *mnt_mountpoint; /* dentry of mountpoint */
struct dentry *mnt_root; /* root of the mounted tree */ struct dentry *mnt_root; /* root of the mounted tree */
struct super_block *mnt_sb; /* pointer to superblock */ struct super_block *mnt_sb; /* pointer to superblock */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册