All of lore.kernel.org
 help / color / mirror / Atom feed
From: weiping zhang <zwp10758@gmail.com>
To: Johannes Thumshirn <jthumshirn@suse.de>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org
Subject: Re: [PATCH] blkcg: add sanity check for blkcg policy operations
Date: Wed, 11 Oct 2017 17:44:38 +0800	[thread overview]
Message-ID: <20171011094438.GA37287@localhost.didichuxing.com> (raw)
In-Reply-To: <20171011075833.oglwgmy763r3egfy@linux-x5ow.site>

On Wed, Oct 11, 2017 at 09:58:33AM +0200, Johannes Thumshirn wrote:
> On Wed, Oct 11, 2017 at 12:00:55AM +0800, weiping zhang wrote:
> > + * blkcg_policy_check_ops - check policy's operations
> > + * @pol: blkcg policy to check
> > + *
> > + * Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs.
> > + * Return true on success and false on failure.
> > + */
> > +static bool blkcg_policy_check_ops(struct blkcg_policy *pol)
> > +{
> > +	if ((pol->cpd_alloc_fn && !pol->cpd_free_fn) ||
> > +		(!pol->cpd_alloc_fn && pol->cpd_free_fn))
> > +		return false;
> > +
> > +	if ((pol->pd_alloc_fn && !pol->pd_free_fn) ||
> > +		(!pol->pd_alloc_fn && pol->pd_free_fn))
> > +		return false;
> > +
> > +	return true;
> > +}
> > +
> > +/**
> >   * blkcg_policy_register - register a blkcg policy
> >   * @pol: blkcg policy to register
> >   *
> > @@ -1419,6 +1439,9 @@ int blkcg_policy_register(struct blkcg_policy *pol)
> >  	if (i >= BLKCG_MAX_POLS)
> >  		goto err_unlock;
> >  
> > +	if (!blkcg_policy_check_ops(pol))
> > +		goto err_unlock;
> > +
> 
> Can you merge it into the caller?
> 
> +	if ((pol->cpd_alloc_fn && !pol->cpd_free_fn) ||
> +		(!pol->cpd_alloc_fn && pol->cpd_free_fn))
> +		goto err_unlock;
> +
> +	if ((pol->pd_alloc_fn && !pol->pd_free_fn) ||
> +		(!pol->pd_alloc_fn && pol->pd_free_fn))
> +		goto err_unlock;
> 
> 
It's ok for me, I send V2 later.

Thanks
Weiping

      reply	other threads:[~2017-10-11  9:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-10 16:00 [PATCH] blkcg: add sanity check for blkcg policy operations weiping zhang
2017-10-11  7:58 ` Johannes Thumshirn
2017-10-11  9:44   ` weiping zhang [this message]

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=20171011094438.GA37287@localhost.didichuxing.com \
    --to=zwp10758@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=jthumshirn@suse.de \
    --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.