linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] blkcg: add sanity check for blkcg policy operations
@ 2017-10-17 15:56 weiping zhang
  2017-11-04 15:03 ` weiping zhang
  2017-11-04 16:10 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: weiping zhang @ 2017-10-17 15:56 UTC (permalink / raw)
  To: axboe; +Cc: jthumshirn, linux-block

blkcg policy should keep cpd/pd's alloc_fn and free_fn in pairs,
otherwise policy would register fail.

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
---
Changes since V4:
 * merge "if(cpd->xxx)" and "if(pd->xxx)" together

Changes since V3:
 * make if more cleaner by using !pold->cpd_alloc_fn ^ !pol->cpd_free_fn

Chagnes since V2:
 * merge blkcg_policy_check_ops into the caller blkcg_policy_register

V1:
 * add blkcg_policy_check_ops to check cpd/pd's alloc_fn and free_fn in
 * pairs.

 block/blk-cgroup.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index e7ec676..4117524 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1419,6 +1419,11 @@ int blkcg_policy_register(struct blkcg_policy *pol)
 	if (i >= BLKCG_MAX_POLS)
 		goto err_unlock;
 
+	/* Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs */
+	if ((!pol->cpd_alloc_fn ^ !pol->cpd_free_fn) ||
+		(!pol->pd_alloc_fn ^ !pol->pd_free_fn))
+		goto err_unlock;
+
 	/* register @pol */
 	pol->plid = i;
 	blkcg_policy[pol->plid] = pol;
-- 
2.9.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] blkcg: add sanity check for blkcg policy operations
  2017-10-17 15:56 [PATCH v4] blkcg: add sanity check for blkcg policy operations weiping zhang
@ 2017-11-04 15:03 ` weiping zhang
  2017-11-04 16:10 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: weiping zhang @ 2017-11-04 15:03 UTC (permalink / raw)
  To: axboe@kernel.dk, jthumshirn@suse.de, linux-block@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 1544 bytes --]

2017年10月17日星期二,weiping zhang <zhangweiping@didichuxing.com> 写道:

> blkcg policy should keep cpd/pd's alloc_fn and free_fn in pairs,
> otherwise policy would register fail.
>
> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de <javascript:;>>
> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com <javascript:;>>
> ---
> Changes since V4:
>  * merge "if(cpd->xxx)" and "if(pd->xxx)" together
>
> Changes since V3:
>  * make if more cleaner by using !pold->cpd_alloc_fn ^ !pol->cpd_free_fn
>
> Chagnes since V2:
>  * merge blkcg_policy_check_ops into the caller blkcg_policy_register
>
> V1:
>  * add blkcg_policy_check_ops to check cpd/pd's alloc_fn and free_fn in
>  * pairs.
>
>  block/blk-cgroup.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index e7ec676..4117524 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -1419,6 +1419,11 @@ int blkcg_policy_register(struct blkcg_policy *pol)
>         if (i >= BLKCG_MAX_POLS)
>                 goto err_unlock;
>
> +       /* Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs */
> +       if ((!pol->cpd_alloc_fn ^ !pol->cpd_free_fn) ||
> +               (!pol->pd_alloc_fn ^ !pol->pd_free_fn))
> +               goto err_unlock;
> +
>         /* register @pol */
>         pol->plid = i;
>         blkcg_policy[pol->plid] = pol;
> --
> 2.9.4
>
> Hello Jens,

A consolidation for blkcg policy operations, would you pick it up?

Thanks ^_^

[-- Attachment #2: Type: text/html, Size: 2160 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v4] blkcg: add sanity check for blkcg policy operations
  2017-10-17 15:56 [PATCH v4] blkcg: add sanity check for blkcg policy operations weiping zhang
  2017-11-04 15:03 ` weiping zhang
@ 2017-11-04 16:10 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2017-11-04 16:10 UTC (permalink / raw)
  To: jthumshirn, linux-block

On 10/17/2017 09:56 AM, weiping zhang wrote:
> blkcg policy should keep cpd/pd's alloc_fn and free_fn in pairs,
> otherwise policy would register fail.

Added, thanks.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-04 16:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-17 15:56 [PATCH v4] blkcg: add sanity check for blkcg policy operations weiping zhang
2017-11-04 15:03 ` weiping zhang
2017-11-04 16:10 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).