提交 b00f5f93 编写于 作者: Y Yu Kuai 提交者: openeuler-sync-bot

blk-iocost: dispatch all throttled bio in ioc_pd_offline

hulk inclusion
category: bugfix
bugzilla: 188107, https://gitee.com/openeuler/kernel/issues/I665S2
CVE: NA

--------------------------------

Otherwise io will hang because timer is canceled. And make iocg->online
updated under both 'ioc->lock' and 'iocg->waitq.lock', so it can be
guaranteed that iocg will stay online while holding any lock.
Signed-off-by: NYu Kuai <yukuai3@huawei.com>
Signed-off-by: NLi Nan <linan122@huawei.com>
(cherry picked from commit bc184a0b)
上级 a413dc66
...@@ -1405,14 +1405,17 @@ static int iocg_wake_fn(struct wait_queue_entry *wq_entry, unsigned mode, ...@@ -1405,14 +1405,17 @@ static int iocg_wake_fn(struct wait_queue_entry *wq_entry, unsigned mode,
{ {
struct iocg_wait *wait = container_of(wq_entry, struct iocg_wait, wait); struct iocg_wait *wait = container_of(wq_entry, struct iocg_wait, wait);
struct iocg_wake_ctx *ctx = (struct iocg_wake_ctx *)key; struct iocg_wake_ctx *ctx = (struct iocg_wake_ctx *)key;
u64 cost = abs_cost_to_cost(wait->abs_cost, ctx->hw_inuse);
ctx->vbudget -= cost; if (ctx->iocg->online) {
u64 cost = abs_cost_to_cost(wait->abs_cost, ctx->hw_inuse);
if (ctx->vbudget < 0) ctx->vbudget -= cost;
return -1; if (ctx->vbudget < 0)
return -1;
iocg_commit_bio(ctx->iocg, wait->bio, wait->abs_cost, cost);
}
iocg_commit_bio(ctx->iocg, wait->bio, wait->abs_cost, cost);
wait->committed = true; wait->committed = true;
/* /*
...@@ -2989,7 +2992,9 @@ static void ioc_pd_offline(struct blkg_policy_data *pd) ...@@ -2989,7 +2992,9 @@ static void ioc_pd_offline(struct blkg_policy_data *pd)
unsigned long flags; unsigned long flags;
if (ioc) { if (ioc) {
spin_lock_irqsave(&ioc->lock, flags); struct iocg_wake_ctx ctx = { .iocg = iocg };
iocg_lock(iocg, true, &flags);
iocg->online = false; iocg->online = false;
...@@ -3004,9 +3009,10 @@ static void ioc_pd_offline(struct blkg_policy_data *pd) ...@@ -3004,9 +3009,10 @@ static void ioc_pd_offline(struct blkg_policy_data *pd)
WARN_ON_ONCE(!list_empty(&iocg->walk_list)); WARN_ON_ONCE(!list_empty(&iocg->walk_list));
WARN_ON_ONCE(!list_empty(&iocg->surplus_list)); WARN_ON_ONCE(!list_empty(&iocg->surplus_list));
spin_unlock_irqrestore(&ioc->lock, flags); iocg_unlock(iocg, true, &flags);
hrtimer_cancel(&iocg->waitq_timer); hrtimer_cancel(&iocg->waitq_timer);
__wake_up(&iocg->waitq, TASK_NORMAL, 0, &ctx);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册