mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
blk-iocost: read params inside lock in sysfs apis
Otherwise, user might get abnormal values if params is updated concurrently. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20230117070806.3857142-4-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
235a5a83f6
commit
35198e3230
@ -3131,6 +3131,7 @@ static u64 ioc_qos_prfill(struct seq_file *sf, struct blkg_policy_data *pd,
|
|||||||
if (!dname)
|
if (!dname)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
spin_lock_irq(&ioc->lock);
|
||||||
seq_printf(sf, "%s enable=%d ctrl=%s rpct=%u.%02u rlat=%u wpct=%u.%02u wlat=%u min=%u.%02u max=%u.%02u\n",
|
seq_printf(sf, "%s enable=%d ctrl=%s rpct=%u.%02u rlat=%u wpct=%u.%02u wlat=%u min=%u.%02u max=%u.%02u\n",
|
||||||
dname, ioc->enabled, ioc->user_qos_params ? "user" : "auto",
|
dname, ioc->enabled, ioc->user_qos_params ? "user" : "auto",
|
||||||
ioc->params.qos[QOS_RPPM] / 10000,
|
ioc->params.qos[QOS_RPPM] / 10000,
|
||||||
@ -3143,6 +3144,7 @@ static u64 ioc_qos_prfill(struct seq_file *sf, struct blkg_policy_data *pd,
|
|||||||
ioc->params.qos[QOS_MIN] % 10000 / 100,
|
ioc->params.qos[QOS_MIN] % 10000 / 100,
|
||||||
ioc->params.qos[QOS_MAX] / 10000,
|
ioc->params.qos[QOS_MAX] / 10000,
|
||||||
ioc->params.qos[QOS_MAX] % 10000 / 100);
|
ioc->params.qos[QOS_MAX] % 10000 / 100);
|
||||||
|
spin_unlock_irq(&ioc->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3322,12 +3324,14 @@ static u64 ioc_cost_model_prfill(struct seq_file *sf,
|
|||||||
if (!dname)
|
if (!dname)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
spin_lock_irq(&ioc->lock);
|
||||||
seq_printf(sf, "%s ctrl=%s model=linear "
|
seq_printf(sf, "%s ctrl=%s model=linear "
|
||||||
"rbps=%llu rseqiops=%llu rrandiops=%llu "
|
"rbps=%llu rseqiops=%llu rrandiops=%llu "
|
||||||
"wbps=%llu wseqiops=%llu wrandiops=%llu\n",
|
"wbps=%llu wseqiops=%llu wrandiops=%llu\n",
|
||||||
dname, ioc->user_cost_model ? "user" : "auto",
|
dname, ioc->user_cost_model ? "user" : "auto",
|
||||||
u[I_LCOEF_RBPS], u[I_LCOEF_RSEQIOPS], u[I_LCOEF_RRANDIOPS],
|
u[I_LCOEF_RBPS], u[I_LCOEF_RSEQIOPS], u[I_LCOEF_RRANDIOPS],
|
||||||
u[I_LCOEF_WBPS], u[I_LCOEF_WSEQIOPS], u[I_LCOEF_WRANDIOPS]);
|
u[I_LCOEF_WBPS], u[I_LCOEF_WSEQIOPS], u[I_LCOEF_WRANDIOPS]);
|
||||||
|
spin_unlock_irq(&ioc->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user