From: Omar Sandoval <osandov@osandov.com>
To: Bart Van Assche <Bart.VanAssche@sandisk.com>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"axboe@fb.com" <axboe@fb.com>,
"kernel-team@fb.com" <kernel-team@fb.com>
Subject: Re: [PATCH 3/9] blk-mq-debugfs: get rid of a bunch of boilerplate
Date: Wed, 3 May 2017 16:22:15 -0700 [thread overview]
Message-ID: <20170503232215.GA29984@vader> (raw)
In-Reply-To: <1493844669.3901.38.camel@sandisk.com>
On Wed, May 03, 2017 at 08:51:11PM +0000, Bart Van Assche wrote:
> On Wed, 2017-05-03 at 12:18 -0700, Omar Sandoval wrote:
> > From: Omar Sandoval <osandov@fb.com>
> >
> > A large part of blk-mq-debugfs.c is file_operations and seq_file
> > boilerplate. This sucks as is but will suck even more when schedulers
> > can define their own debugfs entries. Factor it all out into a single
> > blk_mq_debugfs_fops which multiplexes as needed. We store the
> > request_queue, blk_mq_hw_ctx, or blk_mq_ctx in the parent directory
> > dentry, which is kind of hacky, but it works.
> >
> > Signed-off-by: Omar Sandoval <osandov@fb.com>
> > ---
> > block/blk-mq-debugfs.c | 469 +++++++++++++++----------------------------------
> > 1 file changed, 138 insertions(+), 331 deletions(-)
> >
> > diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
> > index f58a116d6cca..00cc89c34590 100644
> > --- a/block/blk-mq-debugfs.c
> > +++ b/block/blk-mq-debugfs.c
> > @@ -26,23 +26,12 @@
> > struct blk_mq_debugfs_attr {
> > const char *name;
> > umode_t mode;
> > - const struct file_operations *fops;
> > + int (*show)(void *, struct seq_file *);
>
> Hello Omar,
>
> The current show functions have the seq_file pointer as first argument
> but for .show() it is the second argument. Please consider to keep that
> pointer as the first argument.
The current show functions aren't the same thing, though. The void *
argument to those is meaningless, and the data is in m->private instead
of being passed in. I don't want to conflate the two calling
conventions.
Really what I wanted were strongly-typed show/write functions, i.e., one of
int (*show)(struct request_queue *, struct seq_file *);
int (*show)(struct blk_mq_hw_ctx *, struct seq_file *);
int (*show)(struct blk_mq_ctx *, struct seq_file *);
But I couldn't come up with a nice way to do that.
> > +static ssize_t queue_state_write(void *data, const char __user *buf,
> > + size_t count, loff_t *ppos)
> > {
> > - struct request_queue *q = file_inode(file)->i_private;
> > + struct request_queue *q = data;
> > char op[16] = { }, *s;
> >
> > - len = min(len, sizeof(op) - 1);
> > - if (copy_from_user(op, ubuf, len))
> > + if (copy_from_user(op, buf, min(count, sizeof(op) - 1)))
> > return -EFAULT;
> > s = op;
> > strsep(&s, " \t\n"); /* strip trailing whitespace */
> > @@ -127,22 +115,9 @@ static ssize_t blk_queue_flags_store(struct file *file, const char __user *ubuf,
> > __func__, op);
> > return -EINVAL;
> > }
> > - return len;
> > -}
> > -
> > -static int blk_queue_flags_open(struct inode *inode, struct file *file)
> > -{
> > - return single_open(file, blk_queue_flags_show, inode->i_private);
> > + return count;
> > }
>
> Please move the return value changes of queue_state_write() into a separate
> patch since these are a bug fix and not related to the removal of the
> boilerplate code.
Sure, I'll do that.
Thanks for the review.
next prev parent reply other threads:[~2017-05-03 23:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 19:18 [PATCH 0/9] blk-mq-debugfs: scheduler support and cleanups Omar Sandoval
2017-05-03 19:18 ` [PATCH 1/9] blk-mq-debugfs: separate flags with | Omar Sandoval
2017-05-03 19:18 ` [PATCH 2/9] blk-mq-debugfs: clean up flag definitions Omar Sandoval
2017-05-03 19:18 ` [PATCH 3/9] blk-mq-debugfs: get rid of a bunch of boilerplate Omar Sandoval
2017-05-03 20:51 ` Bart Van Assche
2017-05-03 23:22 ` Omar Sandoval [this message]
2017-05-03 19:18 ` [PATCH 4/9] blk-mq: Do not invoke queue operations on a dead queue Omar Sandoval
2017-05-03 19:18 ` [PATCH 5/9] blk-mq: move debugfs declarations to a separate header file Omar Sandoval
2017-05-03 19:18 ` [PATCH 6/9] blk-mq: untangle debugfs and sysfs Omar Sandoval
2017-05-03 19:19 ` [PATCH 7/9] blk-mq-debugfs: allow schedulers to register debugfs attributes Omar Sandoval
2017-05-03 19:19 ` [PATCH 8/9] kyber: add " Omar Sandoval
2017-05-03 19:19 ` [PATCH 9/9] mq-deadline: " Omar Sandoval
2017-05-03 19:57 ` [PATCH 10/9] blk-mq-debugfs: rename hw queue directories from <n> to hctx<n> Omar Sandoval
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=20170503232215.GA29984@vader \
--to=osandov@osandov.com \
--cc=Bart.VanAssche@sandisk.com \
--cc=axboe@fb.com \
--cc=kernel-team@fb.com \
--cc=linux-block@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.