diff options
author | Tejun Heo <tj@kernel.org> | 2014-05-13 12:16:21 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-05-13 12:16:21 -0400 |
commit | 451af504df0c62f695a69b83c250486e77c66378 (patch) | |
tree | f89879cf3f88e9da346d8bd3fa1ae192a280d772 | |
parent | b41686401e501430ffe93b575ef7959d2ecc6f2e (diff) |
cgroup: replace cftype->write_string() with cftype->write()
Convert all cftype->write_string() users to the new cftype->write()
which maps directly to kernfs write operation and has full access to
kernfs and cgroup contexts. The conversions are mostly mechanical.
* @css and @cft are accessed using of_css() and of_cft() accessors
respectively instead of being specified as arguments.
* Should return @nbytes on success instead of 0.
* @buf is not trimmed automatically. Trim if necessary. Note that
blkcg and netprio don't need this as the parsers already handle
whitespaces.
cftype->write_string() has no user left after the conversions and
removed.
While at it, remove unnecessary local variable @p in
cgroup_subtree_control_write() and stale comment about
CGROUP_LOCAL_BUFFER_SIZE in cgroup_freezer.c.
This patch doesn't introduce any visible behavior changes.
v2: netprio was missing from conversion. Converted.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Aristeu Rozanski <arozansk@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Li Zefan <lizefan@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Neil Horman <nhorman@tuxdriver.com>
Cc: "David S. Miller" <davem@davemloft.net>
-rw-r--r-- | block/blk-throttle.c | 32 | ||||
-rw-r--r-- | block/cfq-iosched.c | 28 | ||||
-rw-r--r-- | include/linux/cgroup.h | 10 | ||||
-rw-r--r-- | kernel/cgroup.c | 38 | ||||
-rw-r--r-- | kernel/cgroup_freezer.c | 20 | ||||
-rw-r--r-- | kernel/cpuset.c | 16 | ||||
-rw-r--r-- | mm/hugetlb_cgroup.c | 17 | ||||
-rw-r--r-- | mm/memcontrol.c | 46 | ||||
-rw-r--r-- | net/core/netprio_cgroup.c | 12 | ||||
-rw-r--r-- | net/ipv4/tcp_memcontrol.c | 16 | ||||
-rw-r--r-- | security/device_cgroup.c | 14 |
11 files changed, 124 insertions, 125 deletions
diff --git a/block/blk-throttle.c b/block/blk-throttle.c index 033745cd7fba..5e8fd1bace98 100644 --- a/block/blk-throttle.c +++ b/block/blk-throttle.c | |||
@@ -1346,10 +1346,10 @@ static int tg_print_conf_uint(struct seq_file *sf, void *v) | |||
1346 | return 0; | 1346 | return 0; |
1347 | } | 1347 | } |
1348 | 1348 | ||
1349 | static int tg_set_conf(struct cgroup_subsys_state *css, struct cftype *cft, | 1349 | static ssize_t tg_set_conf(struct kernfs_open_file *of, |
1350 | const char *buf, bool is_u64) | 1350 | char *buf, size_t nbytes, loff_t off, bool is_u64) |
1351 | { | 1351 | { |
1352 | struct blkcg *blkcg = css_to_blkcg(css); | 1352 | struct blkcg *blkcg = css_to_blkcg(of_css(of)); |
1353 | struct blkg_conf_ctx ctx; | 1353 | struct blkg_conf_ctx ctx; |
1354 | struct throtl_grp *tg; | 1354 | struct throtl_grp *tg; |
1355 | struct throtl_service_queue *sq; | 1355 | struct throtl_service_queue *sq; |
@@ -1368,9 +1368,9 @@ static int tg_set_conf(struct cgroup_subsys_state *css, struct cftype *cft, | |||
1368 | ctx.v = -1; | 1368 | ctx.v = -1; |
1369 | 1369 | ||
1370 | if (is_u64) | 1370 | if (is_u64) |
1371 | *(u64 *)((void *)tg + cft->private) = ctx.v; | 1371 | *(u64 *)((void *)tg + of_cft(of)->private) = ctx.v; |
1372 | else | 1372 | else |
1373 | *(unsigned int *)((void *)tg + cft->private) = ctx.v; | 1373 | *(unsigned int *)((void *)tg + of_cft(of)->private) = ctx.v; |
1374 | 1374 | ||
1375 | throtl_log(&tg->service_queue, | 1375 | throtl_log(&tg->service_queue, |
1376 | "limit change rbps=%llu wbps=%llu riops=%u wiops=%u", | 1376 | "limit change rbps=%llu wbps=%llu riops=%u wiops=%u", |
@@ -1404,19 +1404,19 @@ static int tg_set_conf(struct cgroup_subsys_state *css, struct cftype *cft, | |||
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | blkg_conf_finish(&ctx); | 1406 | blkg_conf_finish(&ctx); |
1407 | return 0; | 1407 | return nbytes; |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | static int tg_set_conf_u64(struct cgroup_subsys_state *css, struct cftype *cft, | 1410 | static ssize_t tg_set_conf_u64(struct kernfs_open_file *of, |
1411 | char *buf) | 1411 | char *buf, size_t nbytes, loff_t off) |
1412 | { | 1412 | { |
1413 | return tg_set_conf(css, cft, buf, true); | 1413 | return tg_set_conf(of, buf, nbytes, off, true); |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | static int tg_set_conf_uint(struct cgroup_subsys_state *css, struct cftype *cft, | 1416 | static ssize_t tg_set_conf_uint(struct kernfs_open_file *of, |
1417 | char *buf) | 1417 | char *buf, size_t nbytes, loff_t off) |
1418 | { | 1418 | { |
1419 | return tg_set_conf(css, cft, buf, false); | 1419 | return tg_set_conf(of, buf, nbytes, off, false); |
1420 | } | 1420 | } |
1421 | 1421 | ||
1422 | static struct cftype throtl_files[] = { | 1422 | static struct cftype throtl_files[] = { |
@@ -1424,25 +1424,25 @@ static struct cftype throtl_files[] = { | |||
1424 | .name = "throttle.read_bps_device", | 1424 | .name = "throttle.read_bps_device", |
1425 | .private = offsetof(struct throtl_grp, bps[READ]), | 1425 | .private = offsetof(struct throtl_grp, bps[READ]), |
1426 | .seq_show = tg_print_conf_u64, | 1426 | .seq_show = tg_print_conf_u64, |
1427 | .write_string = tg_set_conf_u64, | 1427 | .write = tg_set_conf_u64, |
1428 | }, | 1428 | }, |
1429 | { | 1429 | { |
1430 | .name = "throttle.write_bps_device", | 1430 | .name = "throttle.write_bps_device", |
1431 | .private = offsetof(struct throtl_grp, bps[WRITE]), | 1431 | .private = offsetof(struct throtl_grp, bps[WRITE]), |
1432 | .seq_show = tg_print_conf_u64, | 1432 | .seq_show = tg_print_conf_u64, |
1433 | .write_string = tg_set_conf_u64, | 1433 | .write = tg_set_conf_u64, |
1434 | }, | 1434 | }, |
1435 | { | 1435 | { |
1436 | .name = "throttle.read_iops_device", | 1436 | .name = "throttle.read_iops_device", |
1437 | .private = offsetof(struct throtl_grp, iops[READ]), | 1437 | .private = offsetof(struct throtl_grp, iops[READ]), |
1438 | .seq_show = tg_print_conf_uint, | 1438 | .seq_show = tg_print_conf_uint, |
1439 | .write_string = tg_set_conf_uint, | 1439 | .write = tg_set_conf_uint, |
1440 | }, | 1440 | }, |
1441 | { | 1441 | { |
1442 | .name = "throttle.write_iops_device", | 1442 | .name = "throttle.write_iops_device", |
1443 | .private = offsetof(struct throtl_grp, iops[WRITE]), | 1443 | .private = offsetof(struct throtl_grp, iops[WRITE]), |
1444 | .seq_show = tg_print_conf_uint, | 1444 | .seq_show = tg_print_conf_uint, |
1445 | .write_string = tg_set_conf_uint, | 1445 | .write = tg_set_conf_uint, |
1446 | }, | 1446 | }, |
1447 | { | 1447 | { |
1448 | .name = "throttle.io_service_bytes", | 1448 | .name = "throttle.io_service_bytes", |
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index e0985f1955e7..a73020b8c9af 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c | |||
@@ -1670,11 +1670,11 @@ static int cfq_print_leaf_weight(struct seq_file *sf, void *v) | |||
1670 | return 0; | 1670 | return 0; |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | static int __cfqg_set_weight_device(struct cgroup_subsys_state *css, | 1673 | static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of, |
1674 | struct cftype *cft, const char *buf, | 1674 | char *buf, size_t nbytes, loff_t off, |
1675 | bool is_leaf_weight) | 1675 | bool is_leaf_weight) |
1676 | { | 1676 | { |
1677 | struct blkcg *blkcg = css_to_blkcg(css); | 1677 | struct blkcg *blkcg = css_to_blkcg(of_css(of)); |
1678 | struct blkg_conf_ctx ctx; | 1678 | struct blkg_conf_ctx ctx; |
1679 | struct cfq_group *cfqg; | 1679 | struct cfq_group *cfqg; |
1680 | int ret; | 1680 | int ret; |
@@ -1697,19 +1697,19 @@ static int __cfqg_set_weight_device(struct cgroup_subsys_state *css, | |||
1697 | } | 1697 | } |
1698 | 1698 | ||
1699 | blkg_conf_finish(&ctx); | 1699 | blkg_conf_finish(&ctx); |
1700 | return ret; | 1700 | return ret ?: nbytes; |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | static int cfqg_set_weight_device(struct cgroup_subsys_state *css, | 1703 | static ssize_t cfqg_set_weight_device(struct kernfs_open_file *of, |
1704 | struct cftype *cft, char *buf) | 1704 | char *buf, size_t nbytes, loff_t off) |
1705 | { | 1705 | { |
1706 | return __cfqg_set_weight_device(css, cft, buf, false); | 1706 | return __cfqg_set_weight_device(of, buf, nbytes, off, false); |
1707 | } | 1707 | } |
1708 | 1708 | ||
1709 | static int cfqg_set_leaf_weight_device(struct cgroup_subsys_state *css, | 1709 | static ssize_t cfqg_set_leaf_weight_device(struct kernfs_open_file *of, |
1710 | struct cftype *cft, char *buf) | 1710 | char *buf, size_t nbytes, loff_t off) |
1711 | { | 1711 | { |
1712 | return __cfqg_set_weight_device(css, cft, buf, true); | 1712 | return __cfqg_set_weight_device(of, buf, nbytes, off, true); |
1713 | } | 1713 | } |
1714 | 1714 | ||
1715 | static int __cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft, | 1715 | static int __cfq_set_weight(struct cgroup_subsys_state *css, struct cftype *cft, |
@@ -1837,7 +1837,7 @@ static struct cftype cfq_blkcg_files[] = { | |||
1837 | .name = "weight_device", | 1837 | .name = "weight_device", |
1838 | .flags = CFTYPE_ONLY_ON_ROOT, | 1838 | .flags = CFTYPE_ONLY_ON_ROOT, |
1839 | .seq_show = cfqg_print_leaf_weight_device, | 1839 | .seq_show = cfqg_print_leaf_weight_device, |
1840 | .write_string = cfqg_set_leaf_weight_device, | 1840 | .write = cfqg_set_leaf_weight_device, |
1841 | }, | 1841 | }, |
1842 | { | 1842 | { |
1843 | .name = "weight", | 1843 | .name = "weight", |
@@ -1851,7 +1851,7 @@ static struct cftype cfq_blkcg_files[] = { | |||
1851 | .name = "weight_device", | 1851 | .name = "weight_device", |
1852 | .flags = CFTYPE_NOT_ON_ROOT, | 1852 | .flags = CFTYPE_NOT_ON_ROOT, |
1853 | .seq_show = cfqg_print_weight_device, | 1853 | .seq_show = cfqg_print_weight_device, |
1854 | .write_string = cfqg_set_weight_device, | 1854 | .write = cfqg_set_weight_device, |
1855 | }, | 1855 | }, |
1856 | { | 1856 | { |
1857 | .name = "weight", | 1857 | .name = "weight", |
@@ -1863,7 +1863,7 @@ static struct cftype cfq_blkcg_files[] = { | |||
1863 | { | 1863 | { |
1864 | .name = "leaf_weight_device", | 1864 | .name = "leaf_weight_device", |
1865 | .seq_show = cfqg_print_leaf_weight_device, | 1865 | .seq_show = cfqg_print_leaf_weight_device, |
1866 | .write_string = cfqg_set_leaf_weight_device, | 1866 | .write = cfqg_set_leaf_weight_device, |
1867 | }, | 1867 | }, |
1868 | { | 1868 | { |
1869 | .name = "leaf_weight", | 1869 | .name = "leaf_weight", |
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index c5a170ca4a48..aecdc84fe128 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h | |||
@@ -453,8 +453,7 @@ struct cftype { | |||
453 | 453 | ||
454 | /* | 454 | /* |
455 | * The maximum length of string, excluding trailing nul, that can | 455 | * The maximum length of string, excluding trailing nul, that can |
456 | * be passed to write_string. If < PAGE_SIZE-1, PAGE_SIZE-1 is | 456 | * be passed to write. If < PAGE_SIZE-1, PAGE_SIZE-1 is assumed. |
457 | * assumed. | ||
458 | */ | 457 | */ |
459 | size_t max_write_len; | 458 | size_t max_write_len; |
460 | 459 | ||
@@ -501,13 +500,6 @@ struct cftype { | |||
501 | s64 val); | 500 | s64 val); |
502 | 501 | ||
503 | /* | 502 | /* |
504 | * write_string() is passed a nul-terminated kernelspace | ||
505 | * buffer of maximum length determined by max_write_len. | ||
506 | * Returns 0 or -ve error code. | ||
507 | */ | ||
508 | int (*write_string)(struct cgroup_subsys_state *css, struct cftype *cft, | ||
509 | char *buffer); | ||
510 | /* | ||
511 | * trigger() callback can be used to get some kick from the | 503 | * trigger() callback can be used to get some kick from the |
512 | * userspace, when the actual string written is not important | 504 | * userspace, when the actual string written is not important |
513 | * at all. The private field can be used to determine the | 505 | * at all. The private field can be used to determine the |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index a16f91d12f4e..2a88ce7b24b6 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -1035,7 +1035,7 @@ static umode_t cgroup_file_mode(const struct cftype *cft) | |||
1035 | mode |= S_IRUGO; | 1035 | mode |= S_IRUGO; |
1036 | 1036 | ||
1037 | if (cft->write_u64 || cft->write_s64 || cft->write || | 1037 | if (cft->write_u64 || cft->write_s64 || cft->write || |
1038 | cft->write_string || cft->trigger) | 1038 | cft->trigger) |
1039 | mode |= S_IWUSR; | 1039 | mode |= S_IWUSR; |
1040 | 1040 | ||
1041 | return mode; | 1041 | return mode; |
@@ -2352,20 +2352,21 @@ static int cgroup_procs_write(struct cgroup_subsys_state *css, | |||
2352 | return attach_task_by_pid(css->cgroup, tgid, true); | 2352 | return attach_task_by_pid(css->cgroup, tgid, true); |
2353 | } | 2353 | } |
2354 | 2354 | ||
2355 | static int cgroup_release_agent_write(struct cgroup_subsys_state *css, | 2355 | static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of, |
2356 | struct cftype *cft, char *buffer) | 2356 | char *buf, size_t nbytes, loff_t off) |
2357 | { | 2357 | { |
2358 | struct cgroup_root *root = css->cgroup->root; | 2358 | struct cgroup *cgrp = of_css(of)->cgroup; |
2359 | struct cgroup_root *root = cgrp->root; | ||
2359 | 2360 | ||
2360 | BUILD_BUG_ON(sizeof(root->release_agent_path) < PATH_MAX); | 2361 | BUILD_BUG_ON(sizeof(root->release_agent_path) < PATH_MAX); |
2361 | if (!cgroup_lock_live_group(css->cgroup)) | 2362 | if (!cgroup_lock_live_group(cgrp)) |
2362 | return -ENODEV; | 2363 | return -ENODEV; |
2363 | spin_lock(&release_agent_path_lock); | 2364 | spin_lock(&release_agent_path_lock); |
2364 | strlcpy(root->release_agent_path, buffer, | 2365 | strlcpy(root->release_agent_path, strstrip(buf), |
2365 | sizeof(root->release_agent_path)); | 2366 | sizeof(root->release_agent_path)); |
2366 | spin_unlock(&release_agent_path_lock); | 2367 | spin_unlock(&release_agent_path_lock); |
2367 | mutex_unlock(&cgroup_mutex); | 2368 | mutex_unlock(&cgroup_mutex); |
2368 | return 0; | 2369 | return nbytes; |
2369 | } | 2370 | } |
2370 | 2371 | ||
2371 | static int cgroup_release_agent_show(struct seq_file *seq, void *v) | 2372 | static int cgroup_release_agent_show(struct seq_file *seq, void *v) |
@@ -2530,21 +2531,22 @@ out_finish: | |||
2530 | } | 2531 | } |
2531 | 2532 | ||
2532 | /* change the enabled child controllers for a cgroup in the default hierarchy */ | 2533 | /* change the enabled child controllers for a cgroup in the default hierarchy */ |
2533 | static int cgroup_subtree_control_write(struct cgroup_subsys_state *dummy_css, | 2534 | static ssize_t cgroup_subtree_control_write(struct kernfs_open_file *of, |
2534 | struct cftype *cft, char *buffer) | 2535 | char *buf, size_t nbytes, |
2536 | loff_t off) | ||
2535 | { | 2537 | { |
2536 | unsigned int enable = 0, disable = 0; | 2538 | unsigned int enable = 0, disable = 0; |
2537 | struct cgroup *cgrp = dummy_css->cgroup, *child; | 2539 | struct cgroup *cgrp = of_css(of)->cgroup, *child; |
2538 | struct cgroup_subsys *ss; | 2540 | struct cgroup_subsys *ss; |
2539 | char *tok, *p; | 2541 | char *tok; |
2540 | int ssid, ret; | 2542 | int ssid, ret; |
2541 | 2543 | ||
2542 | /* | 2544 | /* |
2543 | * Parse input - space separated list of subsystem names prefixed | 2545 | * Parse input - space separated list of subsystem names prefixed |
2544 | * with either + or -. | 2546 | * with either + or -. |
2545 | */ | 2547 | */ |
2546 | p = buffer; | 2548 | buf = strstrip(buf); |
2547 | while ((tok = strsep(&p, " "))) { | 2549 | while ((tok = strsep(&buf, " "))) { |
2548 | if (tok[0] == '\0') | 2550 | if (tok[0] == '\0') |
2549 | continue; | 2551 | continue; |
2550 | for_each_subsys(ss, ssid) { | 2552 | for_each_subsys(ss, ssid) { |
@@ -2692,7 +2694,7 @@ out_unlock_tree: | |||
2692 | out_unbreak: | 2694 | out_unbreak: |
2693 | kernfs_unbreak_active_protection(cgrp->control_kn); | 2695 | kernfs_unbreak_active_protection(cgrp->control_kn); |
2694 | cgroup_put(cgrp); | 2696 | cgroup_put(cgrp); |
2695 | return ret; | 2697 | return ret ?: nbytes; |
2696 | 2698 | ||
2697 | err_undo_css: | 2699 | err_undo_css: |
2698 | cgrp->child_subsys_mask &= ~enable; | 2700 | cgrp->child_subsys_mask &= ~enable; |
@@ -2738,9 +2740,7 @@ static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf, | |||
2738 | css = cgroup_css(cgrp, cft->ss); | 2740 | css = cgroup_css(cgrp, cft->ss); |
2739 | rcu_read_unlock(); | 2741 | rcu_read_unlock(); |
2740 | 2742 | ||
2741 | if (cft->write_string) { | 2743 | if (cft->write_u64) { |
2742 | ret = cft->write_string(css, cft, strstrip(buf)); | ||
2743 | } else if (cft->write_u64) { | ||
2744 | unsigned long long v; | 2744 | unsigned long long v; |
2745 | ret = kstrtoull(buf, 0, &v); | 2745 | ret = kstrtoull(buf, 0, &v); |
2746 | if (!ret) | 2746 | if (!ret) |
@@ -3984,7 +3984,7 @@ static struct cftype cgroup_base_files[] = { | |||
3984 | .name = "cgroup.subtree_control", | 3984 | .name = "cgroup.subtree_control", |
3985 | .flags = CFTYPE_ONLY_ON_DFL, | 3985 | .flags = CFTYPE_ONLY_ON_DFL, |
3986 | .seq_show = cgroup_subtree_control_show, | 3986 | .seq_show = cgroup_subtree_control_show, |
3987 | .write_string = cgroup_subtree_control_write, | 3987 | .write = cgroup_subtree_control_write, |
3988 | }, | 3988 | }, |
3989 | { | 3989 | { |
3990 | .name = "cgroup.populated", | 3990 | .name = "cgroup.populated", |
@@ -4018,7 +4018,7 @@ static struct cftype cgroup_base_files[] = { | |||
4018 | .name = "release_agent", | 4018 | .name = "release_agent", |
4019 | .flags = CFTYPE_INSANE | CFTYPE_ONLY_ON_ROOT, | 4019 | .flags = CFTYPE_INSANE | CFTYPE_ONLY_ON_ROOT, |
4020 | .seq_show = cgroup_release_agent_show, | 4020 | .seq_show = cgroup_release_agent_show, |
4021 | .write_string = cgroup_release_agent_write, | 4021 | .write = cgroup_release_agent_write, |
4022 | .max_write_len = PATH_MAX - 1, | 4022 | .max_write_len = PATH_MAX - 1, |
4023 | }, | 4023 | }, |
4024 | { } /* terminate */ | 4024 | { } /* terminate */ |
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index 0398f7e9ac81..6b4e60e33a9a 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c | |||
@@ -73,10 +73,6 @@ bool cgroup_freezing(struct task_struct *task) | |||
73 | return ret; | 73 | return ret; |
74 | } | 74 | } |
75 | 75 | ||
76 | /* | ||
77 | * cgroups_write_string() limits the size of freezer state strings to | ||
78 | * CGROUP_LOCAL_BUFFER_SIZE | ||
79 | */ | ||
80 | static const char *freezer_state_strs(unsigned int state) | 76 | static const char *freezer_state_strs(unsigned int state) |
81 | { | 77 | { |
82 | if (state & CGROUP_FROZEN) | 78 | if (state & CGROUP_FROZEN) |
@@ -423,20 +419,22 @@ static void freezer_change_state(struct freezer *freezer, bool freeze) | |||
423 | mutex_unlock(&freezer_mutex); | 419 | mutex_unlock(&freezer_mutex); |
424 | } | 420 | } |
425 | 421 | ||
426 | static int freezer_write(struct cgroup_subsys_state *css, struct cftype *cft, | 422 | static ssize_t freezer_write(struct kernfs_open_file *of, |
427 | char *buffer) | 423 | char *buf, size_t nbytes, loff_t off) |
428 | { | 424 | { |
429 | bool freeze; | 425 | bool freeze; |
430 | 426 | ||
431 | if (strcmp(buffer, freezer_state_strs(0)) == 0) | 427 | buf = strstrip(buf); |
428 | |||
429 | if (strcmp(buf, freezer_state_strs(0)) == 0) | ||
432 | freeze = false; | 430 | freeze = false; |
433 | else if (strcmp(buffer, freezer_state_strs(CGROUP_FROZEN)) == 0) | 431 | else if (strcmp(buf, freezer_state_strs(CGROUP_FROZEN)) == 0) |
434 | freeze = true; | 432 | freeze = true; |
435 | else | 433 | else |
436 | return -EINVAL; | 434 | return -EINVAL; |
437 | 435 | ||
438 | freezer_change_state(css_freezer(css), freeze); | 436 | freezer_change_state(css_freezer(of_css(of)), freeze); |
439 | return 0; | 437 | return nbytes; |
440 | } | 438 | } |
441 | 439 | ||
442 | static u64 freezer_self_freezing_read(struct cgroup_subsys_state *css, | 440 | static u64 freezer_self_freezing_read(struct cgroup_subsys_state *css, |
@@ -460,7 +458,7 @@ static struct cftype files[] = { | |||
460 | .name = "state", | 458 | .name = "state", |
461 | .flags = CFTYPE_NOT_ON_ROOT, | 459 | .flags = CFTYPE_NOT_ON_ROOT, |
462 | .seq_show = freezer_read, | 460 | .seq_show = freezer_read, |
463 | .write_string = freezer_write, | 461 | .write = freezer_write, |
464 | }, | 462 | }, |
465 | { | 463 | { |
466 | .name = "self_freezing", | 464 | .name = "self_freezing", |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 37ca0a5c226d..2f4b08b8db24 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -1603,13 +1603,15 @@ out_unlock: | |||
1603 | /* | 1603 | /* |
1604 | * Common handling for a write to a "cpus" or "mems" file. | 1604 | * Common handling for a write to a "cpus" or "mems" file. |
1605 | */ | 1605 | */ |
1606 | static int cpuset_write_resmask(struct cgroup_subsys_state *css, | 1606 | static ssize_t cpuset_write_resmask(struct kernfs_open_file *of, |
1607 | struct cftype *cft, char *buf) | 1607 | char *buf, size_t nbytes, loff_t off) |
1608 | { | 1608 | { |
1609 | struct cpuset *cs = css_cs(css); | 1609 | struct cpuset *cs = css_cs(of_css(of)); |
1610 | struct cpuset *trialcs; | 1610 | struct cpuset *trialcs; |
1611 | int retval = -ENODEV; | 1611 | int retval = -ENODEV; |
1612 | 1612 | ||
1613 | buf = strstrip(buf); | ||
1614 | |||
1613 | /* | 1615 | /* |
1614 | * CPU or memory hotunplug may leave @cs w/o any execution | 1616 | * CPU or memory hotunplug may leave @cs w/o any execution |
1615 | * resources, in which case the hotplug code asynchronously updates | 1617 | * resources, in which case the hotplug code asynchronously updates |
@@ -1633,7 +1635,7 @@ static int cpuset_write_resmask(struct cgroup_subsys_state *css, | |||
1633 | goto out_unlock; | 1635 | goto out_unlock; |
1634 | } | 1636 | } |
1635 | 1637 | ||
1636 | switch (cft->private) { | 1638 | switch (of_cft(of)->private) { |
1637 | case FILE_CPULIST: | 1639 | case FILE_CPULIST: |
1638 | retval = update_cpumask(cs, trialcs, buf); | 1640 | retval = update_cpumask(cs, trialcs, buf); |
1639 | break; | 1641 | break; |
@@ -1648,7 +1650,7 @@ static int cpuset_write_resmask(struct cgroup_subsys_state *css, | |||
1648 | free_trial_cpuset(trialcs); | 1650 | free_trial_cpuset(trialcs); |
1649 | out_unlock: | 1651 | out_unlock: |
1650 | mutex_unlock(&cpuset_mutex); | 1652 | mutex_unlock(&cpuset_mutex); |
1651 | return retval; | 1653 | return retval ?: nbytes; |
1652 | } | 1654 | } |
1653 | 1655 | ||
1654 | /* | 1656 | /* |
@@ -1750,7 +1752,7 @@ static struct cftype files[] = { | |||
1750 | { | 1752 | { |
1751 | .name = "cpus", | 1753 | .name = "cpus", |
1752 | .seq_show = cpuset_common_seq_show, | 1754 | .seq_show = cpuset_common_seq_show, |
1753 | .write_string = cpuset_write_resmask, | 1755 | .write = cpuset_write_resmask, |
1754 | .max_write_len = (100U + 6 * NR_CPUS), | 1756 | .max_write_len = (100U + 6 * NR_CPUS), |
1755 | .private = FILE_CPULIST, | 1757 | .private = FILE_CPULIST, |
1756 | }, | 1758 | }, |
@@ -1758,7 +1760,7 @@ static struct cftype files[] = { | |||
1758 | { | 1760 | { |
1759 | .name = "mems", | 1761 | .name = "mems", |
1760 | .seq_show = cpuset_common_seq_show, | 1762 | .seq_show = cpuset_common_seq_show, |
1761 | .write_string = cpuset_write_resmask, | 1763 | .write = cpuset_write_resmask, |
1762 | .max_write_len = (100U + 6 * MAX_NUMNODES), | 1764 | .max_write_len = (100U + 6 * MAX_NUMNODES), |
1763 | .private = FILE_MEMLIST, | 1765 | .private = FILE_MEMLIST, |
1764 | }, | 1766 | }, |
diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c index 372f1adca491..191de26b0148 100644 --- a/mm/hugetlb_cgroup.c +++ b/mm/hugetlb_cgroup.c | |||
@@ -253,15 +253,16 @@ static u64 hugetlb_cgroup_read_u64(struct cgroup_subsys_state *css, | |||
253 | return res_counter_read_u64(&h_cg->hugepage[idx], name); | 253 | return res_counter_read_u64(&h_cg->hugepage[idx], name); |
254 | } | 254 | } |
255 | 255 | ||
256 | static int hugetlb_cgroup_write(struct cgroup_subsys_state *css, | 256 | static ssize_t hugetlb_cgroup_write(struct kernfs_open_file *of, |
257 | struct cftype *cft, char *buffer) | 257 | char *buf, size_t nbytes, loff_t off) |
258 | { | 258 | { |
259 | int idx, name, ret; | 259 | int idx, name, ret; |
260 | unsigned long long val; | 260 | unsigned long long val; |
261 | struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(css); | 261 | struct hugetlb_cgroup *h_cg = hugetlb_cgroup_from_css(of_css(of)); |
262 | 262 | ||
263 | idx = MEMFILE_IDX(cft->private); | 263 | buf = strstrip(buf); |
264 | name = MEMFILE_ATTR(cft->private); | 264 | idx = MEMFILE_IDX(of_cft(of)->private); |
265 | name = MEMFILE_ATTR(of_cft(of)->private); | ||
265 | 266 | ||
266 | switch (name) { | 267 | switch (name) { |
267 | case RES_LIMIT: | 268 | case RES_LIMIT: |
@@ -271,7 +272,7 @@ static int hugetlb_cgroup_write(struct cgroup_subsys_state *css, | |||
271 | break; | 272 | break; |
272 | } | 273 | } |
273 | /* This function does all necessary parse...reuse it */ | 274 | /* This function does all necessary parse...reuse it */ |
274 | ret = res_counter_memparse_write_strategy(buffer, &val); | 275 | ret = res_counter_memparse_write_strategy(buf, &val); |
275 | if (ret) | 276 | if (ret) |
276 | break; | 277 | break; |
277 | ret = res_counter_set_limit(&h_cg->hugepage[idx], val); | 278 | ret = res_counter_set_limit(&h_cg->hugepage[idx], val); |
@@ -280,7 +281,7 @@ static int hugetlb_cgroup_write(struct cgroup_subsys_state *css, | |||
280 | ret = -EINVAL; | 281 | ret = -EINVAL; |
281 | break; | 282 | break; |
282 | } | 283 | } |
283 | return ret; | 284 | return ret ?: nbytes; |
284 | } | 285 | } |
285 | 286 | ||
286 | static int hugetlb_cgroup_reset(struct cgroup_subsys_state *css, | 287 | static int hugetlb_cgroup_reset(struct cgroup_subsys_state *css, |
@@ -331,7 +332,7 @@ static void __init __hugetlb_cgroup_file_init(int idx) | |||
331 | snprintf(cft->name, MAX_CFTYPE_NAME, "%s.limit_in_bytes", buf); | 332 | snprintf(cft->name, MAX_CFTYPE_NAME, "%s.limit_in_bytes", buf); |
332 | cft->private = MEMFILE_PRIVATE(idx, RES_LIMIT); | 333 | cft->private = MEMFILE_PRIVATE(idx, RES_LIMIT); |
333 | cft->read_u64 = hugetlb_cgroup_read_u64; | 334 | cft->read_u64 = hugetlb_cgroup_read_u64; |
334 | cft->write_string = hugetlb_cgroup_write; | 335 | cft->write = hugetlb_cgroup_write; |
335 | 336 | ||
336 | /* Add the usage file */ | 337 | /* Add the usage file */ |
337 | cft = &h->cgroup_files[1]; | 338 | cft = &h->cgroup_files[1]; |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5cf3246314a2..7098a43f7447 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -5143,17 +5143,18 @@ static int memcg_update_kmem_limit(struct mem_cgroup *memcg, | |||
5143 | * The user of this function is... | 5143 | * The user of this function is... |
5144 | * RES_LIMIT. | 5144 | * RES_LIMIT. |
5145 | */ | 5145 | */ |
5146 | static int mem_cgroup_write(struct cgroup_subsys_state *css, struct cftype *cft, | 5146 | static ssize_t mem_cgroup_write(struct kernfs_open_file *of, |
5147 | char *buffer) | 5147 | char *buf, size_t nbytes, loff_t off) |
5148 | { | 5148 | { |
5149 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 5149 | struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); |
5150 | enum res_type type; | 5150 | enum res_type type; |
5151 | int name; | 5151 | int name; |
5152 | unsigned long long val; | 5152 | unsigned long long val; |
5153 | int ret; | 5153 | int ret; |
5154 | 5154 | ||
5155 | type = MEMFILE_TYPE(cft->private); | 5155 | buf = strstrip(buf); |
5156 | name = MEMFILE_ATTR(cft->private); | 5156 | type = MEMFILE_TYPE(of_cft(of)->private); |
5157 | name = MEMFILE_ATTR(of_cft(of)->private); | ||
5157 | 5158 | ||
5158 | switch (name) { | 5159 | switch (name) { |
5159 | case RES_LIMIT: | 5160 | case RES_LIMIT: |
@@ -5162,7 +5163,7 @@ static int mem_cgroup_write(struct cgroup_subsys_state *css, struct cftype *cft, | |||
5162 | break; | 5163 | break; |
5163 | } | 5164 | } |
5164 | /* This function does all necessary parse...reuse it */ | 5165 | /* This function does all necessary parse...reuse it */ |
5165 | ret = res_counter_memparse_write_strategy(buffer, &val); | 5166 | ret = res_counter_memparse_write_strategy(buf, &val); |
5166 | if (ret) | 5167 | if (ret) |
5167 | break; | 5168 | break; |
5168 | if (type == _MEM) | 5169 | if (type == _MEM) |
@@ -5175,7 +5176,7 @@ static int mem_cgroup_write(struct cgroup_subsys_state *css, struct cftype *cft, | |||
5175 | return -EINVAL; | 5176 | return -EINVAL; |
5176 | break; | 5177 | break; |
5177 | case RES_SOFT_LIMIT: | 5178 | case RES_SOFT_LIMIT: |
5178 | ret = res_counter_memparse_write_strategy(buffer, &val); | 5179 | ret = res_counter_memparse_write_strategy(buf, &val); |
5179 | if (ret) | 5180 | if (ret) |
5180 | break; | 5181 | break; |
5181 | /* | 5182 | /* |
@@ -5192,7 +5193,7 @@ static int mem_cgroup_write(struct cgroup_subsys_state *css, struct cftype *cft, | |||
5192 | ret = -EINVAL; /* should be BUG() ? */ | 5193 | ret = -EINVAL; /* should be BUG() ? */ |
5193 | break; | 5194 | break; |
5194 | } | 5195 | } |
5195 | return ret; | 5196 | return ret ?: nbytes; |
5196 | } | 5197 | } |
5197 | 5198 | ||
5198 | static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg, | 5199 | static void memcg_get_hierarchical_limit(struct mem_cgroup *memcg, |
@@ -5964,9 +5965,10 @@ static void memcg_event_ptable_queue_proc(struct file *file, | |||
5964 | * Input must be in format '<event_fd> <control_fd> <args>'. | 5965 | * Input must be in format '<event_fd> <control_fd> <args>'. |
5965 | * Interpretation of args is defined by control file implementation. | 5966 | * Interpretation of args is defined by control file implementation. |
5966 | */ | 5967 | */ |
5967 | static int memcg_write_event_control(struct cgroup_subsys_state *css, | 5968 | static ssize_t memcg_write_event_control(struct kernfs_open_file *of, |
5968 | struct cftype *cft, char *buffer) | 5969 | char *buf, size_t nbytes, loff_t off) |
5969 | { | 5970 | { |
5971 | struct cgroup_subsys_state *css = of_css(of); | ||
5970 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 5972 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); |
5971 | struct mem_cgroup_event *event; | 5973 | struct mem_cgroup_event *event; |
5972 | struct cgroup_subsys_state *cfile_css; | 5974 | struct cgroup_subsys_state *cfile_css; |
@@ -5977,15 +5979,17 @@ static int memcg_write_event_control(struct cgroup_subsys_state *css, | |||
5977 | char *endp; | 5979 | char *endp; |
5978 | int ret; | 5980 | int ret; |
5979 | 5981 | ||
5980 | efd = simple_strtoul(buffer, &endp, 10); | 5982 | buf = strstrip(buf); |
5983 | |||
5984 | efd = simple_strtoul(buf, &endp, 10); | ||
5981 | if (*endp != ' ') | 5985 | if (*endp != ' ') |
5982 | return -EINVAL; | 5986 | return -EINVAL; |
5983 | buffer = endp + 1; | 5987 | buf = endp + 1; |
5984 | 5988 | ||
5985 | cfd = simple_strtoul(buffer, &endp, 10); | 5989 | cfd = simple_strtoul(buf, &endp, 10); |
5986 | if ((*endp != ' ') && (*endp != '\0')) | 5990 | if ((*endp != ' ') && (*endp != '\0')) |
5987 | return -EINVAL; | 5991 | return -EINVAL; |
5988 | buffer = endp + 1; | 5992 | buf = endp + 1; |
5989 | 5993 | ||
5990 | event = kzalloc(sizeof(*event), GFP_KERNEL); | 5994 | event = kzalloc(sizeof(*event), GFP_KERNEL); |
5991 | if (!event) | 5995 | if (!event) |
@@ -6063,7 +6067,7 @@ static int memcg_write_event_control(struct cgroup_subsys_state *css, | |||
6063 | goto out_put_cfile; | 6067 | goto out_put_cfile; |
6064 | } | 6068 | } |
6065 | 6069 | ||
6066 | ret = event->register_event(memcg, event->eventfd, buffer); | 6070 | ret = event->register_event(memcg, event->eventfd, buf); |
6067 | if (ret) | 6071 | if (ret) |
6068 | goto out_put_css; | 6072 | goto out_put_css; |
6069 | 6073 | ||
@@ -6076,7 +6080,7 @@ static int memcg_write_event_control(struct cgroup_subsys_state *css, | |||
6076 | fdput(cfile); | 6080 | fdput(cfile); |
6077 | fdput(efile); | 6081 | fdput(efile); |
6078 | 6082 | ||
6079 | return 0; | 6083 | return nbytes; |
6080 | 6084 | ||
6081 | out_put_css: | 6085 | out_put_css: |
6082 | css_put(css); | 6086 | css_put(css); |
@@ -6107,13 +6111,13 @@ static struct cftype mem_cgroup_files[] = { | |||
6107 | { | 6111 | { |
6108 | .name = "limit_in_bytes", | 6112 | .name = "limit_in_bytes", |
6109 | .private = MEMFILE_PRIVATE(_MEM, RES_LIMIT), | 6113 | .private = MEMFILE_PRIVATE(_MEM, RES_LIMIT), |
6110 | .write_string = mem_cgroup_write, | 6114 | .write = mem_cgroup_write, |
6111 | .read_u64 = mem_cgroup_read_u64, | 6115 | .read_u64 = mem_cgroup_read_u64, |
6112 | }, | 6116 | }, |
6113 | { | 6117 | { |
6114 | .name = "soft_limit_in_bytes", | 6118 | .name = "soft_limit_in_bytes", |
6115 | .private = MEMFILE_PRIVATE(_MEM, RES_SOFT_LIMIT), | 6119 | .private = MEMFILE_PRIVATE(_MEM, RES_SOFT_LIMIT), |
6116 | .write_string = mem_cgroup_write, | 6120 | .write = mem_cgroup_write, |
6117 | .read_u64 = mem_cgroup_read_u64, | 6121 | .read_u64 = mem_cgroup_read_u64, |
6118 | }, | 6122 | }, |
6119 | { | 6123 | { |
@@ -6138,7 +6142,7 @@ static struct cftype mem_cgroup_files[] = { | |||
6138 | }, | 6142 | }, |
6139 | { | 6143 | { |
6140 | .name = "cgroup.event_control", /* XXX: for compat */ | 6144 | .name = "cgroup.event_control", /* XXX: for compat */ |
6141 | .write_string = memcg_write_event_control, | 6145 | .write = memcg_write_event_control, |
6142 | .flags = CFTYPE_NO_PREFIX, | 6146 | .flags = CFTYPE_NO_PREFIX, |
6143 | .mode = S_IWUGO, | 6147 | .mode = S_IWUGO, |
6144 | }, | 6148 | }, |
@@ -6171,7 +6175,7 @@ static struct cftype mem_cgroup_files[] = { | |||
6171 | { | 6175 | { |
6172 | .name = "kmem.limit_in_bytes", | 6176 | .name = "kmem.limit_in_bytes", |
6173 | .private = MEMFILE_PRIVATE(_KMEM, RES_LIMIT), | 6177 | .private = MEMFILE_PRIVATE(_KMEM, RES_LIMIT), |
6174 | .write_string = mem_cgroup_write, | 6178 | .write = mem_cgroup_write, |
6175 | .read_u64 = mem_cgroup_read_u64, | 6179 | .read_u64 = mem_cgroup_read_u64, |
6176 | }, | 6180 | }, |
6177 | { | 6181 | { |
@@ -6217,7 +6221,7 @@ static struct cftype memsw_cgroup_files[] = { | |||
6217 | { | 6221 | { |
6218 | .name = "memsw.limit_in_bytes", | 6222 | .name = "memsw.limit_in_bytes", |
6219 | .private = MEMFILE_PRIVATE(_MEMSWAP, RES_LIMIT), | 6223 | .private = MEMFILE_PRIVATE(_MEMSWAP, RES_LIMIT), |
6220 | .write_string = mem_cgroup_write, | 6224 | .write = mem_cgroup_write, |
6221 | .read_u64 = mem_cgroup_read_u64, | 6225 | .read_u64 = mem_cgroup_read_u64, |
6222 | }, | 6226 | }, |
6223 | { | 6227 | { |
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c index 3825f669147b..b990cefd906b 100644 --- a/net/core/netprio_cgroup.c +++ b/net/core/netprio_cgroup.c | |||
@@ -185,15 +185,15 @@ static int read_priomap(struct seq_file *sf, void *v) | |||
185 | return 0; | 185 | return 0; |
186 | } | 186 | } |
187 | 187 | ||
188 | static int write_priomap(struct cgroup_subsys_state *css, struct cftype *cft, | 188 | static ssize_t write_priomap(struct kernfs_open_file *of, |
189 | char *buffer) | 189 | char *buf, size_t nbytes, loff_t off) |
190 | { | 190 | { |
191 | char devname[IFNAMSIZ + 1]; | 191 | char devname[IFNAMSIZ + 1]; |
192 | struct net_device *dev; | 192 | struct net_device *dev; |
193 | u32 prio; | 193 | u32 prio; |
194 | int ret; | 194 | int ret; |
195 | 195 | ||
196 | if (sscanf(buffer, "%"__stringify(IFNAMSIZ)"s %u", devname, &prio) != 2) | 196 | if (sscanf(buf, "%"__stringify(IFNAMSIZ)"s %u", devname, &prio) != 2) |
197 | return -EINVAL; | 197 | return -EINVAL; |
198 | 198 | ||
199 | dev = dev_get_by_name(&init_net, devname); | 199 | dev = dev_get_by_name(&init_net, devname); |
@@ -202,11 +202,11 @@ static int write_priomap(struct cgroup_subsys_state *css, struct cftype *cft, | |||
202 | 202 | ||
203 | rtnl_lock(); | 203 | rtnl_lock(); |
204 | 204 | ||
205 | ret = netprio_set_prio(css, dev, prio); | 205 | ret = netprio_set_prio(of_css(of), dev, prio); |
206 | 206 | ||
207 | rtnl_unlock(); | 207 | rtnl_unlock(); |
208 | dev_put(dev); | 208 | dev_put(dev); |
209 | return ret; | 209 | return ret ?: nbytes; |
210 | } | 210 | } |
211 | 211 | ||
212 | static int update_netprio(const void *v, struct file *file, unsigned n) | 212 | static int update_netprio(const void *v, struct file *file, unsigned n) |
@@ -239,7 +239,7 @@ static struct cftype ss_files[] = { | |||
239 | { | 239 | { |
240 | .name = "ifpriomap", | 240 | .name = "ifpriomap", |
241 | .seq_show = read_priomap, | 241 | .seq_show = read_priomap, |
242 | .write_string = write_priomap, | 242 | .write = write_priomap, |
243 | }, | 243 | }, |
244 | { } /* terminate */ | 244 | { } /* terminate */ |
245 | }; | 245 | }; |
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c index d4f015ad6c84..841fd3fa937a 100644 --- a/net/ipv4/tcp_memcontrol.c +++ b/net/ipv4/tcp_memcontrol.c | |||
@@ -102,17 +102,19 @@ static int tcp_update_limit(struct mem_cgroup *memcg, u64 val) | |||
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
104 | 104 | ||
105 | static int tcp_cgroup_write(struct cgroup_subsys_state *css, struct cftype *cft, | 105 | static ssize_t tcp_cgroup_write(struct kernfs_open_file *of, |
106 | char *buffer) | 106 | char *buf, size_t nbytes, loff_t off) |
107 | { | 107 | { |
108 | struct mem_cgroup *memcg = mem_cgroup_from_css(css); | 108 | struct mem_cgroup *memcg = mem_cgroup_from_css(of_css(of)); |
109 | unsigned long long val; | 109 | unsigned long long val; |
110 | int ret = 0; | 110 | int ret = 0; |
111 | 111 | ||
112 | switch (cft->private) { | 112 | buf = strstrip(buf); |
113 | |||
114 | switch (of_cft(of)->private) { | ||
113 | case RES_LIMIT: | 115 | case RES_LIMIT: |
114 | /* see memcontrol.c */ | 116 | /* see memcontrol.c */ |
115 | ret = res_counter_memparse_write_strategy(buffer, &val); | 117 | ret = res_counter_memparse_write_strategy(buf, &val); |
116 | if (ret) | 118 | if (ret) |
117 | break; | 119 | break; |
118 | ret = tcp_update_limit(memcg, val); | 120 | ret = tcp_update_limit(memcg, val); |
@@ -121,7 +123,7 @@ static int tcp_cgroup_write(struct cgroup_subsys_state *css, struct cftype *cft, | |||
121 | ret = -EINVAL; | 123 | ret = -EINVAL; |
122 | break; | 124 | break; |
123 | } | 125 | } |
124 | return ret; | 126 | return ret ?: nbytes; |
125 | } | 127 | } |
126 | 128 | ||
127 | static u64 tcp_read_stat(struct mem_cgroup *memcg, int type, u64 default_val) | 129 | static u64 tcp_read_stat(struct mem_cgroup *memcg, int type, u64 default_val) |
@@ -193,7 +195,7 @@ static int tcp_cgroup_reset(struct cgroup_subsys_state *css, unsigned int event) | |||
193 | static struct cftype tcp_files[] = { | 195 | static struct cftype tcp_files[] = { |
194 | { | 196 | { |
195 | .name = "kmem.tcp.limit_in_bytes", | 197 | .name = "kmem.tcp.limit_in_bytes", |
196 | .write_string = tcp_cgroup_write, | 198 | .write = tcp_cgroup_write, |
197 | .read_u64 = tcp_cgroup_read, | 199 | .read_u64 = tcp_cgroup_read, |
198 | .private = RES_LIMIT, | 200 | .private = RES_LIMIT, |
199 | }, | 201 | }, |
diff --git a/security/device_cgroup.c b/security/device_cgroup.c index 9134dbf70d3e..7dbac4061b1c 100644 --- a/security/device_cgroup.c +++ b/security/device_cgroup.c | |||
@@ -767,27 +767,27 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup, | |||
767 | return rc; | 767 | return rc; |
768 | } | 768 | } |
769 | 769 | ||
770 | static int devcgroup_access_write(struct cgroup_subsys_state *css, | 770 | static ssize_t devcgroup_access_write(struct kernfs_open_file *of, |
771 | struct cftype *cft, char *buffer) | 771 | char *buf, size_t nbytes, loff_t off) |
772 | { | 772 | { |
773 | int retval; | 773 | int retval; |
774 | 774 | ||
775 | mutex_lock(&devcgroup_mutex); | 775 | mutex_lock(&devcgroup_mutex); |
776 | retval = devcgroup_update_access(css_to_devcgroup(css), | 776 | retval = devcgroup_update_access(css_to_devcgroup(of_css(of)), |
777 | cft->private, buffer); | 777 | of_cft(of)->private, strstrip(buf)); |
778 | mutex_unlock(&devcgroup_mutex); | 778 | mutex_unlock(&devcgroup_mutex); |
779 | return retval; | 779 | return retval ?: nbytes; |
780 | } | 780 | } |
781 | 781 | ||
782 | static struct cftype dev_cgroup_files[] = { | 782 | static struct cftype dev_cgroup_files[] = { |
783 | { | 783 | { |
784 | .name = "allow", | 784 | .name = "allow", |
785 | .write_string = devcgroup_access_write, | 785 | .write = devcgroup_access_write, |
786 | .private = DEVCG_ALLOW, | 786 | .private = DEVCG_ALLOW, |
787 | }, | 787 | }, |
788 | { | 788 | { |
789 | .name = "deny", | 789 | .name = "deny", |
790 | .write_string = devcgroup_access_write, | 790 | .write = devcgroup_access_write, |
791 | .private = DEVCG_DENY, | 791 | .private = DEVCG_DENY, |
792 | }, | 792 | }, |
793 | { | 793 | { |