From: "Paul Menage" <menage@google.com>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] cgroups: introduce cft->read_seq()
Date: Wed, 2 Apr 2008 21:36:13 -0700 [thread overview]
Message-ID: <6599ad830804022136o24be5797s20843e18c91aeaf0@mail.gmail.com> (raw)
In-Reply-To: <20080403010130.GA20543@sergelap.austin.ibm.com>
On Wed, Apr 2, 2008 at 6:01 PM, Serge E. Hallyn <serue@us.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
next prev parent reply other threads:[~2008-04-03 4:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-03 1:01 Serge E. Hallyn
2008-04-03 1:48 ` Li Zefan
2008-04-03 2:29 ` Li Zefan
2008-04-03 3:53 ` Serge E. Hallyn
2008-04-03 4:36 ` Paul Menage [this message]
2008-04-03 4:53 ` serge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6599ad830804022136o24be5797s20843e18c91aeaf0@mail.gmail.com \
--to=menage@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®