Split wbt_init() into wbt_alloc() and wbt_init(), and prepare for moving wbt allocation into blk_alloc_queue(). Reported-by: Yi Zhang <yi.zhang@xxxxxxxxxx> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- block/blk-wbt.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 42aed0160f86..efff1232446f 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -809,7 +809,7 @@ static struct rq_qos_ops wbt_rqos_ops = { #endif }; -int wbt_init(struct request_queue *q) +static int wbt_alloc(struct request_queue *q) { struct rq_wb *rwb; int i; @@ -832,7 +832,6 @@ int wbt_init(struct request_queue *q) rwb->rqos.q = q; rwb->last_comp = rwb->last_issue = jiffies; rwb->win_nsec = RWB_WINDOW_NSEC; - rwb->enable_state = WBT_STATE_ON_DEFAULT; rwb->wc = 1; rwb->rq_depth.default_depth = RWB_DEF_DEPTH; @@ -842,6 +841,19 @@ int wbt_init(struct request_queue *q) rq_qos_add(q, &rwb->rqos); blk_stat_add_callback(q, rwb->cb); + return 0; +} + +int wbt_init(struct request_queue *q) +{ + int ret = wbt_alloc(q); + struct rq_wb *rwb; + + if (ret) + return ret; + + rwb = RQWB(wbt_rq_qos(q)); + rwb->enable_state = WBT_STATE_ON_DEFAULT; rwb->min_lat_nsec = wbt_default_latency_nsec(q); wbt_queue_depth_changed(&rwb->rqos); -- 2.29.2