mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-05 20:07:58 +07:00
cgroup: remove struct cgroup_seqfile_state
We can use struct cfent instead. v2: - remove cgroup_seqfile_release(). Signed-off-by: Li Zefan <lizefan@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
parent
2a4ac63333
commit
e0798ce273
@ -2397,11 +2397,6 @@ static ssize_t cgroup_file_read(struct file *file, char __user *buf,
|
|||||||
* supports string->u64 maps, but can be extended in future.
|
* supports string->u64 maps, but can be extended in future.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct cgroup_seqfile_state {
|
|
||||||
struct cftype *cft;
|
|
||||||
struct cgroup *cgroup;
|
|
||||||
};
|
|
||||||
|
|
||||||
static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value)
|
static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value)
|
||||||
{
|
{
|
||||||
struct seq_file *sf = cb->state;
|
struct seq_file *sf = cb->state;
|
||||||
@ -2410,59 +2405,45 @@ static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value)
|
|||||||
|
|
||||||
static int cgroup_seqfile_show(struct seq_file *m, void *arg)
|
static int cgroup_seqfile_show(struct seq_file *m, void *arg)
|
||||||
{
|
{
|
||||||
struct cgroup_seqfile_state *state = m->private;
|
struct cfent *cfe = m->private;
|
||||||
struct cftype *cft = state->cft;
|
struct cftype *cft = cfe->type;
|
||||||
|
struct cgroup *cgrp = __d_cgrp(cfe->dentry->d_parent);
|
||||||
|
|
||||||
if (cft->read_map) {
|
if (cft->read_map) {
|
||||||
struct cgroup_map_cb cb = {
|
struct cgroup_map_cb cb = {
|
||||||
.fill = cgroup_map_add,
|
.fill = cgroup_map_add,
|
||||||
.state = m,
|
.state = m,
|
||||||
};
|
};
|
||||||
return cft->read_map(state->cgroup, cft, &cb);
|
return cft->read_map(cgrp, cft, &cb);
|
||||||
}
|
}
|
||||||
return cft->read_seq_string(state->cgroup, cft, m);
|
return cft->read_seq_string(cgrp, cft, m);
|
||||||
}
|
|
||||||
|
|
||||||
static int cgroup_seqfile_release(struct inode *inode, struct file *file)
|
|
||||||
{
|
|
||||||
struct seq_file *seq = file->private_data;
|
|
||||||
kfree(seq->private);
|
|
||||||
return single_release(inode, file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_operations cgroup_seqfile_operations = {
|
static const struct file_operations cgroup_seqfile_operations = {
|
||||||
.read = seq_read,
|
.read = seq_read,
|
||||||
.write = cgroup_file_write,
|
.write = cgroup_file_write,
|
||||||
.llseek = seq_lseek,
|
.llseek = seq_lseek,
|
||||||
.release = cgroup_seqfile_release,
|
.release = single_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cgroup_file_open(struct inode *inode, struct file *file)
|
static int cgroup_file_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
struct cfent *cfe;
|
||||||
struct cftype *cft;
|
struct cftype *cft;
|
||||||
|
|
||||||
err = generic_file_open(inode, file);
|
err = generic_file_open(inode, file);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
cft = __d_cft(file->f_dentry);
|
cfe = __d_cfe(file->f_dentry);
|
||||||
|
cft = cfe->type;
|
||||||
|
|
||||||
if (cft->read_map || cft->read_seq_string) {
|
if (cft->read_map || cft->read_seq_string) {
|
||||||
struct cgroup_seqfile_state *state;
|
|
||||||
|
|
||||||
state = kzalloc(sizeof(*state), GFP_USER);
|
|
||||||
if (!state)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
state->cft = cft;
|
|
||||||
state->cgroup = __d_cgrp(file->f_dentry->d_parent);
|
|
||||||
file->f_op = &cgroup_seqfile_operations;
|
file->f_op = &cgroup_seqfile_operations;
|
||||||
err = single_open(file, cgroup_seqfile_show, state);
|
err = single_open(file, cgroup_seqfile_show, cfe);
|
||||||
if (err < 0)
|
} else if (cft->open) {
|
||||||
kfree(state);
|
|
||||||
} else if (cft->open)
|
|
||||||
err = cft->open(inode, file);
|
err = cft->open(inode, file);
|
||||||
else
|
}
|
||||||
err = 0;
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user