lkml.org 
[lkml]   [2023]   [Feb]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] blk-iocost: initialize rqos before accessing it
Hello, Breno.

On Fri, Feb 24, 2023 at 08:07:14AM -0800, Breno Leitao wrote:
> diff --git a/block/blk-iocost.c b/block/blk-iocost.c
> index ff534e9d92dc..6cced8a76e9c 100644
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -2878,11 +2878,6 @@ static int blk_iocost_init(struct gendisk *disk)
> atomic64_set(&ioc->cur_period, 0);
> atomic_set(&ioc->hweight_gen, 0);
>
> - spin_lock_irq(&ioc->lock);
> - ioc->autop_idx = AUTOP_INVALID;
> - ioc_refresh_params(ioc, true);
> - spin_unlock_irq(&ioc->lock);
> -
> /*
> * rqos must be added before activation to allow ioc_pd_init() to
> * lookup the ioc from q. This means that the rqos methods may get
> @@ -2893,6 +2888,11 @@ static int blk_iocost_init(struct gendisk *disk)
> if (ret)
> goto err_free_ioc;
>
> + spin_lock_irq(&ioc->lock);
> + ioc->autop_idx = AUTOP_INVALID;
> + ioc_refresh_params(ioc, true);
> + spin_unlock_irq(&ioc->lock);
> +

I'm a bit worried about registering the rqos before ioc_refresh_params() as
that initializes all the internal parameters and letting IOs flow through
without initializing them can lead to subtle issues. Can you please instead
explicitly pass @q into ioc_refresh_params() (and explain why we need it
passed explicitly in the function comment)?

Thanks.

--
tejun

\
 
 \ /
  Last update: 2023-03-27 00:36    [W:0.057 / U:1.308 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site