All of lore.kernel.org
 help / color / mirror / Atom feed
From: weiping zhang <zwp10758@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: jthumshirn@suse.de, linux-block@vger.kernel.org
Subject: Re: [PATCH v2] blkcg: add sanity check for blkcg policy operations
Date: Thu, 12 Oct 2017 14:26:08 +0800	[thread overview]
Message-ID: <20171012062608.GA11125@source.didichuxing.com> (raw)
In-Reply-To: <3397954d-e59d-09d5-7aab-cb5f5ac4ce63@kernel.dk>

On Wed, Oct 11, 2017 at 10:51:32AM -0600, Jens Axboe wrote:
> On 10/11/2017 03:46 AM, weiping zhang wrote:
> > blkcg policy should keep cpd/pd's alloc_fn and free_fn in pairs,
> > otherwise policy would register fail.
> > 
> > Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> > ---
> >  block/blk-cgroup.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> > index e7ec676..67b01c5 100644
> > --- a/block/blk-cgroup.c
> > +++ b/block/blk-cgroup.c
> > @@ -1419,6 +1419,16 @@ int blkcg_policy_register(struct blkcg_policy *pol)
> >  	if (i >= BLKCG_MAX_POLS)
> >  		goto err_unlock;
> >  
> > +	/* Make sure cpd_alloc_fn and cpd_free_fn in pairs */
> > +	if ((pol->cpd_alloc_fn && !pol->cpd_free_fn) ||
> > +		(!pol->cpd_alloc_fn && pol->cpd_free_fn))
> > +		goto err_unlock;
> 
> This might be cleaner (and more readable) as:
> 
>         if (!pol->cpd_alloc_fn ^ !pol->cpd_free_fn)
>                 goto err_unlock;
> 
> Ditto for the pd part.
> 
Really nice, I'll send v3.

Thanks

      reply	other threads:[~2017-10-12  6:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11  9:46 [PATCH v2] blkcg: add sanity check for blkcg policy operations weiping zhang
2017-10-11 16:51 ` Jens Axboe
2017-10-12  6:26   ` 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=20171012062608.GA11125@source.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.