aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2012-05-08 00:02:02 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-05-29 23:28:41 -0400
commit962830df366b66e71849040770ae6ba55a8b4aec (patch)
tree0af9487fd8d5a73fa7adbde0bed368ada4298e39
parenteea62f831b8030b0eeea8314eed73b6132d1de26 (diff)
brlocks/lglocks: API cleanups
lglocks and brlocks are currently generated with some complicated macros in lglock.h. But there's no reason to not just use common utility functions and put all the data into a common data structure. In preparation, this patch changes the API to look more like normal function calls with pointers, not magic macros. The patch is rather large because I move over all users in one go to keep it bisectable. This impacts the VFS somewhat in terms of lines changed. But no actual behaviour change. [akpm@linux-foundation.org: checkpatch fixes] Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/dcache.c4
-rw-r--r--fs/file_table.c16
-rw-r--r--fs/namei.c24
-rw-r--r--fs/namespace.c139
-rw-r--r--fs/pnode.c4
-rw-r--r--fs/proc_namespace.c4
6 files changed, 96 insertions, 95 deletions
diff --git a/fs/dcache.c b/fs/dcache.c
index 4435d8b32904..40469044088d 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2575,7 +2575,7 @@ static int prepend_path(const struct path *path,
2575 bool slash = false; 2575 bool slash = false;
2576 int error = 0; 2576 int error = 0;
2577 2577
2578 br_read_lock(vfsmount_lock); 2578 br_read_lock(&vfsmount_lock);
2579 while (dentry != root->dentry || vfsmnt != root->mnt) { 2579 while (dentry != root->dentry || vfsmnt != root->mnt) {
2580 struct dentry * parent; 2580 struct dentry * parent;
2581 2581
@@ -2606,7 +2606,7 @@ static int prepend_path(const struct path *path,
2606 error = prepend(buffer, buflen, "/", 1); 2606 error = prepend(buffer, buflen, "/", 1);
2607 2607
2608out: 2608out:
2609 br_read_unlock(vfsmount_lock); 2609 br_read_unlock(&vfsmount_lock);
2610 return error; 2610 return error;
2611 2611
2612global_root: 2612global_root:
diff --git a/fs/file_table.c b/fs/file_table.c
index f5c67c59ec10..a305d9e2d1b2 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -420,9 +420,9 @@ static inline void __file_sb_list_add(struct file *file, struct super_block *sb)
420 */ 420 */
421void file_sb_list_add(struct file *file, struct super_block *sb) 421void file_sb_list_add(struct file *file, struct super_block *sb)
422{ 422{
423 lg_local_lock(files_lglock); 423 lg_local_lock(&files_lglock);
424 __file_sb_list_add(file, sb); 424 __file_sb_list_add(file, sb);
425 lg_local_unlock(files_lglock); 425 lg_local_unlock(&files_lglock);
426} 426}
427 427
428/** 428/**
@@ -435,9 +435,9 @@ void file_sb_list_add(struct file *file, struct super_block *sb)
435void file_sb_list_del(struct file *file) 435void file_sb_list_del(struct file *file)
436{ 436{
437 if (!list_empty(&file->f_u.fu_list)) { 437 if (!list_empty(&file->f_u.fu_list)) {
438 lg_local_lock_cpu(files_lglock, file_list_cpu(file)); 438 lg_local_lock_cpu(&files_lglock, file_list_cpu(file));
439 list_del_init(&file->f_u.fu_list); 439 list_del_init(&file->f_u.fu_list);
440 lg_local_unlock_cpu(files_lglock, file_list_cpu(file)); 440 lg_local_unlock_cpu(&files_lglock, file_list_cpu(file));
441 } 441 }
442} 442}
443 443
@@ -484,7 +484,7 @@ void mark_files_ro(struct super_block *sb)
484 struct file *f; 484 struct file *f;
485 485
486retry: 486retry:
487 lg_global_lock(files_lglock); 487 lg_global_lock(&files_lglock);
488 do_file_list_for_each_entry(sb, f) { 488 do_file_list_for_each_entry(sb, f) {
489 struct vfsmount *mnt; 489 struct vfsmount *mnt;
490 if (!S_ISREG(f->f_path.dentry->d_inode->i_mode)) 490 if (!S_ISREG(f->f_path.dentry->d_inode->i_mode))
@@ -501,12 +501,12 @@ retry:
501 file_release_write(f); 501 file_release_write(f);
502 mnt = mntget(f->f_path.mnt); 502 mnt = mntget(f->f_path.mnt);
503 /* This can sleep, so we can't hold the spinlock. */ 503 /* This can sleep, so we can't hold the spinlock. */
504 lg_global_unlock(files_lglock); 504 lg_global_unlock(&files_lglock);
505 mnt_drop_write(mnt); 505 mnt_drop_write(mnt);
506 mntput(mnt); 506 mntput(mnt);
507 goto retry; 507 goto retry;
508 } while_file_list_for_each_entry; 508 } while_file_list_for_each_entry;
509 lg_global_unlock(files_lglock); 509 lg_global_unlock(&files_lglock);
510} 510}
511 511
512void __init files_init(unsigned long mempages) 512void __init files_init(unsigned long mempages)
@@ -524,6 +524,6 @@ void __init files_init(unsigned long mempages)
524 n = (mempages * (PAGE_SIZE / 1024)) / 10; 524 n = (mempages * (PAGE_SIZE / 1024)) / 10;
525 files_stat.max_files = max_t(unsigned long, n, NR_FILE); 525 files_stat.max_files = max_t(unsigned long, n, NR_FILE);
526 files_defer_init(); 526 files_defer_init();
527 lg_lock_init(files_lglock); 527 lg_lock_init(&files_lglock, "files_lglock");
528 percpu_counter_init(&nr_files, 0); 528 percpu_counter_init(&nr_files, 0);
529} 529}
diff --git a/fs/namei.c b/fs/namei.c
index c651f02c9fec..93ac9323b1f7 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -449,7 +449,7 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
449 mntget(nd->path.mnt); 449 mntget(nd->path.mnt);
450 450
451 rcu_read_unlock(); 451 rcu_read_unlock();
452 br_read_unlock(vfsmount_lock); 452 br_read_unlock(&vfsmount_lock);
453 nd->flags &= ~LOOKUP_RCU; 453 nd->flags &= ~LOOKUP_RCU;
454 return 0; 454 return 0;
455 455
@@ -507,14 +507,14 @@ static int complete_walk(struct nameidata *nd)
507 if (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) { 507 if (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) {
508 spin_unlock(&dentry->d_lock); 508 spin_unlock(&dentry->d_lock);
509 rcu_read_unlock(); 509 rcu_read_unlock();
510 br_read_unlock(vfsmount_lock); 510 br_read_unlock(&vfsmount_lock);
511 return -ECHILD; 511 return -ECHILD;
512 } 512 }
513 BUG_ON(nd->inode != dentry->d_inode); 513 BUG_ON(nd->inode != dentry->d_inode);
514 spin_unlock(&dentry->d_lock); 514 spin_unlock(&dentry->d_lock);
515 mntget(nd->path.mnt); 515 mntget(nd->path.mnt);
516 rcu_read_unlock(); 516 rcu_read_unlock();
517 br_read_unlock(vfsmount_lock); 517 br_read_unlock(&vfsmount_lock);
518 } 518 }
519 519
520 if (likely(!(nd->flags & LOOKUP_JUMPED))) 520 if (likely(!(nd->flags & LOOKUP_JUMPED)))
@@ -681,15 +681,15 @@ int follow_up(struct path *path)
681 struct mount *parent; 681 struct mount *parent;
682 struct dentry *mountpoint; 682 struct dentry *mountpoint;
683 683
684 br_read_lock(vfsmount_lock); 684 br_read_lock(&vfsmount_lock);
685 parent = mnt->mnt_parent; 685 parent = mnt->mnt_parent;
686 if (&parent->mnt == path->mnt) { 686 if (&parent->mnt == path->mnt) {
687 br_read_unlock(vfsmount_lock); 687 br_read_unlock(&vfsmount_lock);
688 return 0; 688 return 0;
689 } 689 }
690 mntget(&parent->mnt); 690 mntget(&parent->mnt);
691 mountpoint = dget(mnt->mnt_mountpoint); 691 mountpoint = dget(mnt->mnt_mountpoint);
692 br_read_unlock(vfsmount_lock); 692 br_read_unlock(&vfsmount_lock);
693 dput(path->dentry); 693 dput(path->dentry);
694 path->dentry = mountpoint; 694 path->dentry = mountpoint;
695 mntput(path->mnt); 695 mntput(path->mnt);
@@ -947,7 +947,7 @@ failed:
947 if (!(nd->flags & LOOKUP_ROOT)) 947 if (!(nd->flags & LOOKUP_ROOT))
948 nd->root.mnt = NULL; 948 nd->root.mnt = NULL;
949 rcu_read_unlock(); 949 rcu_read_unlock();
950 br_read_unlock(vfsmount_lock); 950 br_read_unlock(&vfsmount_lock);
951 return -ECHILD; 951 return -ECHILD;
952} 952}
953 953
@@ -1265,7 +1265,7 @@ static void terminate_walk(struct nameidata *nd)
1265 if (!(nd->flags & LOOKUP_ROOT)) 1265 if (!(nd->flags & LOOKUP_ROOT))
1266 nd->root.mnt = NULL; 1266 nd->root.mnt = NULL;
1267 rcu_read_unlock(); 1267 rcu_read_unlock();
1268 br_read_unlock(vfsmount_lock); 1268 br_read_unlock(&vfsmount_lock);
1269 } 1269 }
1270} 1270}
1271 1271
@@ -1620,7 +1620,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1620 nd->path = nd->root; 1620 nd->path = nd->root;
1621 nd->inode = inode; 1621 nd->inode = inode;
1622 if (flags & LOOKUP_RCU) { 1622 if (flags & LOOKUP_RCU) {
1623 br_read_lock(vfsmount_lock); 1623 br_read_lock(&vfsmount_lock);
1624 rcu_read_lock(); 1624 rcu_read_lock();
1625 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); 1625 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
1626 } else { 1626 } else {
@@ -1633,7 +1633,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1633 1633
1634 if (*name=='/') { 1634 if (*name=='/') {
1635 if (flags & LOOKUP_RCU) { 1635 if (flags & LOOKUP_RCU) {
1636 br_read_lock(vfsmount_lock); 1636 br_read_lock(&vfsmount_lock);
1637 rcu_read_lock(); 1637 rcu_read_lock();
1638 set_root_rcu(nd); 1638 set_root_rcu(nd);
1639 } else { 1639 } else {
@@ -1646,7 +1646,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1646 struct fs_struct *fs = current->fs; 1646 struct fs_struct *fs = current->fs;
1647 unsigned seq; 1647 unsigned seq;
1648 1648
1649 br_read_lock(vfsmount_lock); 1649 br_read_lock(&vfsmount_lock);
1650 rcu_read_lock(); 1650 rcu_read_lock();
1651 1651
1652 do { 1652 do {
@@ -1682,7 +1682,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
1682 if (fput_needed) 1682 if (fput_needed)
1683 *fp = file; 1683 *fp = file;
1684 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); 1684 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
1685 br_read_lock(vfsmount_lock); 1685 br_read_lock(&vfsmount_lock);
1686 rcu_read_lock(); 1686 rcu_read_lock();
1687 } else { 1687 } else {
1688 path_get(&file->f_path); 1688 path_get(&file->f_path);
diff --git a/fs/namespace.c b/fs/namespace.c
index e6081996c9a2..224aff1c0dfd 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -397,7 +397,7 @@ static int mnt_make_readonly(struct mount *mnt)
397{ 397{
398 int ret = 0; 398 int ret = 0;
399 399
400 br_write_lock(vfsmount_lock); 400 br_write_lock(&vfsmount_lock);
401 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; 401 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD;
402 /* 402 /*
403 * After storing MNT_WRITE_HOLD, we'll read the counters. This store 403 * After storing MNT_WRITE_HOLD, we'll read the counters. This store
@@ -431,15 +431,15 @@ static int mnt_make_readonly(struct mount *mnt)
431 */ 431 */
432 smp_wmb(); 432 smp_wmb();
433 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; 433 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
434 br_write_unlock(vfsmount_lock); 434 br_write_unlock(&vfsmount_lock);
435 return ret; 435 return ret;
436} 436}
437 437
438static void __mnt_unmake_readonly(struct mount *mnt) 438static void __mnt_unmake_readonly(struct mount *mnt)
439{ 439{
440 br_write_lock(vfsmount_lock); 440 br_write_lock(&vfsmount_lock);
441 mnt->mnt.mnt_flags &= ~MNT_READONLY; 441 mnt->mnt.mnt_flags &= ~MNT_READONLY;
442 br_write_unlock(vfsmount_lock); 442 br_write_unlock(&vfsmount_lock);
443} 443}
444 444
445int sb_prepare_remount_readonly(struct super_block *sb) 445int sb_prepare_remount_readonly(struct super_block *sb)
@@ -451,7 +451,7 @@ int sb_prepare_remount_readonly(struct super_block *sb)
451 if (atomic_long_read(&sb->s_remove_count)) 451 if (atomic_long_read(&sb->s_remove_count))
452 return -EBUSY; 452 return -EBUSY;
453 453
454 br_write_lock(vfsmount_lock); 454 br_write_lock(&vfsmount_lock);
455 list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) { 455 list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
456 if (!(mnt->mnt.mnt_flags & MNT_READONLY)) { 456 if (!(mnt->mnt.mnt_flags & MNT_READONLY)) {
457 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; 457 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD;
@@ -473,7 +473,7 @@ int sb_prepare_remount_readonly(struct super_block *sb)
473 if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD) 473 if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD)
474 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; 474 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
475 } 475 }
476 br_write_unlock(vfsmount_lock); 476 br_write_unlock(&vfsmount_lock);
477 477
478 return err; 478 return err;
479} 479}
@@ -522,14 +522,14 @@ struct vfsmount *lookup_mnt(struct path *path)
522{ 522{
523 struct mount *child_mnt; 523 struct mount *child_mnt;
524 524
525 br_read_lock(vfsmount_lock); 525 br_read_lock(&vfsmount_lock);
526 child_mnt = __lookup_mnt(path->mnt, path->dentry, 1); 526 child_mnt = __lookup_mnt(path->mnt, path->dentry, 1);
527 if (child_mnt) { 527 if (child_mnt) {
528 mnt_add_count(child_mnt, 1); 528 mnt_add_count(child_mnt, 1);
529 br_read_unlock(vfsmount_lock); 529 br_read_unlock(&vfsmount_lock);
530 return &child_mnt->mnt; 530 return &child_mnt->mnt;
531 } else { 531 } else {
532 br_read_unlock(vfsmount_lock); 532 br_read_unlock(&vfsmount_lock);
533 return NULL; 533 return NULL;
534 } 534 }
535} 535}
@@ -714,9 +714,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
714 mnt->mnt.mnt_sb = root->d_sb; 714 mnt->mnt.mnt_sb = root->d_sb;
715 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 715 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
716 mnt->mnt_parent = mnt; 716 mnt->mnt_parent = mnt;
717 br_write_lock(vfsmount_lock); 717 br_write_lock(&vfsmount_lock);
718 list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts); 718 list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts);
719 br_write_unlock(vfsmount_lock); 719 br_write_unlock(&vfsmount_lock);
720 return &mnt->mnt; 720 return &mnt->mnt;
721} 721}
722EXPORT_SYMBOL_GPL(vfs_kern_mount); 722EXPORT_SYMBOL_GPL(vfs_kern_mount);
@@ -745,9 +745,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
745 mnt->mnt.mnt_root = dget(root); 745 mnt->mnt.mnt_root = dget(root);
746 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 746 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
747 mnt->mnt_parent = mnt; 747 mnt->mnt_parent = mnt;
748 br_write_lock(vfsmount_lock); 748 br_write_lock(&vfsmount_lock);
749 list_add_tail(&mnt->mnt_instance, &sb->s_mounts); 749 list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
750 br_write_unlock(vfsmount_lock); 750 br_write_unlock(&vfsmount_lock);
751 751
752 if (flag & CL_SLAVE) { 752 if (flag & CL_SLAVE) {
753 list_add(&mnt->mnt_slave, &old->mnt_slave_list); 753 list_add(&mnt->mnt_slave, &old->mnt_slave_list);
@@ -803,35 +803,36 @@ static void mntput_no_expire(struct mount *mnt)
803{ 803{
804put_again: 804put_again:
805#ifdef CONFIG_SMP 805#ifdef CONFIG_SMP
806 br_read_lock(vfsmount_lock); 806 br_read_lock(&vfsmount_lock);
807 if (likely(atomic_read(&mnt->mnt_longterm))) { 807 if (likely(atomic_read(&mnt->mnt_longterm))) {
808 mnt_add_count(mnt, -1); 808 mnt_add_count(mnt, -1);
809 br_read_unlock(vfsmount_lock); 809 br_read_unlock(&vfsmount_lock);
810 return; 810 return;
811 } 811 }
812 br_read_unlock(vfsmount_lock); 812 br_read_unlock(&vfsmount_lock);
813 813
814 br_write_lock(vfsmount_lock); 814 br_write_lock(&vfsmount_lock);
815 mnt_add_count(mnt, -1); 815 mnt_add_count(mnt, -1);
816 if (mnt_get_count(mnt)) { 816 if (mnt_get_count(mnt)) {
817 br_write_unlock(vfsmount_lock); 817 br_write_unlock(&vfsmount_lock);
818 return; 818 return;
819 } 819 }
820#else 820#else
821 mnt_add_count(mnt, -1); 821 mnt_add_count(mnt, -1);
822 if (likely(mnt_get_count(mnt))) 822 if (likely(mnt_get_count(mnt)))
823 return; 823 return;
824 br_write_lock(vfsmount_lock); 824 br_write_lock(&vfsmount_lock);
825#endif 825#endif
826 if (unlikely(mnt->mnt_pinned)) { 826 if (unlikely(mnt->mnt_pinned)) {
827 mnt_add_count(mnt, mnt->mnt_pinned + 1); 827 mnt_add_count(mnt, mnt->mnt_pinned + 1);
828 mnt->mnt_pinned = 0; 828 mnt->mnt_pinned = 0;
829 br_write_unlock(vfsmount_lock); 829 br_write_unlock(&vfsmount_lock);
830 acct_auto_close_mnt(&mnt->mnt); 830 acct_auto_close_mnt(&mnt->mnt);
831 goto put_again; 831 goto put_again;
832 } 832 }
833
833 list_del(&mnt->mnt_instance); 834 list_del(&mnt->mnt_instance);
834 br_write_unlock(vfsmount_lock); 835 br_write_unlock(&vfsmount_lock);
835 mntfree(mnt); 836 mntfree(mnt);
836} 837}
837 838
@@ -857,21 +858,21 @@ EXPORT_SYMBOL(mntget);
857 858
858void mnt_pin(struct vfsmount *mnt) 859void mnt_pin(struct vfsmount *mnt)
859{ 860{
860 br_write_lock(vfsmount_lock); 861 br_write_lock(&vfsmount_lock);
861 real_mount(mnt)->mnt_pinned++; 862 real_mount(mnt)->mnt_pinned++;
862 br_write_unlock(vfsmount_lock); 863 br_write_unlock(&vfsmount_lock);
863} 864}
864EXPORT_SYMBOL(mnt_pin); 865EXPORT_SYMBOL(mnt_pin);
865 866
866void mnt_unpin(struct vfsmount *m) 867void mnt_unpin(struct vfsmount *m)
867{ 868{
868 struct mount *mnt = real_mount(m); 869 struct mount *mnt = real_mount(m);
869 br_write_lock(vfsmount_lock); 870 br_write_lock(&vfsmount_lock);
870 if (mnt->mnt_pinned) { 871 if (mnt->mnt_pinned) {
871 mnt_add_count(mnt, 1); 872 mnt_add_count(mnt, 1);
872 mnt->mnt_pinned--; 873 mnt->mnt_pinned--;
873 } 874 }
874 br_write_unlock(vfsmount_lock); 875 br_write_unlock(&vfsmount_lock);
875} 876}
876EXPORT_SYMBOL(mnt_unpin); 877EXPORT_SYMBOL(mnt_unpin);
877 878
@@ -988,12 +989,12 @@ int may_umount_tree(struct vfsmount *m)
988 BUG_ON(!m); 989 BUG_ON(!m);
989 990
990 /* write lock needed for mnt_get_count */ 991 /* write lock needed for mnt_get_count */
991 br_write_lock(vfsmount_lock); 992 br_write_lock(&vfsmount_lock);
992 for (p = mnt; p; p = next_mnt(p, mnt)) { 993 for (p = mnt; p; p = next_mnt(p, mnt)) {
993 actual_refs += mnt_get_count(p); 994 actual_refs += mnt_get_count(p);
994 minimum_refs += 2; 995 minimum_refs += 2;
995 } 996 }
996 br_write_unlock(vfsmount_lock); 997 br_write_unlock(&vfsmount_lock);
997 998
998 if (actual_refs > minimum_refs) 999 if (actual_refs > minimum_refs)
999 return 0; 1000 return 0;
@@ -1020,10 +1021,10 @@ int may_umount(struct vfsmount *mnt)
1020{ 1021{
1021 int ret = 1; 1022 int ret = 1;
1022 down_read(&namespace_sem); 1023 down_read(&namespace_sem);
1023 br_write_lock(vfsmount_lock); 1024 br_write_lock(&vfsmount_lock);
1024 if (propagate_mount_busy(real_mount(mnt), 2)) 1025 if (propagate_mount_busy(real_mount(mnt), 2))
1025 ret = 0; 1026 ret = 0;
1026 br_write_unlock(vfsmount_lock); 1027 br_write_unlock(&vfsmount_lock);
1027 up_read(&namespace_sem); 1028 up_read(&namespace_sem);
1028 return ret; 1029 return ret;
1029} 1030}
@@ -1040,13 +1041,13 @@ void release_mounts(struct list_head *head)
1040 struct dentry *dentry; 1041 struct dentry *dentry;
1041 struct mount *m; 1042 struct mount *m;
1042 1043
1043 br_write_lock(vfsmount_lock); 1044 br_write_lock(&vfsmount_lock);
1044 dentry = mnt->mnt_mountpoint; 1045 dentry = mnt->mnt_mountpoint;
1045 m = mnt->mnt_parent; 1046 m = mnt->mnt_parent;
1046 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 1047 mnt->mnt_mountpoint = mnt->mnt.mnt_root;
1047 mnt->mnt_parent = mnt; 1048 mnt->mnt_parent = mnt;
1048 m->mnt_ghosts--; 1049 m->mnt_ghosts--;
1049 br_write_unlock(vfsmount_lock); 1050 br_write_unlock(&vfsmount_lock);
1050 dput(dentry); 1051 dput(dentry);
1051 mntput(&m->mnt); 1052 mntput(&m->mnt);
1052 } 1053 }
@@ -1112,12 +1113,12 @@ static int do_umount(struct mount *mnt, int flags)
1112 * probably don't strictly need the lock here if we examined 1113 * probably don't strictly need the lock here if we examined
1113 * all race cases, but it's a slowpath. 1114 * all race cases, but it's a slowpath.
1114 */ 1115 */
1115 br_write_lock(vfsmount_lock); 1116 br_write_lock(&vfsmount_lock);
1116 if (mnt_get_count(mnt) != 2) { 1117 if (mnt_get_count(mnt) != 2) {
1117 br_write_unlock(vfsmount_lock); 1118 br_write_unlock(&vfsmount_lock);
1118 return -EBUSY; 1119 return -EBUSY;
1119 } 1120 }
1120 br_write_unlock(vfsmount_lock); 1121 br_write_unlock(&vfsmount_lock);
1121 1122
1122 if (!xchg(&mnt->mnt_expiry_mark, 1)) 1123 if (!xchg(&mnt->mnt_expiry_mark, 1))
1123 return -EAGAIN; 1124 return -EAGAIN;
@@ -1159,7 +1160,7 @@ static int do_umount(struct mount *mnt, int flags)
1159 } 1160 }
1160 1161
1161 down_write(&namespace_sem); 1162 down_write(&namespace_sem);
1162 br_write_lock(vfsmount_lock); 1163 br_write_lock(&vfsmount_lock);
1163 event++; 1164 event++;
1164 1165
1165 if (!(flags & MNT_DETACH)) 1166 if (!(flags & MNT_DETACH))
@@ -1171,7 +1172,7 @@ static int do_umount(struct mount *mnt, int flags)
1171 umount_tree(mnt, 1, &umount_list); 1172 umount_tree(mnt, 1, &umount_list);
1172 retval = 0; 1173 retval = 0;
1173 } 1174 }
1174 br_write_unlock(vfsmount_lock); 1175 br_write_unlock(&vfsmount_lock);
1175 up_write(&namespace_sem); 1176 up_write(&namespace_sem);
1176 release_mounts(&umount_list); 1177 release_mounts(&umount_list);
1177 return retval; 1178 return retval;
@@ -1286,19 +1287,19 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
1286 q = clone_mnt(p, p->mnt.mnt_root, flag); 1287 q = clone_mnt(p, p->mnt.mnt_root, flag);
1287 if (!q) 1288 if (!q)
1288 goto Enomem; 1289 goto Enomem;
1289 br_write_lock(vfsmount_lock); 1290 br_write_lock(&vfsmount_lock);
1290 list_add_tail(&q->mnt_list, &res->mnt_list); 1291 list_add_tail(&q->mnt_list, &res->mnt_list);
1291 attach_mnt(q, &path); 1292 attach_mnt(q, &path);
1292 br_write_unlock(vfsmount_lock); 1293 br_write_unlock(&vfsmount_lock);
1293 } 1294 }
1294 } 1295 }
1295 return res; 1296 return res;
1296Enomem: 1297Enomem:
1297 if (res) { 1298 if (res) {
1298 LIST_HEAD(umount_list); 1299 LIST_HEAD(umount_list);
1299 br_write_lock(vfsmount_lock); 1300 br_write_lock(&vfsmount_lock);
1300 umount_tree(res, 0, &umount_list); 1301 umount_tree(res, 0, &umount_list);
1301 br_write_unlock(vfsmount_lock); 1302 br_write_unlock(&vfsmount_lock);
1302 release_mounts(&umount_list); 1303 release_mounts(&umount_list);
1303 } 1304 }
1304 return NULL; 1305 return NULL;
@@ -1318,9 +1319,9 @@ void drop_collected_mounts(struct vfsmount *mnt)
1318{ 1319{
1319 LIST_HEAD(umount_list); 1320 LIST_HEAD(umount_list);
1320 down_write(&namespace_sem); 1321 down_write(&namespace_sem);
1321 br_write_lock(vfsmount_lock); 1322 br_write_lock(&vfsmount_lock);
1322 umount_tree(real_mount(mnt), 0, &umount_list); 1323 umount_tree(real_mount(mnt), 0, &umount_list);
1323 br_write_unlock(vfsmount_lock); 1324 br_write_unlock(&vfsmount_lock);
1324 up_write(&namespace_sem); 1325 up_write(&namespace_sem);
1325 release_mounts(&umount_list); 1326 release_mounts(&umount_list);
1326} 1327}
@@ -1448,7 +1449,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
1448 if (err) 1449 if (err)
1449 goto out_cleanup_ids; 1450 goto out_cleanup_ids;
1450 1451
1451 br_write_lock(vfsmount_lock); 1452 br_write_lock(&vfsmount_lock);
1452 1453
1453 if (IS_MNT_SHARED(dest_mnt)) { 1454 if (IS_MNT_SHARED(dest_mnt)) {
1454 for (p = source_mnt; p; p = next_mnt(p, source_mnt)) 1455 for (p = source_mnt; p; p = next_mnt(p, source_mnt))
@@ -1467,7 +1468,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
1467 list_del_init(&child->mnt_hash); 1468 list_del_init(&child->mnt_hash);
1468 commit_tree(child); 1469 commit_tree(child);
1469 } 1470 }
1470 br_write_unlock(vfsmount_lock); 1471 br_write_unlock(&vfsmount_lock);
1471 1472
1472 return 0; 1473 return 0;
1473 1474
@@ -1565,10 +1566,10 @@ static int do_change_type(struct path *path, int flag)
1565 goto out_unlock; 1566 goto out_unlock;
1566 } 1567 }
1567 1568
1568 br_write_lock(vfsmount_lock); 1569 br_write_lock(&vfsmount_lock);
1569 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) 1570 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
1570 change_mnt_propagation(m, type); 1571 change_mnt_propagation(m, type);
1571 br_write_unlock(vfsmount_lock); 1572 br_write_unlock(&vfsmount_lock);
1572 1573
1573 out_unlock: 1574 out_unlock:
1574 up_write(&namespace_sem); 1575 up_write(&namespace_sem);
@@ -1617,9 +1618,9 @@ static int do_loopback(struct path *path, char *old_name,
1617 1618
1618 err = graft_tree(mnt, path); 1619 err = graft_tree(mnt, path);
1619 if (err) { 1620 if (err) {
1620 br_write_lock(vfsmount_lock); 1621 br_write_lock(&vfsmount_lock);
1621 umount_tree(mnt, 0, &umount_list); 1622 umount_tree(mnt, 0, &umount_list);
1622 br_write_unlock(vfsmount_lock); 1623 br_write_unlock(&vfsmount_lock);
1623 } 1624 }
1624out2: 1625out2:
1625 unlock_mount(path); 1626 unlock_mount(path);
@@ -1677,16 +1678,16 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
1677 else 1678 else
1678 err = do_remount_sb(sb, flags, data, 0); 1679 err = do_remount_sb(sb, flags, data, 0);
1679 if (!err) { 1680 if (!err) {
1680 br_write_lock(vfsmount_lock); 1681 br_write_lock(&vfsmount_lock);
1681 mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK; 1682 mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK;
1682 mnt->mnt.mnt_flags = mnt_flags; 1683 mnt->mnt.mnt_flags = mnt_flags;
1683 br_write_unlock(vfsmount_lock); 1684 br_write_unlock(&vfsmount_lock);
1684 } 1685 }
1685 up_write(&sb->s_umount); 1686 up_write(&sb->s_umount);
1686 if (!err) { 1687 if (!err) {
1687 br_write_lock(vfsmount_lock); 1688 br_write_lock(&vfsmount_lock);
1688 touch_mnt_namespace(mnt->mnt_ns); 1689 touch_mnt_namespace(mnt->mnt_ns);
1689 br_write_unlock(vfsmount_lock); 1690 br_write_unlock(&vfsmount_lock);
1690 } 1691 }
1691 return err; 1692 return err;
1692} 1693}
@@ -1893,9 +1894,9 @@ fail:
1893 /* remove m from any expiration list it may be on */ 1894 /* remove m from any expiration list it may be on */
1894 if (!list_empty(&mnt->mnt_expire)) { 1895 if (!list_empty(&mnt->mnt_expire)) {
1895 down_write(&namespace_sem); 1896 down_write(&namespace_sem);
1896 br_write_lock(vfsmount_lock); 1897 br_write_lock(&vfsmount_lock);
1897 list_del_init(&mnt->mnt_expire); 1898 list_del_init(&mnt->mnt_expire);
1898 br_write_unlock(vfsmount_lock); 1899 br_write_unlock(&vfsmount_lock);
1899 up_write(&namespace_sem); 1900 up_write(&namespace_sem);
1900 } 1901 }
1901 mntput(m); 1902 mntput(m);
@@ -1911,11 +1912,11 @@ fail:
1911void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list) 1912void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list)
1912{ 1913{
1913 down_write(&namespace_sem); 1914 down_write(&namespace_sem);
1914 br_write_lock(vfsmount_lock); 1915 br_write_lock(&vfsmount_lock);
1915 1916
1916 list_add_tail(&real_mount(mnt)->mnt_expire, expiry_list); 1917 list_add_tail(&real_mount(mnt)->mnt_expire, expiry_list);
1917 1918
1918 br_write_unlock(vfsmount_lock); 1919 br_write_unlock(&vfsmount_lock);
1919 up_write(&namespace_sem); 1920 up_write(&namespace_sem);
1920} 1921}
1921EXPORT_SYMBOL(mnt_set_expiry); 1922EXPORT_SYMBOL(mnt_set_expiry);
@@ -1935,7 +1936,7 @@ void mark_mounts_for_expiry(struct list_head *mounts)
1935 return; 1936 return;
1936 1937
1937 down_write(&namespace_sem); 1938 down_write(&namespace_sem);
1938 br_write_lock(vfsmount_lock); 1939 br_write_lock(&vfsmount_lock);
1939 1940
1940 /* extract from the expiration list every vfsmount that matches the 1941 /* extract from the expiration list every vfsmount that matches the
1941 * following criteria: 1942 * following criteria:
@@ -1954,7 +1955,7 @@ void mark_mounts_for_expiry(struct list_head *mounts)
1954 touch_mnt_namespace(mnt->mnt_ns); 1955 touch_mnt_namespace(mnt->mnt_ns);
1955 umount_tree(mnt, 1, &umounts); 1956 umount_tree(mnt, 1, &umounts);
1956 } 1957 }
1957 br_write_unlock(vfsmount_lock); 1958 br_write_unlock(&vfsmount_lock);
1958 up_write(&namespace_sem); 1959 up_write(&namespace_sem);
1959 1960
1960 release_mounts(&umounts); 1961 release_mounts(&umounts);
@@ -2218,9 +2219,9 @@ void mnt_make_shortterm(struct vfsmount *m)
2218 struct mount *mnt = real_mount(m); 2219 struct mount *mnt = real_mount(m);
2219 if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) 2220 if (atomic_add_unless(&mnt->mnt_longterm, -1, 1))
2220 return; 2221 return;
2221 br_write_lock(vfsmount_lock); 2222 br_write_lock(&vfsmount_lock);
2222 atomic_dec(&mnt->mnt_longterm); 2223 atomic_dec(&mnt->mnt_longterm);
2223 br_write_unlock(vfsmount_lock); 2224 br_write_unlock(&vfsmount_lock);
2224#endif 2225#endif
2225} 2226}
2226 2227
@@ -2250,9 +2251,9 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
2250 return ERR_PTR(-ENOMEM); 2251 return ERR_PTR(-ENOMEM);
2251 } 2252 }
2252 new_ns->root = new; 2253 new_ns->root = new;
2253 br_write_lock(vfsmount_lock); 2254 br_write_lock(&vfsmount_lock);
2254 list_add_tail(&new_ns->list, &new->mnt_list); 2255 list_add_tail(&new_ns->list, &new->mnt_list);
2255 br_write_unlock(vfsmount_lock); 2256 br_write_unlock(&vfsmount_lock);
2256 2257
2257 /* 2258 /*
2258 * Second pass: switch the tsk->fs->* elements and mark new vfsmounts 2259 * Second pass: switch the tsk->fs->* elements and mark new vfsmounts
@@ -2416,9 +2417,9 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry,
2416int path_is_under(struct path *path1, struct path *path2) 2417int path_is_under(struct path *path1, struct path *path2)
2417{ 2418{
2418 int res; 2419 int res;
2419 br_read_lock(vfsmount_lock); 2420 br_read_lock(&vfsmount_lock);
2420 res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2); 2421 res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2);
2421 br_read_unlock(vfsmount_lock); 2422 br_read_unlock(&vfsmount_lock);
2422 return res; 2423 return res;
2423} 2424}
2424EXPORT_SYMBOL(path_is_under); 2425EXPORT_SYMBOL(path_is_under);
@@ -2505,7 +2506,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2505 /* make sure we can reach put_old from new_root */ 2506 /* make sure we can reach put_old from new_root */
2506 if (!is_path_reachable(real_mount(old.mnt), old.dentry, &new)) 2507 if (!is_path_reachable(real_mount(old.mnt), old.dentry, &new))
2507 goto out4; 2508 goto out4;
2508 br_write_lock(vfsmount_lock); 2509 br_write_lock(&vfsmount_lock);
2509 detach_mnt(new_mnt, &parent_path); 2510 detach_mnt(new_mnt, &parent_path);
2510 detach_mnt(root_mnt, &root_parent); 2511 detach_mnt(root_mnt, &root_parent);
2511 /* mount old root on put_old */ 2512 /* mount old root on put_old */
@@ -2513,7 +2514,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
2513 /* mount new_root on / */ 2514 /* mount new_root on / */
2514 attach_mnt(new_mnt, &root_parent); 2515 attach_mnt(new_mnt, &root_parent);
2515 touch_mnt_namespace(current->nsproxy->mnt_ns); 2516 touch_mnt_namespace(current->nsproxy->mnt_ns);
2516 br_write_unlock(vfsmount_lock); 2517 br_write_unlock(&vfsmount_lock);
2517 chroot_fs_refs(&root, &new); 2518 chroot_fs_refs(&root, &new);
2518 error = 0; 2519 error = 0;
2519out4: 2520out4:
@@ -2576,7 +2577,7 @@ void __init mnt_init(void)
2576 for (u = 0; u < HASH_SIZE; u++) 2577 for (u = 0; u < HASH_SIZE; u++)
2577 INIT_LIST_HEAD(&mount_hashtable[u]); 2578 INIT_LIST_HEAD(&mount_hashtable[u]);
2578 2579
2579 br_lock_init(vfsmount_lock); 2580 br_lock_init(&vfsmount_lock);
2580 2581
2581 err = sysfs_init(); 2582 err = sysfs_init();
2582 if (err) 2583 if (err)
@@ -2596,9 +2597,9 @@ void put_mnt_ns(struct mnt_namespace *ns)
2596 if (!atomic_dec_and_test(&ns->count)) 2597 if (!atomic_dec_and_test(&ns->count))
2597 return; 2598 return;
2598 down_write(&namespace_sem); 2599 down_write(&namespace_sem);
2599 br_write_lock(vfsmount_lock); 2600 br_write_lock(&vfsmount_lock);
2600 umount_tree(ns->root, 0, &umount_list); 2601 umount_tree(ns->root, 0, &umount_list);
2601 br_write_unlock(vfsmount_lock); 2602 br_write_unlock(&vfsmount_lock);
2602 up_write(&namespace_sem); 2603 up_write(&namespace_sem);
2603 release_mounts(&umount_list); 2604 release_mounts(&umount_list);
2604 kfree(ns); 2605 kfree(ns);
diff --git a/fs/pnode.c b/fs/pnode.c
index ab5fa9e1a79a..bed378db0758 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -257,12 +257,12 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry,
257 prev_src_mnt = child; 257 prev_src_mnt = child;
258 } 258 }
259out: 259out:
260 br_write_lock(vfsmount_lock); 260 br_write_lock(&vfsmount_lock);
261 while (!list_empty(&tmp_list)) { 261 while (!list_empty(&tmp_list)) {
262 child = list_first_entry(&tmp_list, struct mount, mnt_hash); 262 child = list_first_entry(&tmp_list, struct mount, mnt_hash);
263 umount_tree(child, 0, &umount_list); 263 umount_tree(child, 0, &umount_list);
264 } 264 }
265 br_write_unlock(vfsmount_lock); 265 br_write_unlock(&vfsmount_lock);
266 release_mounts(&umount_list); 266 release_mounts(&umount_list);
267 return ret; 267 return ret;
268} 268}
diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c
index 12412852d88a..5e289a7cbad1 100644
--- a/fs/proc_namespace.c
+++ b/fs/proc_namespace.c
@@ -23,12 +23,12 @@ static unsigned mounts_poll(struct file *file, poll_table *wait)
23 23
24 poll_wait(file, &p->ns->poll, wait); 24 poll_wait(file, &p->ns->poll, wait);
25 25
26 br_read_lock(vfsmount_lock); 26 br_read_lock(&vfsmount_lock);
27 if (p->m.poll_event != ns->event) { 27 if (p->m.poll_event != ns->event) {
28 p->m.poll_event = ns->event; 28 p->m.poll_event = ns->event;
29 res |= POLLERR | POLLPRI; 29 res |= POLLERR | POLLPRI;
30 } 30 }
31 br_read_unlock(vfsmount_lock); 31 br_read_unlock(&vfsmount_lock);
32 32
33 return res; 33 return res;
34} 34}