All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-02  2:07 ` Yu Kuai
  0 siblings, 0 replies; 10+ messages in thread
From: Yu Kuai @ 2021-11-02  2:07 UTC (permalink / raw)
  To: tj, axboe, yukuai3; +Cc: cgroups, linux-block, linux-kernel, yi.zhang

If blk_queue_enter() failed due to queue is dying, the
blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.

Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-cgroup.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 88b1fce90520..663aabfeba18 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 	 */
 	ret = blk_queue_enter(q, 0);
 	if (ret)
-		return ret;
+		goto fail;
 
 	rcu_read_lock();
 	spin_lock_irq(&q->queue_lock);
@@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 		new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
 		if (unlikely(!new_blkg)) {
 			ret = -ENOMEM;
-			goto fail;
+			goto fail_exit_queue;
 		}
 
 		if (radix_tree_preload(GFP_KERNEL)) {
 			blkg_free(new_blkg);
 			ret = -ENOMEM;
-			goto fail;
+			goto fail_exit_queue;
 		}
 
 		rcu_read_lock();
@@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 fail_unlock:
 	spin_unlock_irq(&q->queue_lock);
 	rcu_read_unlock();
+fail_exit_queue:
+	blk_queue_exit(q);
 fail:
 	blkdev_put_no_open(bdev);
-	blk_queue_exit(q);
 	/*
 	 * If queue was bypassing, we should retry.  Do so after a
 	 * short msleep().  It isn't strictly necessary but queue
-- 
2.31.1


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

* [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-02  2:07 ` Yu Kuai
  0 siblings, 0 replies; 10+ messages in thread
From: Yu Kuai @ 2021-11-02  2:07 UTC (permalink / raw)
  To: tj, axboe, yukuai3; +Cc: cgroups, linux-block, linux-kernel, yi.zhang

If blk_queue_enter() failed due to queue is dying, the
blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.

Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/blk-cgroup.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 88b1fce90520..663aabfeba18 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 	 */
 	ret = blk_queue_enter(q, 0);
 	if (ret)
-		return ret;
+		goto fail;
 
 	rcu_read_lock();
 	spin_lock_irq(&q->queue_lock);
@@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 		new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
 		if (unlikely(!new_blkg)) {
 			ret = -ENOMEM;
-			goto fail;
+			goto fail_exit_queue;
 		}
 
 		if (radix_tree_preload(GFP_KERNEL)) {
 			blkg_free(new_blkg);
 			ret = -ENOMEM;
-			goto fail;
+			goto fail_exit_queue;
 		}
 
 		rcu_read_lock();
@@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 fail_unlock:
 	spin_unlock_irq(&q->queue_lock);
 	rcu_read_unlock();
+fail_exit_queue:
+	blk_queue_exit(q);
 fail:
 	blkdev_put_no_open(bdev);
