[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6599ad830804022136o24be5797s20843e18c91aeaf0@mail.gmail.com>
Date: Wed, 2 Apr 2008 21:36:13 -0700
From: "Paul Menage" <menage@...gle.com>
To: "Serge E. Hallyn" <serue@...ibm.com>
Cc: lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] cgroups: introduce cft->read_seq()
On Wed, Apr 2, 2008 at 6:01 PM, Serge E. Hallyn <serue@...ibm.com> wrote:
> + /*
> + * read_seq() is used for outputting a simple sequence
> + * using seqfile.
> + */
> + int (*read_seq) (struct cgroup *cont, struct cftype *cft,
> + struct seq_file *m);
Maybe make it read_seq_string() to emphasise that it's not intended
for structured data?
>
> -static int cgroup_seqfile_show(struct seq_file *m, void *arg)
> +static int cgroup_map_seqfile_show(struct seq_file *m, void *arg)
> {
> struct cgroup_seqfile_state *state = m->private;
> struct cftype *cft = state->cft;
> @@ -1529,6 +1529,13 @@ static int cgroup_seqfile_show(struct seq_file *m, void *arg)
> return cft->read_map(state->cgroup, cft, &cb);
> }
I think you can make this simpler - have cgroup_seqfile_show() switch
based on whether the cft has a read_seq_string or a read_map, and then
you only need one function.
>
> +static int cgroup_simple_seqfile_show(struct seq_file *m, void *arg)
> +{
> + struct cgroup_seqfile_state *state = m->private;
> + struct cftype *cft = state->cft;
> + return cft->read_seq(state->cgroup, cft, m);
> +}
> +
> int cgroup_seqfile_release(struct inode *inode, struct file *file)
> {
> struct seq_file *seq = file->private_data;
> @@ -1562,7 +1569,18 @@ static int cgroup_file_open(struct inode *inode, struct file *file)
> 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);
> + err = single_open(file, cgroup_map_seqfile_show, state);
> + if (err < 0)
> + kfree(state);
> + } else if (cft->read_seq) {
> + struct cgroup_seqfile_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_simple_seqfile_show, state);
> if (err < 0)
> kfree(state);
and this arm can just be eliminated, by adding "||
cft->read_seq_string" to the test for cft_read_seq_map above.
It was always my intention that cgroup_seqfile_show() be able to
handle multiple data types, but up until now we only had one.
Paul
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists