cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: axboe@kernel.dk
Cc: vgoyal@redhat.com, linux-kernel@vger.kernel.org,
	avanzini.arianna@gmail.com, kernel-team@fb.com,
	hannes@cmpxchg.org, lizefan@huawei.com, cgroups@vger.kernel.org,
	Tejun Heo <tj@kernel.org>
Subject: [PATCH 04/10] blkcg: refine error codes returned during blkcg configuration
Date: Fri, 24 Jul 2015 14:43:48 -0400	[thread overview]
Message-ID: <1437763434-28699-5-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1437763434-28699-1-git-send-email-tj@kernel.org>

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>
---
 block/blk-cgroup.c  | 12 ++++++------
 block/cfq-iosched.c |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 63c0914..a192f98 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -179,7 +179,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
 
 	/* blkg holds a reference to blkcg */
 	if (!css_tryget_online(&blkcg->css)) {
-		ret = -EINVAL;
+		ret = -ENODEV;
 		goto err_free_blkg;
 	}
 
@@ -205,7 +205,7 @@ static struct blkcg_gq *blkg_create(struct blkcg *blkcg,
 	if (blkcg_parent(blkcg)) {
 		blkg->parent = __blkg_lookup(blkcg_parent(blkcg), q, false);
 		if (WARN_ON_ONCE(!blkg->parent)) {
-			ret = -EINVAL;
+			ret = -ENODEV;
 			goto err_put_congested;
 		}
 		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.
 	 */
 	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);
 	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);
 	if (!disk)
-		return -EINVAL;
+		return -ENODEV;
 	if (part) {
 		put_disk(disk);
-		return -EINVAL;
+		return -ENODEV;
 	}
 
 	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))
 		blkg = blkg_lookup_create(blkcg, disk->queue);
 	else
-		blkg = ERR_PTR(-EINVAL);
+		blkg = ERR_PTR(-EOPNOTSUPP);
 
 	if (IS_ERR(blkg)) {
 		ret = PTR_ERR(blkg);
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index bcf4026..38277e3 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1755,7 +1755,7 @@ static ssize_t __cfqg_set_weight_device(struct kernfs_open_file *of,
 	cfqg = blkg_to_cfqg(ctx.blkg);
 	cfqgd = blkcg_to_cfqgd(blkcg);
 
-	ret = -EINVAL;
+	ret = -ERANGE;
 	if (!ctx.v || (ctx.v >= CFQ_WEIGHT_MIN && ctx.v <= CFQ_WEIGHT_MAX)) {
 		if (!is_leaf_weight) {
 			cfqg->dev_weight = ctx.v;
-- 
2.4.3

  parent reply	other threads:[~2015-07-24 18:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-24 18:43 [PATCHSET block/for-4.3] blkcg: implement interface for the unified hierarchy Tejun Heo
2015-07-24 18:43 ` [PATCH 02/10] cgroup: introduce cgroup_subsys->legacy_name Tejun Heo
     [not found]   ` <1437763434-28699-3-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-28  6:39     ` Zefan Li
2015-07-28 15:23       ` Tejun Heo
2015-07-28 17:56   ` [PATCH v2 " Tejun Heo
2015-08-18 21:01     ` Tejun Heo
2015-07-29  1:18   ` [PATCH " Zefan Li
2015-07-24 18:43 ` [PATCH 03/10] blkcg: remove unnecessary NULL checks from __cfqg_set_weight_device() Tejun Heo
2015-07-24 18:43 ` Tejun Heo [this message]
2015-07-24 18:43 ` [PATCH 07/10] blkcg: move body parsing from blkg_conf_prep() to its callers Tejun Heo
2015-07-24 18:43 ` [PATCH 08/10] blkcg: separate out tg_conf_updated() from tg_set_conf() Tejun Heo
2015-07-24 18:43 ` [PATCH 09/10] blkcg: misc preparations for unified hierarchy interface Tejun Heo
2015-07-24 18:43 ` [PATCH 10/10] blkcg: implement interface for the unified hierarchy Tejun Heo
     [not found]   ` <1437763434-28699-11-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-30 22:58     ` [PATCH v2 " Tejun Heo
     [not found] ` <1437763434-28699-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-24 18:43   ` [PATCH 01/10] cgroup: don't print subsystems for the default hierarchy Tejun Heo
     [not found]     ` <1437763434-28699-2-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2015-07-29  1:18       ` Zefan Li
2015-08-18 21:01       ` Tejun Heo
2015-07-24 18:43   ` [PATCH 05/10] blkcg: rename subsystem name from blkio to io Tejun Heo
2015-07-24 18:43   ` [PATCH 06/10] blkcg: mark existing cftypes as legacy Tejun Heo
2015-07-27 16:12   ` [PATCHSET block/for-4.3] blkcg: implement interface for the unified hierarchy Vivek Goyal
     [not found]     ` <20150727161209.GB16064-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-27 18:13       ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437763434-28699-5-git-send-email-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=avanzini.arianna@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).