-	blk_queue_exit(q);
 	/*
 	 * If queue was bypassing, we should retry.  Do so after a
 	 * short msleep().  It isn't strictly necessary but queue
-- 
2.31.1


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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
  2021-11-02  2:07 ` Yu Kuai
@ 2021-11-06  9:12   ` yukuai (C)
  -1 siblings, 0 replies; 10+ messages in thread
From: yukuai (C) @ 2021-11-06  9:12 UTC (permalink / raw)
  To: tj, axboe; +Cc: cgroups, linux-block, linux-kernel, yi.zhang

On 2021/11/02 10:07, Yu Kuai wrote:
friendly ping...
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   block/blk-cgroup.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 88b1fce90520..663aabfeba18 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   	 */
>   	ret = blk_queue_enter(q, 0);
>   	if (ret)
> -		return ret;
> +		goto fail;
>   
>   	rcu_read_lock();
>   	spin_lock_irq(&q->queue_lock);
> @@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   		new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
>   		if (unlikely(!new_blkg)) {
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		if (radix_tree_preload(GFP_KERNEL)) {
>   			blkg_free(new_blkg);
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		rcu_read_lock();
> @@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   fail_unlock:
>   	spin_unlock_irq(&q->queue_lock);
>   	rcu_read_unlock();
> +fail_exit_queue:
> +	blk_queue_exit(q);
>   fail:
>   	blkdev_put_no_open(bdev);
> -	blk_queue_exit(q);
>   	/*
>   	 * If queue was bypassing, we should retry.  Do so after a
>   	 * short msleep().  It isn't strictly necessary but queue
> 

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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-06  9:12   ` yukuai (C)
  0 siblings, 0 replies; 10+ messages in thread
From: yukuai (C) @ 2021-11-06  9:12 UTC (permalink / raw)
  To: tj, axboe; +Cc: cgroups, linux-block, linux-kernel, yi.zhang

On 2021/11/02 10:07, Yu Kuai wrote:
friendly ping...
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   block/blk-cgroup.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 88b1fce90520..663aabfeba18 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   	 */
>   	ret = blk_queue_enter(q, 0);
>   	if (ret)
> -		return ret;
> +		goto fail;
>   
>   	rcu_read_lock();
>   	spin_lock_irq(&q->queue_lock);
> @@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   		new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
>   		if (unlikely(!new_blkg)) {
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		if (radix_tree_preload(GFP_KERNEL)) {
>   			blkg_free(new_blkg);
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		rcu_read_lock();
> @@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   fail_unlock:
>   	spin_unlock_irq(&q->queue_lock);
>   	rcu_read_unlock();
> +fail_exit_queue:
> +	blk_queue_exit(q);
>   fail:
>   	blkdev_put_no_open(bdev);
> -	blk_queue_exit(q);
>   	/*
>   	 * If queue was bypassing, we should retry.  Do so after a
>   	 * short msleep().  It isn't strictly necessary but queue
> 

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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-15 21:37   ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2021-11-15 21:37 UTC (permalink / raw)
  To: Yu Kuai; +Cc: axboe, cgroups, linux-block, linux-kernel, yi.zhang

On Tue, Nov 02, 2021 at 10:07:05AM +0800, Yu Kuai wrote:
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-15 21:37   ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2021-11-15 21:37 UTC (permalink / raw)
  To: Yu Kuai
  Cc: axboe-tSWWG44O7X1aa/9Udqfwiw, cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-block-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	yi.zhang-hv44wF8Li93QT0dZR+AlfA

On Tue, Nov 02, 2021 at 10:07:05AM +0800, Yu Kuai wrote:
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
> Signed-off-by: Yu Kuai <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

Acked-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>

Thanks.

-- 
tejun

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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-19  8:09   ` yukuai (C)
  0 siblings, 0 replies; 10+ messages in thread
From: yukuai (C) @ 2021-11-19  8:09 UTC (permalink / raw)
  To: tj, axboe; +Cc: cgroups, linux-block, linux-kernel, yi.zhang

On 2021/11/02 10:07, Yu Kuai wrote:
Hi, Jens

friendly ping ...

Thanks,
Kuai
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
>   block/blk-cgroup.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 88b1fce90520..663aabfeba18 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   	 */
>   	ret = blk_queue_enter(q, 0);
>   	if (ret)
> -		return ret;
> +		goto fail;
>   
>   	rcu_read_lock();
>   	spin_lock_irq(&q->queue_lock);
> @@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   		new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
>   		if (unlikely(!new_blkg)) {
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		if (radix_tree_preload(GFP_KERNEL)) {
>   			blkg_free(new_blkg);
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		rcu_read_lock();
> @@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   fail_unlock:
>   	spin_unlock_irq(&q->queue_lock);
>   	rcu_read_unlock();
> +fail_exit_queue:
> +	blk_queue_exit(q);
>   fail:
>   	blkdev_put_no_open(bdev);
> -	blk_queue_exit(q);
>   	/*
>   	 * If queue was bypassing, we should retry.  Do so after a
>   	 * short msleep().  It isn't strictly necessary but queue
> 

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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-19  8:09   ` yukuai (C)
  0 siblings, 0 replies; 10+ messages in thread
From: yukuai (C) @ 2021-11-19  8:09 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A, axboe-tSWWG44O7X1aa/9Udqfwiw
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-block-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	yi.zhang-hv44wF8Li93QT0dZR+AlfA

On 2021/11/02 10:07, Yu Kuai wrote:
Hi, Jens

friendly ping ...

Thanks,
Kuai
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> Fixes: 0c9d338c8443 ("blk-cgroup: synchronize blkg creation against policy deactivation")
> Signed-off-by: Yu Kuai <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
>   block/blk-cgroup.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 88b1fce90520..663aabfeba18 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   	 */
>   	ret = blk_queue_enter(q, 0);
>   	if (ret)
> -		return ret;
> +		goto fail;
>   
>   	rcu_read_lock();
>   	spin_lock_irq(&q->queue_lock);
> @@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   		new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
>   		if (unlikely(!new_blkg)) {
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		if (radix_tree_preload(GFP_KERNEL)) {
>   			blkg_free(new_blkg);
>   			ret = -ENOMEM;
> -			goto fail;
> +			goto fail_exit_queue;
>   		}
>   
>   		rcu_read_lock();
> @@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
>   fail_unlock:
>   	spin_unlock_irq(&q->queue_lock);
>   	rcu_read_unlock();
> +fail_exit_queue:
> +	blk_queue_exit(q);
>   fail:
>   	blkdev_put_no_open(bdev);
> -	blk_queue_exit(q);
>   	/*
>   	 * If queue was bypassing, we should retry.  Do so after a
>   	 * short msleep().  It isn't strictly necessary but queue
> 

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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-19 13:27   ` Jens Axboe
  0 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2021-11-19 13:27 UTC (permalink / raw)
  To: tj, Yu Kuai; +Cc: linux-kernel, cgroups, linux-block, yi.zhang

On Tue, 2 Nov 2021 10:07:05 +0800, Yu Kuai wrote:
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> 

Applied, thanks!

[1/1] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
      commit: 15c30104965101b8e76b24d27035569d6613a7d6

Best regards,
-- 
Jens Axboe



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

* Re: [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
@ 2021-11-19 13:27   ` Jens Axboe
  0 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2021-11-19 13:27 UTC (permalink / raw)
  To: tj-DgEjT+Ai2ygdnm+yROfE0A, Yu Kuai
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-block-u79uwXL29TY76Z2rM5mHXA,
	yi.zhang-hv44wF8Li93QT0dZR+AlfA

On Tue, 2 Nov 2021 10:07:05 +0800, Yu Kuai wrote:
> If blk_queue_enter() failed due to queue is dying, the
> blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded.
> 
> 

Applied, thanks!

[1/1] blk-cgroup: fix missing put device in error path from blkg_conf_pref()
      commit: 15c30104965101b8e76b24d27035569d6613a7d6

Best regards,
-- 
Jens Axboe



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

end of thread, other threads:[~2021-11-19 13:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02  2:07 [PATCH] blk-cgroup: fix missing put device in error path from blkg_conf_pref() Yu Kuai
2021-11-02  2:07 ` Yu Kuai
2021-11-06  9:12 ` yukuai (C)
2021-11-06  9:12   ` yukuai (C)
2021-11-15 21:37 ` Tejun Heo
2021-11-15 21:37   ` Tejun Heo
2021-11-19  8:09 ` yukuai (C)
2021-11-19  8:09   ` yukuai (C)
2021-11-19 13:27 ` Jens Axboe
2021-11-19 13:27   ` Jens Axboe

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.