aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c291
1 files changed, 235 insertions, 56 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 3dbfc072ec70..3ddfd9046c44 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -138,6 +138,64 @@ void mnt_release_group_id(struct vfsmount *mnt)
138 mnt->mnt_group_id = 0; 138 mnt->mnt_group_id = 0;
139} 139}
140 140
141/*
142 * vfsmount lock must be held for read
143 */
144static inline void mnt_add_count(struct vfsmount *mnt, int n)
145{
146#ifdef CONFIG_SMP
147 this_cpu_add(mnt->mnt_pcp->mnt_count, n);
148#else
149 preempt_disable();
150 mnt->mnt_count += n;
151 preempt_enable();
152#endif
153}
154
155static inline void mnt_set_count(struct vfsmount *mnt, int n)
156{
157#ifdef CONFIG_SMP
158 this_cpu_write(mnt->mnt_pcp->mnt_count, n);
159#else
160 mnt->mnt_count = n;
161#endif
162}
163
164/*
165 * vfsmount lock must be held for read
166 */
167static inline void mnt_inc_count(struct vfsmount *mnt)
168{
169 mnt_add_count(mnt, 1);
170}
171
172/*
173 * vfsmount lock must be held for read
174 */
175static inline void mnt_dec_count(struct vfsmount *mnt)
176{
177 mnt_add_count(mnt, -1);
178}
179
180/*
181 * vfsmount lock must be held for write
182 */
183unsigned int mnt_get_count(struct vfsmount *mnt)
184{
185#ifdef CONFIG_SMP
186 unsigned int count = atomic_read(&mnt->mnt_longrefs);
187 int cpu;
188
189 for_each_possible_cpu(cpu) {
190 count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count;
191 }
192
193 return count;
194#else
195 return mnt->mnt_count;
196#endif
197}
198
141struct vfsmount *alloc_vfsmnt(const char *name) 199struct vfsmount *alloc_vfsmnt(const char *name)
142{ 200{
143 struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); 201 struct vfsmount *mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
@@ -154,7 +212,17 @@ struct vfsmount *alloc_vfsmnt(const char *name)
154 goto out_free_id; 212 goto out_free_id;
155 } 213 }
156 214
157 atomic_set(&mnt->mnt_count, 1); 215#ifdef CONFIG_SMP
216 mnt->mnt_pcp = alloc_percpu(struct mnt_pcp);
217 if (!mnt->mnt_pcp)
218 goto out_free_devname;
219
220 atomic_set(&mnt->mnt_longrefs, 1);
221#else
222 mnt->mnt_count = 1;
223 mnt->mnt_writers = 0;
224#endif
225
158 INIT_LIST_HEAD(&mnt->mnt_hash); 226 INIT_LIST_HEAD(&mnt->mnt_hash);
159 INIT_LIST_HEAD(&mnt->mnt_child); 227 INIT_LIST_HEAD(&mnt->mnt_child);
160 INIT_LIST_HEAD(&mnt->mnt_mounts); 228 INIT_LIST_HEAD(&mnt->mnt_mounts);
@@ -166,13 +234,6 @@ struct vfsmount *alloc_vfsmnt(const char *name)
166#ifdef CONFIG_FSNOTIFY 234#ifdef CONFIG_FSNOTIFY
167 INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); 235 INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks);
168#endif 236#endif
169#ifdef CONFIG_SMP
170 mnt->mnt_writers = alloc_percpu(int);
171 if (!mnt->mnt_writers)
172 goto out_free_devname;
173#else
174 mnt->mnt_writers = 0;
175#endif
176 } 237 }
177 return mnt; 238 return mnt;
178 239
@@ -216,32 +277,32 @@ int __mnt_is_readonly(struct vfsmount *mnt)
216} 277}
217EXPORT_SYMBOL_GPL(__mnt_is_readonly); 278EXPORT_SYMBOL_GPL(__mnt_is_readonly);
218 279
219static inline void inc_mnt_writers(struct vfsmount *mnt) 280static inline void mnt_inc_writers(struct vfsmount *mnt)
220{ 281{
221#ifdef CONFIG_SMP 282#ifdef CONFIG_SMP
222 (*per_cpu_ptr(mnt->mnt_writers, smp_processor_id()))++; 283 this_cpu_inc(mnt->mnt_pcp->mnt_writers);
223#else 284#else
224 mnt->mnt_writers++; 285 mnt->mnt_writers++;
225#endif 286#endif
226} 287}
227 288
228static inline void dec_mnt_writers(struct vfsmount *mnt) 289static inline void mnt_dec_writers(struct vfsmount *mnt)
229{ 290{
230#ifdef CONFIG_SMP 291#ifdef CONFIG_SMP
231 (*per_cpu_ptr(mnt->mnt_writers, smp_processor_id()))--; 292 this_cpu_dec(mnt->mnt_pcp->mnt_writers);
232#else 293#else
233 mnt->mnt_writers--; 294 mnt->mnt_writers--;
234#endif 295#endif
235} 296}
236 297
237static unsigned int count_mnt_writers(struct vfsmount *mnt) 298static unsigned int mnt_get_writers(struct vfsmount *mnt)
238{ 299{
239#ifdef CONFIG_SMP 300#ifdef CONFIG_SMP
240 unsigned int count = 0; 301 unsigned int count = 0;
241 int cpu; 302 int cpu;
242 303
243 for_each_possible_cpu(cpu) { 304 for_each_possible_cpu(cpu) {
244 count += *per_cpu_ptr(mnt->mnt_writers, cpu); 305 count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_writers;
245 } 306 }
246 307
247 return count; 308 return count;
@@ -273,9 +334,9 @@ int mnt_want_write(struct vfsmount *mnt)
273 int ret = 0; 334 int ret = 0;
274 335
275 preempt_disable(); 336 preempt_disable();
276 inc_mnt_writers(mnt); 337 mnt_inc_writers(mnt);
277 /* 338 /*
278 * The store to inc_mnt_writers must be visible before we pass 339 * The store to mnt_inc_writers must be visible before we pass
279 * MNT_WRITE_HOLD loop below, so that the slowpath can see our 340 * MNT_WRITE_HOLD loop below, so that the slowpath can see our
280 * incremented count after it has set MNT_WRITE_HOLD. 341 * incremented count after it has set MNT_WRITE_HOLD.
281 */ 342 */
@@ -289,7 +350,7 @@ int mnt_want_write(struct vfsmount *mnt)
289 */ 350 */
290 smp_rmb(); 351 smp_rmb();
291 if (__mnt_is_readonly(mnt)) { 352 if (__mnt_is_readonly(mnt)) {
292 dec_mnt_writers(mnt); 353 mnt_dec_writers(mnt);
293 ret = -EROFS; 354 ret = -EROFS;
294 goto out; 355 goto out;
295 } 356 }
@@ -317,7 +378,7 @@ int mnt_clone_write(struct vfsmount *mnt)
317 if (__mnt_is_readonly(mnt)) 378 if (__mnt_is_readonly(mnt))
318 return -EROFS; 379 return -EROFS;
319 preempt_disable(); 380 preempt_disable();
320 inc_mnt_writers(mnt); 381 mnt_inc_writers(mnt);
321 preempt_enable(); 382 preempt_enable();
322 return 0; 383 return 0;
323} 384}
@@ -351,7 +412,7 @@ EXPORT_SYMBOL_GPL(mnt_want_write_file);
351void mnt_drop_write(struct vfsmount *mnt) 412void mnt_drop_write(struct vfsmount *mnt)
352{ 413{
353 preempt_disable(); 414 preempt_disable();
354 dec_mnt_writers(mnt); 415 mnt_dec_writers(mnt);
355 preempt_enable(); 416 preempt_enable();
356} 417}
357EXPORT_SYMBOL_GPL(mnt_drop_write); 418EXPORT_SYMBOL_GPL(mnt_drop_write);
@@ -384,7 +445,7 @@ static int mnt_make_readonly(struct vfsmount *mnt)
384 * MNT_WRITE_HOLD, so it can't be decremented by another CPU while 445 * MNT_WRITE_HOLD, so it can't be decremented by another CPU while
385 * we're counting up here. 446 * we're counting up here.
386 */ 447 */
387 if (count_mnt_writers(mnt) > 0) 448 if (mnt_get_writers(mnt) > 0)
388 ret = -EBUSY; 449 ret = -EBUSY;
389 else 450 else
390 mnt->mnt_flags |= MNT_READONLY; 451 mnt->mnt_flags |= MNT_READONLY;
@@ -418,7 +479,7 @@ void free_vfsmnt(struct vfsmount *mnt)
418 kfree(mnt->mnt_devname); 479 kfree(mnt->mnt_devname);
419 mnt_free_id(mnt); 480 mnt_free_id(mnt);
420#ifdef CONFIG_SMP 481#ifdef CONFIG_SMP
421 free_percpu(mnt->mnt_writers); 482 free_percpu(mnt->mnt_pcp);
422#endif 483#endif
423 kmem_cache_free(mnt_cache, mnt); 484 kmem_cache_free(mnt_cache, mnt);
424} 485}
@@ -492,6 +553,27 @@ static void __touch_mnt_namespace(struct mnt_namespace *ns)
492} 553}
493 554
494/* 555/*
556 * Clear dentry's mounted state if it has no remaining mounts.
557 * vfsmount_lock must be held for write.
558 */
559static void dentry_reset_mounted(struct vfsmount *mnt, struct dentry *dentry)
560{
561 unsigned u;
562
563 for (u = 0; u < HASH_SIZE; u++) {
564 struct vfsmount *p;
565
566 list_for_each_entry(p, &mount_hashtable[u], mnt_hash) {
567 if (p->mnt_mountpoint == dentry)
568 return;
569 }
570 }
571 spin_lock(&dentry->d_lock);
572 dentry->d_flags &= ~DCACHE_MOUNTED;
573 spin_unlock(&dentry->d_lock);
574}
575
576/*
495 * vfsmount lock must be held for write 577 * vfsmount lock must be held for write
496 */ 578 */
497static void detach_mnt(struct vfsmount *mnt, struct path *old_path) 579static void detach_mnt(struct vfsmount *mnt, struct path *old_path)
@@ -502,7 +584,7 @@ static void detach_mnt(struct vfsmount *mnt, struct path *old_path)
502 mnt->mnt_mountpoint = mnt->mnt_root; 584 mnt->mnt_mountpoint = mnt->mnt_root;
503 list_del_init(&mnt->mnt_child); 585 list_del_init(&mnt->mnt_child);
504 list_del_init(&mnt->mnt_hash); 586 list_del_init(&mnt->mnt_hash);
505 old_path->dentry->d_mounted--; 587 dentry_reset_mounted(old_path->mnt, old_path->dentry);
506} 588}
507 589
508/* 590/*
@@ -513,7 +595,9 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
513{ 595{
514 child_mnt->mnt_parent = mntget(mnt); 596 child_mnt->mnt_parent = mntget(mnt);
515 child_mnt->mnt_mountpoint = dget(dentry); 597 child_mnt->mnt_mountpoint = dget(dentry);
516 dentry->d_mounted++; 598 spin_lock(&dentry->d_lock);
599 dentry->d_flags |= DCACHE_MOUNTED;
600 spin_unlock(&dentry->d_lock);
517} 601}
518 602
519/* 603/*
@@ -629,9 +713,10 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root,
629 return NULL; 713 return NULL;
630} 714}
631 715
632static inline void __mntput(struct vfsmount *mnt) 716static inline void mntfree(struct vfsmount *mnt)
633{ 717{
634 struct super_block *sb = mnt->mnt_sb; 718 struct super_block *sb = mnt->mnt_sb;
719
635 /* 720 /*
636 * This probably indicates that somebody messed 721 * This probably indicates that somebody messed
637 * up a mnt_want/drop_write() pair. If this 722 * up a mnt_want/drop_write() pair. If this
@@ -639,38 +724,123 @@ static inline void __mntput(struct vfsmount *mnt)
639 * to make r/w->r/o transitions. 724 * to make r/w->r/o transitions.
640 */ 725 */
641 /* 726 /*
642 * atomic_dec_and_lock() used to deal with ->mnt_count decrements 727 * The locking used to deal with mnt_count decrement provides barriers,
643 * provides barriers, so count_mnt_writers() below is safe. AV 728 * so mnt_get_writers() below is safe.
644 */ 729 */
645 WARN_ON(count_mnt_writers(mnt)); 730 WARN_ON(mnt_get_writers(mnt));
646 fsnotify_vfsmount_delete(mnt); 731 fsnotify_vfsmount_delete(mnt);
647 dput(mnt->mnt_root); 732 dput(mnt->mnt_root);
648 free_vfsmnt(mnt); 733 free_vfsmnt(mnt);
649 deactivate_super(sb); 734 deactivate_super(sb);
650} 735}
651 736
652void mntput_no_expire(struct vfsmount *mnt) 737#ifdef CONFIG_SMP
653{ 738static inline void __mntput(struct vfsmount *mnt, int longrefs)
654repeat: 739{
655 if (atomic_add_unless(&mnt->mnt_count, -1, 1)) 740 if (!longrefs) {
656 return; 741put_again:
742 br_read_lock(vfsmount_lock);
743 if (likely(atomic_read(&mnt->mnt_longrefs))) {
744 mnt_dec_count(mnt);
745 br_read_unlock(vfsmount_lock);
746 return;
747 }
748 br_read_unlock(vfsmount_lock);
749 } else {
750 BUG_ON(!atomic_read(&mnt->mnt_longrefs));
751 if (atomic_add_unless(&mnt->mnt_longrefs, -1, 1))
752 return;
753 }
754
657 br_write_lock(vfsmount_lock); 755 br_write_lock(vfsmount_lock);
658 if (!atomic_dec_and_test(&mnt->mnt_count)) { 756 if (!longrefs)
757 mnt_dec_count(mnt);
758 else
759 atomic_dec(&mnt->mnt_longrefs);
760 if (mnt_get_count(mnt)) {
659 br_write_unlock(vfsmount_lock); 761 br_write_unlock(vfsmount_lock);
660 return; 762 return;
661 } 763 }
662 if (likely(!mnt->mnt_pinned)) { 764 if (unlikely(mnt->mnt_pinned)) {
765 mnt_add_count(mnt, mnt->mnt_pinned + 1);
766 mnt->mnt_pinned = 0;
663 br_write_unlock(vfsmount_lock); 767 br_write_unlock(vfsmount_lock);
664 __mntput(mnt); 768 acct_auto_close_mnt(mnt);
769 goto put_again;
770 }
771 br_write_unlock(vfsmount_lock);
772 mntfree(mnt);
773}
774#else
775static inline void __mntput(struct vfsmount *mnt, int longrefs)
776{
777put_again:
778 mnt_dec_count(mnt);
779 if (likely(mnt_get_count(mnt)))
665 return; 780 return;
781 br_write_lock(vfsmount_lock);
782 if (unlikely(mnt->mnt_pinned)) {
783 mnt_add_count(mnt, mnt->mnt_pinned + 1);
784 mnt->mnt_pinned = 0;
785 br_write_unlock(vfsmount_lock);
786 acct_auto_close_mnt(mnt);
787 goto put_again;
666 } 788 }
667 atomic_add(mnt->mnt_pinned + 1, &mnt->mnt_count);
668 mnt->mnt_pinned = 0;
669 br_write_unlock(vfsmount_lock); 789 br_write_unlock(vfsmount_lock);
670 acct_auto_close_mnt(mnt); 790 mntfree(mnt);
671 goto repeat; 791}
792#endif
793
794static void mntput_no_expire(struct vfsmount *mnt)
795{
796 __mntput(mnt, 0);
797}
798
799void mntput(struct vfsmount *mnt)
800{
801 if (mnt) {
802 /* avoid cacheline pingpong, hope gcc doesn't get "smart" */
803 if (unlikely(mnt->mnt_expiry_mark))
804 mnt->mnt_expiry_mark = 0;
805 __mntput(mnt, 0);
806 }
807}
808EXPORT_SYMBOL(mntput);
809
810struct vfsmount *mntget(struct vfsmount *mnt)
811{
812 if (mnt)
813 mnt_inc_count(mnt);
814 return mnt;
672} 815}
673EXPORT_SYMBOL(mntput_no_expire); 816EXPORT_SYMBOL(mntget);
817
818void mntput_long(struct vfsmount *mnt)
819{
820#ifdef CONFIG_SMP
821 if (mnt) {
822 /* avoid cacheline pingpong, hope gcc doesn't get "smart" */
823 if (unlikely(mnt->mnt_expiry_mark))
824 mnt->mnt_expiry_mark = 0;
825 __mntput(mnt, 1);
826 }
827#else
828 mntput(mnt);
829#endif
830}
831EXPORT_SYMBOL(mntput_long);
832
833struct vfsmount *mntget_long(struct vfsmount *mnt)
834{
835#ifdef CONFIG_SMP
836 if (mnt)
837 atomic_inc(&mnt->mnt_longrefs);
838 return mnt;
839#else
840 return mntget(mnt);
841#endif
842}
843EXPORT_SYMBOL(mntget_long);
674 844
675void mnt_pin(struct vfsmount *mnt) 845void mnt_pin(struct vfsmount *mnt)
676{ 846{
@@ -678,19 +848,17 @@ void mnt_pin(struct vfsmount *mnt)
678 mnt->mnt_pinned++; 848 mnt->mnt_pinned++;
679 br_write_unlock(vfsmount_lock); 849 br_write_unlock(vfsmount_lock);
680} 850}
681
682EXPORT_SYMBOL(mnt_pin); 851EXPORT_SYMBOL(mnt_pin);
683 852
684void mnt_unpin(struct vfsmount *mnt) 853void mnt_unpin(struct vfsmount *mnt)
685{ 854{
686 br_write_lock(vfsmount_lock); 855 br_write_lock(vfsmount_lock);
687 if (mnt->mnt_pinned) { 856 if (mnt->mnt_pinned) {
688 atomic_inc(&mnt->mnt_count); 857 mnt_inc_count(mnt);
689 mnt->mnt_pinned--; 858 mnt->mnt_pinned--;
690 } 859 }
691 br_write_unlock(vfsmount_lock); 860 br_write_unlock(vfsmount_lock);
692} 861}
693
694EXPORT_SYMBOL(mnt_unpin); 862EXPORT_SYMBOL(mnt_unpin);
695 863
696static inline void mangle(struct seq_file *m, const char *s) 864static inline void mangle(struct seq_file *m, const char *s)
@@ -985,12 +1153,13 @@ int may_umount_tree(struct vfsmount *mnt)
985 int minimum_refs = 0; 1153 int minimum_refs = 0;
986 struct vfsmount *p; 1154 struct vfsmount *p;
987 1155
988 br_read_lock(vfsmount_lock); 1156 /* write lock needed for mnt_get_count */
1157 br_write_lock(vfsmount_lock);
989 for (p = mnt; p; p = next_mnt(p, mnt)) { 1158 for (p = mnt; p; p = next_mnt(p, mnt)) {
990 actual_refs += atomic_read(&p->mnt_count); 1159 actual_refs += mnt_get_count(p);
991 minimum_refs += 2; 1160 minimum_refs += 2;
992 } 1161 }
993 br_read_unlock(vfsmount_lock); 1162 br_write_unlock(vfsmount_lock);
994 1163
995 if (actual_refs > minimum_refs) 1164 if (actual_refs > minimum_refs)
996 return 0; 1165 return 0;
@@ -1017,10 +1186,10 @@ int may_umount(struct vfsmount *mnt)
1017{ 1186{
1018 int ret = 1; 1187 int ret = 1;
1019 down_read(&namespace_sem); 1188 down_read(&namespace_sem);
1020 br_read_lock(vfsmount_lock); 1189 br_write_lock(vfsmount_lock);
1021 if (propagate_mount_busy(mnt, 2)) 1190 if (propagate_mount_busy(mnt, 2))
1022 ret = 0; 1191 ret = 0;
1023 br_read_unlock(vfsmount_lock); 1192 br_write_unlock(vfsmount_lock);
1024 up_read(&namespace_sem); 1193 up_read(&namespace_sem);
1025 return ret; 1194 return ret;
1026} 1195}
@@ -1047,7 +1216,7 @@ void release_mounts(struct list_head *head)
1047 dput(dentry); 1216 dput(dentry);
1048 mntput(m); 1217 mntput(m);
1049 } 1218 }
1050 mntput(mnt); 1219 mntput_long(mnt);
1051 } 1220 }
1052} 1221}
1053 1222
@@ -1073,7 +1242,7 @@ void umount_tree(struct vfsmount *mnt, int propagate, struct list_head *kill)
1073 list_del_init(&p->mnt_child); 1242 list_del_init(&p->mnt_child);
1074 if (p->mnt_parent != p) { 1243 if (p->mnt_parent != p) {
1075 p->mnt_parent->mnt_ghosts++; 1244 p->mnt_parent->mnt_ghosts++;
1076 p->mnt_mountpoint->d_mounted--; 1245 dentry_reset_mounted(p->mnt_parent, p->mnt_mountpoint);
1077 } 1246 }
1078 change_mnt_propagation(p, MS_PRIVATE); 1247 change_mnt_propagation(p, MS_PRIVATE);
1079 } 1248 }
@@ -1102,8 +1271,16 @@ static int do_umount(struct vfsmount *mnt, int flags)
1102 flags & (MNT_FORCE | MNT_DETACH)) 1271 flags & (MNT_FORCE | MNT_DETACH))
1103 return -EINVAL; 1272 return -EINVAL;
1104 1273
1105 if (atomic_read(&mnt->mnt_count) != 2) 1274 /*
1275 * probably don't strictly need the lock here if we examined
1276 * all race cases, but it's a slowpath.
1277 */
1278 br_write_lock(vfsmount_lock);
1279 if (mnt_get_count(mnt) != 2) {
1280 br_write_lock(vfsmount_lock);
1106 return -EBUSY; 1281 return -EBUSY;
1282 }
1283 br_write_unlock(vfsmount_lock);
1107 1284
1108 if (!xchg(&mnt->mnt_expiry_mark, 1)) 1285 if (!xchg(&mnt->mnt_expiry_mark, 1))
1109 return -EAGAIN; 1286 return -EAGAIN;
@@ -1792,7 +1969,7 @@ int do_add_mount(struct vfsmount *newmnt, struct path *path,
1792 1969
1793unlock: 1970unlock:
1794 up_write(&namespace_sem); 1971 up_write(&namespace_sem);
1795 mntput(newmnt); 1972 mntput_long(newmnt);
1796 return err; 1973 return err;
1797} 1974}
1798 1975
@@ -2125,11 +2302,11 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2125 if (fs) { 2302 if (fs) {
2126 if (p == fs->root.mnt) { 2303 if (p == fs->root.mnt) {
2127 rootmnt = p; 2304 rootmnt = p;
2128 fs->root.mnt = mntget(q); 2305 fs->root.mnt = mntget_long(q);
2129 } 2306 }
2130 if (p == fs->pwd.mnt) { 2307 if (p == fs->pwd.mnt) {
2131 pwdmnt = p; 2308 pwdmnt = p;
2132 fs->pwd.mnt = mntget(q); 2309 fs->pwd.mnt = mntget_long(q);
2133 } 2310 }
2134 } 2311 }
2135 p = next_mnt(p, mnt_ns->root); 2312 p = next_mnt(p, mnt_ns->root);
@@ -2138,9 +2315,9 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2138 up_write(&namespace_sem); 2315 up_write(&namespace_sem);
2139 2316
2140 if (rootmnt) 2317 if (rootmnt)
2141 mntput(rootmnt); 2318 mntput_long(rootmnt);
2142 if (pwdmnt) 2319 if (pwdmnt)
2143 mntput(pwdmnt); 2320 mntput_long(pwdmnt);
2144 2321
2145 return new_ns; 2322 return new_ns;
2146} 2323}
@@ -2327,6 +2504,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2327 touch_mnt_namespace(current->nsproxy->mnt_ns); 2504 touch_mnt_namespace(current->nsproxy->mnt_ns);
2328 br_write_unlock(vfsmount_lock); 2505 br_write_unlock(vfsmount_lock);
2329 chroot_fs_refs(&root, &new); 2506 chroot_fs_refs(&root, &new);
2507
2330 error = 0; 2508 error = 0;
2331 path_put(&root_parent); 2509 path_put(&root_parent);
2332 path_put(&parent_path); 2510 path_put(&parent_path);
@@ -2353,6 +2531,7 @@ static void __init init_mount_tree(void)
2353 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); 2531 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
2354 if (IS_ERR(mnt)) 2532 if (IS_ERR(mnt))
2355 panic("Can't create rootfs"); 2533 panic("Can't create rootfs");
2534
2356 ns = create_mnt_ns(mnt); 2535 ns = create_mnt_ns(mnt);
2357 if (IS_ERR(ns)) 2536 if (IS_ERR(ns))
2358 panic("Can't allocate initial namespace"); 2537 panic("Can't allocate initial namespace");