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>
This commit is contained in:
parent
b41686401e
commit
451af504df
11 changed files with 124 additions and 125 deletions
|
@ -73,10 +73,6 @@ bool cgroup_freezing(struct task_struct *task)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* cgroups_write_string() limits the size of freezer state strings to
|
||||
* CGROUP_LOCAL_BUFFER_SIZE
|
||||
*/
|
||||
static const char *freezer_state_strs(unsigned int state)
|
||||
{
|
||||
if (state & CGROUP_FROZEN)
|
||||
|
@ -423,20 +419,22 @@ static void freezer_change_state(struct freezer *freezer, bool freeze)
|
|||
mutex_unlock(&freezer_mutex);
|
||||
}
|
||||
|
||||
static int freezer_write(struct cgroup_subsys_state *css, struct cftype *cft,
|
||||
char *buffer)
|
||||
static ssize_t freezer_write(struct kernfs_open_file *of,
|
||||
char *buf, size_t nbytes, loff_t off)
|
||||
{
|
||||
bool freeze;
|
||||
|
||||
if (strcmp(buffer, freezer_state_strs(0)) == 0)
|
||||
buf = strstrip(buf);
|
||||
|
||||
if (strcmp(buf, freezer_state_strs(0)) == 0)
|
||||
freeze = false;
|
||||
else if (strcmp(buffer, freezer_state_strs(CGROUP_FROZEN)) == 0)
|
||||
else if (strcmp(buf, freezer_state_strs(CGROUP_FROZEN)) == 0)
|
||||
freeze = true;
|
||||
else
|
||||
return -EINVAL;
|
||||
|
||||
freezer_change_state(css_freezer(css), freeze);
|
||||
return 0;
|
||||
freezer_change_state(css_freezer(of_css(of)), freeze);
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
static u64 freezer_self_freezing_read(struct cgroup_subsys_state *css,
|
||||
|
@ -460,7 +458,7 @@ static struct cftype files[] = {
|
|||
.name = "state",
|
||||
.flags = CFTYPE_NOT_ON_ROOT,
|
||||
.seq_show = freezer_read,
|
||||
.write_string = freezer_write,
|
||||
.write = freezer_write,
|
||||
},
|
||||
{
|
||||
.name = "self_freezing",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue