aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-25 00:50:41 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-03 22:57:10 -0500
commit15169fe784a9846b24cdb0840329d41aebc23249 (patch)
treeef9e843dcd333204fd7fdca6d21fe96d0647da80 /fs
parent143c8c91cee7efdd732ec5f61b3471fc46192f20 (diff)
vfs: mnt_id/mnt_group_id moved
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/fhandle.c4
-rw-r--r--fs/mount.h2
-rw-r--r--fs/namespace.c30
-rw-r--r--fs/pnode.c4
4 files changed, 22 insertions, 18 deletions
diff --git a/fs/fhandle.c b/fs/fhandle.c
index 6b088641f5bf..5eff7116951e 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -10,6 +10,7 @@
10#include <linux/personality.h> 10#include <linux/personality.h>
11#include <asm/uaccess.h> 11#include <asm/uaccess.h>
12#include "internal.h" 12#include "internal.h"
13#include "mount.h"
13 14
14static long do_sys_name_to_handle(struct path *path, 15static long do_sys_name_to_handle(struct path *path,
15 struct file_handle __user *ufh, 16 struct file_handle __user *ufh,
@@ -66,7 +67,8 @@ static long do_sys_name_to_handle(struct path *path,
66 } else 67 } else
67 retval = 0; 68 retval = 0;
68 /* copy the mount id */ 69 /* copy the mount id */
69 if (copy_to_user(mnt_id, &path->mnt->mnt_id, sizeof(*mnt_id)) || 70 if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
71 sizeof(*mnt_id)) ||
70 copy_to_user(ufh, handle, 72 copy_to_user(ufh, handle,
71 sizeof(struct file_handle) + handle_bytes)) 73 sizeof(struct file_handle) + handle_bytes))
72 retval = -EFAULT; 74 retval = -EFAULT;
diff --git a/fs/mount.h b/fs/mount.h
index 4a5f1dca0c2e..c7bd401960ea 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -26,6 +26,8 @@ struct mount {
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 struct mnt_namespace *mnt_ns; /* containing namespace */
29 int mnt_id; /* mount identifier */
30 int mnt_group_id; /* peer group identifier */
29}; 31};
30 32
31static inline struct mount *real_mount(struct vfsmount *mnt) 33static inline struct mount *real_mount(struct vfsmount *mnt)
diff --git a/fs/namespace.c b/fs/namespace.c
index 4cdb7f698613..dfed9a25f204 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -85,9 +85,9 @@ static int mnt_alloc_id(struct mount *mnt)
85retry: 85retry:
86 ida_pre_get(&mnt_id_ida, GFP_KERNEL); 86 ida_pre_get(&mnt_id_ida, GFP_KERNEL);
87 spin_lock(&mnt_id_lock); 87 spin_lock(&mnt_id_lock);
88 res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt.mnt_id); 88 res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt_id);
89 if (!res) 89 if (!res)
90 mnt_id_start = mnt->mnt.mnt_id + 1; 90 mnt_id_start = mnt->mnt_id + 1;
91 spin_unlock(&mnt_id_lock); 91 spin_unlock(&mnt_id_lock);
92 if (res == -EAGAIN) 92 if (res == -EAGAIN)
93 goto retry; 93 goto retry;
@@ -97,7 +97,7 @@ retry:
97 97
98static void mnt_free_id(struct mount *mnt) 98static void mnt_free_id(struct mount *mnt)
99{ 99{
100 int id = mnt->mnt.mnt_id; 100 int id = mnt->mnt_id;
101 spin_lock(&mnt_id_lock); 101 spin_lock(&mnt_id_lock);
102 ida_remove(&mnt_id_ida, id); 102 ida_remove(&mnt_id_ida, id);
103 if (mnt_id_start > id) 103 if (mnt_id_start > id)
@@ -119,9 +119,9 @@ static int mnt_alloc_group_id(struct mount *mnt)
119 119
120 res = ida_get_new_above(&mnt_group_ida, 120 res = ida_get_new_above(&mnt_group_ida,
121 mnt_group_start, 121 mnt_group_start,
122 &mnt->mnt.mnt_group_id); 122 &mnt->mnt_group_id);
123 if (!res) 123 if (!res)
124 mnt_group_start = mnt->mnt.mnt_group_id + 1; 124 mnt_group_start = mnt->mnt_group_id + 1;
125 125
126 return res; 126 return res;
127} 127}
@@ -131,11 +131,11 @@ static int mnt_alloc_group_id(struct mount *mnt)
131 */ 131 */
132void mnt_release_group_id(struct mount *mnt) 132void mnt_release_group_id(struct mount *mnt)
133{ 133{
134 int id = mnt->mnt.mnt_group_id; 134 int id = mnt->mnt_group_id;
135 ida_remove(&mnt_group_ida, id); 135 ida_remove(&mnt_group_ida, id);
136 if (mnt_group_start > id) 136 if (mnt_group_start > id)
137 mnt_group_start = id; 137 mnt_group_start = id;
138 mnt->mnt.mnt_group_id = 0; 138 mnt->mnt_group_id = 0;
139} 139}
140 140
141/* 141/*
@@ -696,11 +696,11 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
696 696
697 if (mnt) { 697 if (mnt) {
698 if (flag & (CL_SLAVE | CL_PRIVATE)) 698 if (flag & (CL_SLAVE | CL_PRIVATE))
699 mnt->mnt.mnt_group_id = 0; /* not a peer of original */ 699 mnt->mnt_group_id = 0; /* not a peer of original */
700 else 700 else
701 mnt->mnt.mnt_group_id = old->mnt.mnt_group_id; 701 mnt->mnt_group_id = old->mnt_group_id;
702 702
703 if ((flag & CL_MAKE_SHARED) && !mnt->mnt.mnt_group_id) { 703 if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) {
704 int err = mnt_alloc_group_id(mnt); 704 int err = mnt_alloc_group_id(mnt);
705 if (err) 705 if (err)
706 goto out_free; 706 goto out_free;
@@ -1029,7 +1029,7 @@ static int show_mountinfo(struct seq_file *m, void *v)
1029 struct path root = p->root; 1029 struct path root = p->root;
1030 int err = 0; 1030 int err = 0;
1031 1031
1032 seq_printf(m, "%i %i %u:%u ", mnt->mnt_id, r->mnt_parent->mnt.mnt_id, 1032 seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id,
1033 MAJOR(sb->s_dev), MINOR(sb->s_dev)); 1033 MAJOR(sb->s_dev), MINOR(sb->s_dev));
1034 if (sb->s_op->show_path) 1034 if (sb->s_op->show_path)
1035 err = sb->s_op->show_path(m, mnt); 1035 err = sb->s_op->show_path(m, mnt);
@@ -1049,9 +1049,9 @@ static int show_mountinfo(struct seq_file *m, void *v)
1049 1049
1050 /* Tagged fields ("foo:X" or "bar") */ 1050 /* Tagged fields ("foo:X" or "bar") */
1051 if (IS_MNT_SHARED(mnt)) 1051 if (IS_MNT_SHARED(mnt))
1052 seq_printf(m, " shared:%i", mnt->mnt_group_id); 1052 seq_printf(m, " shared:%i", r->mnt_group_id);
1053 if (IS_MNT_SLAVE(r)) { 1053 if (IS_MNT_SLAVE(r)) {
1054 int master = r->mnt_master->mnt.mnt_group_id; 1054 int master = r->mnt_master->mnt_group_id;
1055 int dom = get_dominating_id(r, &p->root); 1055 int dom = get_dominating_id(r, &p->root);
1056 seq_printf(m, " master:%i", master); 1056 seq_printf(m, " master:%i", master);
1057 if (dom && dom != master) 1057 if (dom && dom != master)
@@ -1507,7 +1507,7 @@ static void cleanup_group_ids(struct mount *mnt, struct mount *end)
1507 struct mount *p; 1507 struct mount *p;
1508 1508
1509 for (p = mnt; p != end; p = next_mnt(p, &mnt->mnt)) { 1509 for (p = mnt; p != end; p = next_mnt(p, &mnt->mnt)) {
1510 if (p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) 1510 if (p->mnt_group_id && !IS_MNT_SHARED(&p->mnt))
1511 mnt_release_group_id(p); 1511 mnt_release_group_id(p);
1512 } 1512 }
1513} 1513}
@@ -1517,7 +1517,7 @@ static int invent_group_ids(struct mount *mnt, bool recurse)
1517 struct mount *p; 1517 struct mount *p;
1518 1518
1519 for (p = mnt; p; p = recurse ? next_mnt(p, &mnt->mnt) : NULL) { 1519 for (p = mnt; p; p = recurse ? next_mnt(p, &mnt->mnt) : NULL) {
1520 if (!p->mnt.mnt_group_id && !IS_MNT_SHARED(&p->mnt)) { 1520 if (!p->mnt_group_id && !IS_MNT_SHARED(&p->mnt)) {
1521 int err = mnt_alloc_group_id(p); 1521 int err = mnt_alloc_group_id(p);
1522 if (err) { 1522 if (err) {
1523 cleanup_group_ids(mnt, p); 1523 cleanup_group_ids(mnt, p);
diff --git a/fs/pnode.c b/fs/pnode.c
index cec329822a16..001c8b0df379 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -58,7 +58,7 @@ int get_dominating_id(struct mount *mnt, const struct path *root)
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_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_group_id;
62 } 62 }
63 63
64 return 0; 64 return 0;
@@ -86,7 +86,7 @@ static int do_make_slave(struct mount *mnt)
86 mnt_release_group_id(mnt); 86 mnt_release_group_id(mnt);
87 87
88 list_del_init(&mnt->mnt_share); 88 list_del_init(&mnt->mnt_share);
89 mnt->mnt.mnt_group_id = 0; 89 mnt->mnt_group_id = 0;
90 90
91 if (peer_mnt) 91 if (peer_mnt)
92 master = peer_mnt; 92 master = peer_mnt;