diff options
Diffstat (limited to 'kernel/cgroup.c')
| -rw-r--r-- | kernel/cgroup.c | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index b303dfc7dce0..79818507e444 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -822,7 +822,7 @@ EXPORT_SYMBOL_GPL(cgroup_unlock); | |||
| 822 | */ | 822 | */ |
| 823 | 823 | ||
| 824 | static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); | 824 | static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode); |
| 825 | static struct dentry *cgroup_lookup(struct inode *, struct dentry *, struct nameidata *); | 825 | static struct dentry *cgroup_lookup(struct inode *, struct dentry *, unsigned int); |
| 826 | static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry); | 826 | static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry); |
| 827 | static int cgroup_populate_dir(struct cgroup *cgrp); | 827 | static int cgroup_populate_dir(struct cgroup *cgrp); |
| 828 | static const struct inode_operations cgroup_dir_inode_operations; | 828 | static const struct inode_operations cgroup_dir_inode_operations; |
| @@ -954,7 +954,7 @@ static int cgroup_rm_file(struct cgroup *cgrp, const struct cftype *cft) | |||
| 954 | 954 | ||
| 955 | dget(d); | 955 | dget(d); |
| 956 | d_delete(d); | 956 | d_delete(d); |
| 957 | simple_unlink(d->d_inode, d); | 957 | simple_unlink(cgrp->dentry->d_inode, d); |
| 958 | list_del_init(&cfe->node); | 958 | list_del_init(&cfe->node); |
| 959 | dput(d); | 959 | dput(d); |
| 960 | 960 | ||
| @@ -1068,28 +1068,24 @@ static int rebind_subsystems(struct cgroupfs_root *root, | |||
| 1068 | BUG_ON(cgrp->subsys[i]); | 1068 | BUG_ON(cgrp->subsys[i]); |
| 1069 | BUG_ON(!dummytop->subsys[i]); | 1069 | BUG_ON(!dummytop->subsys[i]); |
| 1070 | BUG_ON(dummytop->subsys[i]->cgroup != dummytop); | 1070 | BUG_ON(dummytop->subsys[i]->cgroup != dummytop); |
| 1071 | mutex_lock(&ss->hierarchy_mutex); | ||
| 1072 | cgrp->subsys[i] = dummytop->subsys[i]; | 1071 | cgrp->subsys[i] = dummytop->subsys[i]; |
| 1073 | cgrp->subsys[i]->cgroup = cgrp; | 1072 | cgrp->subsys[i]->cgroup = cgrp; |
| 1074 | list_move(&ss->sibling, &root->subsys_list); | 1073 | list_move(&ss->sibling, &root->subsys_list); |
| 1075 | ss->root = root; | 1074 | ss->root = root; |
| 1076 | if (ss->bind) | 1075 | if (ss->bind) |
| 1077 | ss->bind(cgrp); | 1076 | ss->bind(cgrp); |
| 1078 | mutex_unlock(&ss->hierarchy_mutex); | ||
| 1079 | /* refcount was already taken, and we're keeping it */ | 1077 | /* refcount was already taken, and we're keeping it */ |
| 1080 | } else if (bit & removed_bits) { | 1078 | } else if (bit & removed_bits) { |
| 1081 | /* We're removing this subsystem */ | 1079 | /* We're removing this subsystem */ |
| 1082 | BUG_ON(ss == NULL); | 1080 | BUG_ON(ss == NULL); |
| 1083 | BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]); | 1081 | BUG_ON(cgrp->subsys[i] != dummytop->subsys[i]); |
| 1084 | BUG_ON(cgrp->subsys[i]->cgroup != cgrp); | 1082 | BUG_ON(cgrp->subsys[i]->cgroup != cgrp); |
| 1085 | mutex_lock(&ss->hierarchy_mutex); | ||
| 1086 | if (ss->bind) | 1083 | if (ss->bind) |
| 1087 | ss->bind(dummytop); | 1084 | ss->bind(dummytop); |
| 1088 | dummytop->subsys[i]->cgroup = dummytop; | 1085 | dummytop->subsys[i]->cgroup = dummytop; |
| 1089 | cgrp->subsys[i] = NULL; | 1086 | cgrp->subsys[i] = NULL; |
| 1090 | subsys[i]->root = &rootnode; | 1087 | subsys[i]->root = &rootnode; |
| 1091 | list_move(&ss->sibling, &rootnode.subsys_list); | 1088 | list_move(&ss->sibling, &rootnode.subsys_list); |
| 1092 | mutex_unlock(&ss->hierarchy_mutex); | ||
| 1093 | /* subsystem is now free - drop reference on module */ | 1089 | /* subsystem is now free - drop reference on module */ |
| 1094 | module_put(ss->module); | 1090 | module_put(ss->module); |
| 1095 | } else if (bit & final_bits) { | 1091 | } else if (bit & final_bits) { |
| @@ -1587,7 +1583,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
| 1587 | opts.new_root = new_root; | 1583 | opts.new_root = new_root; |
| 1588 | 1584 | ||
| 1589 | /* Locate an existing or new sb for this hierarchy */ | 1585 | /* Locate an existing or new sb for this hierarchy */ |
| 1590 | sb = sget(fs_type, cgroup_test_super, cgroup_set_super, &opts); | 1586 | sb = sget(fs_type, cgroup_test_super, cgroup_set_super, 0, &opts); |
| 1591 | if (IS_ERR(sb)) { | 1587 | if (IS_ERR(sb)) { |
| 1592 | ret = PTR_ERR(sb); | 1588 | ret = PTR_ERR(sb); |
| 1593 | cgroup_drop_root(opts.new_root); | 1589 | cgroup_drop_root(opts.new_root); |
| @@ -2570,7 +2566,7 @@ static const struct inode_operations cgroup_dir_inode_operations = { | |||
| 2570 | .rename = cgroup_rename, | 2566 | .rename = cgroup_rename, |
| 2571 | }; | 2567 | }; |
| 2572 | 2568 | ||
| 2573 | static struct dentry *cgroup_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | 2569 | static struct dentry *cgroup_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) |
| 2574 | { | 2570 | { |
| 2575 | if (dentry->d_name.len > NAME_MAX) | 2571 | if (dentry->d_name.len > NAME_MAX) |
| 2576 | return ERR_PTR(-ENAMETOOLONG); | 2572 | return ERR_PTR(-ENAMETOOLONG); |
| @@ -3915,37 +3911,6 @@ static void init_cgroup_css(struct cgroup_subsys_state *css, | |||
| 3915 | set_bit(CSS_CLEAR_CSS_REFS, &css->flags); | 3911 | set_bit(CSS_CLEAR_CSS_REFS, &css->flags); |
| 3916 | } | 3912 | } |
| 3917 | 3913 | ||
| 3918 | static void cgroup_lock_hierarchy(struct cgroupfs_root *root) | ||
| 3919 | { | ||
| 3920 | /* We need to take each hierarchy_mutex in a consistent order */ | ||
| 3921 | int i; | ||
| 3922 | |||
| 3923 | /* | ||
| 3924 | * No worry about a race with rebind_subsystems that might mess up the | ||
| 3925 | * locking order, since both parties are under cgroup_mutex. | ||
| 3926 | */ | ||
| 3927 | for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { | ||
| 3928 | struct cgroup_subsys *ss = subsys[i]; | ||
| 3929 | if (ss == NULL) | ||
| 3930 | continue; | ||
| 3931 | if (ss->root == root) | ||
| 3932 | mutex_lock(&ss->hierarchy_mutex); | ||
| 3933 | } | ||
| 3934 | } | ||
| 3935 | |||
| 3936 | static void cgroup_unlock_hierarchy(struct cgroupfs_root *root) | ||
| 3937 | { | ||
| 3938 | int i; | ||
| 3939 | |||
| 3940 | for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { | ||
| 3941 | struct cgroup_subsys *ss = subsys[i]; | ||
| 3942 | if (ss == NULL) | ||
| 3943 | continue; | ||
| 3944 | if (ss->root == root) | ||
| 3945 | mutex_unlock(&ss->hierarchy_mutex); | ||
| 3946 | } | ||
| 3947 | } | ||
| 3948 | |||
| 3949 | /* | 3914 | /* |
| 3950 | * cgroup_create - create a cgroup | 3915 | * cgroup_create - create a cgroup |
| 3951 | * @parent: cgroup that will be parent of the new cgroup | 3916 | * @parent: cgroup that will be parent of the new cgroup |
| @@ -4006,9 +3971,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
| 4006 | ss->post_clone(cgrp); | 3971 | ss->post_clone(cgrp); |
| 4007 | } | 3972 | } |
| 4008 | 3973 | ||
| 4009 | cgroup_lock_hierarchy(root); | ||
| 4010 | list_add(&cgrp->sibling, &cgrp->parent->children); | 3974 | list_add(&cgrp->sibling, &cgrp->parent->children); |
| 4011 | cgroup_unlock_hierarchy(root); | ||
| 4012 | root->number_of_cgroups++; | 3975 | root->number_of_cgroups++; |
| 4013 | 3976 | ||
| 4014 | err = cgroup_create_dir(cgrp, dentry, mode); | 3977 | err = cgroup_create_dir(cgrp, dentry, mode); |
| @@ -4035,9 +3998,7 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, | |||
| 4035 | 3998 | ||
| 4036 | err_remove: | 3999 | err_remove: |
| 4037 | 4000 | ||
| 4038 | cgroup_lock_hierarchy(root); | ||
| 4039 | list_del(&cgrp->sibling); | 4001 | list_del(&cgrp->sibling); |
| 4040 | cgroup_unlock_hierarchy(root); | ||
| 4041 | root->number_of_cgroups--; | 4002 | root->number_of_cgroups--; |
| 4042 | 4003 | ||
| 4043 | err_destroy: | 4004 | err_destroy: |
| @@ -4245,10 +4206,8 @@ again: | |||
| 4245 | list_del_init(&cgrp->release_list); | 4206 | list_del_init(&cgrp->release_list); |
| 4246 | raw_spin_unlock(&release_list_lock); | 4207 | raw_spin_unlock(&release_list_lock); |
| 4247 | 4208 | ||
| 4248 | cgroup_lock_hierarchy(cgrp->root); | ||
| 4249 | /* delete this cgroup from parent->children */ | 4209 | /* delete this cgroup from parent->children */ |
| 4250 | list_del_init(&cgrp->sibling); | 4210 | list_del_init(&cgrp->sibling); |
| 4251 | cgroup_unlock_hierarchy(cgrp->root); | ||
| 4252 | 4211 | ||
| 4253 | list_del_init(&cgrp->allcg_node); | 4212 | list_del_init(&cgrp->allcg_node); |
| 4254 | 4213 | ||
| @@ -4322,8 +4281,6 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss) | |||
| 4322 | * need to invoke fork callbacks here. */ | 4281 | * need to invoke fork callbacks here. */ |
| 4323 | BUG_ON(!list_empty(&init_task.tasks)); | 4282 | BUG_ON(!list_empty(&init_task.tasks)); |
| 4324 | 4283 | ||
| 4325 | mutex_init(&ss->hierarchy_mutex); | ||
| 4326 | lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key); | ||
| 4327 | ss->active = 1; | 4284 | ss->active = 1; |
| 4328 | 4285 | ||
| 4329 | /* this function shouldn't be used with modular subsystems, since they | 4286 | /* this function shouldn't be used with modular subsystems, since they |
| @@ -4450,8 +4407,6 @@ int __init_or_module cgroup_load_subsys(struct cgroup_subsys *ss) | |||
| 4450 | } | 4407 | } |
| 4451 | write_unlock(&css_set_lock); | 4408 | write_unlock(&css_set_lock); |
| 4452 | 4409 | ||
| 4453 | mutex_init(&ss->hierarchy_mutex); | ||
| 4454 | lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key); | ||
| 4455 | ss->active = 1; | 4410 | ss->active = 1; |
| 4456 | 4411 | ||
| 4457 | /* success! */ | 4412 | /* success! */ |
