mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-23 23:21:46 +00:00
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
|
@ -1603,13 +1603,15 @@ out_unlock:
|
|||
/*
|
||||
* Common handling for a write to a "cpus" or "mems" file.
|
||||
*/
|
||||
static int cpuset_write_resmask(struct cgroup_subsys_state *css,
|
||||
struct cftype *cft, char *buf)
|
||||
static ssize_t cpuset_write_resmask(struct kernfs_open_file *of,
|
||||
char *buf, size_t nbytes, loff_t off)
|
||||
{
|
||||
struct cpuset *cs = css_cs(css);
|
||||
struct cpuset *cs = css_cs(of_css(of));
|
||||
struct cpuset *trialcs;
|
||||
int retval = -ENODEV;
|
||||
|
||||
buf = strstrip(buf);
|
||||
|
||||
/*
|
||||
* CPU or memory hotunplug may leave @cs w/o any execution
|
||||
* resources, in which case the hotplug code asynchronously updates
|
||||
|
@ -1633,7 +1635,7 @@ static int cpuset_write_resmask(struct cgroup_subsys_state *css,
|
|||
goto out_unlock;
|
||||
}
|
||||
|
||||
switch (cft->private) {
|
||||
switch (of_cft(of)->private) {
|
||||
case FILE_CPULIST:
|
||||
retval = update_cpumask(cs, trialcs, buf);
|
||||
break;
|
||||
|
@ -1648,7 +1650,7 @@ static int cpuset_write_resmask(struct cgroup_subsys_state *css,
|
|||
free_trial_cpuset(trialcs);
|
||||
out_unlock:
|
||||
mutex_unlock(&cpuset_mutex);
|
||||
return retval;
|
||||
return retval ?: nbytes;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1750,7 +1752,7 @@ static struct cftype files[] = {
|
|||
{
|
||||
.name = "cpus",
|
||||
.seq_show = cpuset_common_seq_show,
|
||||
.write_string = cpuset_write_resmask,
|
||||
.write = cpuset_write_resmask,
|
||||
.max_write_len = (100U + 6 * NR_CPUS),
|
||||
.private = FILE_CPULIST,
|
||||
},
|
||||
|
@ -1758,7 +1760,7 @@ static struct cftype files[] = {
|
|||
{
|
||||
.name = "mems",
|
||||
.seq_show = cpuset_common_seq_show,
|
||||
.write_string = cpuset_write_resmask,
|
||||
.write = cpuset_write_resmask,
|
||||
.max_write_len = (100U + 6 * MAX_NUMNODES),
|
||||
.private = FILE_MEMLIST,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue