* [PATCH v2 5/5] cgroup: remove struct cgroup_seqfile_state
@ 2013-07-31 9:36 Li Zefan
[not found] ` <51F8DA99.3010303-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Li Zefan @ 2013-07-31 9:36 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
We can use struct cfent instead.
v2:
- remove cgroup_seqfile_release().
Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
kernel/cgroup.c | 45 +++++++++++++--------------------------------
1 file changed, 13 insertions(+), 32 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 0d378b1..c836dff 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2362,11 +2362,6 @@ static ssize_t cgroup_file_read(struct file *file, char __user *buf,
* 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)
{
struct seq_file *sf = cb->state;
@@ -2375,59 +2370,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)
{
- struct cgroup_seqfile_state *state = m->private;
- struct cftype *cft = state->cft;
+ struct cfent *cfe = m->private;
+ struct cftype *cft = cfe->type;
+ struct cgroup *cgrp = __d_cgrp(cfe->dentry->d_parent);
+
if (cft->read_map) {
struct cgroup_map_cb cb = {
.fill = cgroup_map_add,
.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);
-}
-
-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);
+ return cft->read_seq_string(cgrp, cft, m);
}
static const struct file_operations cgroup_seqfile_operations = {
.read = seq_read,
.write = cgroup_file_write,
.llseek = seq_lseek,
- .release = cgroup_seqfile_release,
+ .release = single_release,
};
static int cgroup_file_open(struct inode *inode, struct file *file)
{
int err;
+ struct cfent *cfe;
struct cftype *cft;
err = generic_file_open(inode, file);
if (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) {
- 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;
- err = single_open(file, cgroup_seqfile_show, state);
- if (err < 0)
- kfree(state);
- } else if (cft->open)
+ err = single_open(file, cgroup_seqfile_show, cfe);
+ } else if (cft->open) {
err = cft->open(inode, file);
- else
- err = 0;
+ }
return err;
}
--
1.8.0.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 5/5] cgroup: remove struct cgroup_seqfile_state
[not found] ` <51F8DA99.3010303-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2013-07-31 11:36 ` Tejun Heo
2013-08-01 1:11 ` Li Zefan
0 siblings, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2013-07-31 11:36 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups
On Wed, Jul 31, 2013 at 05:36:25PM +0800, Li Zefan wrote:
> We can use struct cfent instead.
>
> v2:
> - remove cgroup_seqfile_release().
>
> Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Applied to libata/for-3.12.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 5/5] cgroup: remove struct cgroup_seqfile_state
2013-07-31 11:36 ` Tejun Heo
@ 2013-08-01 1:11 ` Li Zefan
[not found] ` <51F9B5BD.2070502-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Li Zefan @ 2013-08-01 1:11 UTC (permalink / raw)
To: Tejun Heo; +Cc: LKML, Cgroups
On 2013/7/31 19:36, Tejun Heo wrote:
> On Wed, Jul 31, 2013 at 05:36:25PM +0800, Li Zefan wrote:
>> We can use struct cfent instead.
>>
>> v2:
>> - remove cgroup_seqfile_release().
>>
>> Signed-off-by: Li Zefan <lizefan@huawei.com>
>
> Applied to libata/for-3.12.
>
libata? I hope you didn't. :)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 5/5] cgroup: remove struct cgroup_seqfile_state
[not found] ` <51F9B5BD.2070502-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2013-08-01 12:08 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2013-08-01 12:08 UTC (permalink / raw)
To: Li Zefan; +Cc: LKML, Cgroups
On Thu, Aug 01, 2013 at 09:11:25AM +0800, Li Zefan wrote:
> On 2013/7/31 19:36, Tejun Heo wrote:
> > On Wed, Jul 31, 2013 at 05:36:25PM +0800, Li Zefan wrote:
> >> We can use struct cfent instead.
> >>
> >> v2:
> >> - remove cgroup_seqfile_release().
> >>
> >> Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> >
> > Applied to libata/for-3.12.
> >
>
> libata? I hope you didn't. :)
Haha, brainfart. I did apply it to cgroup/for-3.12. :)
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-01 12:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-31 9:36 [PATCH v2 5/5] cgroup: remove struct cgroup_seqfile_state Li Zefan
[not found] ` <51F8DA99.3010303-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-07-31 11:36 ` Tejun Heo
2013-08-01 1:11 ` Li Zefan
[not found] ` <51F9B5BD.2070502-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-08-01 12:08 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).