aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-24 20:38:33 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-03 22:57:00 -0500
commitb105e270b4e9419f4b9536f6862b1b32985bc9d2 (patch)
tree41c2d66b9ef8a1f26b99da2876c3b6f9ef519fc7 /fs
parentcbbe362cd68441edf1ebbafeea1c8e09cce4a7f9 (diff)
vfs: spread struct mount - alloc_vfsmnt/free_vfsmnt/mnt_alloc_id/mnt_free_id
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/namespace.c81
1 files changed, 40 insertions, 41 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 91bd15d9b2cd..98b49351fbde 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -78,16 +78,16 @@ static inline unsigned long hash(struct vfsmount *mnt, struct dentry *dentry)
78 * allocation is serialized by namespace_sem, but we need the spinlock to 78 * allocation is serialized by namespace_sem, but we need the spinlock to
79 * serialize with freeing. 79 * serialize with freeing.
80 */ 80 */
81static int mnt_alloc_id(struct vfsmount *mnt) 81static int mnt_alloc_id(struct mount *mnt)
82{ 82{
83 int res; 83 int res;
84 84
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_id); 88 res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt.mnt_id);
89 if (!res) 89 if (!res)
90 mnt_id_start = mnt->mnt_id + 1; 90 mnt_id_start = mnt->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;
@@ -95,9 +95,9 @@ retry:
95 return res; 95 return res;
96} 96}
97 97
98static void mnt_free_id(struct vfsmount *mnt) 98static void mnt_free_id(struct mount *mnt)
99{ 99{
100 int id = mnt->mnt_id; 100 int id = mnt->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)
@@ -171,14 +171,14 @@ unsigned int mnt_get_count(struct vfsmount *mnt)
171#endif 171#endif
172} 172}
173 173
174static struct vfsmount *alloc_vfsmnt(const char *name) 174static struct mount *alloc_vfsmnt(const char *name)
175{ 175{
176 struct mount *p = kmem_cache_zalloc(mnt_cache, GFP_KERNEL); 176 struct mount *p = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
177 if (p) { 177 if (p) {
178 struct vfsmount *mnt = &p->mnt; 178 struct vfsmount *mnt = &p->mnt;
179 int err; 179 int err;
180 180
181 err = mnt_alloc_id(mnt); 181 err = mnt_alloc_id(p);
182 if (err) 182 if (err)
183 goto out_free_cache; 183 goto out_free_cache;
184 184
@@ -211,14 +211,14 @@ static struct vfsmount *alloc_vfsmnt(const char *name)
211 INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks); 211 INIT_HLIST_HEAD(&mnt->mnt_fsnotify_marks);
212#endif 212#endif
213 } 213 }
214 return &p->mnt; 214 return p;
215 215
216#ifdef CONFIG_SMP 216#ifdef CONFIG_SMP
217out_free_devname: 217out_free_devname:
218 kfree(p->mnt.mnt_devname); 218 kfree(p->mnt.mnt_devname);
219#endif 219#endif
220out_free_id: 220out_free_id:
221 mnt_free_id(&p->mnt); 221 mnt_free_id(p);
222out_free_cache: 222out_free_cache:
223 kmem_cache_free(mnt_cache, p); 223 kmem_cache_free(mnt_cache, p);
224 return NULL; 224 return NULL;
@@ -448,15 +448,14 @@ static void __mnt_unmake_readonly(struct vfsmount *mnt)
448 br_write_unlock(vfsmount_lock); 448 br_write_unlock(vfsmount_lock);
449} 449}
450 450
451static void free_vfsmnt(struct vfsmount *mnt) 451static void free_vfsmnt(struct mount *mnt)
452{ 452{
453 struct mount *p = real_mount(mnt); 453 kfree(mnt->mnt.mnt_devname);
454 kfree(mnt->mnt_devname);
455 mnt_free_id(mnt); 454 mnt_free_id(mnt);
456#ifdef CONFIG_SMP 455#ifdef CONFIG_SMP
457 free_percpu(mnt->mnt_pcp); 456 free_percpu(mnt->mnt.mnt_pcp);
458#endif 457#endif
459 kmem_cache_free(mnt_cache, p); 458 kmem_cache_free(mnt_cache, mnt);
460} 459}
461 460
462/* 461/*
@@ -661,7 +660,7 @@ static struct mount *skip_mnt_tree(struct mount *p)
661struct vfsmount * 660struct vfsmount *
662vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data) 661vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void *data)
663{ 662{
664 struct vfsmount *mnt; 663 struct mount *mnt;
665 struct dentry *root; 664 struct dentry *root;
666 665
667 if (!type) 666 if (!type)
@@ -672,7 +671,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
672 return ERR_PTR(-ENOMEM); 671 return ERR_PTR(-ENOMEM);
673 672
674 if (flags & MS_KERNMOUNT) 673 if (flags & MS_KERNMOUNT)
675 mnt->mnt_flags = MNT_INTERNAL; 674 mnt->mnt.mnt_flags = MNT_INTERNAL;
676 675
677 root = mount_fs(type, flags, name, data); 676 root = mount_fs(type, flags, name, data);
678 if (IS_ERR(root)) { 677 if (IS_ERR(root)) {
@@ -680,11 +679,11 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
680 return ERR_CAST(root); 679 return ERR_CAST(root);
681 } 680 }
682 681
683 mnt->mnt_root = root; 682 mnt->mnt.mnt_root = root;
684 mnt->mnt_sb = root->d_sb; 683 mnt->mnt.mnt_sb = root->d_sb;
685 mnt->mnt_mountpoint = mnt->mnt_root; 684 mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root;
686 mnt->mnt_parent = mnt; 685 mnt->mnt.mnt_parent = &mnt->mnt;
687 return mnt; 686 return &mnt->mnt;
688} 687}
689EXPORT_SYMBOL_GPL(vfs_kern_mount); 688EXPORT_SYMBOL_GPL(vfs_kern_mount);
690 689
@@ -692,49 +691,49 @@ static struct vfsmount *clone_mnt(struct vfsmount *old, struct dentry *root,
692 int flag) 691 int flag)
693{ 692{
694 struct super_block *sb = old->mnt_sb; 693 struct super_block *sb = old->mnt_sb;
695 struct vfsmount *mnt = alloc_vfsmnt(old->mnt_devname); 694 struct mount *mnt = alloc_vfsmnt(old->mnt_devname);
696 695
697 if (mnt) { 696 if (mnt) {
698 if (flag & (CL_SLAVE | CL_PRIVATE)) 697 if (flag & (CL_SLAVE | CL_PRIVATE))
699 mnt->mnt_group_id = 0; /* not a peer of original */ 698 mnt->mnt.mnt_group_id = 0; /* not a peer of original */
700 else 699 else
701 mnt->mnt_group_id = old->mnt_group_id; 700 mnt->mnt.mnt_group_id = old->mnt_group_id;
702 701
703 if ((flag & CL_MAKE_SHARED) && !mnt->mnt_group_id) { 702 if ((flag & CL_MAKE_SHARED) && !mnt->mnt.mnt_group_id) {
704 int err = mnt_alloc_group_id(real_mount(mnt)); 703 int err = mnt_alloc_group_id(mnt);
705 if (err) 704 if (err)
706 goto out_free; 705 goto out_free;
707 } 706 }
708 707
709 mnt->mnt_flags = old->mnt_flags & ~MNT_WRITE_HOLD; 708 mnt->mnt.mnt_flags = old->mnt_flags & ~MNT_WRITE_HOLD;
710 atomic_inc(&sb->s_active); 709 atomic_inc(&sb->s_active);
711 mnt->mnt_sb = sb; 710 mnt->mnt.mnt_sb = sb;
712 mnt->mnt_root = dget(root); 711 mnt->mnt.mnt_root = dget(root);
713 mnt->mnt_mountpoint = mnt->mnt_root; 712 mnt->mnt.mnt_mountpoint = mnt->mnt.mnt_root;
714 mnt->mnt_parent = mnt; 713 mnt->mnt.mnt_parent = &mnt->mnt;
715 714
716 if (flag & CL_SLAVE) { 715 if (flag & CL_SLAVE) {
717 list_add(&mnt->mnt_slave, &old->mnt_slave_list); 716 list_add(&mnt->mnt.mnt_slave, &old->mnt_slave_list);
718 mnt->mnt_master = old; 717 mnt->mnt.mnt_master = old;
719 CLEAR_MNT_SHARED(mnt); 718 CLEAR_MNT_SHARED(&mnt->mnt);
720 } else if (!(flag & CL_PRIVATE)) { 719 } else if (!(flag & CL_PRIVATE)) {
721 if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old)) 720 if ((flag & CL_MAKE_SHARED) || IS_MNT_SHARED(old))
722 list_add(&mnt->mnt_share, &old->mnt_share); 721 list_add(&mnt->mnt.mnt_share, &old->mnt_share);
723 if (IS_MNT_SLAVE(old)) 722 if (IS_MNT_SLAVE(old))
724 list_add(&mnt->mnt_slave, &old->mnt_slave); 723 list_add(&mnt->mnt.mnt_slave, &old->mnt_slave);
725 mnt->mnt_master = old->mnt_master; 724 mnt->mnt.mnt_master = old->mnt_master;
726 } 725 }
727 if (flag & CL_MAKE_SHARED) 726 if (flag & CL_MAKE_SHARED)
728 set_mnt_shared(mnt); 727 set_mnt_shared(&mnt->mnt);
729 728
730 /* stick the duplicate mount on the same expiry list 729 /* stick the duplicate mount on the same expiry list
731 * as the original if that was on one */ 730 * as the original if that was on one */
732 if (flag & CL_EXPIRE) { 731 if (flag & CL_EXPIRE) {
733 if (!list_empty(&old->mnt_expire)) 732 if (!list_empty(&old->mnt_expire))
734 list_add(&mnt->mnt_expire, &old->mnt_expire); 733 list_add(&mnt->mnt.mnt_expire, &old->mnt_expire);
735 } 734 }
736 } 735 }
737 return mnt; 736 return &mnt->mnt;
738 737
739 out_free: 738 out_free:
740 free_vfsmnt(mnt); 739 free_vfsmnt(mnt);
@@ -758,7 +757,7 @@ static inline void mntfree(struct vfsmount *mnt)
758 WARN_ON(mnt_get_writers(mnt)); 757 WARN_ON(mnt_get_writers(mnt));
759 fsnotify_vfsmount_delete(mnt); 758 fsnotify_vfsmount_delete(mnt);
760 dput(mnt->mnt_root); 759 dput(mnt->mnt_root);
761 free_vfsmnt(mnt); 760 free_vfsmnt(real_mount(mnt));
762 deactivate_super(sb); 761 deactivate_super(sb);
763} 762}
764 763