aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 7ccba4bc5e3b..0249f4be9b5c 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -703,7 +703,7 @@ static int cgroup_mkdir(struct inode *dir, struct dentry *dentry, int mode);
703static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry); 703static int cgroup_rmdir(struct inode *unused_dir, struct dentry *dentry);
704static int cgroup_populate_dir(struct cgroup *cgrp); 704static int cgroup_populate_dir(struct cgroup *cgrp);
705static const struct inode_operations cgroup_dir_inode_operations; 705static const struct inode_operations cgroup_dir_inode_operations;
706static struct file_operations proc_cgroupstats_operations; 706static const struct file_operations proc_cgroupstats_operations;
707 707
708static struct backing_dev_info cgroup_backing_dev_info = { 708static struct backing_dev_info cgroup_backing_dev_info = {
709 .name = "cgroup", 709 .name = "cgroup",
@@ -1710,14 +1710,13 @@ static ssize_t cgroup_write_X64(struct cgroup *cgrp, struct cftype *cft,
1710 return -EFAULT; 1710 return -EFAULT;
1711 1711
1712 buffer[nbytes] = 0; /* nul-terminate */ 1712 buffer[nbytes] = 0; /* nul-terminate */
1713 strstrip(buffer);
1714 if (cft->write_u64) { 1713 if (cft->write_u64) {
1715 u64 val = simple_strtoull(buffer, &end, 0); 1714 u64 val = simple_strtoull(strstrip(buffer), &end, 0);
1716 if (*end) 1715 if (*end)
1717 return -EINVAL; 1716 return -EINVAL;
1718 retval = cft->write_u64(cgrp, cft, val); 1717 retval = cft->write_u64(cgrp, cft, val);
1719 } else { 1718 } else {
1720 s64 val = simple_strtoll(buffer, &end, 0); 1719 s64 val = simple_strtoll(strstrip(buffer), &end, 0);
1721 if (*end) 1720 if (*end)
1722 return -EINVAL; 1721 return -EINVAL;
1723 retval = cft->write_s64(cgrp, cft, val); 1722 retval = cft->write_s64(cgrp, cft, val);
@@ -1753,8 +1752,7 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
1753 } 1752 }
1754 1753
1755 buffer[nbytes] = 0; /* nul-terminate */ 1754 buffer[nbytes] = 0; /* nul-terminate */
1756 strstrip(buffer); 1755 retval = cft->write_string(cgrp, cft, strstrip(buffer));
1757 retval = cft->write_string(cgrp, cft, buffer);
1758 if (!retval) 1756 if (!retval)
1759 retval = nbytes; 1757 retval = nbytes;
1760out: 1758out:
@@ -1863,7 +1861,7 @@ static int cgroup_seqfile_release(struct inode *inode, struct file *file)
1863 return single_release(inode, file); 1861 return single_release(inode, file);
1864} 1862}
1865 1863
1866static struct file_operations cgroup_seqfile_operations = { 1864static const struct file_operations cgroup_seqfile_operations = {
1867 .read = seq_read, 1865 .read = seq_read,
1868 .write = cgroup_file_write, 1866 .write = cgroup_file_write,
1869 .llseek = seq_lseek, 1867 .llseek = seq_lseek,
@@ -1922,7 +1920,7 @@ static int cgroup_rename(struct inode *old_dir, struct dentry *old_dentry,
1922 return simple_rename(old_dir, old_dentry, new_dir, new_dentry); 1920 return simple_rename(old_dir, old_dentry, new_dir, new_dentry);
1923} 1921}
1924 1922
1925static struct file_operations cgroup_file_operations = { 1923static const struct file_operations cgroup_file_operations = {
1926 .read = cgroup_file_read, 1924 .read = cgroup_file_read,
1927 .write = cgroup_file_write, 1925 .write = cgroup_file_write,
1928 .llseek = generic_file_llseek, 1926 .llseek = generic_file_llseek,
@@ -3369,7 +3367,7 @@ static int cgroup_open(struct inode *inode, struct file *file)
3369 return single_open(file, proc_cgroup_show, pid); 3367 return single_open(file, proc_cgroup_show, pid);
3370} 3368}
3371 3369
3372struct file_operations proc_cgroup_operations = { 3370const struct file_operations proc_cgroup_operations = {
3373 .open = cgroup_open, 3371 .open = cgroup_open,
3374 .read = seq_read, 3372 .read = seq_read,
3375 .llseek = seq_lseek, 3373 .llseek = seq_lseek,
@@ -3398,7 +3396,7 @@ static int cgroupstats_open(struct inode *inode, struct file *file)
3398 return single_open(file, proc_cgroupstats_show, NULL); 3396 return single_open(file, proc_cgroupstats_show, NULL);
3399} 3397}
3400 3398
3401static struct file_operations proc_cgroupstats_operations = { 3399static const struct file_operations proc_cgroupstats_operations = {
3402 .open = cgroupstats_open, 3400 .open = cgroupstats_open,
3403 .read = seq_read, 3401 .read = seq_read,
3404 .llseek = seq_lseek, 3402 .llseek = seq_lseek,
@@ -3708,8 +3706,10 @@ static void check_for_release(struct cgroup *cgrp)
3708void __css_put(struct cgroup_subsys_state *css) 3706void __css_put(struct cgroup_subsys_state *css)
3709{ 3707{
3710 struct cgroup *cgrp = css->cgroup; 3708 struct cgroup *cgrp = css->cgroup;
3709 int val;
3711 rcu_read_lock(); 3710 rcu_read_lock();
3712 if (atomic_dec_return(&css->refcnt) == 1) { 3711 val = atomic_dec_return(&css->refcnt);
3712 if (val == 1) {
3713 if (notify_on_release(cgrp)) { 3713 if (notify_on_release(cgrp)) {
3714 set_bit(CGRP_RELEASABLE, &cgrp->flags); 3714 set_bit(CGRP_RELEASABLE, &cgrp->flags);
3715 check_for_release(cgrp); 3715 check_for_release(cgrp);
@@ -3717,6 +3717,7 @@ void __css_put(struct cgroup_subsys_state *css)
3717 cgroup_wakeup_rmdir_waiter(cgrp); 3717 cgroup_wakeup_rmdir_waiter(cgrp);
3718 } 3718 }
3719 rcu_read_unlock(); 3719 rcu_read_unlock();
3720 WARN_ON_ONCE(val < 1);
3720} 3721}
3721 3722
3722/* 3723/*