diff options
-rw-r--r-- | fs/mount.h | 12 | ||||
-rw-r--r-- | fs/namespace.c | 40 | ||||
-rw-r--r-- | include/linux/mount.h | 12 |
3 files changed, 32 insertions, 32 deletions
diff --git a/fs/mount.h b/fs/mount.h index 853738f5897f..452ae41e0131 100644 --- a/fs/mount.h +++ b/fs/mount.h | |||
@@ -1,10 +1,22 @@ | |||
1 | #include <linux/mount.h> | 1 | #include <linux/mount.h> |
2 | 2 | ||
3 | struct mnt_pcp { | ||
4 | int mnt_count; | ||
5 | int mnt_writers; | ||
6 | }; | ||
7 | |||
3 | struct mount { | 8 | struct mount { |
4 | struct list_head mnt_hash; | 9 | struct list_head mnt_hash; |
5 | struct mount *mnt_parent; | 10 | struct mount *mnt_parent; |
6 | struct dentry *mnt_mountpoint; | 11 | struct dentry *mnt_mountpoint; |
7 | struct vfsmount mnt; | 12 | struct vfsmount mnt; |
13 | #ifdef CONFIG_SMP | ||
14 | struct mnt_pcp __percpu *mnt_pcp; | ||
15 | atomic_t mnt_longterm; /* how many of the refs are longterm */ | ||
16 | #else | ||
17 | int mnt_count; | ||
18 | int mnt_writers; | ||
19 | #endif | ||
8 | }; | 20 | }; |
9 | 21 | ||
10 | static inline struct mount *real_mount(struct vfsmount *mnt) | 22 | static inline struct mount *real_mount(struct vfsmount *mnt) |
diff --git a/fs/namespace.c b/fs/namespace.c index a13165c871c2..3fdd30add4f9 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -144,10 +144,10 @@ void mnt_release_group_id(struct mount *mnt) | |||
144 | static inline void mnt_add_count(struct mount *mnt, int n) | 144 | static inline void mnt_add_count(struct mount *mnt, int n) |
145 | { | 145 | { |
146 | #ifdef CONFIG_SMP | 146 | #ifdef CONFIG_SMP |
147 | this_cpu_add(mnt->mnt.mnt_pcp->mnt_count, n); | 147 | this_cpu_add(mnt->mnt_pcp->mnt_count, n); |
148 | #else | 148 | #else |
149 | preempt_disable(); | 149 | preempt_disable(); |
150 | mnt->mnt.mnt_count += n; | 150 | mnt->mnt_count += n; |
151 | preempt_enable(); | 151 | preempt_enable(); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
@@ -162,12 +162,12 @@ unsigned int mnt_get_count(struct mount *mnt) | |||
162 | int cpu; | 162 | int cpu; |
163 | 163 | ||
164 | for_each_possible_cpu(cpu) { | 164 | for_each_possible_cpu(cpu) { |
165 | count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_count; | 165 | count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count; |
166 | } | 166 | } |
167 | 167 | ||
168 | return count; | 168 | return count; |
169 | #else | 169 | #else |
170 | return mnt->mnt.mnt_count; | 170 | return mnt->mnt_count; |
171 | #endif | 171 | #endif |
172 | } | 172 | } |
173 | 173 | ||
@@ -189,14 +189,14 @@ static struct mount *alloc_vfsmnt(const char *name) | |||
189 | } | 189 | } |
190 | 190 | ||
191 | #ifdef CONFIG_SMP | 191 | #ifdef CONFIG_SMP |
192 | mnt->mnt_pcp = alloc_percpu(struct mnt_pcp); | 192 | p->mnt_pcp = alloc_percpu(struct mnt_pcp); |
193 | if (!mnt->mnt_pcp) | 193 | if (!p->mnt_pcp) |
194 | goto out_free_devname; | 194 | goto out_free_devname; |
195 | 195 | ||
196 | this_cpu_add(mnt->mnt_pcp->mnt_count, 1); | 196 | this_cpu_add(p->mnt_pcp->mnt_count, 1); |
197 | #else | 197 | #else |
198 | mnt->mnt_count = 1; | 198 | p->mnt_count = 1; |
199 | mnt->mnt_writers = 0; | 199 | p->mnt_writers = 0; |
200 | #endif | 200 | #endif |
201 | 201 | ||
202 | INIT_LIST_HEAD(&p->mnt_hash); | 202 | INIT_LIST_HEAD(&p->mnt_hash); |
@@ -256,18 +256,18 @@ EXPORT_SYMBOL_GPL(__mnt_is_readonly); | |||
256 | static inline void mnt_inc_writers(struct mount *mnt) | 256 | static inline void mnt_inc_writers(struct mount *mnt) |
257 | { | 257 | { |
258 | #ifdef CONFIG_SMP | 258 | #ifdef CONFIG_SMP |
259 | this_cpu_inc(mnt->mnt.mnt_pcp->mnt_writers); | 259 | this_cpu_inc(mnt->mnt_pcp->mnt_writers); |
260 | #else | 260 | #else |
261 | mnt->mnt.mnt_writers++; | 261 | mnt->mnt_writers++; |
262 | #endif | 262 | #endif |
263 | } | 263 | } |
264 | 264 | ||
265 | static inline void mnt_dec_writers(struct mount *mnt) | 265 | static inline void mnt_dec_writers(struct mount *mnt) |
266 | { | 266 | { |
267 | #ifdef CONFIG_SMP | 267 | #ifdef CONFIG_SMP |
268 | this_cpu_dec(mnt->mnt.mnt_pcp->mnt_writers); | 268 | this_cpu_dec(mnt->mnt_pcp->mnt_writers); |
269 | #else | 269 | #else |
270 | mnt->mnt.mnt_writers--; | 270 | mnt->mnt_writers--; |
271 | #endif | 271 | #endif |
272 | } | 272 | } |
273 | 273 | ||
@@ -278,7 +278,7 @@ static unsigned int mnt_get_writers(struct mount *mnt) | |||
278 | int cpu; | 278 | int cpu; |
279 | 279 | ||
280 | for_each_possible_cpu(cpu) { | 280 | for_each_possible_cpu(cpu) { |
281 | count += per_cpu_ptr(mnt->mnt.mnt_pcp, cpu)->mnt_writers; | 281 | count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_writers; |
282 | } | 282 | } |
283 | 283 | ||
284 | return count; | 284 | return count; |
@@ -454,7 +454,7 @@ static void free_vfsmnt(struct mount *mnt) | |||
454 | kfree(mnt->mnt.mnt_devname); | 454 | kfree(mnt->mnt.mnt_devname); |
455 | mnt_free_id(mnt); | 455 | mnt_free_id(mnt); |
456 | #ifdef CONFIG_SMP | 456 | #ifdef CONFIG_SMP |
457 | free_percpu(mnt->mnt.mnt_pcp); | 457 | free_percpu(mnt->mnt_pcp); |
458 | #endif | 458 | #endif |
459 | kmem_cache_free(mnt_cache, mnt); | 459 | kmem_cache_free(mnt_cache, mnt); |
460 | } | 460 | } |
@@ -594,7 +594,7 @@ static void attach_mnt(struct mount *mnt, struct path *path) | |||
594 | static inline void __mnt_make_longterm(struct mount *mnt) | 594 | static inline void __mnt_make_longterm(struct mount *mnt) |
595 | { | 595 | { |
596 | #ifdef CONFIG_SMP | 596 | #ifdef CONFIG_SMP |
597 | atomic_inc(&mnt->mnt.mnt_longterm); | 597 | atomic_inc(&mnt->mnt_longterm); |
598 | #endif | 598 | #endif |
599 | } | 599 | } |
600 | 600 | ||
@@ -602,7 +602,7 @@ static inline void __mnt_make_longterm(struct mount *mnt) | |||
602 | static inline void __mnt_make_shortterm(struct mount *mnt) | 602 | static inline void __mnt_make_shortterm(struct mount *mnt) |
603 | { | 603 | { |
604 | #ifdef CONFIG_SMP | 604 | #ifdef CONFIG_SMP |
605 | atomic_dec(&mnt->mnt.mnt_longterm); | 605 | atomic_dec(&mnt->mnt_longterm); |
606 | #endif | 606 | #endif |
607 | } | 607 | } |
608 | 608 | ||
@@ -769,7 +769,7 @@ static void mntput_no_expire(struct vfsmount *m) | |||
769 | put_again: | 769 | put_again: |
770 | #ifdef CONFIG_SMP | 770 | #ifdef CONFIG_SMP |
771 | br_read_lock(vfsmount_lock); | 771 | br_read_lock(vfsmount_lock); |
772 | if (likely(atomic_read(&mnt->mnt.mnt_longterm))) { | 772 | if (likely(atomic_read(&mnt->mnt_longterm))) { |
773 | mnt_add_count(mnt, -1); | 773 | mnt_add_count(mnt, -1); |
774 | br_read_unlock(vfsmount_lock); | 774 | br_read_unlock(vfsmount_lock); |
775 | return; | 775 | return; |
@@ -2375,10 +2375,10 @@ void mnt_make_shortterm(struct vfsmount *m) | |||
2375 | { | 2375 | { |
2376 | #ifdef CONFIG_SMP | 2376 | #ifdef CONFIG_SMP |
2377 | struct mount *mnt = real_mount(m); | 2377 | struct mount *mnt = real_mount(m); |
2378 | if (atomic_add_unless(&mnt->mnt.mnt_longterm, -1, 1)) | 2378 | if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) |
2379 | return; | 2379 | return; |
2380 | br_write_lock(vfsmount_lock); | 2380 | br_write_lock(vfsmount_lock); |
2381 | atomic_dec(&mnt->mnt.mnt_longterm); | 2381 | atomic_dec(&mnt->mnt_longterm); |
2382 | br_write_unlock(vfsmount_lock); | 2382 | br_write_unlock(vfsmount_lock); |
2383 | #endif | 2383 | #endif |
2384 | } | 2384 | } |
diff --git a/include/linux/mount.h b/include/linux/mount.h index e3f005993d0f..cc01ed1bc719 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
@@ -47,21 +47,9 @@ struct mnt_namespace; | |||
47 | 47 | ||
48 | #define MNT_INTERNAL 0x4000 | 48 | #define MNT_INTERNAL 0x4000 |
49 | 49 | ||
50 | struct mnt_pcp { | ||
51 | int mnt_count; | ||
52 | int mnt_writers; | ||
53 | }; | ||
54 | |||
55 | struct vfsmount { | 50 | struct vfsmount { |
56 | struct dentry *mnt_root; /* root of the mounted tree */ | 51 | struct dentry *mnt_root; /* root of the mounted tree */ |
57 | struct super_block *mnt_sb; /* pointer to superblock */ | 52 | struct super_block *mnt_sb; /* pointer to superblock */ |
58 | #ifdef CONFIG_SMP | ||
59 | struct mnt_pcp __percpu *mnt_pcp; | ||
60 | atomic_t mnt_longterm; /* how many of the refs are longterm */ | ||
61 | #else | ||
62 | int mnt_count; | ||
63 | int mnt_writers; | ||
64 | #endif | ||
65 | struct list_head mnt_mounts; /* list of children, anchored here */ | 53 | struct list_head mnt_mounts; /* list of children, anchored here */ |
66 | struct list_head mnt_child; /* and going through their mnt_child */ | 54 | struct list_head mnt_child; /* and going through their mnt_child */ |
67 | int mnt_flags; | 55 | int mnt_flags; |