blkcg: refine error codes returned during blkcg configuration
blkcg currently returns -EINVAL for most errors which can be pretty confusing given that the failure modes are quite varied. Update the error returns so that * -EINVAL only for syntactic errors. * -ERANGE if the value is out of range. * -ENODEV if the target device can't be found. * -EOPNOTSUPP if the policy is not enabled on the target device. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@fb.com>
This commit is contained in:
Родитель
5332dfc364
Коммит
20386ce014
|
@ -179,7 +179,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
|
||||||
|
|
||||||
/* blkg holds a reference to blkcg */
|
/* blkg holds a reference to blkcg */
|
||||||
if (!css_tryget_online(&blkcg->css)) {
|
if (!css_tryget_online(&blkcg->css)) {
|
||||||
ret = -EINVAL;
|
ret = -ENODEV;
|
||||||
goto err_free_blkg;
|
goto err_free_blkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
|
||||||
if (blkcg_parent(blkcg)) {
|
if (blkcg_parent(blkcg)) {
|
||||||
blkg->parent = __blkg_lookup(blkcg_parent(blkcg), q, false);
|
blkg->parent = __blkg_lookup(blkcg_parent(blkcg), q, false);
|
||||||
if (WARN_ON_ONCE(!blkg->parent)) {
|
if (WARN_ON_ONCE(!blkg->parent)) {
|
||||||
ret = -EINVAL;
|
ret = -ENODEV;
|
||||||
goto err_put_congested;
|
goto err_put_congested;
|
||||||
}
|
}
|
||||||
blkg_get(blkg->parent);
|
blkg_get(blkg->parent);
|
||||||
|
@ -279,7 +279,7 @@ struct blkcg_gq *blkg_lookup_create(struct blkcg *blkcg,
|
||||||
* we shouldn't allow anything to go through for a bypassing queue.
|
* we shouldn't allow anything to go through for a bypassing queue.
|
||||||
*/
|
*/
|
||||||
if (unlikely(blk_queue_bypass(q)))
|
if (unlikely(blk_queue_bypass(q)))
|
||||||
return ERR_PTR(blk_queue_dying(q) ? -EINVAL : -EBUSY);
|
return ERR_PTR(blk_queue_dying(q) ? -ENODEV : -EBUSY);
|
||||||
|
|
||||||
blkg = __blkg_lookup(blkcg, q, true);
|
blkg = __blkg_lookup(blkcg, q, true);
|
||||||
if (blkg)
|
if (blkg)
|
||||||
|
@ -792,10 +792,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
||||||
|
|
||||||
disk = get_gendisk(MKDEV(major, minor), &part);
|
disk = get_gendisk(MKDEV(major, minor), &part);
|
||||||
if (!disk)
|
if (!disk)
|
||||||
return -EINVAL;
|
return -ENODEV;
|
||||||
if (part) {
|
if (part) {
|
||||||
put_disk(disk);
|
put_disk(disk);
|
||||||
return -EINVAL;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
|
@ -804,7 +804,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
|
||||||
if (blkcg_policy_enabled(disk->queue, pol))
|
if (blkcg_policy_enabled(disk->queue, pol))
|
||||||
blkg = blkg_lookup_create(blkcg, disk->queue);
|
blkg = blkg_lookup_create(blkcg, disk->queue);
|
||||||
else
|
else
|
||||||
blkg = ERR_PTR(-EINVAL);
|
blkg = ERR_PTR(-EOPNOTSUPP);
|
||||||
|
|
||||||
if (IS_ERR(blkg)) {
|
if (IS_ERR(blkg)) {
|
||||||
ret = PTR_ERR(blkg);
|
ret = PTR_ERR(blkg);
|
||||||
|
|
|
@ -1755,7 +1755,7 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of,
|
||||||
cfqg = blkg_to_cfqg(ctx.blkg);
|
cfqg = blkg_to_cfqg(ctx.blkg);
|
||||||
cfqgd = blkcg_to_cfqgd(blkcg);
|
cfqgd = blkcg_to_cfqgd(blkcg);
|
||||||
|
|
||||||
ret = -EINVAL;
|
ret = -ERANGE;
|
||||||
if (!ctx.v || (ctx.v >= CFQ_WEIGHT_MIN && ctx.v <= CFQ_WEIGHT_MAX)) {
|
if (!ctx.v || (ctx.v >= CFQ_WEIGHT_MIN && ctx.v <= CFQ_WEIGHT_MAX)) {
|
||||||
if (!is_leaf_weight) {
|
if (!is_leaf_weight) {
|
||||||
cfqg->dev_weight = ctx.v;
|
cfqg->dev_weight = ctx.v;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче