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 /net/ipv4/tcp_memcontrol.c | |
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>
Diffstat (limited to 'net/ipv4/tcp_memcontrol.c')
-rw-r--r-- | net/ipv4/tcp_memcontrol.c | 16 |
1 files changed, 9 insertions, 7 deletions
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 | }, |